@malloy-publisher/app 0.0.218 → 0.0.220
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/api-doc.yaml +262 -25
- package/dist/assets/{EnvironmentPage-DxOiCxcd.js → EnvironmentPage-BqLiaatL.js} +1 -1
- package/dist/assets/{HomePage-i8qAtD6x.js → HomePage-G_xpt9XE.js} +1 -1
- package/dist/assets/LightMode-s1PDRIsF.js +1 -0
- package/dist/assets/MainPage-C6TfpC92.js +2 -0
- package/dist/assets/{MaterializationsPage-6OEVM543.js → MaterializationsPage-BMO1afhm.js} +1 -1
- package/dist/assets/ModelPage-zHOJwMnU.js +1 -0
- package/dist/assets/{PackagePage-BVmoVsPQ.js → PackagePage-GCaWmELQ.js} +1 -1
- package/dist/assets/{RouteError-DFX521_t.js → RouteError-CIC588k4.js} +1 -1
- package/dist/assets/ThemeEditorPage-BdbIfIGO.js +1 -0
- package/dist/assets/{WorkbookPage-CzucDJ-T.js → WorkbookPage-C8ucK_H8.js} +1 -1
- package/dist/assets/{core-B95VQkAV.es-Cbn-yKG-.js → core-DFvqRVqM.es-NtfPVC7h.js} +1 -1
- package/dist/assets/github-dark-DenFmJkN.es-DHJKELXO.js +1 -0
- package/dist/assets/index-8E2uLeV9.js +2541 -0
- package/dist/assets/index-B3NcDPbp.js +18 -0
- package/dist/assets/index-BxDMCn3s.js +527 -0
- package/dist/assets/index-aYNf0kTZ.js +1 -0
- package/dist/assets/index-aYtt-ovi.js +1761 -0
- package/dist/assets/index-w_0OQJgZ.js +23 -0
- package/dist/index.html +1 -1
- package/package.json +3 -2
- package/dist/assets/MainPage-B58d5pmX.js +0 -2
- package/dist/assets/ModelPage-8d5l7YkU.js +0 -1
- package/dist/assets/index--xJ1pzL-.js +0 -455
- package/dist/assets/index-Bxkza-hz.js +0 -40
- package/dist/assets/index-DxRKma36.js +0 -1760
- package/dist/assets/index.umd-o-yUIEtS.js +0 -2467
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{aI as ci}from"./index-BxDMCn3s.js";import{r as di}from"./index-w_0OQJgZ.js";function pi(u,re){for(var j=0;j<re.length;j++){const N=re[j];if(typeof N!="string"&&!Array.isArray(N)){for(const E in N)if(E!=="default"&&!(E in u)){const S=Object.getOwnPropertyDescriptor(N,E);S&&Object.defineProperty(u,E,S.get?S:{enumerable:!0,get:()=>N[E]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var bt={},ut={},Or;function Vt(){if(Or)return ut;Or=1,Object.defineProperty(ut,"__esModule",{value:!0}),ut.isChainOp=u,ut.isStringCondition=re,ut.isStringFilter=j,ut.isBooleanFilter=N,ut.isNumberFilter=E,ut.isTemporalFilter=S,ut.isFilterExpression=w,ut.isFilterable=y;function u(o){return["and","or",","].includes(o)}function re(o){return["starts","ends","contains","="].includes(o.operator)}function j(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","empty","and","or",",","()"].includes(o.operator)}function N(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","true","false","=false","=true"].includes(o.operator)}function E(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null"].includes(o.operator)}function S(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null"].includes(o.operator)}function w(o){return typeof o=="object"&&o!==null&&"operator"in o}function y(o){return["string","number","boolean","timestamp","timestamptz","date"].includes(o)}return ut}var Pt={},Er;function hi(){return Er||(Er=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.BooleanFilterExpression=void 0,Pt.BooleanFilterExpression={parse(u){var re;if(u.match(/^\s*$/))return{parsed:null,log:[]};const j={parsed:null,log:[]};let N=u.toLowerCase().trim().replace(/\s\s+/," "),E=!1;if(N.startsWith("not ")&&(E=!0,N=N.slice(4)),N==="true")j.parsed={operator:"true"};else if(N==="=true")j.parsed={operator:"=true"};else if(N==="false")j.parsed={operator:"false"};else if(N==="=false")j.parsed={operator:"=false"};else if(N==="null")j.parsed={operator:"null"};else{const S=u.match(/[^\s]/),w=S&&(re=S.index)!==null&&re!==void 0?re:0;j.log=[{message:`Illegal boolean filter '${N}'. Must be one of true,=true,false,=false,null`,severity:"error",startIndex:w,endIndex:w+u.length-1}]}return E&&j.parsed&&(j.parsed.not=!0),j},unparse(u){return u===null?"":(u.not?"not ":"")+u.operator}}),Pt}var pr={},Ue={},kr;function Ht(){if(kr)return Ue;kr=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.maybeNot=re,Ue.unescape=j,Ue.escape=N,Ue.matchOp=S,Ue.conjoin=y,Ue.joinNumbers=o,Ue.mkRange=d,Ue.mkValues=t,Ue.numNot=D,Ue.temporalNot=x,Ue.joinTemporal=Z,Ue.timeLiteral=ee,Ue.mkUnits=ce;const u=Vt();function re(O){const[A,b]=O;return A&&b&&(0,u.isStringFilter)(b)?{...b,not:!0}:b}function j(O){return O.replace(/\\(.)/g,"$1")}function N(O){const A=O.toLowerCase();return A==="null"||A==="empty"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function E(O){let A=!1,b=!1,B=0,de=!1;const Fe=O.length;for(let ve=0;ve<Fe;ve+=1){const Ye=O[ve];if(Ye===" "||Ye===" "){B+=1;continue}B=0,Ye==="%"?(de=!0,ve===0&&(A=!0),b=!0):(b=!1,Ye==="\\"?ve+=1:Ye==="_"&&(de=!0))}return{hasLike:de,percentEnd:b&&Fe>1,percentStart:A&&Fe>1,endSpace:B}}function S(O){let A=O.trimStart();const{hasLike:b,percentEnd:B,percentStart:de,endSpace:Fe}=E(A);if(Fe>0&&(A=A.slice(0,-Fe)),b){if(de&&B){const ve=A.slice(1,-1);if(!E(ve).hasLike&&ve.length>0)return{operator:"contains",values:[j(ve)]}}else if(B){const ve=A.slice(0,-1);if(!E(ve).hasLike)return{operator:"starts",values:[j(ve)]}}else if(de){const ve=A.slice(1);if(!E(ve).hasLike)return{operator:"ends",values:[j(ve)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:{operator:"=",values:[j(A)]}}function w(O,A){var b,B;return O.operator===A.operator&&((b=O.not)!==null&&b!==void 0?b:!1)===((B=A.not)!==null&&B!==void 0?B:!1)}function y(O,A,b){if(A=A.toLowerCase(),(0,u.isStringFilter)(O)&&(0,u.isStringFilter)(b)){if(A===","){if(O.operator==="~"&&w(O,b))return{...O,escaped_values:[...O.escaped_values,...b.escaped_values]};if((0,u.isStringCondition)(O)&&w(O,b))return{...O,values:[...O.values,...b.values]}}const B=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(B)return O.operator===B?{...O,members:[...O.members,b]}:{operator:B,members:[O,b]}}return null}function o(O,A,b){if(A=A.toLowerCase(),(0,u.isNumberFilter)(O)&&(0,u.isNumberFilter)(b)){if(A==="or"&&O.operator==="="&&w(O,b)){const B={operator:"=",values:[...O.values,...b.values]};return O.not&&(B.not=!0),B}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}}return null}function d(O,A,b,B){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:b,endOperator:B===")"?"<":"<="}}function t(O,A){return{values:[O,...A]}}function D(O,A){return(0,u.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function x(O,A){if((0,u.isTemporalFilter)(O)&&A){if("not"in O){const b={...O};return O.not?delete b.not:b.not=!0,b}return{...O,not:!0}}return O}function Z(O,A,b){return A=A.toLowerCase(),(0,u.isTemporalFilter)(O)&&(0,u.isTemporalFilter)(b)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}:null}function ee(O,A){const b={moment:"literal",literal:O};return A&&(b.units=A),b}function ce(O){switch(O.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return Ue}var hr,Rr;function mi(){if(Rr)return hr;Rr=1;const{numNot:u,mkRange:re,joinNumbers:j,mkValues:N}=Ht();function E(o,d){function t(){this.constructor=o}t.prototype=d.prototype,o.prototype=new t}function S(o,d,t,D){var x=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(x,S.prototype),x.expected=d,x.found=t,x.location=D,x.name="SyntaxError",x}E(S,Error);function w(o,d,t){return t=t||" ",o.length>d?o:(d-=o.length,t+=t.repeat(d),o+t.slice(0,d))}S.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var t=null,D;for(D=0;D<o.length;D++)if(o[D].source===this.location.source){t=o[D].text.split(/\r\n|\n|\r/g);break}var x=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(x):x,ee=this.location.source+":"+Z.line+":"+Z.column;if(t){var ce=this.location.end,O=w("",Z.line.toString().length," "),A=t[x.line-1],b=x.line===ce.line?ce.column:A.length+1,B=b-x.column||1;d+=`
|
|
2
|
+
--> `+ee+`
|
|
3
|
+
`+O+` |
|
|
4
|
+
`+Z.line+" | "+A+`
|
|
5
|
+
`+O+" | "+w("",x.column-1," ")+w("",B,"^")}else d+=`
|
|
6
|
+
at `+ee}return d},S.buildMessage=function(o,d){var t={literal:function(A){return'"'+x(A.text)+'"'},class:function(A){var b=A.parts.map(function(B){return Array.isArray(B)?Z(B[0])+"-"+Z(B[1]):Z(B)});return"["+(A.inverted?"^":"")+b.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(A){return A.description}};function D(A){return A.charCodeAt(0).toString(16).toUpperCase()}function x(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function Z(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function ee(A){return t[A.type](A)}function ce(A){var b=A.map(ee),B,de;if(b.sort(),b.length>0){for(B=1,de=1;B<b.length;B++)b[B-1]!==b[B]&&(b[de]=b[B],de++);b.length=de}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function O(A){return A?'"'+x(A)+'"':"end of input"}return"Expected "+ce(o)+" but "+O(d)+" found."};function y(o,d){d=d!==void 0?d:{};var t={},D=d.grammarSource,x={numberFilter:Lt},Z=Lt,ee="(",ce=")",O="!=",A=",",b="=",B="<=",de=">=",Fe="[",ve="]",Ye="-",Ae=".",pe="not",Pe="null",tt="and",Re="or",Ge="to",it=/^[<>]/,Ee=/^[0-9]/,at=/^[Ee]/,Ce=/^[+\-]/,De=/^[a-zA-Z]/,st=/^[ \t]/,qe=be("(",!1),Oe=be(")",!1),ke=be("!=",!1),xe=be(",",!1),Je=be("=",!1),He=be("<=",!1),je=be(">=",!1),q=yt(["<",">"],!1,!1),h=be("[",!1),$=be("]",!1),k=be("-",!1),F=yt([["0","9"]],!1,!1),z=be(".",!1),Y=yt(["E","e"],!1,!1),we=yt(["+","-"],!1,!1),Qe=be("not",!0),rt=be("null",!0),C=be("and",!0),nt=be("or",!0),ot=be("to",!0),_e=yt([["a","z"],["A","Z"]],!1,!1),Ze=Kt("whitespace"),ct=yt([" "," "],!1,!1),gt=function(g,v){return v.reduce((L,[,Q,,K])=>j(L,Q,K),g)},We=function(g,v){return u(v,g)},Ke=function(g){return g},ze=function(){return{operator:"null"}},Me=function(g){return{operator:"()",expr:g}},_=function(g,v,L,Q){return re(g,v,L,Q)},I=function(g,v){return{operator:"!=",...N(g,v.map(L=>L[3]))}},ie=function(g,v){return{operator:"=",...N(g,v.map(L=>L[3]))}},W=function(g,v){return{operator:g,values:[v]}},ue=function(g,v){return{operator:"=",...N(g,v.map(L=>L[3]))}},Se=function(){return"["},lt=function(){return"("},Xe=function(){return"]"},At=function(){return")"},m=function(g){return g},e=function(){return"or"},a=function(){return"and"},f=function(){return"not"},l=d.peg$currPos|0,R=[{line:1,column:1}],J=l,fe=d.peg$maxFailExpected||[],V=d.peg$silentFails|0,he;if(d.startRule){if(!(d.startRule in x))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');Z=x[d.startRule]}function be(g,v){return{type:"literal",text:g,ignoreCase:v}}function yt(g,v,L){return{type:"class",parts:g,inverted:v,ignoreCase:L}}function Zt(){return{type:"end"}}function Kt(g){return{type:"other",description:g}}function Bt(g){var v=R[g],L;if(v)return v;if(g>=R.length)L=R.length-1;else for(L=g;!R[--L];);for(v=R[L],v={line:v.line,column:v.column};L<g;)o.charCodeAt(L)===10?(v.line++,v.column=1):v.column++,L++;return R[g]=v,v}function Gt(g,v,L){var Q=Bt(g),K=Bt(v),P={source:D,start:{offset:g,line:Q.line,column:Q.column},end:{offset:v,line:K.line,column:K.column}};return P}function te(g){l<J||(l>J&&(J=l,fe=[]),fe.push(g))}function Xt(g,v,L){return new S(S.buildMessage(g,v),g,v,L)}function Lt(){var g,v,L,Q,K,P,G,H;if(g=l,v=It(),v!==t){for(L=[],Q=l,K=me(),P=jt(),P!==t?(G=me(),H=It(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);Q!==t;)L.push(Q),Q=l,K=me(),P=jt(),P!==t?(G=me(),H=It(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);g=gt(v,L)}else l=g,g=t;return g}function It(){var g,v,L;return g=l,v=rr(),v!==t?(me(),L=Ut(),L!==t?g=We(v,L):(l=g,g=t)):(l=g,g=t),g===t&&(g=l,v=Ut(),v!==t&&(v=Ke(v)),g=v),g}function Ut(){var g,v,L,Q,K,P,G,H,le,ge;if(g=l,v=nr(),v!==t&&(v=ze()),g=v,g===t&&(g=l,o.charCodeAt(l)===40?(v=ee,l++):(v=t,V===0&&te(qe)),v!==t?(L=me(),Q=Lt(),Q!==t?(K=me(),o.charCodeAt(l)===41?(P=ce,l++):(P=t,V===0&&te(Oe)),P!==t?g=Me(Q):(l=g,g=t)):(l=g,g=t)):(l=g,g=t),g===t&&(g=l,v=er(),v!==t?(L=me(),Q=et(),Q!==t?(K=me(),P=sr(),P!==t?(G=me(),H=et(),H!==t?(le=me(),ge=tr(),ge!==t?g=_(v,Q,H,ge):(l=g,g=t)):(l=g,g=t)):(l=g,g=t)):(l=g,g=t)):(l=g,g=t),g===t))){if(g=l,o.substr(l,2)===O?(v=O,l+=2):(v=t,V===0&&te(ke)),v!==t)if(L=me(),Q=et(),Q!==t){for(K=[],P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);P!==t;)K.push(P),P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);g=I(Q,K)}else l=g,g=t;else l=g,g=t;if(g===t){if(g=l,o.charCodeAt(l)===61?(v=b,l++):(v=t,V===0&&te(Je)),v!==t)if(L=me(),Q=et(),Q!==t){for(K=[],P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);P!==t;)K.push(P),P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);g=ie(Q,K)}else l=g,g=t;else l=g,g=t;if(g===t&&(g=l,v=l,o.substr(l,2)===B?(L=B,l+=2):(L=t,V===0&&te(He)),L===t&&(o.substr(l,2)===de?(L=de,l+=2):(L=t,V===0&&te(je)),L===t&&(L=o.charAt(l),it.test(L)?l++:(L=t,V===0&&te(q)))),L!==t?v=o.substring(v,l):v=L,v!==t?(L=me(),Q=et(),Q!==t?g=W(v,Q):(l=g,g=t)):(l=g,g=t),g===t))if(g=l,v=et(),v!==t){for(L=[],Q=l,K=me(),o.charCodeAt(l)===44?(P=A,l++):(P=t,V===0&&te(xe)),P!==t?(G=me(),H=et(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);Q!==t;)L.push(Q),Q=l,K=me(),o.charCodeAt(l)===44?(P=A,l++):(P=t,V===0&&te(xe)),P!==t?(G=me(),H=et(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);g=ue(v,L)}else l=g,g=t}}return g}function er(){var g,v;return g=l,o.charCodeAt(l)===91?(v=Fe,l++):(v=t,V===0&&te(h)),v!==t&&(v=Se()),g=v,g===t&&(g=l,o.charCodeAt(l)===40?(v=ee,l++):(v=t,V===0&&te(qe)),v!==t&&(v=lt()),g=v),g}function tr(){var g,v;return g=l,o.charCodeAt(l)===93?(v=ve,l++):(v=t,V===0&&te($)),v!==t&&(v=Xe()),g=v,g===t&&(g=l,o.charCodeAt(l)===41?(v=ce,l++):(v=t,V===0&&te(Oe)),v!==t&&(v=At()),g=v),g}function et(){var g,v,L,Q,K,P,G,H,le,ge;if(g=l,v=l,L=l,o.charCodeAt(l)===45?(Q=Ye,l++):(Q=t,V===0&&te(k)),Q===t&&(Q=null),K=l,P=[],G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F)),G!==t)for(;G!==t;)P.push(G),G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F));else P=t;if(P!==t){for(o.charCodeAt(l)===46?(G=Ae,l++):(G=t,V===0&&te(z)),G===t&&(G=null),H=[],le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F));le!==t;)H.push(le),le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F));P=[P,G,H],K=P}else l=K,K=t;if(K===t){for(K=l,P=[],G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F));G!==t;)P.push(G),G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F));if(o.charCodeAt(l)===46?(G=Ae,l++):(G=t,V===0&&te(z)),G!==t){if(H=[],le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F)),le!==t)for(;le!==t;)H.push(le),le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F));else H=t;H!==t?(P=[P,G,H],K=P):(l=K,K=t)}else l=K,K=t}if(K!==t){if(P=l,G=o.charAt(l),at.test(G)?l++:(G=t,V===0&&te(Y)),G!==t){if(H=o.charAt(l),Ce.test(H)?l++:(H=t,V===0&&te(we)),H===t&&(H=null),le=[],ge=o.charAt(l),Ee.test(ge)?l++:(ge=t,V===0&&te(F)),ge!==t)for(;ge!==t;)le.push(ge),ge=o.charAt(l),Ee.test(ge)?l++:(ge=t,V===0&&te(F));else le=t;le!==t?(G=[G,H,le],P=G):(l=P,P=t)}else l=P,P=t;P===t&&(P=null),Q=[Q,K,P],L=Q}else l=L,L=t;return L!==t?v=o.substring(v,l):v=L,v!==t&&(v=m(v)),g=v,g}function jt(){var g,v;return g=l,v=ar(),v!==t&&(v=e()),g=v,g===t&&(g=l,v=ir(),v!==t&&(v=a()),g=v),g}function rr(){var g,v,L,Q;return g=l,v=o.substr(l,3),v.toLowerCase()===pe?l+=3:(v=t,V===0&&te(Qe)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?g=f():(l=g,g=t)):(l=g,g=t),g}function nr(){var g,v,L,Q;return g=l,v=o.substr(l,4),v.toLowerCase()===Pe?l+=4:(v=t,V===0&&te(rt)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function ir(){var g,v,L,Q;return g=l,v=o.substr(l,3),v.toLowerCase()===tt?l+=3:(v=t,V===0&&te(C)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function ar(){var g,v,L,Q;return g=l,v=o.substr(l,2),v.toLowerCase()===Re?l+=2:(v=t,V===0&&te(nt)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function sr(){var g,v,L,Q;return g=l,v=o.substr(l,2),v.toLowerCase()===Ge?l+=2:(v=t,V===0&&te(ot)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function Tt(){var g;return g=o.charAt(l),De.test(g)?l++:(g=t,V===0&&te(_e)),g}function me(){var g,v;for(V++,g=[],v=o.charAt(l),st.test(v)?l++:(v=t,V===0&&te(ct));v!==t;)g.push(v),v=o.charAt(l),st.test(v)?l++:(v=t,V===0&&te(ct));return V--,v=t,V===0&&te(Ze),g}if(he=Z(),d.peg$library)return{peg$result:he,peg$currPos:l,peg$FAILED:t,peg$maxFailExpected:fe,peg$maxFailPos:J};if(he!==t&&l===o.length)return he;throw he!==t&&l<o.length&&te(Zt()),Xt(fe,J<o.length?o.charAt(J):null,J<o.length?Gt(J,J+1):Gt(J,J))}return hr={StartRules:["numberFilter"],SyntaxError:S,parse:y},hr}var Yt={},Vr;function wr(){if(Vr)return Yt;Vr=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.run_parser=j;const u=Vt();function re(N){return N instanceof Error&&"location"in N}function j(N,E){try{const S=E(N);return(0,u.isFilterExpression)(S)?{parsed:S,log:[]}:{parsed:null,log:[]}}catch(S){if(re(S)){const w=S.location,y=w?w.start.offset:0,o=w?w.end.offset-1:N.length-1;return{parsed:null,log:[{message:S.message,startIndex:y,endIndex:Math.max(y,o),severity:"error"}]}}throw S}}return Yt}var Lr;function gi(){return Lr||(Lr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.NumberFilterExpression=void 0;const re=Vt(),j=mi(),N=wr();u.NumberFilterExpression={parse(E){if(E.match(/^\s*$/))return{parsed:null,log:[]};const S=(0,N.run_parser)(E,j.parse);return S.parsed&&(0,re.isNumberFilter)(S.parsed)?{parsed:S.parsed,log:[]}:{parsed:null,log:S.log}},unparse(E){if(E===null)return"";switch(E.operator){case"=":return E.values.join(", ");case"!=":return"!= "+E.values.join(", ");case">":case"<":case"<=":case">=":return E.not?E.values.map(S=>E.operator==="="?`not ${S}`:`not ${E.operator} ${S}`).join(", "):E.values.map(S=>`${E.operator} ${S}`).join(", ");case"range":{const S=E.startOperator===">"?"(":"[",w=E.endOperator==="<"?")":"]",y=`${S}${E.startValue} to ${E.endValue}${w}`;return E.not?`not ${y}`:y}case"null":return E.not?"not null":"null";case"and":case"or":return E.members.map(S=>u.NumberFilterExpression.unparse(S)).join(` ${E.operator} `);case"()":{const S="("+u.NumberFilterExpression.unparse(E.expr)+")";return E.not?"not "+S:S}}return`no unparse for ${JSON.stringify(E)}`}}})(pr)),pr}var mr={},gr,Ir;function yi(){if(Ir)return gr;Ir=1;const{conjoin:u,maybeNot:re,matchOp:j}=Ht();function N(y,o){function d(){this.constructor=y}d.prototype=o.prototype,y.prototype=new d}function E(y,o,d,t){var D=Error.call(this,y);return Object.setPrototypeOf&&Object.setPrototypeOf(D,E.prototype),D.expected=o,D.found=d,D.location=t,D.name="SyntaxError",D}N(E,Error);function S(y,o,d){return d=d||" ",y.length>o?y:(o-=y.length,d+=d.repeat(o),y+d.slice(0,o))}E.prototype.format=function(y){var o="Error: "+this.message;if(this.location){var d=null,t;for(t=0;t<y.length;t++)if(y[t].source===this.location.source){d=y[t].text.split(/\r\n|\n|\r/g);break}var D=this.location.start,x=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(D):D,Z=this.location.source+":"+x.line+":"+x.column;if(d){var ee=this.location.end,ce=S("",x.line.toString().length," "),O=d[D.line-1],A=D.line===ee.line?ee.column:O.length+1,b=A-D.column||1;o+=`
|
|
7
|
+
--> `+Z+`
|
|
8
|
+
`+ce+` |
|
|
9
|
+
`+x.line+" | "+O+`
|
|
10
|
+
`+ce+" | "+S("",D.column-1," ")+S("",b,"^")}else o+=`
|
|
11
|
+
at `+Z}return o},E.buildMessage=function(y,o){var d={literal:function(O){return'"'+D(O.text)+'"'},class:function(O){var A=O.parts.map(function(b){return Array.isArray(b)?x(b[0])+"-"+x(b[1]):x(b)});return"["+(O.inverted?"^":"")+A.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(O){return O.description}};function t(O){return O.charCodeAt(0).toString(16).toUpperCase()}function D(O){return O.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(A){return"\\x0"+t(A)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(A){return"\\x"+t(A)})}function x(O){return O.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(A){return"\\x0"+t(A)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(A){return"\\x"+t(A)})}function Z(O){return d[O.type](O)}function ee(O){var A=O.map(Z),b,B;if(A.sort(),A.length>0){for(b=1,B=1;b<A.length;b++)A[b-1]!==A[b]&&(A[B]=A[b],B++);A.length=B}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}function ce(O){return O?'"'+D(O)+'"':"end of input"}return"Expected "+ee(y)+" but "+ce(o)+" found."};function w(y,o){o=o!==void 0?o:{};var d={},t=o.grammarSource,D={stringFilter:ct},x=ct,Z="-",ee="(",ce=")",O="\\",A=",",b=";",B="|",de=/^[^\n,;()|]/,Fe=/^[ \t]/,ve=Y("-",!1),Ye=Y("(",!1),Ae=Y(")",!1),pe=C("match string"),Pe=Y("\\",!1),tt=Qe(),Re=we([`
|
|
12
|
+
`,",",";","(",")","|"],!0,!1),Ge=Y(",",!1),it=Y(";",!1),Ee=Y("|",!1),at=C("whitespace"),Ce=we([" "," "],!1,!1),De=function(_,I){return I.reduce((ie,[,W,,ue])=>u(ie,W,ue),_)},st=function(_){return re([!0,_])},qe=function(_){return _},Oe=function(_){return{operator:"()",expr:_}},ke=function(_){return j(_)},xe=function(_){return _},Je=function(){return","},He=function(){return";"},je=function(){return"|"},q=o.peg$currPos|0,h=[{line:1,column:1}],$=q,k=o.peg$maxFailExpected||[],F=o.peg$silentFails|0,z;if(o.startRule){if(!(o.startRule in D))throw new Error(`Can't start parsing from rule "`+o.startRule+'".');x=D[o.startRule]}function Y(_,I){return{type:"literal",text:_,ignoreCase:I}}function we(_,I,ie){return{type:"class",parts:_,inverted:I,ignoreCase:ie}}function Qe(){return{type:"any"}}function rt(){return{type:"end"}}function C(_){return{type:"other",description:_}}function nt(_){var I=h[_],ie;if(I)return I;if(_>=h.length)ie=h.length-1;else for(ie=_;!h[--ie];);for(I=h[ie],I={line:I.line,column:I.column};ie<_;)y.charCodeAt(ie)===10?(I.line++,I.column=1):I.column++,ie++;return h[_]=I,I}function ot(_,I,ie){var W=nt(_),ue=nt(I),Se={source:t,start:{offset:_,line:W.line,column:W.column},end:{offset:I,line:ue.line,column:ue.column}};return Se}function _e(_){q<$||(q>$&&($=q,k=[]),k.push(_))}function Ze(_,I,ie){return new E(E.buildMessage(_,I),_,I,ie)}function ct(){var _,I,ie,W,ue,Se,lt,Xe;if(_=q,Me(),I=gt(),I!==d){for(ie=[],W=q,ue=Me(),Se=ze(),Se!==d?(lt=Me(),Xe=gt(),Xe!==d?(ue=[ue,Se,lt,Xe],W=ue):(q=W,W=d)):(q=W,W=d);W!==d;)ie.push(W),W=q,ue=Me(),Se=ze(),Se!==d?(lt=Me(),Xe=gt(),Xe!==d?(ue=[ue,Se,lt,Xe],W=ue):(q=W,W=d)):(q=W,W=d);_=De(I,ie)}else q=_,_=d;return _}function gt(){var _,I,ie;return _=q,y.charCodeAt(q)===45?(I=Z,q++):(I=d,F===0&&_e(ve)),I!==d?(Me(),ie=We(),ie!==d?_=st(ie):(q=_,_=d)):(q=_,_=d),_===d&&(_=q,I=We(),I!==d&&(I=qe(I)),_=I),_}function We(){var _,I,ie,W;return _=q,y.charCodeAt(q)===40?(I=ee,q++):(I=d,F===0&&_e(Ye)),I!==d?(Me(),ie=ct(),ie!==d?(Me(),y.charCodeAt(q)===41?(W=ce,q++):(W=d,F===0&&_e(Ae)),W!==d?_=Oe(ie):(q=_,_=d)):(q=_,_=d)):(q=_,_=d),_===d&&(_=q,I=Ke(),I!==d&&(I=ke(I)),_=I),_}function Ke(){var _,I,ie,W,ue,Se;if(F++,_=q,I=q,ie=[],W=q,y.charCodeAt(q)===92?(ue=O,q++):(ue=d,F===0&&_e(Pe)),ue!==d?(y.length>q?(Se=y.charAt(q),q++):(Se=d,F===0&&_e(tt)),Se!==d?(ue=[ue,Se],W=ue):(q=W,W=d)):(q=W,W=d),W===d&&(W=y.charAt(q),de.test(W)?q++:(W=d,F===0&&_e(Re))),W!==d)for(;W!==d;)ie.push(W),W=q,y.charCodeAt(q)===92?(ue=O,q++):(ue=d,F===0&&_e(Pe)),ue!==d?(y.length>q?(Se=y.charAt(q),q++):(Se=d,F===0&&_e(tt)),Se!==d?(ue=[ue,Se],W=ue):(q=W,W=d)):(q=W,W=d),W===d&&(W=y.charAt(q),de.test(W)?q++:(W=d,F===0&&_e(Re)));else ie=d;return ie!==d?I=y.substring(I,q):I=ie,I!==d&&(I=xe(I)),_=I,F--,_===d&&(I=d,F===0&&_e(pe)),_}function ze(){var _,I;return _=q,y.charCodeAt(q)===44?(I=A,q++):(I=d,F===0&&_e(Ge)),I!==d&&(I=Je()),_=I,_===d&&(_=q,y.charCodeAt(q)===59?(I=b,q++):(I=d,F===0&&_e(it)),I!==d&&(I=He()),_=I,_===d&&(_=q,y.charCodeAt(q)===124?(I=B,q++):(I=d,F===0&&_e(Ee)),I!==d&&(I=je()),_=I)),_}function Me(){var _,I;for(F++,_=[],I=y.charAt(q),Fe.test(I)?q++:(I=d,F===0&&_e(Ce));I!==d;)_.push(I),I=y.charAt(q),Fe.test(I)?q++:(I=d,F===0&&_e(Ce));return F--,I=d,F===0&&_e(at),_}if(z=x(),o.peg$library)return{peg$result:z,peg$currPos:q,peg$FAILED:d,peg$maxFailExpected:k,peg$maxFailPos:$};if(z!==d&&q===y.length)return z;throw z!==d&&q<y.length&&_e(rt()),Ze(k,$<y.length?y.charAt($):null,$<y.length?ot($,$+1):ot($,$))}return gr={StartRules:["stringFilter"],SyntaxError:E,parse:w},gr}var Cr;function vi(){return Cr||(Cr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.StringFilterExpression=void 0;const re=Vt(),j=yi(),N=Ht(),E=wr();u.StringFilterExpression={parse(S){if(S.match(/^\s*$/))return{parsed:null,log:[]};const w=(0,E.run_parser)(S,j.parse);return w.parsed&&(0,re.isStringFilter)(w.parsed)?{parsed:w.parsed,log:[]}:{parsed:null,log:w.log}},unparse(S){if(S===null)return"";switch(S.operator){case"=":return S.not?S.values.map(w=>"-"+(0,N.escape)(w)).join(", "):S.values.map(w=>(0,N.escape)(w)).join(", ");case"~":return S.not?S.escaped_values.map(w=>"-"+w).join(", "):S.escaped_values.join(", ");case"starts":return S.not?S.values.map(w=>"-"+(0,N.escape)(w)+"%").join(", "):S.values.map(w=>(0,N.escape)(w)+"%").join(", ");case"ends":return S.not?S.values.map(w=>"-%"+(0,N.escape)(w)).join(", "):S.values.map(w=>"%"+(0,N.escape)(w)).join(", ");case"contains":return S.not?S.values.map(w=>"-%"+(0,N.escape)(w)+"%").join(", "):S.values.map(w=>"%"+(0,N.escape)(w)+"%").join(", ");case"or":return S.members.map(w=>u.StringFilterExpression.unparse(w)).join(" | ");case"and":return S.members.map(w=>u.StringFilterExpression.unparse(w)).join("; ");case",":return S.members.map(w=>u.StringFilterExpression.unparse(w)).join(", ");case"()":{const w="("+u.StringFilterExpression.unparse(S.expr)+")";return S.not?"-"+w:w}case"null":return S.not?"-null":"null";case"empty":return S.not?"-empty":"empty"}}}})(mr)),mr}var yr={},vr,Dr;function wi(){if(Dr)return vr;Dr=1;const{temporalNot:u,joinTemporal:re,timeLiteral:j,mkUnits:N}=Ht();function E(o,d){function t(){this.constructor=o}t.prototype=d.prototype,o.prototype=new t}function S(o,d,t,D){var x=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(x,S.prototype),x.expected=d,x.found=t,x.location=D,x.name="SyntaxError",x}E(S,Error);function w(o,d,t){return t=t||" ",o.length>d?o:(d-=o.length,t+=t.repeat(d),o+t.slice(0,d))}S.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var t=null,D;for(D=0;D<o.length;D++)if(o[D].source===this.location.source){t=o[D].text.split(/\r\n|\n|\r/g);break}var x=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(x):x,ee=this.location.source+":"+Z.line+":"+Z.column;if(t){var ce=this.location.end,O=w("",Z.line.toString().length," "),A=t[x.line-1],b=x.line===ce.line?ce.column:A.length+1,B=b-x.column||1;d+=`
|
|
13
|
+
--> `+ee+`
|
|
14
|
+
`+O+` |
|
|
15
|
+
`+Z.line+" | "+A+`
|
|
16
|
+
`+O+" | "+w("",x.column-1," ")+w("",B,"^")}else d+=`
|
|
17
|
+
at `+ee}return d},S.buildMessage=function(o,d){var t={literal:function(A){return'"'+x(A.text)+'"'},class:function(A){var b=A.parts.map(function(B){return Array.isArray(B)?Z(B[0])+"-"+Z(B[1]):Z(B)});return"["+(A.inverted?"^":"")+b.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(A){return A.description}};function D(A){return A.charCodeAt(0).toString(16).toUpperCase()}function x(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function Z(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function ee(A){return t[A.type](A)}function ce(A){var b=A.map(ee),B,de;if(b.sort(),b.length>0){for(B=1,de=1;B<b.length;B++)b[B-1]!==b[B]&&(b[de]=b[B],de++);b.length=de}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function O(A){return A?'"'+x(A)+'"':"end of input"}return"Expected "+ce(o)+" but "+O(d)+" found."};function y(o,d){d=d!==void 0?d:{};var t={},D=d.grammarSource,x={temporalFilter:or},Z=or,ee="(",ce=")",O="second",A="minute",b="hour",B="day",de="week",Fe="month",ve="quarter",Ye="year",Ae="s",pe="-",Pe=":",tt="not",Re="null",Ge="to",it="now",Ee="last",at="this",Ce="next",De="ago",st="from",qe="before",Oe="after",ke="through",xe="starting",Je="for",He="today",je="yesterday",q="tomorrow",h="and",$="or",k="monday",F="tuesday",z="wednesday",Y="thursday",we="friday",Qe="saturday",rt="sunday",C=/^[0-9]/,nt=/^[ Tt]/,ot=/^[.,]/,_e=/^[Ww]/,Ze=/^[Kk]/,ct=/^[Qq]/,gt=/^[1234]/,We=/^[a-zA-Z]/,Ke=/^[ \t]/,ze=ne("(",!1),Me=ne(")",!1),_=ht([["0","9"]],!1,!1),I=ne("second",!0),ie=ne("minute",!0),W=ne("hour",!0),ue=ne("day",!0),Se=ne("week",!0),lt=ne("month",!0),Xe=ne("quarter",!0),At=ne("year",!0),m=ne("s",!0),e=ne("-",!1),a=ht([" ","T","t"],!1,!1),f=ne(":",!1),l=ht([".",","],!1,!1),R=ht(["W","w"],!1,!1),J=ht(["K","k"],!1,!1),fe=ht(["Q","q"],!1,!1),V=ht(["1","2","3","4"],!1,!1),he=ne("not",!0),be=ne("null",!0),yt=ne("to",!0),Zt=ne("now",!0),Kt=ne("last",!0),Bt=ne("this",!0),Gt=ne("next",!0),te=ne("ago",!0),Xt=ne("from",!0),Lt=ne("before",!0),It=ne("after",!0),Ut=ne("through",!0),er=ne("starting",!0),tr=ne("for",!0),et=ne("today",!0),jt=ne("yesterday",!0),rr=ne("tomorrow",!0),nr=ne("and",!0),ir=ne("or",!0),ar=ne("monday",!0),sr=ne("tuesday",!0),Tt=ne("wednesday",!0),me=ne("thursday",!0),g=ne("friday",!0),v=ne("saturday",!0),L=ne("sunday",!0),Q=ht([["a","z"],["A","Z"]],!1,!1),K=_r("optional whitespace"),P=ht([" "," "],!1,!1),G=_r("whitespace"),H=function(n,s){return s.reduce((i,[,c,,M])=>re(i,c,M),n)},le=function(n){return u(n,!0)},ge=function(n){return n},Yr=function(){return{operator:"null"}},Jr=function(n){return{operator:"()",expr:n}},Hr=function(n){return{operator:"before",before:n}},Zr=function(n){return{operator:"before",before:n,not:!0}},Kr=function(n){return{operator:"after",after:n}},Xr=function(n){return{operator:"after",after:n,not:!0}},en=function(n,s){return{operator:n,...s}},tn=function(n,s){return{operator:"to",fromMoment:n,toMoment:s}},rn=function(n,s){return{...s,operator:"for",begin:n}},nn=function(n){return{operator:"in",in:n}},an=function(n){return{operator:"in_last",...n}},sn=function(){return"last"},on=function(){return"next"},ln=function(n,s){return{units:s,n}},fn=function(n){return n},un=function(n){return N(n)},cn=function(){return{moment:"now"}},dn=function(){return{moment:"today"}},pn=function(){return{moment:"yesterday"}},hn=function(){return{moment:"tomorrow"}},mn=function(n){return{moment:"ago",...n}},gn=function(n){return{moment:"from_now",...n}},yn=function(n){return{moment:n.toLowerCase(),which:"next"}},vn=function(n){return{moment:n.toLowerCase(),which:"last"}},wn=function(n,s){return{moment:n,units:s}},_n=function(n){return{moment:n.toLowerCase(),which:"last"}},An=function(n){return n},Tn=function(){return"this"},$n=function(){return"next"},Sn=function(){return"last"},bn=function(n){return j(n)},Fn=function(n){return j(n,"week")},On=function(n){return j(n,"quarter")},En=function(n){return j(n,"minute")},kn=function(n){return j(n,"hour")},Rn=function(n){return j(n,"day")},Vn=function(n){return j(n,"month")},Ln=function(n){return j(n,"year")},In=function(n){return n},Cn=function(){return"or"},Dn=function(){return"and"},r=d.peg$currPos|0,kt=[{line:1,column:1}],ft=r,Wt=d.peg$maxFailExpected||[],p=d.peg$silentFails|0,Ct;if(d.startRule){if(!(d.startRule in x))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');Z=x[d.startRule]}function ne(n,s){return{type:"literal",text:n,ignoreCase:s}}function ht(n,s,i){return{type:"class",parts:n,inverted:s,ignoreCase:i}}function xn(){return{type:"end"}}function _r(n){return{type:"other",description:n}}function Ar(n){var s=kt[n],i;if(s)return s;if(n>=kt.length)i=kt.length-1;else for(i=n;!kt[--i];);for(s=kt[i],s={line:s.line,column:s.column};i<n;)o.charCodeAt(i)===10?(s.line++,s.column=1):s.column++,i++;return kt[n]=s,s}function Tr(n,s,i){var c=Ar(n),M=Ar(s),U={source:D,start:{offset:n,line:c.line,column:c.column},end:{offset:s,line:M.line,column:M.column}};return U}function T(n){r<ft||(r>ft&&(ft=r,Wt=[]),Wt.push(n))}function Nn(n,s,i){return new S(S.buildMessage(n,s),n,s,i)}function or(){var n,s,i,c,M,U,X,ae;if(n=r,s=lr(),s!==t){for(i=[],c=r,M=Rt(),U=br(),U!==t?(X=Rt(),ae=lr(),ae!==t?(M=[M,U,X,ae],c=M):(r=c,c=t)):(r=c,c=t);c!==t;)i.push(c),c=r,M=Rt(),U=br(),U!==t?(X=Rt(),ae=lr(),ae!==t?(M=[M,U,X,ae],c=M):(r=c,c=t)):(r=c,c=t);n=H(s,i)}else r=n,n=t;return n}function lr(){var n,s,i,c;return n=r,s=Bn(),s!==t?(i=Be(),i!==t?(c=$r(),c!==t?n=le(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=$r(),s!==t&&(s=ge(s)),n=s),n}function $r(){var n,s,i,c,M,U;return n=r,s=Gn(),s!==t&&(s=Yr()),n=s,n===t&&(n=r,o.charCodeAt(r)===40?(s=ee,r++):(s=t,p===0&&T(ze)),s!==t?(i=Rt(),c=or(),c!==t?(M=Rt(),o.charCodeAt(r)===41?(U=ce,r++):(U=t,p===0&&T(Me)),U!==t?n=Jr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Yn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Hr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Zn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Zr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Jn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Kr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Hn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Xr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Pn(),s!==t?(i=Be(),i!==t?(c=Dt(),c!==t?n=en(s,c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=vt(),s!==t?(i=Be(),i!==t?(c=Un(),c!==t?(M=Be(),M!==t?(U=vt(),U!==t?n=tn(s,U):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=vt(),s!==t?(i=Be(),i!==t?(c=Kn(),c!==t?(M=Be(),M!==t?(U=Dt(),U!==t?n=rn(s,U):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=vt(),s!==t&&(s=nn(s)),n=s,n===t&&(n=r,s=Dt(),s!==t&&(s=an(s)),n=s)))))))))),n}function Pn(){var n,s;return n=r,s=ur(),s!==t&&(s=sn()),n=s,n===t&&(n=r,s=cr(),s!==t&&(s=on()),n=s),n}function Dt(){var n,s,i,c;return n=r,s=qn(),s!==t?(i=Be(),i!==t?(c=Sr(),c!==t?n=ln(s,c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n}function qn(){var n,s,i,c;if(n=r,s=r,i=[],c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t)for(;c!==t;)i.push(c),c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_));else i=t;return i!==t?s=o.substring(s,r):s=i,s!==t&&(s=fn(s)),n=s,n}function Sr(){var n,s,i,c,M;return n=r,s=r,i=o.substr(r,6),i.toLowerCase()===O?r+=6:(i=t,p===0&&T(I)),i===t&&(i=o.substr(r,6),i.toLowerCase()===A?r+=6:(i=t,p===0&&T(ie)),i===t&&(i=o.substr(r,4),i.toLowerCase()===b?r+=4:(i=t,p===0&&T(W)),i===t&&(i=o.substr(r,3),i.toLowerCase()===B?r+=3:(i=t,p===0&&T(ue)),i===t&&(i=o.substr(r,4),i.toLowerCase()===de?r+=4:(i=t,p===0&&T(Se)),i===t&&(i=o.substr(r,5),i.toLowerCase()===Fe?r+=5:(i=t,p===0&&T(lt)),i===t&&(i=o.substr(r,7),i.toLowerCase()===ve?r+=7:(i=t,p===0&&T(Xe)),i===t&&(i=o.substr(r,4),i.toLowerCase()===Ye?r+=4:(i=t,p===0&&T(At))))))))),i!==t?s=o.substring(s,r):s=i,s!==t?(i=o.charAt(r),i.toLowerCase()===Ae?r++:(i=t,p===0&&T(m)),i===t&&(i=null),c=r,p++,M=ye(),p--,M===t?c=void 0:(r=c,c=t),c!==t?n=un(s):(r=n,n=t)):(r=n,n=t),n}function vt(){var n,s,i,c,M,U;return n=r,s=Fr(),s!==t&&(s=cn()),n=s,n===t&&(n=r,s=Xn(),s!==t&&(s=dn()),n=s,n===t&&(n=r,s=ei(),s!==t&&(s=pn()),n=s,n===t&&(n=r,s=ti(),s!==t&&(s=hn()),n=s,n===t&&(n=r,s=Dt(),s!==t?(i=Be(),i!==t?(c=Wn(),c!==t?n=mn(s):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Dt(),s!==t?(i=Be(),i!==t?(c=zn(),c!==t?(M=Be(),M!==t?(U=Fr(),U!==t?n=gn(s):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=cr(),s!==t?(i=Be(),i!==t?(c=fr(),c!==t?n=yn(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=ur(),s!==t?(i=Be(),i!==t?(c=fr(),c!==t?n=vn(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Qn(),s!==t?(i=Be(),i!==t?(c=Sr(),c!==t?n=wn(s,c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=fr(),s!==t&&(s=_n(s)),n=s,n===t&&(n=r,s=Mn(),s!==t&&(s=An(s)),n=s)))))))))),n}function Qn(){var n,s;return n=r,s=jn(),s!==t&&(s=Tn()),n=s,n===t&&(n=r,s=cr(),s!==t&&(s=$n()),n=s,n===t&&(n=r,s=ur(),s!==t&&(s=Sn()),n=s)),n}function Mn(){var n,s,i,c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie,wt,dt,pt,zt,xt,Nt,$t,St,dr,_t;if(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t)if(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t)if(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t)if(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t)if(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t)if(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t)if(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t)if(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t)if(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t)if($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t)if(Ne=o.charAt(r),nt.test(Ne)?r++:(Ne=t,p===0&&T(a)),Ne!==t)if(Le=o.charAt(r),C.test(Le)?r++:(Le=t,p===0&&T(_)),Le!==t)if(Ie=o.charAt(r),C.test(Ie)?r++:(Ie=t,p===0&&T(_)),Ie!==t)if(o.charCodeAt(r)===58?(wt=Pe,r++):(wt=t,p===0&&T(f)),wt!==t)if(dt=o.charAt(r),C.test(dt)?r++:(dt=t,p===0&&T(_)),dt!==t)if(pt=o.charAt(r),C.test(pt)?r++:(pt=t,p===0&&T(_)),pt!==t)if(o.charCodeAt(r)===58?(zt=Pe,r++):(zt=t,p===0&&T(f)),zt!==t)if(xt=o.charAt(r),C.test(xt)?r++:(xt=t,p===0&&T(_)),xt!==t)if(Nt=o.charAt(r),C.test(Nt)?r++:(Nt=t,p===0&&T(_)),Nt!==t){if($t=r,St=o.charAt(r),ot.test(St)?r++:(St=t,p===0&&T(l)),St!==t){for(dr=[],_t=o.charAt(r),C.test(_t)?r++:(_t=t,p===0&&T(_));_t!==t;)dr.push(_t),_t=o.charAt(r),C.test(_t)?r++:(_t=t,p===0&&T(_));St=[St,dr],$t=St}else r=$t,$t=t;$t===t&&($t=null),c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie,wt,dt,pt,zt,xt,Nt,$t],i=c}else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;return i!==t?s=o.substring(s,r):s=i,s!==t&&(s=bn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(o.charCodeAt(r)===45?(Ne=pe,r++):(Ne=t,p===0&&T(e)),Ne!==t?(Le=o.charAt(r),_e.test(Le)?r++:(Le=t,p===0&&T(R)),Le!==t?(Ie=o.charAt(r),Ze.test(Ie)?r++:(Ie=t,p===0&&T(J)),Ie!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Fn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),ct.test(se)?r++:(se=t,p===0&&T(fe)),se!==t?(oe=o.charAt(r),gt.test(oe)?r++:(oe=t,p===0&&T(V)),oe!==t?(c=[c,M,U,X,ae,se,oe],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=On(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(Ne=o.charAt(r),nt.test(Ne)?r++:(Ne=t,p===0&&T(a)),Ne!==t?(Le=o.charAt(r),C.test(Le)?r++:(Le=t,p===0&&T(_)),Le!==t?(Ie=o.charAt(r),C.test(Ie)?r++:(Ie=t,p===0&&T(_)),Ie!==t?(o.charCodeAt(r)===58?(wt=Pe,r++):(wt=t,p===0&&T(f)),wt!==t?(dt=o.charAt(r),C.test(dt)?r++:(dt=t,p===0&&T(_)),dt!==t?(pt=o.charAt(r),C.test(pt)?r++:(pt=t,p===0&&T(_)),pt!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie,wt,dt,pt],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=En(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(Ne=o.charAt(r),nt.test(Ne)?r++:(Ne=t,p===0&&T(a)),Ne!==t?(Le=o.charAt(r),C.test(Le)?r++:(Le=t,p===0&&T(_)),Le!==t?(Ie=o.charAt(r),C.test(Ie)?r++:(Ie=t,p===0&&T(_)),Ie!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=kn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Rn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(c=[c,M,U,X,ae,se,oe],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Vn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(c=[c,M,U,X],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Ln(s)),n=s))))))),n}function fr(){var n,s,i;return n=r,s=r,i=ii(),i===t&&(i=ai(),i===t&&(i=si(),i===t&&(i=oi(),i===t&&(i=li(),i===t&&(i=fi(),i===t&&(i=ui())))))),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=In(s)),n=s,n}function br(){var n,s;return n=r,s=ni(),s!==t&&(s=Cn()),n=s,n===t&&(n=r,s=ri(),s!==t&&(s=Dn()),n=s),n}function Bn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===tt?r+=3:(s=t,p===0&&T(he)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Gn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Re?r+=4:(s=t,p===0&&T(be)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Un(){var n,s,i,c;return n=r,s=o.substr(r,2),s.toLowerCase()===Ge?r+=2:(s=t,p===0&&T(yt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Fr(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===it?r+=3:(s=t,p===0&&T(Zt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ur(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Ee?r+=4:(s=t,p===0&&T(Kt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function jn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===at?r+=4:(s=t,p===0&&T(Bt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function cr(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Ce?r+=4:(s=t,p===0&&T(Gt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Wn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===De?r+=3:(s=t,p===0&&T(te)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function zn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===st?r+=4:(s=t,p===0&&T(Xt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Yn(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===qe?r+=6:(s=t,p===0&&T(Lt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Jn(){var n,s,i,c;return n=r,s=o.substr(r,5),s.toLowerCase()===Oe?r+=5:(s=t,p===0&&T(It)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Hn(){var n,s,i,c;return n=r,s=o.substr(r,7),s.toLowerCase()===ke?r+=7:(s=t,p===0&&T(Ut)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Zn(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===xe?r+=8:(s=t,p===0&&T(er)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Kn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===Je?r+=3:(s=t,p===0&&T(tr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Xn(){var n,s,i,c;return n=r,s=o.substr(r,5),s.toLowerCase()===He?r+=5:(s=t,p===0&&T(et)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ei(){var n,s,i,c;return n=r,s=o.substr(r,9),s.toLowerCase()===je?r+=9:(s=t,p===0&&T(jt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ti(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===q?r+=8:(s=t,p===0&&T(rr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ri(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===h?r+=3:(s=t,p===0&&T(nr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ni(){var n,s,i,c;return n=r,s=o.substr(r,2),s.toLowerCase()===$?r+=2:(s=t,p===0&&T(ir)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ii(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===k?r+=6:(s=t,p===0&&T(ar)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ai(){var n,s,i,c;return n=r,s=o.substr(r,7),s.toLowerCase()===F?r+=7:(s=t,p===0&&T(sr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function si(){var n,s,i,c;return n=r,s=o.substr(r,9),s.toLowerCase()===z?r+=9:(s=t,p===0&&T(Tt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function oi(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===Y?r+=8:(s=t,p===0&&T(me)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function li(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===we?r+=6:(s=t,p===0&&T(g)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function fi(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===Qe?r+=8:(s=t,p===0&&T(v)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ui(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===rt?r+=6:(s=t,p===0&&T(L)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ye(){var n;return n=o.charAt(r),We.test(n)?r++:(n=t,p===0&&T(Q)),n}function Rt(){var n,s;for(p++,n=[],s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P));s!==t;)n.push(s),s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P));return p--,s=t,p===0&&T(K),n}function Be(){var n,s;if(p++,n=[],s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P)),s!==t)for(;s!==t;)n.push(s),s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P));else n=t;return p--,n===t&&(s=t,p===0&&T(G)),n}if(Ct=Z(),d.peg$library)return{peg$result:Ct,peg$currPos:r,peg$FAILED:t,peg$maxFailExpected:Wt,peg$maxFailPos:ft};if(Ct!==t&&r===o.length)return Ct;throw Ct!==t&&r<o.length&&T(xn()),Nn(Wt,ft<o.length?o.charAt(ft):null,ft<o.length?Tr(ft,ft+1):Tr(ft,ft))}return vr={StartRules:["temporalFilter"],SyntaxError:S,parse:y},vr}var xr;function _i(){return xr||(xr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.TemporalFilterExpression=void 0;const re=Vt(),j=wi(),N=wr();u.TemporalFilterExpression={parse(y){if(y.match(/^\s*$/))return{parsed:null,log:[]};const o=(0,N.run_parser)(y,j.parse);return o.parsed&&(0,re.isTemporalFilter)(o.parsed)?{parsed:o.parsed,log:[]}:{parsed:null,log:o.log}},unparse(y){if(y===null)return"";switch(y.operator){case"null":return E(y,"null");case"in":return E(y,w(y.in));case"()":return"("+u.TemporalFilterExpression.unparse(y.expr)+")";case"in_last":return E(y,S(y));case"last":case"next":return E(y,`${y.operator} ${S(y)}`);case"before":return`${y.not?"starting":"before"} ${w(y.before)}`;case"after":return`${y.not?"through":"after"} ${w(y.after)}`;case"to":return E(y,`${w(y.fromMoment)} to ${w(y.toMoment)}`);case"for":return E(y,`${w(y.begin)} for ${S(y)}`);case"or":return y.members.map(o=>u.TemporalFilterExpression.unparse(o)).join(" or ");case"and":return y.members.map(o=>u.TemporalFilterExpression.unparse(o)).join(" and ")}}};function E(y,o){return"not"in y&&y.not?"not "+o:o}function S(y){return y.n==="1"?`1 ${y.units}`:`${y.n} ${y.units}s`}function w(y){switch(y.moment){case"literal":return y.literal;case"now":case"today":case"yesterday":case"tomorrow":return y.moment;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return y.which==="next"?"next "+y.moment:y.moment;case"this":case"next":case"last":return`${y.moment} ${y.units}`;case"ago":return`${S(y)} ago`;case"from_now":return`${S(y)} from now`}}})(yr)),yr}var Nr;function Ai(){return Nr||(Nr=1,(function(u){var re=bt&&bt.__createBinding||(Object.create?(function(y,o,d,t){t===void 0&&(t=d);var D=Object.getOwnPropertyDescriptor(o,d);(!D||("get"in D?!o.__esModule:D.writable||D.configurable))&&(D={enumerable:!0,get:function(){return o[d]}}),Object.defineProperty(y,t,D)}):(function(y,o,d,t){t===void 0&&(t=d),y[t]=o[d]})),j=bt&&bt.__exportStar||function(y,o){for(var d in y)d!=="default"&&!Object.prototype.hasOwnProperty.call(o,d)&&re(o,y,d)};Object.defineProperty(u,"__esModule",{value:!0}),u.TemporalFilterExpression=u.StringFilterExpression=u.NumberFilterExpression=u.BooleanFilterExpression=void 0,j(Vt(),u);var N=hi();Object.defineProperty(u,"BooleanFilterExpression",{enumerable:!0,get:function(){return N.BooleanFilterExpression}});var E=gi();Object.defineProperty(u,"NumberFilterExpression",{enumerable:!0,get:function(){return E.NumberFilterExpression}});var S=vi();Object.defineProperty(u,"StringFilterExpression",{enumerable:!0,get:function(){return S.StringFilterExpression}});var w=_i();Object.defineProperty(u,"TemporalFilterExpression",{enumerable:!0,get:function(){return w.TemporalFilterExpression}})})(bt)),bt}var Ft={},qt={},Pr;function Wr(){return Pr||(Pr=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.MALLOY_INTERFACE_TYPES=void 0,qt.MALLOY_INTERFACE_TYPES={Aggregate:{type:"struct",name:"Aggregate",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},Annotation:{type:"struct",name:"Annotation",fields:{value:{type:"string",optional:!1,array:!1}}},AnonymousQueryInfo:{type:"struct",name:"AnonymousQueryInfo",fields:{schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},ArrayCell:{type:"struct",name:"ArrayCell",fields:{array_value:{type:"Cell",array:!0,optional:!1}}},ArrayType:{type:"struct",name:"ArrayType",fields:{element_type:{type:"AtomicType",optional:!1,array:!1}}},AtomicType:{type:"union",name:"AtomicType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",timestamptz_type:"TimestamptzType"}},BooleanCell:{type:"struct",name:"BooleanCell",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanLiteral:{type:"struct",name:"BooleanLiteral",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanType:{type:"struct",name:"BooleanType",fields:{}},CalculateInfo:{type:"struct",name:"CalculateInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},CalculateOperation:{type:"struct",name:"CalculateOperation",fields:{name:{type:"string",optional:!1,array:!1},field:{type:"Field",optional:!1,array:!1}}},Cell:{type:"union",name:"Cell",options:{string_cell:"StringCell",boolean_cell:"BooleanCell",date_cell:"DateCell",timestamp_cell:"TimestampCell",number_cell:"NumberCell",json_cell:"JSONCell",record_cell:"RecordCell",array_cell:"ArrayCell",null_cell:"NullCell",sql_native_cell:"SQLNativeCell"}},CompileModelRequest:{type:"struct",name:"CompileModelRequest",fields:{model_url:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileModelResponse:{type:"struct",name:"CompileModelResponse",fields:{model:{type:"ModelInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileQueryRequest:{type:"struct",name:"CompileQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileQueryResponse:{type:"struct",name:"CompileQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileSourceRequest:{type:"struct",name:"CompileSourceRequest",fields:{model_url:{type:"string",optional:!1,array:!1},name:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileSourceResponse:{type:"struct",name:"CompileSourceResponse",fields:{source:{type:"SourceInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompilerNeeds:{type:"struct",name:"CompilerNeeds",fields:{table_schemas:{type:"SQLTable",array:!0,optional:!0},sql_schemas:{type:"SQLQuery",array:!0,optional:!0},files:{type:"File",array:!0,optional:!0},connections:{type:"Connection",array:!0,optional:!0},translations:{type:"Translation",array:!0,optional:!0}}},Connection:{type:"struct",name:"Connection",fields:{name:{type:"string",optional:!1,array:!1},dialect:{type:"string",optional:!0,array:!1}}},Data:{type:"union",name:"Data",options:{record_cell:"RecordCell",array_cell:"ArrayCell"}},DateCell:{type:"struct",name:"DateCell",fields:{date_value:{type:"string",optional:!1,array:!1}}},DateLiteral:{type:"struct",name:"DateLiteral",fields:{date_value:{type:"string",optional:!1,array:!1},granularity:{type:"DateTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},DateTimeframe:{type:"enum",name:"DateTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5}},DateType:{type:"struct",name:"DateType",fields:{timeframe:{type:"DateTimeframe",optional:!0,array:!1}}},DimensionInfo:{type:"struct",name:"DimensionInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},DocumentPosition:{type:"struct",name:"DocumentPosition",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},DocumentRange:{type:"struct",name:"DocumentRange",fields:{start:{type:"DocumentPosition",optional:!1,array:!1},end:{type:"DocumentPosition",optional:!1,array:!1}}},DrillOperation:{type:"struct",name:"DrillOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},Expression:{type:"union",name:"Expression",options:{field_reference:"Reference",time_truncation:"TimeTruncationFieldReference",filtered_field:"FilteredField",literal_value:"LiteralValueExpression",moving_average:"MovingAverage"}},Field:{type:"struct",name:"Field",fields:{expression:{type:"Expression",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},FieldInfo:{type:"union",name:"FieldInfo",options:{dimension:"DimensionInfo",measure:"MeasureInfo",join:"JoinInfo",view:"ViewInfo",calculate:"CalculateInfo"}},File:{type:"struct",name:"File",fields:{url:{type:"string",optional:!1,array:!1},contents:{type:"string",optional:!0,array:!1},invalidation_key:{type:"string",optional:!0,array:!1}}},Filter:{type:"union",name:"Filter",options:{filter_string:"FilterStringApplication",literal_equality:"LiteralEqualityComparison"}},FilterExpressionLiteral:{type:"struct",name:"FilterExpressionLiteral",fields:{filter_expression_value:{type:"string",optional:!1,array:!1}}},FilterExpressionType:{type:"struct",name:"FilterExpressionType",fields:{filter_type:{type:"FilterableType",optional:!1,array:!1}}},FilterOperation:{type:"struct",name:"FilterOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},FilterStringApplication:{type:"struct",name:"FilterStringApplication",fields:{expression:{type:"Expression",optional:!1,array:!1},filter:{type:"string",optional:!1,array:!1}}},FilterableType:{type:"union",name:"FilterableType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",date_type:"DateType",timestamp_type:"TimestampType",timestamptz_type:"TimestamptzType"}},FilteredField:{type:"struct",name:"FilteredField",fields:{field_reference:{type:"Reference",optional:!1,array:!1},where:{type:"FilterOperation",array:!0,optional:!1}}},GroupBy:{type:"struct",name:"GroupBy",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},JSONCell:{type:"struct",name:"JSONCell",fields:{json_value:{type:"string",optional:!1,array:!1}}},JSONType:{type:"struct",name:"JSONType",fields:{}},JoinInfo:{type:"struct",name:"JoinInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},relationship:{type:"Relationship",optional:!1,array:!1}}},Limit:{type:"struct",name:"Limit",fields:{limit:{type:"number",optional:!1,array:!1}}},LiteralEqualityComparison:{type:"struct",name:"LiteralEqualityComparison",fields:{expression:{type:"Expression",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},LiteralValue:{type:"union",name:"LiteralValue",options:{string_literal:"StringLiteral",number_literal:"NumberLiteral",date_literal:"DateLiteral",timestamp_literal:"TimestampLiteral",boolean_literal:"BooleanLiteral",null_literal:"NullLiteral",filter_expression_literal:"FilterExpressionLiteral"}},LiteralValueExpression:{type:"struct",name:"LiteralValueExpression",fields:{literal_value:{type:"LiteralValue",optional:!1,array:!1}}},Location:{type:"struct",name:"Location",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"Range",optional:!1,array:!1}}},LogMessage:{type:"struct",name:"LogMessage",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"DocumentRange",optional:!1,array:!1},severity:{type:"LogSeverity",optional:!1,array:!1},message:{type:"string",optional:!1,array:!1}}},LogSeverity:{type:"enum",name:"LogSeverity",values:{debug:1,info:2,warn:3,error:4}},MeasureInfo:{type:"struct",name:"MeasureInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ModelEntryValue:{type:"union",name:"ModelEntryValue",options:{source:"SourceInfo",query:"QueryInfo"}},ModelInfo:{type:"struct",name:"ModelInfo",fields:{entries:{type:"ModelEntryValue",array:!0,optional:!1},annotations:{type:"Annotation",array:!0,optional:!0},anonymous_queries:{type:"AnonymousQueryInfo",array:!0,optional:!1}}},MovingAverage:{type:"struct",name:"MovingAverage",fields:{field_reference:{type:"Reference",optional:!1,array:!1},rows_preceding:{type:"number",optional:!0,array:!1},rows_following:{type:"number",optional:!0,array:!1},partition_fields:{type:"Reference",array:!0,optional:!0}}},Nest:{type:"struct",name:"Nest",fields:{name:{type:"string",optional:!0,array:!1},view:{type:"View",optional:!1,array:!1}}},NullCell:{type:"struct",name:"NullCell",fields:{}},NullLiteral:{type:"struct",name:"NullLiteral",fields:{}},NumberCell:{type:"struct",name:"NumberCell",fields:{number_value:{type:"number",optional:!1,array:!1},subtype:{type:"NumberSubtype",optional:!0,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberLiteral:{type:"struct",name:"NumberLiteral",fields:{number_value:{type:"number",optional:!1,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberSubtype:{type:"enum",name:"NumberSubtype",values:{integer:1,decimal:2,bigint:3}},NumberType:{type:"struct",name:"NumberType",fields:{subtype:{type:"NumberSubtype",optional:!0,array:!1}}},OrderBy:{type:"struct",name:"OrderBy",fields:{field_reference:{type:"Reference",optional:!1,array:!1},direction:{type:"OrderByDirection",optional:!0,array:!1}}},OrderByDirection:{type:"enum",name:"OrderByDirection",values:{asc:1,desc:2}},ParameterInfo:{type:"struct",name:"ParameterInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"ParameterType",optional:!1,array:!1},default_value:{type:"LiteralValue",optional:!0,array:!1}}},ParameterType:{type:"union",name:"ParameterType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",filter_expression_type:"FilterExpressionType",timestamptz_type:"TimestamptzType"}},ParameterValue:{type:"struct",name:"ParameterValue",fields:{name:{type:"string",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},Position:{type:"struct",name:"Position",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},Query:{type:"struct",name:"Query",fields:{definition:{type:"QueryDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},QueryArrow:{type:"struct",name:"QueryArrow",fields:{source:{type:"QueryArrowSource",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},QueryArrowSource:{type:"union",name:"QueryArrowSource",options:{refinement:"QueryRefinement",source_reference:"Reference"}},QueryDefinition:{type:"union",name:"QueryDefinition",options:{arrow:"QueryArrow",query_reference:"Reference",refinement:"QueryRefinement"}},QueryInfo:{type:"struct",name:"QueryInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},QueryRefinement:{type:"struct",name:"QueryRefinement",fields:{base:{type:"QueryDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},Range:{type:"struct",name:"Range",fields:{start:{type:"Position",optional:!1,array:!1},end:{type:"Position",optional:!1,array:!1}}},RecordCell:{type:"struct",name:"RecordCell",fields:{record_value:{type:"Cell",array:!0,optional:!1}}},RecordType:{type:"struct",name:"RecordType",fields:{fields:{type:"DimensionInfo",array:!0,optional:!1}}},Reference:{type:"struct",name:"Reference",fields:{name:{type:"string",optional:!1,array:!1},path:{type:"string",array:!0,optional:!0},parameters:{type:"ParameterValue",array:!0,optional:!0}}},Relationship:{type:"enum",name:"Relationship",values:{one:1,many:2,cross:3}},Result:{type:"struct",name:"Result",fields:{data:{type:"Data",optional:!0,array:!1},schema:{type:"Schema",optional:!1,array:!1},sql:{type:"string",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},model_annotations:{type:"Annotation",array:!0,optional:!0},query_timezone:{type:"string",optional:!0,array:!1},source_annotations:{type:"Annotation",array:!0,optional:!0}}},RunIndexQueryRequest:{type:"struct",name:"RunIndexQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},source_name:{type:"string",optional:!1,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunIndexQueryResponse:{type:"struct",name:"RunIndexQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},RunQueryRequest:{type:"struct",name:"RunQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunQueryResponse:{type:"struct",name:"RunQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},SQLNativeCell:{type:"struct",name:"SQLNativeCell",fields:{sql_native_value:{type:"string",optional:!1,array:!1}}},SQLNativeType:{type:"struct",name:"SQLNativeType",fields:{sql_type:{type:"string",optional:!0,array:!1}}},SQLQuery:{type:"struct",name:"SQLQuery",fields:{sql:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},SQLTable:{type:"struct",name:"SQLTable",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},Schema:{type:"struct",name:"Schema",fields:{fields:{type:"FieldInfo",array:!0,optional:!1}}},SourceInfo:{type:"struct",name:"SourceInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},parameters:{type:"ParameterInfo",array:!0,optional:!0}}},StringCell:{type:"struct",name:"StringCell",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringLiteral:{type:"struct",name:"StringLiteral",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringType:{type:"struct",name:"StringType",fields:{}},TimeTruncationFieldReference:{type:"struct",name:"TimeTruncationFieldReference",fields:{field_reference:{type:"Reference",optional:!1,array:!1},truncation:{type:"TimestampTimeframe",optional:!1,array:!1}}},TimestampCell:{type:"struct",name:"TimestampCell",fields:{timestamp_value:{type:"string",optional:!1,array:!1}}},TimestampLiteral:{type:"struct",name:"TimestampLiteral",fields:{timestamp_value:{type:"string",optional:!1,array:!1},granularity:{type:"TimestampTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},TimestampTimeframe:{type:"enum",name:"TimestampTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5,hour:6,minute:7,second:8}},TimestampType:{type:"struct",name:"TimestampType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimestamptzType:{type:"struct",name:"TimestamptzType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimingInfo:{type:"struct",name:"TimingInfo",fields:{name:{type:"string",optional:!1,array:!1},duration_ms:{type:"number",optional:!1,array:!1},detailed_timing:{type:"TimingInfo",array:!0,optional:!0}}},Translation:{type:"struct",name:"Translation",fields:{url:{type:"string",optional:!1,array:!1},compiled_model_json:{type:"string",optional:!0,array:!1}}},View:{type:"struct",name:"View",fields:{definition:{type:"ViewDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ViewArrow:{type:"struct",name:"ViewArrow",fields:{source:{type:"ViewDefinition",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},ViewDefinition:{type:"union",name:"ViewDefinition",options:{arrow:"ViewArrow",view_reference:"Reference",refinement:"ViewRefinement",segment:"ViewSegment"}},ViewInfo:{type:"struct",name:"ViewInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"View",optional:!0,array:!1}}},ViewOperation:{type:"union",name:"ViewOperation",options:{group_by:"GroupBy",aggregate:"Aggregate",order_by:"OrderBy",limit:"Limit",where:"FilterOperation",nest:"Nest",having:"FilterOperation",drill:"DrillOperation",calculate:"CalculateOperation"}},ViewRefinement:{type:"struct",name:"ViewRefinement",fields:{base:{type:"ViewDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},ViewSegment:{type:"struct",name:"ViewSegment",fields:{operations:{type:"ViewOperation",array:!0,optional:!1}}}}),qt}var Qt={},Jt={},Mt={},qr;function Ti(){return qr||(qr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.RESERVED_WORDS=void 0,Mt.RESERVED_WORDS=["all","and","as","asc","avg","boolean","by","case","cast","compose","count","date","day","days","desc","distinct","else","end","exclude","export","extend","false","filter","for","from","full","has","hour","hours","import","in","include","inner","internal","is","json","left","like","max","min","minute","minutes","month","months","not","now","null","number","on","or","pick","private","public","quarter","quarters","right","second","seconds","source","sql","string","sum","table","then","this","timestamp","timestamptz","to","true","virtual","week","weeks","when","with","year","years"]),Mt}var Qr;function $i(){if(Qr)return Jt;Qr=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.maybeQuoteIdentifier=j;const u=Ti();function re(N){const E=!N.match(/^[A-Za-z_][A-Za-z_0-9]*$/),S=u.RESERVED_WORDS.includes(N.toLowerCase());return E||S}function j(N){return re(N)?`\`${N}\``:N}return Jt}var Mr;function Si(){if(Mr)return Qt;Mr=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.queryToMalloy=re,Qt.filterToMalloy=j;const u=$i();function re(h,{tabWidth:$}={tabWidth:2}){const k=ce(h);return y(k,{tabWidth:$})}function j(h,{tabWidth:$}={tabWidth:2}){const k=Je(h);return y(k,{tabWidth:$})}const N=Symbol("indent"),E=Symbol("newline"),S=Symbol("outdent"),w=Symbol("optional_newline_indent");function y(h,{tabWidth:$}={tabWidth:2}){let k="",F=0,z=!0;for(const Y of h)if(Y===E)k+=`
|
|
18
|
+
`,z=!0;else if(Y===S)F--;else if(Y===N)F++;else{if(Y===w)continue;z&&(k+=" ".repeat(F*$),z=!1),k+=Y}return k}function o(h,$,k,F){var z;if($.includes(E))return[h,E,N,...$,E,S,k];const we=((z=F?.spaces)!==null&&z!==void 0?z:!0)?" ":"";return[h,we,...$,we,k]}function d(h){return{contents:h,quoteCharacter:'"'}}function t(h,$){const k=[];for(let F=0;F<h.length;F++){const z=h[F];k.push(z),F<h.length-1&&k.push($)}return k}function D(h){var $,k;switch(h.kind){case"filter_expression_literal":return[ke(h.filter_expression_value)];case"boolean_literal":return[h.boolean_value.toString()];case"string_literal":{const{contents:F,quoteCharacter:z}=d(h.string_value);return[z,F,z]}case"number_literal":return[h.number_value.toString()];case"null_literal":return["null"];case"date_literal":return[Z(x(h.date_value),($=h.granularity)!==null&&$!==void 0?$:"day",h.timezone)];case"timestamp_literal":return[Z(x(h.timestamp_value),(k=h.granularity)!==null&&k!==void 0?k:"second",h.timezone)]}}function x(h){let $;if($=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/.exec(h)){const[k,F,z,Y,we,Qe,rt]=$;return[F,z,Y,we,Qe,rt]}else if($=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/.exec(h)){const[k,F,z,Y,we,Qe]=$;return[F,z,Y,we,Qe,"00"]}else if($=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d)(?:00)?/.exec(h)){const[k,F,z,Y,we]=$;return[F,z,Y,we,"00","00"]}else if($=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(h)){const[k,F,z,Y]=$;return[F,z,Y,"00","00","00"]}else if($=/(\d\d\d\d)-(\d\d)/.exec(h)){const[k,F,z]=$;return[F,z,"01","00","00","00"]}else if($=/(\d\d\d\d)/.exec(h)){const[k,F]=$;return[F,"01","01","00","00","00"]}return["1970","01","01","00","00","00"]}function Z([h,$,k,F,z,Y],we,Qe){switch(we){case"year":return`@${h}`;case"quarter":{const rt=Math.floor(+$/3)+1;return`@${h}-Q${rt}`}case"month":return`@${h}-${$}`;case"week":return`@${h}-${$}-${k}-WK`;case"day":return`@${h}-${$}-${k}`;case"hour":return`@${h}-${$}-${k} ${F}`;case"minute":return`@${h}-${$}-${k} ${F}:${z}`;case"second":return Qe!==void 0?`@${h}-${$}-${k} ${F}:${z}:${Y}[${Qe}]`:`@${h}-${$}-${k} ${F}:${z}:${Y}`;default:throw new Error("Unknown timeframe.")}}function ee(h){var $;const k=[];for(const F of($=h.path)!==null&&$!==void 0?$:[])k.push((0,u.maybeQuoteIdentifier)(F)),k.push(".");if(k.push((0,u.maybeQuoteIdentifier)(h.name)),h.parameters){const F=[];for(let z=0;z<h.parameters.length;z++){const Y=h.parameters[z];F.push((0,u.maybeQuoteIdentifier)(Y.name)),F.push(" is "),F.push(...D(Y.value)),z<h.parameters.length-1&&F.push(",",E)}k.push(...o("(",F,")",{spaces:!1}))}return k}function ce(h){const $=[];return $.push(...je(h.annotations)),$.push("run: "),$.push(...A(h.definition)),$}function O(h){const $=[];switch(h.kind){case"source_reference":{$.push(...ee(h));break}case"refinement":$.push(...A(h));break}return $}function A(h){const $=[];switch(h.kind){case"arrow":{$.push(...O(h.source)),$.push(" -> "),$.push(...b(h.view));break}case"query_reference":{$.push(...ee(h));break}case"refinement":{const k=A(h.base);h.base.kind==="arrow"?$.push(...o("(",k,")",{spaces:!1})):$.push(...k),$.push(" + "),$.push(...b(h.refinement));break}}return $}function b(h){const $=[];switch(h.kind){case"arrow":{$.push(...b(h.source)),$.push(" -> "),$.push(...b(h.view));break}case"view_reference":{$.push(...ee(h));break}case"refinement":{$.push(...b(h.base)),$.push(" + "),$.push(...b(h.refinement));break}case"segment":{$.push(...B(h));break}}return $}function B(h){if(h.operations.length===0)return["{ }"];const $=h.operations.length>1,k=[];for(let F=0;F<h.operations.length;F++){const z=h.operations[F],Y=[z];for(;F<h.operations.length-1;){const we=h.operations[F+1];if(we.kind===z.kind)Y.push(we),F++;else break}k.push(...de(Y)),$&&F<h.operations.length-1&&k.push(E)}return o("{",k,"}")}function de(h){switch(h[0].kind){case"aggregate":return Pe(h,"aggregate");case"group_by":return Pe(h,"group_by");case"order_by":return tt(h);case"nest":return Ge(h);case"limit":return Ce(h);case"where":return De(h);case"having":return qe(h);case"drill":return st(h);case"calculate":return Pe(h,"calculate")}}function Fe(h,$,k=""){const F=[];F.push(`${h}:`);const z=$.length>1||$.some(Y=>Y.includes(E));z?F.push(E,N):F.push(" ");for(let Y=0;Y<$.length;Y++){const we=$[Y];F.push(...we),$.length>1&&Y<$.length-1&&F.push(k),z&&Y<$.length-1&&F.push(E)}return z&&F.push(S),F}function ve(h){const $=[];return $.push(...Ae(h.expression)),$}function Ye(h){return h}function Ae(h){var $;switch(h.kind){case"field_reference":return ee(h);case"time_truncation":return[...ee(h.field_reference),".",h.truncation];case"filtered_field":return[...ee(h.field_reference),...o(" {",De(h.where),"}")];case"literal_value":return D(h.literal_value);case"moving_average":{const k=["avg_moving",...o("(",[...ee(h.field_reference),h.rows_preceding!==void 0?`, ${h.rows_preceding}`:", 0",h.rows_following!==void 0?`, ${h.rows_following}`:""],")",{spaces:!1})];return!(($=h.partition_fields)===null||$===void 0)&&$.length&&k.push(...o(" {",["partition_by",": ",...t(h.partition_fields.flatMap(F=>ee(F)),", ")],"}")),k}}}function pe(h,$=!1){const k=[];return $||k.push(...je(h.field.annotations)),h.name&&(k.push((0,u.maybeQuoteIdentifier)(h.name)),k.push(" is ")),k.push(...ve(h.field)),k}function Pe(h,$){const k=[],F=h.length===1;return F&&k.push(...je(h[0].field.annotations)),k.push(...Fe($,h.map(z=>pe(z,F)))),k}function tt(h){return Fe("order_by",h.map(Re),",")}function Re(h){const $=[];return $.push(...ee(h.field_reference)),h.direction&&($.push(" "),$.push(h.direction)),$}function Ge(h){const $=[],k=h.length===1;return k&&$.push(...je(h[0].view.annotations)),$.push(...Fe("nest",h.map(F=>it(F,k)))),$}function it(h,$=!1){const k=[];return $||k.push(...je(h.view.annotations)),h.name&&(k.push((0,u.maybeQuoteIdentifier)(h.name)),k.push(" is ")),k.push(...Ee(h.view)),k}function Ee(h){return b(h.definition)}function at(h){return[`limit: ${h.limit}`]}function Ce(h){const $=[];for(let k=0;k<h.length;k++)k!==0&&$.push(E),$.push(...at(h[k]));return $}function De(h){return Fe("where",h.map(He),",")}function st(h){return Fe("drill",h.map(He),",")}function qe(h){return Fe("having",h.map(He),",")}const Oe=["`","'",'"'];function ke(h){let $,k;for(const F of Oe){const z=xe(h,F);if(z===h)return`f${F}${h}${F}`;(k===void 0||z.length<k.length)&&($=F,k=z)}return`f${$}${k}${$}`}function xe(h,$){let k="";for(let F=0;F<h.length;F++)h.slice(F).startsWith($)?(k+="\\"+$,F+=$.length):(k+=h[F],h[F]==="\\"&&(k+=h[++F]));return k}function Je(h){switch(h.kind){case"filter_string":return[...Ae(h.expression)," ~ ",ke(h.filter)];case"literal_equality":return[...Ae(h.expression)," = ",...D(h.value)]}}function He(h){return Je(h.filter)}function je(h){return h?h.flatMap(q):[]}function q(h){return[h.value.trim(),E]}return Qt}var Ot={},Br;function bi(){if(Br)return Ot;Br=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.nestUnions=re,Ot.unnestUnions=j,Ot.convertFromThrift=N,Ot.convertToThrift=S;const u=Wr();function re(w){if(w==null)return w;if(typeof w=="string"||typeof w=="number"||typeof w=="boolean")return w;if(Array.isArray(w))return w.map(re);{const y={};let o;for(const d in w)d==="kind"?o=w[d]:y[d]=re(w[d]);return o===void 0?y:{[o]:y}}}function j(w,y){if(w==null)return w;if(typeof w=="string"||typeof w=="number"||typeof w=="boolean")return w;if(Array.isArray(w))return w.map(o=>j(o,y));{const o=E(y);if(o.type==="union"){for(const d in o.options)if(w[d]!==void 0){const t=j(w[d],o.options[d]);if(typeof t=="object")return{kind:d,...t}}}else if(o.type==="struct"){const d={};for(const t in w){const D=o.fields[t];if(D===void 0)throw new Error(`Unknown field ${t} in ${y}`);d[t]=j(w[t],D.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${y}`)}}function N(w,y){if(w==null)return w;if(typeof w=="string"||typeof w=="boolean")return w;if(typeof w=="number"){if(y==="number")return w;const o=E(y);if(o.type!=="enum")throw new Error(`Found a number where a ${y} was expected`);const d=Object.entries(o.values).find(([,t])=>t===w);if(d===void 0)throw new Error(`${w} is not a valid enum value for ${y}`);return d[0]}else{if(Array.isArray(w))return w.map(o=>N(o,y));{const o=E(y);if(o.type==="union"){for(const d in o.options)if(w[d]!==void 0&&w[d]!==null){const t=N(w[d],o.options[d]);if(typeof t=="object")return{kind:d,...t}}}else if(o.type==="struct"){const d={};for(const t in w){const D=o.fields[t];if(D===void 0)throw new Error(`Unknown field ${t} in ${y}`);d[t]=N(w[t],D.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${y}`)}}}function E(w){const y=u.MALLOY_INTERFACE_TYPES[w];if(y===void 0)throw new Error(`Unknown Malloy interface type ${w}`);return y}function S(w,y){if(w==null)return w;if(typeof w=="number"||typeof w=="boolean")return w;if(typeof w=="string"){if(y==="string")return w;const o=E(y);if(o.type==="enum"){const d=o.values[w];if(d===void 0)throw new Error(`${w} is not a valid enum value for ${y}`);return d}}else{if(Array.isArray(w))return w.map(o=>S(o,y));{const o=E(y);if(o.type==="union"){const d=w.kind,t=o.options[d];if(t===void 0)throw new Error(`${d} is not a valid union of ${y}`);const D=E(t);if(D.type!=="struct")throw new Error("Union fields must be structs");const x={};for(const Z in w){if(Z==="kind")continue;const ee=D.fields[Z];x[Z]=S(w[Z],ee.type)}return{[d]:x}}else if(o.type==="struct"){const d={};for(const t in w){const D=o.fields[t];if(D===void 0)throw new Error(`Unknown field ${t} in ${y}`);d[t]=S(w[t],D.type)}return d}}}}return Ot}var Gr;function Fi(){return Gr||(Gr=1,(function(u){var re=Ft&&Ft.__createBinding||(Object.create?(function(S,w,y,o){o===void 0&&(o=y);var d=Object.getOwnPropertyDescriptor(w,y);(!d||("get"in d?!w.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return w[y]}}),Object.defineProperty(S,o,d)}):(function(S,w,y,o){o===void 0&&(o=y),S[o]=w[y]})),j=Ft&&Ft.__exportStar||function(S,w){for(var y in S)y!=="default"&&!Object.prototype.hasOwnProperty.call(w,y)&&re(w,S,y)};Object.defineProperty(u,"__esModule",{value:!0}),u.thingy4sddfdfsd=u.thingy4sdfsd=u.thingy4dfdsfs=u.thingy4asdfas=u.thingy4asdfasdf=u.thingy3dfdf=u.thingy3=u.thingy2asdf=u.thingyssdfg=u.thingy123r=u.thingy1=u.res=u.test=u.convertToThrift=u.convertFromThrift=u.unnestUnions=u.nestUnions=u.filterToMalloy=u.queryToMalloy=void 0,j(Wr(),u);var N=Si();Object.defineProperty(u,"queryToMalloy",{enumerable:!0,get:function(){return N.queryToMalloy}}),Object.defineProperty(u,"filterToMalloy",{enumerable:!0,get:function(){return N.filterToMalloy}});var E=bi();Object.defineProperty(u,"nestUnions",{enumerable:!0,get:function(){return E.nestUnions}}),Object.defineProperty(u,"unnestUnions",{enumerable:!0,get:function(){return E.unnestUnions}}),Object.defineProperty(u,"convertFromThrift",{enumerable:!0,get:function(){return E.convertFromThrift}}),Object.defineProperty(u,"convertToThrift",{enumerable:!0,get:function(){return E.convertToThrift}}),u.test={entries:[{kind:"source",name:"flights",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"boolean_type"},annotations:[{value:"# foo=1"}]},{kind:"dimension",name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}},{kind:"dimension",name:"arr_rec",type:{kind:"array_type",element_type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}}},{kind:"dimension",name:"rec",type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}},{kind:"join",name:"carriers",relationship:"one",schema:{fields:[{kind:"dimension",name:"code",type:{kind:"string_type"}}]}},{kind:"view",name:"by_carrier",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]}}]},parameters:[{name:"param",type:{kind:"number_type"},default_value:{kind:"number_literal",number_value:7}}]}],anonymous_queries:[]},u.res={connection_name:"foo",data:{kind:"array_cell",array_value:[{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"UA"},{kind:"number_cell",number_value:12341234}]},{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"AA"},{kind:"number_cell",number_value:2343}]}]},schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]},sql:"SELECT * ..."},u.thingy1={definition:{kind:"query_reference",name:"flights_by_carrier"}},u.thingy123r={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},u.thingyssdfg={definition:{kind:"refinement",base:{kind:"query_reference",name:"flights"},refinement:{kind:"view_reference",name:"by_carrier"}}},u.thingy2asdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:"carrier"},filter:"WN"}}]}}}},u.thingy3={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}}},u.thingy3dfdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"view_reference",name:"top10"}}}},u.thingy4asdfasdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}},u.thingy4asdfas={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},u.thingy4dfdsfs={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"limit",limit:10}]}}}},u.thingy4sdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"limit",limit:10}]}}},u.thingy4sddfdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[]}}}})(Ft)),Ft}var Et={},mt={},Ur;function Oi(){return Ur||(Ur=1,(function(u){var re=mt&&mt.__createBinding||(Object.create?(function(m,e,a,f){f===void 0&&(f=a);var l=Object.getOwnPropertyDescriptor(e,a);(!l||("get"in l?!e.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(m,f,l)}):(function(m,e,a,f){f===void 0&&(f=a),m[f]=e[a]})),j=mt&&mt.__setModuleDefault||(Object.create?(function(m,e){Object.defineProperty(m,"default",{enumerable:!0,value:e})}):function(m,e){m.default=e}),N=mt&&mt.__importStar||(function(){var m=function(e){return m=Object.getOwnPropertyNames||function(a){var f=[];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(f[f.length]=l);return f},m(e)};return function(e){if(e&&e.__esModule)return e;var a={};if(e!=null)for(var f=m(e),l=0;l<f.length;l++)f[l]!=="default"&&re(a,e,f[l]);return j(a,e),a}})();Object.defineProperty(u,"__esModule",{value:!0}),u.ASTAnnotationList=u.ASTLimitViewOperation=u.ASTView=u.ASTFilterWithLiteralEquality=u.ASTFilterWithFilterString=u.ASTFilter=u.ASTCalculateViewOperation=u.ASTHavingViewOperation=u.ASTDrillViewOperation=u.ASTWhereViewOperation=u.ASTNestViewOperation=u.ASTFilteredFieldExpression=u.ASTFilterOperationList=u.ASTFilterOperation=u.ASTMovingAverageExpression=u.ASTFieldReferenceList=u.ASTLiteralValueExpression=u.ASTTimeTruncationExpression=u.ASTReferenceExpression=u.ASTExpression=u.ASTField=u.ASTAggregateViewOperation=u.ASTGroupByViewOperation=u.ASTOrderByViewOperation=u.ASTViewOperation=u.ASTViewOperationList=u.ASTSegmentViewDefinition=u.ASTRefinementViewDefinition=u.ASTArrowViewDefinition=u.ASTReferenceViewDefinition=u.ASTReferenceQueryArrowSource=u.ASTReferenceQueryDefinition=u.ASTRefinementQueryDefinition=u.ASTArrowQueryDefinition=u.ASTQueryDefinition=u.ASTQueryArrowSource=u.ASTUnimplemented=u.ASTFilterExpressionLiteralValue=u.ASTTimestampLiteralValue=u.ASTDateLiteralValue=u.ASTBooleanLiteralValue=u.ASTNumberLiteralValue=u.ASTNullLiteralValue=u.ASTStringLiteralValue=u.ASTLiteralValue=u.ASTParameterValue=u.ASTParameterValueList=u.ASTFieldReference=u.ASTReference=u.ASTQuery=void 0,u.ASTAnnotation=void 0;const E=N(Fi()),S=di(),w=N(Ai());class y{constructor(){this.edited=!1}edit(){return this.edited=!0,this._parent&&this._parent.edit(),this}get as(){const e=this;return{Query(){if(e instanceof D)return e;throw new Error("Not an ASTQuery")},Reference(){if(e instanceof x)return e;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(e instanceof tt)return e;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(e instanceof ee)return e;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(e instanceof $)return e;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(e instanceof k)return e;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(e instanceof ce)return e;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(e instanceof O)return e;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(e instanceof b)return e;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(e instanceof st)return e;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(e instanceof Oe)return e;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(e instanceof ke)return e;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(e instanceof qe)return e;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(e instanceof xe)return e;throw new Error("Not an ASTField")},ReferenceExpression(){if(e instanceof Je)return e;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(e instanceof Ee)return e;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(e instanceof Ae)return e;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(e instanceof at)return e;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(e instanceof Ce)return e;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(e instanceof He)return e;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(e instanceof F)return e;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(e instanceof Y)return e;throw new Error("Not an ASTNestViewOperation")},View(){if(e instanceof _e)return e;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(e instanceof De)return e;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(e instanceof Ze)return e;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(e instanceof We)return e;throw new Error("Not an ASTAnnotationList")},Annotation(){if(e instanceof Ke)return e;throw new Error("Not an ASTAnnotation")}}}get find(){const e=this;return{Query(a){return e.findAny(a).as.Query()},Reference(a){return e.findAny(a).as.Reference()},ReferenceQueryArrowSource(a){return e.findAny(a).as.ReferenceQueryArrowSource()},ParameterValueList(a){return e.findAny(a).as.ParameterValueList()},FilterOperation(a){return e.findAny(a).as.FilterOperation()},FilterOperationList(a){return e.findAny(a).as.FilterOperationList()},ParameterValue(a){return e.findAny(a).as.ParameterValue()},StringLiteralValue(a){return e.findAny(a).as.StringLiteralValue()},NumberLiteralValue(a){return e.findAny(a).as.NumberLiteralValue()},ViewOperationList(a){return e.findAny(a).as.ViewOperationList()},GroupByViewOperation(a){return e.findAny(a).as.GroupByViewOperation()},AggregateViewOperation(a){return e.findAny(a).as.AggregateViewOperation()},OrderByViewOperation(a){return e.findAny(a).as.OrderByViewOperation()},Field(a){return e.findAny(a).as.Field()},ReferenceExpression(a){return e.findAny(a).as.ReferenceExpression()},ReferenceViewDefinition(a){return e.findAny(a).as.ReferenceViewDefinition()},ArrowQueryDefinition(a){return e.findAny(a).as.ArrowQueryDefinition()},ArrowViewDefinition(a){return e.findAny(a).as.ArrowViewDefinition()},RefinementViewDefinition(a){return e.findAny(a).as.RefinementViewDefinition()},TimeTruncationExpression(a){return e.findAny(a).as.TimeTruncationExpression()},FilteredFieldExpression(a){return e.findAny(a).as.FilteredFieldExpression()},NestViewOperation(a){return e.findAny(a).as.NestViewOperation()},View(a){return e.findAny(a).as.View()},SegmentViewDefinition(a){return e.findAny(a).as.SegmentViewDefinition()},LimitViewOperation(a){return e.findAny(a).as.LimitViewOperation()},AnnotationList(a){return e.findAny(a).as.AnnotationList()},Annotation(a){return e.findAny(a).as.Annotation()}}}get parent(){if(this._parent===void 0)throw new Error("This node does not have a parent");return this._parent}set parent(e){this._parent=e}static schemaTryGet(e,a,f){return y._schemaTryGet(e,a,f,!1)}static schemaTryGetDrillField(e,a,f){return y._schemaTryGet(e,a,f,!0)}static _schemaTryGet(e,a,f,l){let R=e.fields;for(const fe of f??[]){const V=R.find(he=>he.name===fe);if(V===void 0)throw new Error(`${fe} not found`);if(V.kind==="join"||l&&V.kind==="view"){R=V.schema.fields;continue}if(V.kind==="dimension"||V.kind==="measure"){if(V.type.kind==="record_type"){R=V.type.fields.map(he=>({kind:V.kind,...he}));continue}else if(V.type.kind==="array_type"&&V.type.element_type.kind==="record_type"){R=V.type.element_type.fields.map(he=>({kind:V.kind,...he}));continue}}throw new Error(`${fe} is not a join, record, or repeated record`)}return R.find(fe=>fe.name===a)}static schemaGet(e,a,f){const l=y.schemaTryGet(e,a,f);if(l===void 0)throw new Error(`${a} not found`);return l}static schemaGetDrillField(e,a,f){const l=y.schemaTryGetDrillField(e,a,f);if(l===void 0)throw new Error(`${a} not found`);return l}static schemaMerge(e,a){return{fields:[...e.fields,...a.fields]}}static tagFor(e,a="# "){var f,l;const R=(l=(f=e.annotations)===null||f===void 0?void 0:f.map(fe=>fe.value))===null||l===void 0?void 0:l.filter(fe=>fe.startsWith(a)),J=new S.TagParser;for(const fe of R??[])J.parseAnnotation(fe);return J.finish()}static fieldWasCalculation(e){if(e.kind!=="dimension")throw new Error(`${e.name} could not be an output field, because it is a ${e.kind}, and only dimensions can appear in output schemas`);return y.tagFor(e,"#(malloy) ").has("calculation")}}function o(m){return Array.isArray(m)||typeof m=="string"||typeof m=="number"||typeof m=="boolean"}class d extends y{constructor(e,a){super(),this.node=e,this.children=a,this.originalChildren=[...a],a.forEach(f=>f.parent=this)}*iter(){for(let e=0;e<this.length;e++)yield this.index(e)}get length(){return this.children.length}get last(){return this.children[this.children.length-1]}index(e){return this.children[e]}insert(e,a){this.edit(),this.children.splice(a,0,e),e.parent=this}add(e){this.edit(),this.children.push(e),e.parent=this}remove(e){const a=this.children.findIndex(f=>f===e);if(a===-1)return this;this.edit(),this.children.splice(a,1)}build(){if(!this.edited)return this.node;const e=this.children.map(a=>a.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=e,e}findAny(e){if(e.length===0)return this;const[a,...f]=e;if(typeof a!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);return this.children[a].findAny(f)}findIndex(e){return this.children.findIndex(e)}indexOf(e){return this.children.indexOf(e)}}class t extends y{constructor(e,a){super(),this.node=e,this.children=a;for(const f in a){const l=a[f];l&&!o(l)&&(l.parent=this)}}build(){if(!this.edited)return this.node;let e=this.node;for(const a in this.children){const f=this.children[a];f===void 0?e={...e,[a]:void 0}:o(f)?this.edited&&(e={...e,[a]:f}):e={...e,[a]:f.build()}}return this.node=e,this.edited=!1,e}findAny(e){if(e.length===0)return this;const[a,...f]=e;if(typeof a!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);const l=this.children[a];if(o(l))throw new Error(`${this.constructor.name}.${a} refers to a basic type, not an ASTNode`);return l._find(f)}}class D extends t{constructor(e){var a,f;let l=e.source;if(l===void 0){if(e.model===void 0)throw new Error("Need a model or source");if(e.query){const V=e.query.definition;if(V.kind==="arrow"&&V.source.kind==="source_reference"){const he=V.source.name;if(l=e.model.entries.find(be=>be.name===he),l===void 0)throw new Error(`Model does not contain source or query named ${he}`)}}if(l===void 0&&(l=e.model.entries[0]),l===void 0)throw new Error("Model does not contain any sources or queries")}const R=I(l),J=(a=e.query)!==null&&a!==void 0?a:{definition:{kind:"arrow",source:{kind:"source_reference",name:R.name},view:{kind:"segment",operations:[]}}},fe=(f=e.model)!==null&&f!==void 0?f:{entries:[R],anonymous_queries:[]};super(J,{definition:u.ASTQueryDefinition.from(J.definition),annotations:J.annotations&&new We(J.annotations)}),this.model=fe,e.source&&this.setSource(e.source.name)}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.parent=this}get annotations(){return this.children.annotations}reorderFields(e){this.definition.reorderFields(e)}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new We([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return ze(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}setViewToEmptySegment(){if(!(this.definition instanceof Ae))throw new Error("Must set source before setting view");return this.definition=new Ae({kind:"arrow",source:this.definition.source.build(),view:{kind:"segment",operations:[]}}),this.definition.view.as.SegmentViewDefinition()}isRunnable(){return this.definition.isRunnable()}isEmpty(){return this.definition instanceof Ae&&this.definition.view instanceof De&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(e){if(this.definition instanceof Ae&&this.definition.source instanceof tt&&this.definition.source.name===e)return;if(this.model.entries.find(f=>f.name===e)===void 0)throw new Error(`Source ${e} is not defined in model`);this.definition=new Ae({kind:"arrow",source:{kind:"source_reference",name:e},view:this.definition instanceof Ae?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(e){const a=this.model.entries.find(f=>f.name===e);if(a===void 0||a.kind!=="query")throw new Error(`No query named ${e} in the model`);this.definition=new Pe({kind:"query_reference",name:e})}getQueryInfo(e){const a=this.model.entries.find(f=>f.name===e);if(a===void 0)throw new Error(`Query ${e} is not defined in model`);if(a.kind!=="query")throw new Error(`Model entry ${e} is not a query`);return a}toMalloy(){return E.queryToMalloy(this.build())}build(){return super.build()}setView(e){if(!(this.definition instanceof Ae))throw new Error("Must set source before setting view");return this.definition=new Ae({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:e}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(e){var a;return e instanceof Pe?(a=this.getQueryInfo(e.name).annotations)!==null&&a!==void 0?a:[]:e instanceof pe?this._getInheritedAnnotations(e.base):e instanceof Ae?e.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}u.ASTQuery=D;class x extends t{constructor(e){super(e,{name:e.name,path:e.path,parameters:e.parameters&&new ee(e.parameters)}),this.reference=e}get name(){return this.children.name}set name(e){this.edit(),this.children.name=e}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}static getOrAddParameters(e){if(e.parameters)return e.parameters;e.edit();const a=new ee([]);return e.parameters=a,a}static setParameter(e,a,f){const l=x.tryGetParameter(e,a);if(l!==void 0){l.value=u.ASTLiteralValue.from(u.ASTLiteralValue.makeLiteral(f));return}return e.getOrAddParameters().addParameter(a,f)}static tryGetParameter(e,a){if(e.parameters!==void 0){for(const f of e.parameters.iter())if(f.name===a)return f}}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}}u.ASTReference=x;class Z extends x{get segment(){const e=this.parent;return e instanceof F||e instanceof He?e.field.segment:e instanceof nt||e instanceof ot?e.segment:e.list.segment}getReferenceSchema(){return this.parent instanceof qe?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const e=this.getReferenceSchema();return y.schemaGet(e,this.name,this.path)}}u.ASTFieldReference=Z;class ee extends d{constructor(e){super(e,e.map(a=>new ce(a)))}get parameters(){return this.children}addParameter(e,a){this.add(new ce({name:e,value:u.ASTLiteralValue.makeLiteral(a)}))}}u.ASTParameterValueList=ee;class ce extends t{constructor(e){super(e,{name:e.name,value:u.ASTLiteralValue.from(e.value)}),this.parameter=e}get name(){return this.children.name}get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}}u.ASTParameterValue=ce,u.ASTLiteralValue={from(m){switch(m.kind){case"string_literal":return new O(m);case"number_literal":return new b(m);case"boolean_literal":return new B(m);case"date_literal":return new de(m);case"timestamp_literal":return new Fe(m);case"null_literal":return new A(m);case"filter_expression_literal":return new ve(m)}},makeLiteral(m){if(m!==null&&typeof m=="object"&&"kind"in m)return m;if(typeof m=="string")return{kind:"string_literal",string_value:m};if(typeof m=="boolean")return{kind:"boolean_literal",boolean_value:m};if(typeof m=="number")return{kind:"number_literal",number_value:m};if(m===null)return{kind:"null_literal"};if("date"in m){const e=m.granularity,a=ue(m.date);return ie(e)?{kind:"date_literal",date_value:a,granularity:e}:{kind:"timestamp_literal",timestamp_value:a,granularity:e}}throw new Error("Unknown literal type")}};class O extends t{constructor(e){super(e,{kind:e.kind,string_value:e.string_value}),this.node=e,this.kind="string_literal"}get fieldType(){return{kind:"string_type"}}}u.ASTStringLiteralValue=O;class A extends t{constructor(e){super(e,{kind:e.kind}),this.node=e,this.kind="null_literal"}get fieldType(){}}u.ASTNullLiteralValue=A;class b extends t{constructor(e){super(e,{kind:e.kind,number_value:e.number_value}),this.node=e,this.kind="number_literal"}get fieldType(){return{kind:"number_type",subtype:Number.isInteger(this.children.number_value)?"integer":"decimal"}}}u.ASTNumberLiteralValue=b;class B extends t{constructor(e){super(e,{kind:e.kind,boolean_value:e.boolean_value}),this.node=e,this.kind="boolean_literal"}get fieldType(){return{kind:"boolean_type"}}}u.ASTBooleanLiteralValue=B;class de extends t{constructor(e){super(e,{kind:e.kind,date_value:e.date_value,granularity:e.granularity}),this.node=e,this.kind="date_literal"}get fieldType(){return{kind:"date_type",timeframe:this.children.granularity}}}u.ASTDateLiteralValue=de;class Fe extends t{constructor(e){super(e,{kind:e.kind,timestamp_value:e.timestamp_value,granularity:e.granularity}),this.node=e,this.kind="timestamp_literal"}get fieldType(){return{kind:"timestamp_type",timeframe:this.children.granularity}}}u.ASTTimestampLiteralValue=Fe;class ve extends t{constructor(e){super(e,{kind:e.kind,filter_expression_value:e.filter_expression_value}),this.node=e,this.kind="filter_expression_literal"}get fieldType(){}}u.ASTFilterExpressionLiteralValue=ve;class Ye extends y{constructor(e){super(),this.node=e}get treeEdited(){return!1}build(){return this.node}findAny(){throw new Error("Tried to find a node from an unimplemented node type")}}u.ASTUnimplemented=Ye,u.ASTQueryArrowSource={from(m){switch(m.kind){case"refinement":return new pe(m);case"source_reference":return new tt(m)}}},u.ASTQueryDefinition={from(m){switch(m.kind){case"arrow":return new Ae(m);case"query_reference":return new Pe(m);case"refinement":return new pe(m)}}};class Ae extends t{constructor(e){super(e,{kind:"arrow",source:u.ASTQueryArrowSource.from(e.source),view:Re.from(e.view)}),this.node=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}getSourceInfo(){return this.source.getSourceInfo()}getOutputSchema(){return this.view.getRefinementSchema()}isRunnable(){return this.view.isRunnable()&&this.source.isRunnable()}get query(){return this.parent.as.Query()}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}reorderFields(e){this.view instanceof De?this.view.reorderFields(e):this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}}u.ASTArrowQueryDefinition=Ae;class pe extends t{constructor(e){super(e,{kind:"refinement",base:u.ASTQueryDefinition.from(e.base),refinement:Re.from(e.refinement)}),this.node=e}get base(){return this.children.base}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}isRunnable(){return!0}get query(){return this.parent.as.Query()}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}getOutputSchema(){const e=this.base.getOutputSchema(),a=this.refinement.getRefinementSchema();return D.schemaMerge(e,a)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.refinement),this.refinement.propagateDown(e)}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getSourceInfo(){return this.base.getSourceInfo()}}u.ASTRefinementQueryDefinition=pe;class Pe extends t{constructor(e){super(e,{kind:"query_reference",name:e.name,path:e.path,parameters:e.parameters&&new ee(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get query(){return this.parent.as.Query()}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getOrAddDefaultSegment(){const e=new pe({kind:"refinement",base:this.build(),refinement:{kind:"segment",operations:[]}});return this.query.definition=e,e.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const a=this.query.model.entries.find(f=>f.name===this.name);if(a===void 0)throw new Error(`Query not found with name ${this.name}`);return a}}u.ASTReferenceQueryDefinition=Pe;class tt extends t{constructor(e){super(e,{kind:"source_reference",name:e.name,path:e.path,parameters:e.parameters&&new ee(e.parameters)}),this.node=e}isRunnable(){return this.areRequiredParametersSet()}get name(){return this.children.name}get arrow(){return this.parent.as.ArrowQueryDefinition()}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getSourceInfo(){const e=this.arrow.query.model.entries.find(a=>a.name===this.name);if(e===void 0)throw new Error(`No query or source named ${this.name}`);return e}getOrAddDefaultSegment(){if(this.getSourceInfo().kind!=="query")throw new Error(`Cannot refine source ${this.name}`);const a=new pe({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=a,a.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var e;const a=this.getSourceInfo();return a.kind==="query"?[]:(e=a.parameters)!==null&&e!==void 0?e:[]}areRequiredParametersSet(){const e=this.getSourceParameters();for(const a of e){if(a.default_value!==void 0)continue;if(this.tryGetParameter(a.name)===void 0)return!1}return!0}}u.ASTReferenceQueryArrowSource=tt;const Re={from(m){switch(m.kind){case"arrow":return new at(m);case"view_reference":return new Ee(m);case"segment":return new De(m);case"refinement":return new Ce(m)}}};function Ge(m,e){const a=m.parent;a instanceof Ae?a.view=e:a instanceof pe?a.refinement=e:a instanceof _e?a.definition=e:a instanceof at?a.source===m?a.source=e:a.view=e:a.base===m?a.base=e:a.refinement=e}function it(m,e,a=[]){const f=m.getInputSchema(),l=D.schemaGet(f,e,a);if(l===void 0)return{isValidViewRefinement:!1,error:`${e} is not defined`};if(l.kind!=="view")return{isValidViewRefinement:!1,error:`${e} is not a view`};const R=m.getOutputSchema();for(const J of l.schema.fields)if(D.schemaTryGet(R,J.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${e} because stage already has an output field named ${J.name}`};return{isValidViewRefinement:!0}}class Ee extends t{constructor(e){super(e,{kind:"view_reference",name:e.name,path:e.path,parameters:e.parameters&&new ee(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get path(){return this.children.path}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}getOrAddDefaultSegment(){return this.addEmptyRefinement()}addEmptyRefinement(){const e=Ce.segmentRefinementOf(this.build());return Ge(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,a){const{error:f}=this.isValidViewRefinement(e,a);if(f)throw new Error(f);const l=Ce.viewRefinementOf(this.build(),e,a);return Ge(this,l),l.refinement.as.ReferenceViewDefinition()}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}isValidViewRefinement(e,a){return it(this,e,a)}getInputSchema(){return At(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const e=this.getInputSchema(),a=y.schemaGet(e,this.name,this.path);if(a.kind!=="view")throw new Error("Not a view");return a}getRefinementSchema(){return this.getViewInfo().schema}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}getInheritedAnnotations(){var e;return(e=this.getViewInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}}u.ASTReferenceViewDefinition=Ee;class at extends t{constructor(e){super(e,{kind:"arrow",source:Re.from(e.source),view:Re.from(e.view)}),this.node=e}isRunnable(){return this.source.isRunnable()&&this.view.isRunnable()}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}addEmptyRefinement(){return this.view.addEmptyRefinement()}addViewRefinement(e,a){return this.view.addViewRefinement(e,a)}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}getInputSchema(){return this.source.getOutputSchema()}getOutputSchema(){return this.view.getRefinementSchema()}getImplicitName(){return this.view.getImplicitName()}getRefinementSchema(){throw new Error("An arrow is not a valid refinement")}isValidViewRefinement(e,a){return it(this,e,a)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}getInheritedAnnotations(){return[]}}u.ASTArrowViewDefinition=at;class Ce extends t{constructor(e){super(e,{kind:"refinement",base:Re.from(e.base),refinement:Re.from(e.refinement)}),this.node=e}isRunnable(){return this.getOutputSchema().fields.length>0}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}get base(){return this.children.base}set base(e){this.edit(),this.children.base=e}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(e,a){return this.refinement.addViewRefinement(e,a)}getInputSchema(){return At(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return y.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(e,a){return it(this,e,a)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){e(this.base),e(this.refinement),this.base.propagateDown(e),this.refinement.propagateDown(e)}getInheritedAnnotations(){return this.base.getInheritedAnnotations()}static viewRefinementOf(e,a,f){return new Ce({kind:"refinement",base:e,refinement:{kind:"view_reference",name:a,path:f}})}static segmentRefinementOf(e){return new Ce({kind:"refinement",base:e,refinement:{kind:"segment",operations:[]}})}}u.ASTRefinementViewDefinition=Ce;class De extends t{constructor(e){super(e,{kind:"segment",operations:new st(e.operations)}),this.node=e,this.DEFAULT_INSERTION_ORDER=["group_by","aggregate","drill","where","having","nest","order_by","calculate","limit"]}isRunnable(){let e=!1;for(const a of this.operations.iter()){if(a instanceof ke||a instanceof Oe)return!0;if(a instanceof Y){if(!a.view.definition.isRunnable())return!1;e=!0}}return e}get operations(){return this.children.operations}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}renameOrderBys(e,a){for(const f of this.operations.iter())f instanceof qe&&f.name===e&&f.setField(a)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}removeOrderBys(e){for(const a of this.operations.iter())a instanceof qe&&a.name===e&&a.delete()}reorderFields(e){const a=[],f=[],l={};let R=!1;for(const V of this.operations.iter()){if((V instanceof ke||V instanceof Oe||V instanceof Y)&&e.includes(V.name)){l[V.name]=V,R=!0;continue}R?f.push(V):a.push(V)}const J=[];for(const V of e){const he=l[V];if(he===void 0)throw new Error(`No field named ${V}`);J.push(he)}const fe=[...a,...J,...f];this.operations.items=fe}renameField(e,a){if(e.name===a)return;const f=this.getOutputSchema();if(y.schemaTryGet(f,a,[]))throw new Error(`Output already has a field named ${a}`);const l=e.name;e.name=a,this.propagateUp(R=>{R instanceof De&&R.renameOrderBys(l,a)})}addOrderBy(e,a){const f=this.getOutputSchema();try{y.schemaGet(f,e,[])}catch{throw new Error(`No such field ${e} in stage output`)}for(const R of this.operations.iter())if(R instanceof qe&&R.name===e)return R.direction=a,R;const l=new qe({kind:"order_by",field_reference:{name:e},direction:a});return this.addOperation(l),l}addEmptyNest(e){const a=new Y({kind:"nest",name:e,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(a),a}firstIndexOfOperationType(e){return this.operations.findIndex(a=>a.kind===e)}findInsertionPoint(e){const a=this.firstIndexOfOperationType(e);if(a>-1){let R=a;for(;this.operations.index(R)&&this.operations.index(R).kind===e;)R++;return R}const f=this.DEFAULT_INSERTION_ORDER.indexOf(e);if(f===-1)throw new Error(`Operation ${e} is not supported for \`findInsertionPoint\``);const l=this.DEFAULT_INSERTION_ORDER.slice(f+1);for(const R of l){const J=this.firstIndexOfOperationType(R);if(J>-1)return J}return this.operations.length}getFieldNamed(e){const a=this.tryGetFieldNamed(e);if(a===void 0)throw new Error("No such field");return a}hasFieldNamed(e){return this.tryGetFieldNamed(e)!==void 0}hasField(e,a){return this.tryGetField(e,a)!==void 0}getField(e,a){const f=this.tryGetField(e,a);if(f===void 0)throw new Error("No such field");return f}tryGetField(e,a){for(const f of this.operations.iter())if(f instanceof Oe||f instanceof ke){const l=f.field.getReference();if(l&&l.name===e&&Se(l.path,a))return f}else if(f instanceof Y){if(f.view instanceof Ee)return f}else if(f instanceof C){const l=f.expression.field.getReference();if(l&&l.name===e&&Se(l.path,a))return f}}tryGetFieldNamed(e){for(const a of this.operations.iter())if((a instanceof Oe||a instanceof ke||a instanceof Y||a instanceof C)&&a.name===e)return a}getGroupBy(e){for(const a of this.operations.iter())if(a instanceof Oe&&a.name===e)return a}removeGroupBy(e){var a;return(a=this.getGroupBy(e))===null||a===void 0||a.delete(),this}addGroupBy(e,a=[],f){const l=this.makeField(e,a,f,"dimension");return this.addOperation(l),l}addDrill(e){const a=new Qe({kind:"drill",...e});return this.addOperation(a),a}addWhere(e,a,f){const l=Array.isArray(a)?a:[],R=f===void 0?a:f,J=typeof R=="string"?R:Me(R),fe=this.getInputSchema(),V=D.schemaGet(fe,e,l);Xe(V,R);const he=new we({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:l},filter:J}});return this.addOperation(he),he}addHaving(e,a,f){const l=Array.isArray(a)?a:[],R=f===void 0?a:f,J=typeof R=="string"?R:Me(R),fe=this.getInputSchema(),V=D.schemaGet(fe,e,l);Xe(V,R);const he=new rt({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:l},filter:J}});return this.addOperation(he),he}addCalculateMovingAverage(e,a,f,l,R){const J=new C({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:a,path:f},rows_preceding:l,rows_following:R}}});return this.addOperation(J),J}addTimeGroupBy(e,a,f,l){const R=this.getInputSchema(),J=y.schemaGet(R,e,a);if(J===void 0)throw new Error(`No such field ${e}`);if(J.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${e}`);if(J.type.kind!==l)throw new Error(`${e} is not a ${l}`);const fe=new Oe({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:e,path:a},truncation:f}}});return this.addOperation(fe),fe}addDateGroupBy(e,a,f){const l=f===void 0?a:f,R=f===void 0?[]:a;return this.addTimeGroupBy(e,R,l,"date_type")}addTimestampGroupBy(e,a,f){const l=f===void 0?a:f,R=f===void 0?[]:a;return this.addTimeGroupBy(e,R,l,"timestamp_type")}addTimestamptzGroupBy(e,a,f){const l=f===void 0?a:f,R=f===void 0?[]:a;return this.addTimeGroupBy(e,R,l,"timestamptz_type")}addAggregate(e,a=[],f){const l=this.makeField(e,a,f,"measure");return this.addOperation(l),l}addNest(e,a){const f=this.makeField(e,[],a,"view");return this.addOperation(f),f}makeField(e,a,f,l){const R=this.getInputSchema(),J=y.schemaGet(R,e,a);if(J===void 0)throw new Error(`No such field ${e}`);if(J.kind!==l){const fe=ct(l),V=l;throw new Error(`Cannot ${fe} non-${V} ${e}`)}return l==="dimension"?Oe.fromReference(e,a,f):l==="measure"?ke.fromReference(e,a,f):Y.fromReference(e,a,f)}addOperation(e){if((e instanceof Oe||e instanceof ke||e instanceof Y||e instanceof C)&&this.hasFieldNamed(e.name))throw new Error(`Query already has a field named ${e.name}`);const a=this.findInsertionPoint(e.kind);return this.operations.insert(e,a),e}getRefinementSchema(){const e=[];for(const a of this.operations.iter())(a instanceof Oe||a instanceof ke||a instanceof Y||a instanceof C)&&e.push(a.getFieldInfo());return{fields:e}}setLimit(e){Ze.validateLimit(e);const a=[...this.operations.iter()].find(u.ASTViewOperation.isLimit);a?a.limit=e:this.operations.add(new Ze({kind:"limit",limit:e}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const e=Ce.segmentRefinementOf(this.build());return Ge(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,a){const{error:f}=this.isValidViewRefinement(e,a);if(f)throw new Error(f);const l=Ce.viewRefinementOf(this.build(),e,a);return Ge(this,l),l.refinement.as.ReferenceViewDefinition()}getInputSchema(){return At(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(e,a){return it(this,e,a)}getInheritedAnnotations(){return[]}}u.ASTSegmentViewDefinition=De;class st extends d{constructor(e){super(e,e.map(a=>u.ASTViewOperation.from(a)))}get items(){return this.children}set items(e){this.edit(),this.children=e}get segment(){return this.parent.as.SegmentViewDefinition()}}u.ASTViewOperationList=st,u.ASTViewOperation={from(m){switch(m.kind){case"group_by":return new Oe(m);case"aggregate":return new ke(m);case"order_by":return new qe(m);case"nest":return new Y(m);case"limit":return new Ze(m);case"where":return new we(m);case"drill":return new Qe(m);case"having":return new rt(m);case"calculate":return new C(m)}},isLimit(m){return m instanceof Ze}};class qe extends t{constructor(e){super(e,{kind:"order_by",field_reference:new Z(e.field_reference),direction:e.direction}),this.node=e,this.kind="order_by"}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get direction(){return this.children.direction}set direction(e){this.direction!==e&&(this.edit(),this.children.direction=e)}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}setField(e){const a=this.list.segment.getOutputSchema();y.schemaGet(a,e,[]),this.edit(),this.children.field_reference=new Z({name:e})}setDirection(e){this.direction=e}}u.ASTOrderByViewOperation=qe;class Oe extends t{constructor(e){super(e,{kind:"group_by",name:e.name,field:new xe(e.field)}),this.node=e,this.kind="group_by"}get field(){return this.children.field}get name(){var e;const a=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(a===void 0)throw new Error("Group by does not have a name");return a}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}rename(e){this.list.segment.renameField(this,e)}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof De&&e.removeOrderBys(this.name)})}getFieldInfo(){return{kind:"dimension",name:this.name,type:this.field.type}}get annotations(){return this.field.annotations}set annotations(e){this.edit(),this.field.annotations=e}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return ze(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}static fromReference(e,a,f){return new Oe({kind:"group_by",name:f,field:{expression:{kind:"field_reference",name:e,path:a}}})}}u.ASTGroupByViewOperation=Oe;class ke extends t{constructor(e){super(e,{kind:"aggregate",name:e.name,field:new xe(e.field)}),this.node=e,this.kind="aggregate"}get field(){return this.children.field}get name(){var e;const a=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(a===void 0)throw new Error("Aggregate does not have a name");return a}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get annotations(){return this.field.annotations}rename(e){this.list.segment.renameField(this,e)}convertToCalculateMovingAverage(e,a,f=0,l=[]){if(!(this.field.expression instanceof Je))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const R=new C({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:a,rows_following:f,partition_fields:l.map(J=>({name:J}))}}});return this.list.add(R),R}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof De&&e.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:S.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return ze(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}addWhere(e,a,f){const l=Array.isArray(a)?a:[],R=f===void 0?a:f,J=typeof R=="string"?R:Me(R),fe=this.list.segment.getInputSchema(),V=D.schemaGet(fe,e,l);Xe(V,R);const he={filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:l},filter:J}};if(this.field.expression instanceof F)return this.field.expression.where.add(new $(he)),this.field.expression;if(this.field.expression instanceof Je){const be=this.field.expression.build();return this.field.expression=new F({kind:"filtered_field",field_reference:{name:be.name,path:be.path,parameters:be.parameters},where:[he]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(e,a,f){return new ke({kind:"aggregate",name:f,field:{expression:{kind:"field_reference",name:e,path:a}}})}}u.ASTAggregateViewOperation=ke;class xe extends t{constructor(e){super(e,{expression:u.ASTExpression.from(e.expression),annotations:e.annotations&&new We(e.annotations)}),this.node=e}get expression(){return this.children.expression}set expression(e){this.edit(),this.children.expression=e,e.parent=this}get name(){return this.expression.name}get type(){const e=this.expression.fieldType;if(e===void 0)throw new Error("Field expression does not have a type");return e}get annotations(){return this.children.annotations}set annotations(e){this.edit(),this.children.annotations=e}getReference(){if(!(this.expression instanceof je))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new We([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return ze(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}u.ASTField=xe,u.ASTExpression={from(m){switch(m.kind){case"field_reference":return new Je(m);case"filtered_field":return new F(m);case"time_truncation":return new He(m);case"literal_value":return new je(m);case"moving_average":return new h(m)}}};class Je extends t{constructor(e){super(e,{kind:e.kind,name:e.name,path:e.path,parameters:e.parameters&&new ee(e.parameters)}),this.node=e,this.kind="field_reference"}get name(){return this.children.name}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get segment(){const e=this.parent;if(e instanceof xe)return e.segment;if(e instanceof nt||e instanceof ot)return e.segment;throw new Error("Invalid expression parent")}get path(){return this.children.path}getReference(){return this.build()}getFieldInfo(){const e=this.segment.getInputSchema(),f=this.parent instanceof ot&&this.parent.parent instanceof Qe?y.schemaGetDrillField(e,this.name,this.path):y.schemaGet(e,this.name,this.path);if(f.kind!=="dimension"&&f.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return f}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}}u.ASTReferenceExpression=Je;class He extends t{constructor(e){super(e,{kind:e.kind,field_reference:new Z(e.field_reference),truncation:e.truncation}),this.node=e,this.kind="time_truncation"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get truncation(){return this.children.truncation}set truncation(e){this.edit(),this.children.truncation=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}getFieldInfo(){const e=this.field.segment.getInputSchema(),a=y.schemaGet(e,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){const e=this.getFieldInfo();if(e.type.kind==="date_type")return{...e.type,timeframe:z(this.truncation)};if(e.type.kind==="timestamp_type"||e.type.kind==="timestamptz_type")return{...e.type,timeframe:this.truncation};throw new Error("This type of field cannot have a time truncation")}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}u.ASTTimeTruncationExpression=He;class je extends t{constructor(e){super(e,{kind:e.kind,literal_value:u.ASTLiteralValue.from(e.literal_value)}),this.node=e,this.kind="time_truncation"}get name(){}get literalValue(){return this.children.literal_value}get fieldType(){return this.literalValue.fieldType}getInheritedAnnotations(){return[]}getFieldInfo(){}}u.ASTLiteralValueExpression=je;class q extends d{constructor(e){super(e,e.map(a=>new Z(a)))}}u.ASTFieldReferenceList=q;class h extends t{constructor(e){super(e,{kind:e.kind,field_reference:new Z(e.field_reference),rows_preceding:e.rows_preceding,rows_following:e.rows_following,partition_fields:new q(e.partition_fields||[])}),this.node=e,this.kind="moving_average"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get rowsPreceding(){return this.children.rows_preceding}set rowsPreceding(e){this.edit(),this.children.rows_preceding=e}get rowsFollowing(){return this.children.rows_following}set rowsFollowing(e){this.edit(),this.children.rows_following=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}get partitionFields(){return this.children.partition_fields}setPartitionFields(e){this.children.partition_fields=new q(e)}getFieldInfo(){const e=this.field.segment.getInputSchema(),a=y.schemaGet(e,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}u.ASTMovingAverageExpression=h;class $ extends t{constructor(e){super(e,{filter:u.ASTFilter.from(e.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}u.ASTFilterOperation=$;class k extends d{constructor(e){super(e,e.map(a=>new $(a)))}get expression(){return this.parent.as.FilteredFieldExpression()}}u.ASTFilterOperationList=k;class F extends t{constructor(e){super(e,{kind:e.kind,field_reference:new Z(e.field_reference),where:new k(e.where)}),this.node=e,this.kind="filtered_field"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get where(){return this.children.where}get field(){return this.parent.as.Field()}getFieldInfo(){const e=this.field.segment.getInputSchema(),a=y.schemaGet(e,this.name,this.fieldReference.path);if(a.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}u.ASTFilteredFieldExpression=F;function z(m){switch(m){case"day":case"week":case"month":case"year":case"quarter":return m;default:throw new Error("Invalid date timeframe")}}class Y extends t{constructor(e){super(e,{kind:"nest",name:e.name,view:new _e(e.view)}),this.node=e,this.kind="nest"}get view(){return this.children.view}get annotations(){return this.view.annotations}get name(){var e;const a=(e=this.children.name)!==null&&e!==void 0?e:this.view.name;if(a===void 0)throw new Error("Nest does not have a name");return a}set name(e){this.name!==e&&(this.edit(),this.view.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}getOrAddAnnotations(){return this.view.getOrAddAnnotations()}getInheritedTag(e="# "){return ze(e,this.view.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}delete(){this.list.remove(this)}rename(e){this.list.segment.renameField(this,e)}getFieldInfo(){return{kind:"view",name:this.name,definition:this.view.build(),schema:this.view.getOutputSchema()}}static fromReference(e,a,f){return new Y({kind:"nest",name:f,view:{definition:{kind:"view_reference",name:e,path:a}}})}}u.ASTNestViewOperation=Y;class we extends t{constructor(e){super(e,{kind:"where",filter:u.ASTFilter.from(e.filter)}),this.node=e,this.kind="where"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTWhereViewOperation=we;class Qe extends t{constructor(e){super(e,{kind:"drill",filter:u.ASTFilter.from(e.filter)}),this.node=e,this.kind="drill"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTDrillViewOperation=Qe;class rt extends t{constructor(e){super(e,{kind:"having",filter:u.ASTFilter.from(e.filter)}),this.node=e,this.kind="having"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTHavingViewOperation=rt;class C extends t{constructor(e){super(e,{kind:"calculate",field:new xe(e.field),name:e.name}),this.node=e,this.kind="calculate"}get expression(){return this.children.field.expression}set expression(e){this.edit(),this.children.field.expression=e,e.parent=this}get name(){return this.node.name}set name(e){this.name!==e&&(this.edit(),this.node.name=e)}getFieldInfo(){return{annotations:[{value:S.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"calculate",name:this.name,type:this.expression.fieldType}}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}u.ASTCalculateViewOperation=C,u.ASTFilter={from(m){switch(m.kind){case"filter_string":return new nt(m);case"literal_equality":return new ot(m)}},getSegment(m){const e=m.parent;return e instanceof $?e.list.expression.field.segment:e.list.segment}};class nt extends t{constructor(e){super(e,{kind:"filter_string",expression:u.ASTExpression.from(e.expression),filter:e.filter}),this.node=e,this.kind="filter_string"}get expression(){return this.children.expression}get filterString(){return this.children.filter}set filterString(e){this.edit(),this.children.filter=e}setFilterString(e){const a=this.getFilterType();_(this.filterString,a),this.filterString=e}get segment(){return u.ASTFilter.getSegment(this)}getFieldInfo(){const e=this.expression.getFieldInfo();if(e===void 0||e.kind!=="dimension"&&e.kind!=="measure")throw new Error("Invalid field type for filter with filter string");return e}getFilterType(){const e=this.getFieldInfo();return lt(e)}setFilter(e){const a=this.getFilterType();if(a!==e.kind)throw new Error(`Invalid filter: expected type ${a}, got ${e.kind}`);this.filterString=Me(e)}getFilter(){const e=this.getFilterType();return _(this.filterString,e)}}u.ASTFilterWithFilterString=nt;class ot extends t{constructor(e){super(e,{kind:"literal_equality",expression:u.ASTExpression.from(e.expression),value:u.ASTLiteralValue.from(e.value)}),this.node=e,this.kind="literal_equality"}get expression(){return this.children.expression}get value(){return this.children.value}get segment(){return u.ASTFilter.getSegment(this)}}u.ASTFilterWithLiteralEquality=ot;class _e extends t{constructor(e){super(e,{definition:Re.from(e.definition),annotations:e.annotations&&new We(e.annotations)}),this.node=e}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.parent=this}get name(){return this.definition.getImplicitName()}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}get nest(){return this.parent.as.NestViewOperation()}getInputSchema(){return this.nest.list.segment.getInputSchema()}getOutputSchema(){return this.definition.getRefinementSchema()}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.definition),this.definition.propagateDown(e)}reorderFields(e){this.definition instanceof De?this.definition.reorderFields(e):this.getOrAddAnnotations().setTagProperty(["field_order"],e)}get annotations(){return this.children.annotations}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new We([]);return this.children.annotations=e,e.parent=this,e}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(e="# "){return ze(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}}u.ASTView=_e;class Ze extends t{get limit(){return this.children.limit}set limit(e){Ze.validateLimit(e),this.edit(),this.children.limit=e}constructor(e){super(e,{kind:e.kind,limit:e.limit}),this.node=e,this.kind="limit"}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}static validateLimit(e){if(!Number.isInteger(e))throw new Error("Limit must be an integer")}}u.ASTLimitViewOperation=Ze;function ct(m){switch(m){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function gt(m){return m}class We extends d{constructor(e){super(e,e.map(a=>new Ke(a)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(e="# "){return ze(e,this.items)}getTag(e="# "){return ze(e,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(e=>e.node)}setTagProperty(e,a=null,f="# "){let l;for(let R=this.items.length-1;R>=0;R--){const J=this.index(R);if(J.hasPrefix(f)&&(l=J,J.hasIntrinsicTagProperty(e))){J.setTagProperty(e,a);return}}l?l.setTagProperty(e,a):this.add(new Ke({value:new S.Tag({prefix:f}).set(e,a).toString()}))}removeTagProperty(e,a="# "){let f;for(let l=this.items.length-1;l>=0;l--){const R=this.index(l);if(R.hasPrefix(a)&&(f=R,R.hasIntrinsicTagProperty(e))){R.removeTagProperty(e);return}}f?f.removeTagProperty(e):this.add(new Ke({value:new S.Tag({prefix:a}).unset(...e).toString()}))}}u.ASTAnnotationList=We;class Ke extends t{get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}constructor(e){super(e,{value:e.value}),this.node=e}get list(){return this.parent.as.AnnotationList()}get index(){return this.list.indexOf(this)}delete(){this.list.remove(this)}getIntrinsicTag(){const e=new S.TagParser;return e.parseAnnotation(this.value),e.finish()}getTag(){const e=new S.TagParser;for(const a of this.list.getInheritedAnnotations())e.parseAnnotation(a.value);for(let a=0;a<=this.index;a++)e.parseAnnotation(this.list.index(a).value);return e.finish()}hasPrefix(e){return this.value.startsWith(e)}hasIntrinsicTagProperty(e){return this.getIntrinsicTag().has(...e)}setTagProperty(e,a){this.value=this.getIntrinsicTag().set(e,a).toString()}removeTagProperty(e){this.value=this.getTag().unset(...e).toString()}}u.ASTAnnotation=Ke;function ze(m,e=[],a=[]){const f=new S.TagParser;for(const R of a)f.parseAnnotation(R.value);const l=e.map(R=>R.value).filter(R=>typeof m=="string"?R.startsWith(m):R.match(m));for(const R of l)f.parseAnnotation(R);return f.finish()}function Me(m){switch(m.kind){case"string":return w.StringFilterExpression.unparse(m.parsed);case"number":return w.NumberFilterExpression.unparse(m.parsed);case"boolean":return w.BooleanFilterExpression.unparse(m.parsed);case"timestamp":case"timestamptz":case"date":return w.TemporalFilterExpression.unparse(m.parsed)}}function _(m,e){function a(f){const l=f.filter(R=>R.severity==="error");if(l.length!==0)throw new Error(`Invalid Malloy filter string: ${l[0].message}`)}switch(e){case"string":{const f=w.StringFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"number":{const f=w.NumberFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"boolean":{const f=w.BooleanFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"timestamp":case"timestamptz":case"date":{const f=w.TemporalFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"other":throw new Error("Not implemented")}}function I(m){return"kind"in m?m:{...m,kind:"source"}}function ie(m){switch(m){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function W(m,e){return m.toString().padStart(e,"0")}function ue(m){const e=W(m.getUTCFullYear(),4),a=W(m.getUTCMonth()+1,2),f=W(m.getUTCDate(),2),l=W(m.getUTCHours(),2),R=W(m.getUTCMinutes(),2),J=W(m.getUTCSeconds(),2);return`${e}-${a}-${f} ${l}:${R}:${J}`}function Se(m,e){const a=m??[],f=e??[];return a.length===f.length&&a.every((l,R)=>l===f[R])}function lt(m){switch(m.type.kind){case"string_type":return"string";case"boolean_type":return"boolean";case"number_type":return"number";case"date_type":return"date";case"timestamp_type":return"timestamp";case"timestamptz_type":return"timestamp";default:return"other"}}function Xe(m,e){if(m.kind!=="dimension"&&m.kind!=="measure")throw new Error(`Cannot filter by field of type ${m.kind}`);const a=lt(m);if(typeof e=="string")_(e,a);else if(e.kind!==a)throw new Error(`Invalid filter for field ${m.name}; expected type ${a}, but got ${e.kind}`)}function At(m){if(m instanceof Ae)return m.getSourceInfo().schema;if(m instanceof pe)throw new Error("unimplemented");return m.getInputSchema()}})(mt)),mt}var jr;function Ei(){return jr||(jr=1,(function(u){var re=Et&&Et.__createBinding||(Object.create?(function(N,E,S,w){w===void 0&&(w=S);var y=Object.getOwnPropertyDescriptor(E,S);(!y||("get"in y?!E.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return E[S]}}),Object.defineProperty(N,w,y)}):(function(N,E,S,w){w===void 0&&(w=S),N[w]=E[S]})),j=Et&&Et.__exportStar||function(N,E){for(var S in N)S!=="default"&&!Object.prototype.hasOwnProperty.call(E,S)&&re(E,N,S)};Object.defineProperty(u,"__esModule",{value:!0}),j(Oi(),u)})(Et)),Et}var zr=Ei();const ki=ci(zr),Li=pi({__proto__:null,default:ki},[zr]);export{Fi as a,zr as d,Li as i,Ai as r};
|