@malloydata/render 0.0.236-dev250219154103 → 0.0.236-dev250221173808

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.
@@ -1251,7 +1251,7 @@ vwwxxyyzz{{|||ҩ
1251
1251
  ˧˨t;˨˫˩˫p9˪ˠ˪ˤ˪˥˪˩˫oˬ˭\x07p˭qˮ˯ ˯s˰˷v<˱˳\x07~˲˱˲˳˳˴˴˶v<˵˲˶˹˷˵˷˸˸˻˹˷˺˼\x07~˻˺˻˼˼u˽˾\f\x07˾˿Ģ’˿̄̀́\f\x07́̂Ĕ‹̂̄̃˽̃̀̄w̅̌z>̆̈\x07~̇̆̇̈̈̉̉̋z>̊̇̋̎̌̊̌̍̍̐̎̌̏̑\x07~̐̏̐̑̑y̖̒\f\x07̓̔Ģ’̔̕\b̗̖̖̗̗̘̘̙̓̕Ģ’̡̛̙̚\f\x07̛̜Ģ’̡̜̝̞\f\x07̞̟Ĕ‹̡̡̟̠̠̠̝̒̚{̢̣\b?̣̪А̤̪2̥̦\x07ţ̦~@̧̨\x07ų̢̪̩̩̤̩̥̪̰̫̬\f̬̭\x07†̭̯|?̮̫̯̲̰̮̰̱̱}̲̰̳̹|?̴̵|?̵̶\x07r̶̷~@̷̸̸̴̹̳̹̺̾N(̻̾L'̼̾^0̺̻̼̽̽̽̾̿̈́\x07x̀̓€Á̓\x07Œ͇͇͈͂̀͂́̓͆̈́͂̈́͆̈́ͅͅ\x07y͈ƒ͉͐ŒG͊͌\x07~͍͍͋͊͋͌͌͏ŒG͎͋͏͎͔͓͕͒͐͐͑͑͒͐\x07~͔͓͔͕͕…͖͗\f\x07͗͘\x07C͙͘\f\x07͙͚j6͚‡͛͜ \x07͜‰ͥ͝Z.͟͞Z.͟͠d3ͥ͢͠͡Z.ͣ͢†Dͣͥͤͤͤͥ͝͞͡‹ͦͨ\x07pͧͦͨͫͩͧͩͪͪͬͫͩͬͮŠFͭͯˆEͮͭͮͯͯͰͰͱ\x07gͱͲø}Ͳ΂ͳ͵\x07pʹͳ͵͸ͶʹͶͷͷ͹͸Ͷ͹ͿŠFͺͼˆEͻͺͻͼͼͽͽ;\x07R;΀ŽHͿͻͿ΀΀΂΁ͩ΁Ͷ΂΃΄ø}΄΅Έ QΆΈ¢R·΅·ΆΈ‘ΉΎ\x07xΊ΍œO΋΍\x07ŒΌΊΌ΋΍ΐΎΌΎΏΏΑΐΎΑΒ\x07yΒ“ΓΘ–LΔΕ\x07~ΕΗ–LΖΔΗΚΘΖΘΙΙΜΚΘΛΝ\x07~ΜΛΜΝΝ•ΞΠø}ΟΡ \bΠΟΠΡΡΥ΢Υ\x07)ΣΥ\x074ΤΞΤ΢ΤΣΥ—ΦΧ\x07ΧΨ”KΨ™ΩΪÈeΪ›Ϋΰ QάΰÀaέΰ˜MήΰšNίΫίάίέίήΰαζø}βγ\x07~γεø}δβεθζδζηηκθζιλ\x07~κικλλŸμν\x07#νξžPξ¡οπ\x07\rπρžPρ£ςω¨Uσυ\x07~τστυυφφψ¨Uχτψϋωχωϊϊύϋωόώ\x07~ύόύώώ¥Ϗϐðyϐ§ϑϓ\x07pϒϑϓϖϔϒϔϕϕϗϖϔϗϘ¦TϘϙ\bϙϚ~@Ϛ©ϛϮ®XϜϮ\\/ϝϮ¬WϞϮ\`1ϟϮ¾\`ϠϮÒjϡϮº^ϢϮ¼_ϣϮÌgϤϮÈeϥϮÂbϦϮ QϧϮ¢RϨϮ´[ϩϮÔkϪϮÖlϫϮØmϬϮ"ϭϛϭϜϭϝϭϞϭϟϭϠϭϡϭϢϭϣϭϤϭϥϭϦϭϧϭϨϭϩϭϪϭϫϭϬϮ«ϯϰ^0ϰ­ϱϲ\f\x07ϲϳ\x07\fϳϴ°Yϴ¯ϵϼ²Z϶ϸ\x07~Ϸ϶ϷϸϸϹϹϻ²ZϺϷϻϾϼϺϼϽϽЀϾϼϿЁ\x07~ЀϿЀЁЁ±ЂЅʍЃЅV,ЄЂЄЃЅ³ІЇ\f\x07ЇЈ\x07ЈЉ¶\\ЉµЊБ¸]ЋЍ\x07~ЌЋ`,x._serializedATNSegment2=`ЌЍЍЎЎА¸]ЏЌАГБЏБВВЕГБДЖ\x07~ЕДЕЖЖ·ЗЛ\f\x07ИЙ4\x1BЙК\bКМЛИЛММННО~@О¹ПР\f\x07РС\x07СТ°YТ»УФ\f\x07ФХ\x07ХЦ°YЦ½ЧШ\f\x07ШЩ ЩЪNJЪ¿ЫЬ\x07ЬбðyЭЮ\x07~ЮаðyЯЭагбЯбввегбдж\x07~едежжÁзи\x07ийÄcйÃксÆdлн\x07~млмнноорÆdпмруспсттхусфц\x07~хфхццÅчъ\x07œшъĢ’щчщшъьыэ \bьыьээÇюя\x07яѐ\x07œѐÉёђ\x07,ђіĢ’ѓє\x07,єіø}ѕёѕѓіËїј\x07"јљ\x07œљÍњѝАћќ\x07ќў\x07ˆѝћѝўўѡџѡ\x07ˆѠњѠџѡÏѢѩÎhѣѥ\x07~ѤѣѤѥѥѦѦѨÎhѧѤѨѫѩѧѩѪѪÑѫѩѬѭ\x07ѭѰÐiѮѯ\x07,ѯѱĢ’ѰѮѰѱѱÓѲѳ\x07ѳѴÚnѴÕѵѶ\x07%Ѷѷârѷ×Ѹѹ\x07pѹÙѺѻ
1252
1252
  ѻÛѼѽ \vѽÝѾѿ \fѿßҀҁ \rҁá҂҅äs҃҅
1253
1253
  ҄҂҄҃҅ã҆҇ ҇å҈҉ ҉çҊҒârҋҒætҌҒêvҍҒ\x07PҎҒ ҏҒ\x07kҐҒ\x07OґҊґҋґҌґҍґҎґҏґҐҒéғқ\x07’Ҕқ\x07“ҕқ\x07”Җқ\x07—җқ\x07–Ҙқ\x07•ҙқ\x07˜ҚғҚҔҚҕҚҖҚҗҚҘҚҙқëҜҝârҝíҞҟârҟïҠҡ ҡñҢң ңóҤҥ ҥõҦҩÞpҧҩârҨҦҨҧҩ÷Ҫҫ\b}ҫԒАҬԒèuҭҮ\x07vҮҳø}үҰ\x07~ҰҲø}ұүҲҵҳұҳҴҴҷҵҳҶҸ\x07~ҷҶҷҸҸҹҹҺ\x07wҺԒһҼ\x07xҼӁȇҽҾ\x07~ҾӀȇҿҽӀӃӁҿӁӂӂӄӃӁӄӅ\x07yӅԒӆӇ\x07‡ӇԒø}\x1BӈӉ\x07NӉԒø}ӊӋ\x07.Ӌӌ\x07tӌӍø}Ӎӎ\x07(ӎӏö|ӏӐ\x07uӐԒӑӒ\x07[ӒӔ\x07ӓӑӓӔӔӕӕӖÜoӖә\x07tӗӚø}ӘӚ\x07ˆәӗәӘәӚӚӛӛӜ\x07uӜԒӝӞАӞӟ\x07ӟӠÜoӠӢ\x07tӡӣø}ӢӡӢӣӣӤӤӥ\x07uӥԒӦӧ\x07tӧӨø}Өө\x07uөԒӪӫАӫӬ\x07Ӭӭðyӭӯ\x07tӮӰψӯӮӯӰӰӱӱӲ\x07uӲԒӳӸðyӴӶ\x07|ӵӷÞpӶӵӶӷӷӹӸӴӸӹӹӼӺӼòzӻӳӻӺӼӽӽӿ\x07tӾԀψӿӾӿԀԀԁԁԂ\x07uԂԒԃԒÂԄԒƄԅԆô{Ԇԇ\x07tԇԌø}Ԉԉ\x07~ԉԋĢ’ԊԈԋԎԌԊԌԍԍԏԎԌԏԐ\x07uԐԒԑҪԑҬԑҭԑһԑӆԑӈԑӊԑӓԑӝԑӦԑӪԑӻԑԃԑԄԑԅԒ՛ԓԔ\fԔԕ ԕ՚ø}\x1BԖԗ\fԗԘ Ԙ՚ø}ԙԚ\fԚԛ\x07bԛ՚ø}Ԝԝ\fԝԞàqԞԟø}ԟ՚ԠԢ\fԡԣ\x07NԢԡԢԣԣԤԤԥ\x07Iԥ՚ø}Ԧԧ\fԧԨ\x07'Ԩ՚ø}ԩԪ\f\rԪԫ\x07Sԫ՚ø}Ԭԭ\f\fԭԮ\x07Ԯ՚ø}\rԯ԰\f ԰՚’JԱԲ\fԲ՚òzԳԴ\fԴԵ\x07Ե՚òzԶԷ\fԷԸ\x07zԸ՚ö|ԹԺ\fԺԻ\x07{Ի՚ö|ԼԽ\fԽԾ\x07<ԾԿø}ԿՀòzՀ՚ՁՂ\fՂՃ\x07qՃ՚þ€ՄՅ\fՅՆ\x07‹Ն՚þ€ՇՈ\fՈՊ\x07CՉՋ\x07NՊՉՊՋՋՌՌ՚\x07PՍՏ\fՎՐ\x07NՏՎՏՐՐՑՑՒ\x07DՒՓ\x07tՓՔՔՕ\x07uՕ՚Ֆ՗\f՗՘\x07‘՘՚þ€ՙԓՙԖՙԙՙԜՙԠՙԦՙԩՙԬՙԯՙԱՙԳՙԶՙԹՙԼՙՁՙՄՙՇՙՍՙՖ՚՝՛ՙ՛՜՜ù՝՛՞՟àq՟ՠø}ՠûաըú~բդ\x07Cգե\x07Nդգդեեզզը\x07Pէաէբըýթհüժի\x07tիլüլխ\x07uխհծհø}կթկժկծհÿձնø}ղճ\x07~ճյø}մղյոնմնշշāոնչջĄƒպչջռռպռսսրվտ\x076տցø}րվրցցăւք\x07Tփօø}քփքօօֆֆև\x07fևֈþ€ֈą։֋\x07-֊֌ø}֋֊֋֌֌֎֍֏Ĉ…֎֍֏֐֐֎֐֑֑֔֒֓\x076֓֕ø}֖֖֔֒֔֕֕֗\x077֗ć֘֙\x07f֚֙ø}֛֚\x07_֛֜ø}֜ĉ֝֞ðy֞ċ֧֟А֠֡Ċ†֢֡\x07C֢֤֣֣֤֤֥֥֧֠ø}֦֦֣֧֟č֭֨ø}֪֩\x07~֪֬ø}ְֱֲ֭֭֭֮֮֫֩֬֯֫֯\x07~ְֱֱֲֲďֳֺĢ’ִֶ\x07~ִֵֵֶֶַַֹĢ’ֵָָֹֺֺֻֻּđֺּֽׄĜ־׀\x07~ֿ־ֿ׀׀ׁׁ׃Ĝֿׂ׃׆ׂׅׅׄׄ׈׆ׇׄ׉\x07~׈ׇ׈׉׉ē׊׋А׋׌\x07׌׎׍׊׍׎׎׏׏ב\x07ˆאגˌבאבגגĕדח\x07xהו\x07
1254
- וטЉזט\x07~חהחזטייחיךךככל\x07yלėםמ\f\x07מנАןס̎נןנססęעף\x07ףתòzפץ\x07ץצÜoצק\x07tקר\x07uרתשעשפתě׫ׯʍ׬ׯĔ‹׭ׯV,׮׫׮׬׮׭ׯĝװ׵Ģ’ױײ\x07ײ״Ģ’׳ױ״׷׵׳׵׶׶ğ׷׵׸׹ðy׹ġ׺׻ðy׻ģ׼׽ðy׽ĥ׾׿ðy׿ħ؀؁âr؁ĩ؂؃ø}؃؄\x07؄ī؅؆þ€؆؇\x07؇ĭ؈؉\x07Œ؉؊\x07Œ؊؋\x07v؋،âr،؍\x07w؍į®IJĴŀŋœŢŭŷƀƇƌƑƗƜƠƱǁLjNJǓǘǜǡǰǵǺǾȇȉȖȞȧȪȱȳȷȾɅɊɎɖɛɟɬɲɹʀʅʍʗʜʣʪʷʺʿˊˑ˓˙˛˪˲˷˻̸̖̠̩̰͔̃̇̌̐̽͂̈́͋͐ͤͩͮͶͻͿ΁·ΌΎΘΜΠΤίζκτωύϔϭϷϼЀЄЌБЕЛбемсхщьѕѝѠѤѩѰ҄ґҚҨҳҷӁӓәӢӯӶӸӻӿԌԑԢՊՏՙ՛դէկնռրք֋֐ֱֵֺֿ֣֦֭֔ׄ׈׍בחינש׮׵`,x._serializedATN=Jj.join([x._serializedATNSegment0,x._serializedATNSegment1,x._serializedATNSegment2],"");class Xj extends ge.ParserRuleContext{EOF(){return this.getToken(x.EOF,0)}malloyStatement(e){return e===void 0?this.getRuleContexts(ev):this.getRuleContext(e,ev)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyDocument}enterRule(e){e.enterMalloyDocument&&e.enterMalloyDocument(this)}exitRule(e){e.exitMalloyDocument&&e.exitMalloyDocument(this)}accept(e){return e.visitMalloyDocument?e.visitMalloyDocument(this):e.visitChildren(this)}}L.MalloyDocumentContext=Xj;class ev extends ge.ParserRuleContext{defineSourceStatement(){return this.tryGetRuleContext(0,aO)}defineQuery(){return this.tryGetRuleContext(0,rg)}importStatement(){return this.tryGetRuleContext(0,cO)}runStatement(){return this.tryGetRuleContext(0,lO)}docAnnotations(){return this.tryGetRuleContext(0,dO)}ignoredObjectAnnotations(){return this.tryGetRuleContext(0,hO)}experimentalStatementForTesting(){return this.tryGetRuleContext(0,mD)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyStatement}enterRule(e){e.enterMalloyStatement&&e.enterMalloyStatement(this)}exitRule(e){e.exitMalloyStatement&&e.exitMalloyStatement(this)}accept(e){return e.visitMalloyStatement?e.visitMalloyStatement(this):e.visitChildren(this)}}L.MalloyStatementContext=ev;class aO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}SOURCE(){return this.getToken(x.SOURCE,0)}sourcePropertyList(){return this.getRuleContext(0,yO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defineSourceStatement}enterRule(e){e.enterDefineSourceStatement&&e.enterDefineSourceStatement(this)}exitRule(e){e.exitDefineSourceStatement&&e.exitDefineSourceStatement(this)}accept(e){return e.visitDefineSourceStatement?e.visitDefineSourceStatement(this):e.visitChildren(this)}}L.DefineSourceStatementContext=aO;class rg extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defineQuery}copyFrom(e){super.copyFrom(e)}}L.DefineQueryContext=rg;class Zj extends rg{topLevelQueryDefs(){return this.getRuleContext(0,pO)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterUse_top_level_query_defs&&e.enterUse_top_level_query_defs(this)}exitRule(e){e.exitUse_top_level_query_defs&&e.exitUse_top_level_query_defs(this)}accept(e){return e.visitUse_top_level_query_defs?e.visitUse_top_level_query_defs(this):e.visitChildren(this)}}L.Use_top_level_query_defsContext=Zj;class eq extends rg{tags(){return this.getRuleContext(0,Mt)}QUERY(){return this.getToken(x.QUERY,0)}topLevelAnonQueryDef(){return this.getRuleContext(0,tv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterAnonymousQuery&&e.enterAnonymousQuery(this)}exitRule(e){e.exitAnonymousQuery&&e.exitAnonymousQuery(this)}accept(e){return e.visitAnonymousQuery?e.visitAnonymousQuery(this):e.visitChildren(this)}}L.AnonymousQueryContext=eq;class tv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}sqExpr(){return this.getRuleContext(0,Zt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topLevelAnonQueryDef}enterRule(e){e.enterTopLevelAnonQueryDef&&e.enterTopLevelAnonQueryDef(this)}exitRule(e){e.exitTopLevelAnonQueryDef&&e.exitTopLevelAnonQueryDef(this)}accept(e){return e.visitTopLevelAnonQueryDef?e.visitTopLevelAnonQueryDef(this):e.visitChildren(this)}}L.TopLevelAnonQueryDefContext=tv;class Mt extends ge.ParserRuleContext{ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_tags}enterRule(e){e.enterTags&&e.enterTags(this)}exitRule(e){e.exitTags&&e.exitTags(this)}accept(e){return e.visitTags?e.visitTags(this):e.visitChildren(this)}}L.TagsContext=Mt;class Ma extends ge.ParserRuleContext{IS(){return this.getToken(x.IS,0)}tags(e){return e===void 0?this.getRuleContexts(Mt):this.getRuleContext(e,Mt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_isDefine}enterRule(e){e.enterIsDefine&&e.enterIsDefine(this)}exitRule(e){e.exitIsDefine&&e.exitIsDefine(this)}accept(e){return e.visitIsDefine?e.visitIsDefine(this):e.visitChildren(this)}}L.IsDefineContext=Ma;class lO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}RUN(){return this.getToken(x.RUN,0)}topLevelAnonQueryDef(){return this.getRuleContext(0,tv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_runStatement}enterRule(e){e.enterRunStatement&&e.enterRunStatement(this)}exitRule(e){e.exitRunStatement&&e.exitRunStatement(this)}accept(e){return e.visitRunStatement?e.visitRunStatement(this):e.visitChildren(this)}}L.RunStatementContext=lO;class nv extends ge.ParserRuleContext{SQL_BEGIN(){return this.getToken(x.SQL_BEGIN,0)}SQL_END(){return this.getToken(x.SQL_END,0)}sqlInterpolation(e){return e===void 0?this.getRuleContexts(rv):this.getRuleContext(e,rv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlString}enterRule(e){e.enterSqlString&&e.enterSqlString(this)}exitRule(e){e.exitSqlString&&e.exitSqlString(this)}accept(e){return e.visitSqlString?e.visitSqlString(this):e.visitChildren(this)}}L.SqlStringContext=nv;class rv extends ge.ParserRuleContext{OPEN_CODE(){return this.getToken(x.OPEN_CODE,0)}sqExpr(){return this.getRuleContext(0,Zt)}CCURLY(){return this.tryGetToken(x.CCURLY,0)}CLOSE_CODE(){return this.tryGetToken(x.CLOSE_CODE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlInterpolation}enterRule(e){e.enterSqlInterpolation&&e.enterSqlInterpolation(this)}exitRule(e){e.exitSqlInterpolation&&e.exitSqlInterpolation(this)}accept(e){return e.visitSqlInterpolation?e.visitSqlInterpolation(this):e.visitChildren(this)}}L.SqlInterpolationContext=rv;class cO extends ge.ParserRuleContext{IMPORT(){return this.getToken(x.IMPORT,0)}importURL(){return this.getRuleContext(0,xO)}importSelect(){return this.tryGetRuleContext(0,fO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importStatement}enterRule(e){e.enterImportStatement&&e.enterImportStatement(this)}exitRule(e){e.exitImportStatement&&e.exitImportStatement(this)}accept(e){return e.visitImportStatement?e.visitImportStatement(this):e.visitChildren(this)}}L.ImportStatementContext=cO;class fO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}importItem(e){return e===void 0?this.getRuleContexts(iv):this.getRuleContext(e,iv)}CCURLY(){return this.getToken(x.CCURLY,0)}FROM(){return this.getToken(x.FROM,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importSelect}enterRule(e){e.enterImportSelect&&e.enterImportSelect(this)}exitRule(e){e.exitImportSelect&&e.exitImportSelect(this)}accept(e){return e.visitImportSelect?e.visitImportSelect(this):e.visitChildren(this)}}L.ImportSelectContext=fO;class iv extends ge.ParserRuleContext{id(e){return e===void 0?this.getRuleContexts(pn):this.getRuleContext(e,pn)}IS(){return this.tryGetToken(x.IS,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importItem}enterRule(e){e.enterImportItem&&e.enterImportItem(this)}exitRule(e){e.exitImportItem&&e.exitImportItem(this)}accept(e){return e.visitImportItem?e.visitImportItem(this):e.visitChildren(this)}}L.ImportItemContext=iv;class xO extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importURL}enterRule(e){e.enterImportURL&&e.enterImportURL(this)}exitRule(e){e.exitImportURL&&e.exitImportURL(this)}accept(e){return e.visitImportURL?e.visitImportURL(this):e.visitChildren(this)}}L.ImportURLContext=xO;class dO extends ge.ParserRuleContext{DOC_ANNOTATION(e){return e===void 0?this.getTokens(x.DOC_ANNOTATION):this.getToken(x.DOC_ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_docAnnotations}enterRule(e){e.enterDocAnnotations&&e.enterDocAnnotations(this)}exitRule(e){e.exitDocAnnotations&&e.exitDocAnnotations(this)}accept(e){return e.visitDocAnnotations?e.visitDocAnnotations(this):e.visitChildren(this)}}L.DocAnnotationsContext=dO;class hO extends ge.ParserRuleContext{ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ignoredObjectAnnotations}enterRule(e){e.enterIgnoredObjectAnnotations&&e.enterIgnoredObjectAnnotations(this)}exitRule(e){e.exitIgnoredObjectAnnotations&&e.exitIgnoredObjectAnnotations(this)}accept(e){return e.visitIgnoredObjectAnnotations?e.visitIgnoredObjectAnnotations(this):e.visitChildren(this)}}L.IgnoredObjectAnnotationsContext=hO;class sv extends ge.ParserRuleContext{DOC_ANNOTATION(e){return e===void 0?this.getTokens(x.DOC_ANNOTATION):this.getToken(x.DOC_ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ignoredModelAnnotations}enterRule(e){e.enterIgnoredModelAnnotations&&e.enterIgnoredModelAnnotations(this)}exitRule(e){e.exitIgnoredModelAnnotations&&e.exitIgnoredModelAnnotations(this)}accept(e){return e.visitIgnoredModelAnnotations?e.visitIgnoredModelAnnotations(this):e.visitChildren(this)}}L.IgnoredModelAnnotationsContext=sv;class pO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}QUERY(){return this.getToken(x.QUERY,0)}topLevelQueryDef(e){return e===void 0?this.getRuleContexts(ov):this.getRuleContext(e,ov)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topLevelQueryDefs}enterRule(e){e.enterTopLevelQueryDefs&&e.enterTopLevelQueryDefs(this)}exitRule(e){e.exitTopLevelQueryDefs&&e.exitTopLevelQueryDefs(this)}accept(e){return e.visitTopLevelQueryDefs?e.visitTopLevelQueryDefs(this):e.visitChildren(this)}}L.TopLevelQueryDefsContext=pO;class ov extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}queryName(){return this.getRuleContext(0,av)}isDefine(){return this.getRuleContext(0,Ma)}sqExpr(){return this.getRuleContext(0,Zt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topLevelQueryDef}enterRule(e){e.enterTopLevelQueryDef&&e.enterTopLevelQueryDef(this)}exitRule(e){e.exitTopLevelQueryDef&&e.exitTopLevelQueryDef(this)}accept(e){return e.visitTopLevelQueryDef?e.visitTopLevelQueryDef(this):e.visitChildren(this)}}L.TopLevelQueryDefContext=ov;class tq extends ge.ParserRuleContext{PLUS(){return this.getToken(x.PLUS,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_refineOperator}enterRule(e){e.enterRefineOperator&&e.enterRefineOperator(this)}exitRule(e){e.exitRefineOperator&&e.exitRefineOperator(this)}accept(e){return e.visitRefineOperator?e.visitRefineOperator(this):e.visitChildren(this)}}L.RefineOperatorContext=tq;class nq extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_turtleName}enterRule(e){e.enterTurtleName&&e.enterTurtleName(this)}exitRule(e){e.exitTurtleName&&e.exitTurtleName(this)}accept(e){return e.visitTurtleName?e.visitTurtleName(this):e.visitChildren(this)}}L.TurtleNameContext=nq;class gO extends ge.ParserRuleContext{connectionId(){return this.getRuleContext(0,uv)}DOT(){return this.getToken(x.DOT,0)}SQL(){return this.getToken(x.SQL,0)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sqlString(){return this.tryGetRuleContext(0,nv)}shortString(){return this.tryGetRuleContext(0,Bv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlSource}enterRule(e){e.enterSqlSource&&e.enterSqlSource(this)}exitRule(e){e.exitSqlSource&&e.exitSqlSource(this)}accept(e){return e.visitSqlSource?e.visitSqlSource(this):e.visitChildren(this)}}L.SqlSourceContext=gO;class ig extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreTable}copyFrom(e){super.copyFrom(e)}}L.ExploreTableContext=ig;class rq extends ig{TABLE(){return this.getToken(x.TABLE,0)}OPAREN(){return this.getToken(x.OPAREN,0)}tableURI(){return this.getRuleContext(0,oD)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterTableFunction&&e.enterTableFunction(this)}exitRule(e){e.exitTableFunction&&e.exitTableFunction(this)}accept(e){return e.visitTableFunction?e.visitTableFunction(this):e.visitChildren(this)}}L.TableFunctionContext=rq;class iq extends ig{connectionId(){return this.getRuleContext(0,uv)}DOT(){return this.getToken(x.DOT,0)}TABLE(){return this.getToken(x.TABLE,0)}OPAREN(){return this.getToken(x.OPAREN,0)}tablePath(){return this.getRuleContext(0,sD)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterTableMethod&&e.enterTableMethod(this)}exitRule(e){e.exitTableMethod&&e.exitTableMethod(this)}accept(e){return e.visitTableMethod?e.visitTableMethod(this):e.visitChildren(this)}}L.TableMethodContext=iq;class uv extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_connectionId}enterRule(e){e.enterConnectionId&&e.enterConnectionId(this)}exitRule(e){e.exitConnectionId&&e.exitConnectionId(this)}accept(e){return e.visitConnectionId?e.visitConnectionId(this):e.visitChildren(this)}}L.ConnectionIdContext=uv;class mO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}queryStatement(e){return e===void 0?this.getRuleContexts(Ov):this.getRuleContext(e,Ov)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryProperties}enterRule(e){e.enterQueryProperties&&e.enterQueryProperties(this)}exitRule(e){e.exitQueryProperties&&e.exitQueryProperties(this)}accept(e){return e.visitQueryProperties?e.visitQueryProperties(this):e.visitChildren(this)}}L.QueryPropertiesContext=mO;class av extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryName}enterRule(e){e.enterQueryName&&e.enterQueryName(this)}exitRule(e){e.exitQueryName&&e.exitQueryName(this)}accept(e){return e.visitQueryName?e.visitQueryName(this):e.visitChildren(this)}}L.QueryNameContext=av;class yO extends ge.ParserRuleContext{sourceDefinition(e){return e===void 0?this.getRuleContexts(lv):this.getRuleContext(e,lv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourcePropertyList}enterRule(e){e.enterSourcePropertyList&&e.enterSourcePropertyList(this)}exitRule(e){e.exitSourcePropertyList&&e.exitSourcePropertyList(this)}accept(e){return e.visitSourcePropertyList?e.visitSourcePropertyList(this):e.visitChildren(this)}}L.SourcePropertyListContext=yO;class lv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}sourceNameDef(){return this.getRuleContext(0,_O)}isDefine(){return this.getRuleContext(0,Ma)}sqExplore(){return this.getRuleContext(0,EO)}sourceParameters(){return this.tryGetRuleContext(0,AO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceDefinition}enterRule(e){e.enterSourceDefinition&&e.enterSourceDefinition(this)}exitRule(e){e.exitSourceDefinition&&e.exitSourceDefinition(this)}accept(e){return e.visitSourceDefinition?e.visitSourceDefinition(this):e.visitChildren(this)}}L.SourceDefinitionContext=lv;class EO extends ge.ParserRuleContext{sqExpr(){return this.getRuleContext(0,Zt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqExplore}enterRule(e){e.enterSqExplore&&e.enterSqExplore(this)}exitRule(e){e.exitSqExplore&&e.exitSqExplore(this)}accept(e){return e.visitSqExplore?e.visitSqExplore(this):e.visitChildren(this)}}L.SqExploreContext=EO;class AO extends ge.ParserRuleContext{OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sourceParameter(e){return e===void 0?this.getRuleContexts(cv):this.getRuleContext(e,cv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceParameters}enterRule(e){e.enterSourceParameters&&e.enterSourceParameters(this)}exitRule(e){e.exitSourceParameters&&e.exitSourceParameters(this)}accept(e){return e.visitSourceParameters?e.visitSourceParameters(this):e.visitChildren(this)}}L.SourceParametersContext=AO;class cv extends ge.ParserRuleContext{parameterNameDef(){return this.getRuleContext(0,vO)}DOUBLECOLON(){return this.tryGetToken(x.DOUBLECOLON,0)}malloyType(){return this.tryGetRuleContext(0,fg)}IS(){return this.tryGetToken(x.IS,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceParameter}enterRule(e){e.enterSourceParameter&&e.enterSourceParameter(this)}exitRule(e){e.exitSourceParameter&&e.exitSourceParameter(this)}accept(e){return e.visitSourceParameter?e.visitSourceParameter(this):e.visitChildren(this)}}L.SourceParameterContext=cv;class vO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_parameterNameDef}enterRule(e){e.enterParameterNameDef&&e.enterParameterNameDef(this)}exitRule(e){e.exitParameterNameDef&&e.exitParameterNameDef(this)}accept(e){return e.visitParameterNameDef?e.visitParameterNameDef(this):e.visitChildren(this)}}L.ParameterNameDefContext=vO;class _O extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceNameDef}enterRule(e){e.enterSourceNameDef&&e.enterSourceNameDef(this)}exitRule(e){e.exitSourceNameDef&&e.exitSourceNameDef(this)}accept(e){return e.visitSourceNameDef?e.visitSourceNameDef(this):e.visitChildren(this)}}L.SourceNameDefContext=_O;class SO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}exploreStatement(e){return e===void 0?this.getRuleContexts(Pr):this.getRuleContext(e,Pr)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreProperties}enterRule(e){e.enterExploreProperties&&e.enterExploreProperties(this)}exitRule(e){e.exitExploreProperties&&e.exitExploreProperties(this)}accept(e){return e.visitExploreProperties?e.visitExploreProperties(this):e.visitChildren(this)}}L.ExplorePropertiesContext=SO;class Pr extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreStatement}copyFrom(e){super.copyFrom(e)}}L.ExploreStatementContext=Pr;class sq extends Pr{defDimensions(){return this.getRuleContext(0,xv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreDimension_stub&&e.enterDefExploreDimension_stub(this)}exitRule(e){e.exitDefExploreDimension_stub&&e.exitDefExploreDimension_stub(this)}accept(e){return e.visitDefExploreDimension_stub?e.visitDefExploreDimension_stub(this):e.visitChildren(this)}}L.DefExploreDimension_stubContext=sq;class oq extends Pr{defMeasures(){return this.getRuleContext(0,fv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreMeasure_stub&&e.enterDefExploreMeasure_stub(this)}exitRule(e){e.exitDefExploreMeasure_stub&&e.exitDefExploreMeasure_stub(this)}accept(e){return e.visitDefExploreMeasure_stub?e.visitDefExploreMeasure_stub(this):e.visitChildren(this)}}L.DefExploreMeasure_stubContext=oq;class uq extends Pr{declareStatement(){return this.getRuleContext(0,og)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefDeclare_stub&&e.enterDefDeclare_stub(this)}exitRule(e){e.exitDefDeclare_stub&&e.exitDefDeclare_stub(this)}accept(e){return e.visitDefDeclare_stub?e.visitDefDeclare_stub(this):e.visitChildren(this)}}L.DefDeclare_stubContext=uq;class aq extends Pr{joinStatement(){return this.getRuleContext(0,Pa)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoin_stub&&e.enterDefJoin_stub(this)}exitRule(e){e.exitDefJoin_stub&&e.exitDefJoin_stub(this)}accept(e){return e.visitDefJoin_stub?e.visitDefJoin_stub(this):e.visitChildren(this)}}L.DefJoin_stubContext=aq;class lq extends Pr{whereStatement(){return this.getRuleContext(0,gf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreWhere_stub&&e.enterDefExploreWhere_stub(this)}exitRule(e){e.exitDefExploreWhere_stub&&e.exitDefExploreWhere_stub(this)}accept(e){return e.visitDefExploreWhere_stub?e.visitDefExploreWhere_stub(this):e.visitChildren(this)}}L.DefExploreWhere_stubContext=lq;class cq extends Pr{PRIMARY_KEY(){return this.getToken(x.PRIMARY_KEY,0)}fieldName(){return this.getRuleContext(0,vr)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExplorePrimaryKey&&e.enterDefExplorePrimaryKey(this)}exitRule(e){e.exitDefExplorePrimaryKey&&e.exitDefExplorePrimaryKey(this)}accept(e){return e.visitDefExplorePrimaryKey?e.visitDefExplorePrimaryKey(this):e.visitChildren(this)}}L.DefExplorePrimaryKeyContext=cq;class fq extends Pr{RENAME(){return this.getToken(x.RENAME,0)}renameList(){return this.getRuleContext(0,CO)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreRename&&e.enterDefExploreRename(this)}exitRule(e){e.exitDefExploreRename&&e.exitDefExploreRename(this)}accept(e){return e.visitDefExploreRename?e.visitDefExploreRename(this):e.visitChildren(this)}}L.DefExploreRenameContext=fq;class xq extends Pr{fieldNameList(){return this.getRuleContext(0,Qd)}ACCEPT(){return this.tryGetToken(x.ACCEPT,0)}EXCEPT(){return this.tryGetToken(x.EXCEPT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreEditField&&e.enterDefExploreEditField(this)}exitRule(e){e.exitDefExploreEditField&&e.exitDefExploreEditField(this)}accept(e){return e.visitDefExploreEditField?e.visitDefExploreEditField(this):e.visitChildren(this)}}L.DefExploreEditFieldContext=xq;class dq extends Pr{tags(){return this.getRuleContext(0,Mt)}subQueryDefList(){return this.getRuleContext(0,UO)}QUERY(){return this.tryGetToken(x.QUERY,0)}VIEW(){return this.tryGetToken(x.VIEW,0)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreQuery&&e.enterDefExploreQuery(this)}exitRule(e){e.exitDefExploreQuery&&e.exitDefExploreQuery(this)}accept(e){return e.visitDefExploreQuery?e.visitDefExploreQuery(this):e.visitChildren(this)}}L.DefExploreQueryContext=dq;class hq extends Pr{timezoneStatement(){return this.getRuleContext(0,Lv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreTimezone&&e.enterDefExploreTimezone(this)}exitRule(e){e.exitDefExploreTimezone&&e.exitDefExploreTimezone(this)}accept(e){return e.visitDefExploreTimezone?e.visitDefExploreTimezone(this):e.visitChildren(this)}}L.DefExploreTimezoneContext=hq;class pq extends Pr{ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreAnnotation&&e.enterDefExploreAnnotation(this)}exitRule(e){e.exitDefExploreAnnotation&&e.exitDefExploreAnnotation(this)}accept(e){return e.visitDefExploreAnnotation?e.visitDefExploreAnnotation(this):e.visitChildren(this)}}L.DefExploreAnnotationContext=pq;class gq extends Pr{ignoredModelAnnotations(){return this.getRuleContext(0,sv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefIgnoreModel_stub&&e.enterDefIgnoreModel_stub(this)}exitRule(e){e.exitDefIgnoreModel_stub&&e.exitDefIgnoreModel_stub(this)}accept(e){return e.visitDefIgnoreModel_stub?e.visitDefIgnoreModel_stub(this):e.visitChildren(this)}}L.DefIgnoreModel_stubContext=gq;class Au extends ge.ParserRuleContext{PUBLIC_KW(){return this.tryGetToken(x.PUBLIC_KW,0)}PRIVATE_KW(){return this.tryGetToken(x.PRIVATE_KW,0)}INTERNAL_KW(){return this.tryGetToken(x.INTERNAL_KW,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_accessLabel}enterRule(e){e.enterAccessLabel&&e.enterAccessLabel(this)}exitRule(e){e.exitAccessLabel&&e.exitAccessLabel(this)}accept(e){return e.visitAccessLabel?e.visitAccessLabel(this):e.visitChildren(this)}}L.AccessLabelContext=Au;class mq extends ge.ParserRuleContext{fieldNameList(){return this.tryGetRuleContext(0,Qd)}STAR(){return this.tryGetToken(x.STAR,0)}starQualified(){return this.tryGetRuleContext(0,Uv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_accessModifierList}enterRule(e){e.enterAccessModifierList&&e.enterAccessModifierList(this)}exitRule(e){e.exitAccessModifierList&&e.exitAccessModifierList(this)}accept(e){return e.visitAccessModifierList?e.visitAccessModifierList(this):e.visitChildren(this)}}L.AccessModifierListContext=mq;class fv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}MEASURE(){return this.getToken(x.MEASURE,0)}defList(){return this.getRuleContext(0,sg)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defMeasures}enterRule(e){e.enterDefMeasures&&e.enterDefMeasures(this)}exitRule(e){e.exitDefMeasures&&e.exitDefMeasures(this)}accept(e){return e.visitDefMeasures?e.visitDefMeasures(this):e.visitChildren(this)}}L.DefMeasuresContext=fv;class xv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}DIMENSION(){return this.getToken(x.DIMENSION,0)}defList(){return this.getRuleContext(0,sg)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defDimensions}enterRule(e){e.enterDefDimensions&&e.enterDefDimensions(this)}exitRule(e){e.exitDefDimensions&&e.exitDefDimensions(this)}accept(e){return e.visitDefDimensions?e.visitDefDimensions(this):e.visitChildren(this)}}L.DefDimensionsContext=xv;class CO extends ge.ParserRuleContext{exploreRenameDef(e){return e===void 0?this.getRuleContexts(dv):this.getRuleContext(e,dv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_renameList}enterRule(e){e.enterRenameList&&e.enterRenameList(this)}exitRule(e){e.exitRenameList&&e.exitRenameList(this)}accept(e){return e.visitRenameList?e.visitRenameList(this):e.visitChildren(this)}}L.RenameListContext=CO;class dv extends ge.ParserRuleContext{fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}isDefine(){return this.getRuleContext(0,Ma)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreRenameDef}enterRule(e){e.enterExploreRenameDef&&e.enterExploreRenameDef(this)}exitRule(e){e.exitExploreRenameDef&&e.exitExploreRenameDef(this)}accept(e){return e.visitExploreRenameDef?e.visitExploreRenameDef(this):e.visitChildren(this)}}L.ExploreRenameDefContext=dv;class sg extends ge.ParserRuleContext{fieldDef(e){return e===void 0?this.getRuleContexts(qd):this.getRuleContext(e,qd)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defList}enterRule(e){e.enterDefList&&e.enterDefList(this)}exitRule(e){e.exitDefList&&e.exitDefList(this)}accept(e){return e.visitDefList?e.visitDefList(this):e.visitChildren(this)}}L.DefListContext=sg;class qd extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldNameDef(){return this.getRuleContext(0,bO)}isDefine(){return this.getRuleContext(0,Ma)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldDef}enterRule(e){e.enterFieldDef&&e.enterFieldDef(this)}exitRule(e){e.exitFieldDef&&e.exitFieldDef(this)}accept(e){return e.visitFieldDef?e.visitFieldDef(this):e.visitChildren(this)}}L.FieldDefContext=qd;class bO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldNameDef}enterRule(e){e.enterFieldNameDef&&e.enterFieldNameDef(this)}exitRule(e){e.exitFieldNameDef&&e.exitFieldNameDef(this)}accept(e){return e.visitFieldNameDef?e.visitFieldNameDef(this):e.visitChildren(this)}}L.FieldNameDefContext=bO;class TO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinNameDef}enterRule(e){e.enterJoinNameDef&&e.enterJoinNameDef(this)}exitRule(e){e.exitJoinNameDef&&e.exitJoinNameDef(this)}accept(e){return e.visitJoinNameDef?e.visitJoinNameDef(this):e.visitChildren(this)}}L.JoinNameDefContext=TO;class og extends ge.ParserRuleContext{DECLARE(){return this.getToken(x.DECLARE,0)}defList(){return this.getRuleContext(0,sg)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_declareStatement}enterRule(e){e.enterDeclareStatement&&e.enterDeclareStatement(this)}exitRule(e){e.exitDeclareStatement&&e.exitDeclareStatement(this)}accept(e){return e.visitDeclareStatement?e.visitDeclareStatement(this):e.visitChildren(this)}}L.DeclareStatementContext=og;class Pa extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinStatement}copyFrom(e){super.copyFrom(e)}}L.JoinStatementContext=Pa;class yq extends Pa{tags(){return this.getRuleContext(0,Mt)}JOIN_ONE(){return this.getToken(x.JOIN_ONE,0)}joinList(){return this.getRuleContext(0,ug)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoinOne&&e.enterDefJoinOne(this)}exitRule(e){e.exitDefJoinOne&&e.exitDefJoinOne(this)}accept(e){return e.visitDefJoinOne?e.visitDefJoinOne(this):e.visitChildren(this)}}L.DefJoinOneContext=yq;class Eq extends Pa{tags(){return this.getRuleContext(0,Mt)}JOIN_MANY(){return this.getToken(x.JOIN_MANY,0)}joinList(){return this.getRuleContext(0,ug)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoinMany&&e.enterDefJoinMany(this)}exitRule(e){e.exitDefJoinMany&&e.exitDefJoinMany(this)}accept(e){return e.visitDefJoinMany?e.visitDefJoinMany(this):e.visitChildren(this)}}L.DefJoinManyContext=Eq;class Aq extends Pa{tags(){return this.getRuleContext(0,Mt)}JOIN_CROSS(){return this.getToken(x.JOIN_CROSS,0)}joinList(){return this.getRuleContext(0,ug)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoinCross&&e.enterDefJoinCross(this)}exitRule(e){e.exitDefJoinCross&&e.exitDefJoinCross(this)}accept(e){return e.visitDefJoinCross?e.visitDefJoinCross(this):e.visitChildren(this)}}L.DefJoinCrossContext=Aq;class RO extends ge.ParserRuleContext{EXTENDQ(){return this.getToken(x.EXTENDQ,0)}queryExtendStatementList(){return this.getRuleContext(0,LO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryExtend}enterRule(e){e.enterQueryExtend&&e.enterQueryExtend(this)}exitRule(e){e.exitQueryExtend&&e.exitQueryExtend(this)}accept(e){return e.visitQueryExtend?e.visitQueryExtend(this):e.visitChildren(this)}}L.QueryExtendContext=RO;class vq extends ge.ParserRuleContext{joinStatement(){return this.tryGetRuleContext(0,Pa)}whereStatement(){return this.tryGetRuleContext(0,gf)}declareStatement(){return this.tryGetRuleContext(0,og)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_modEither}enterRule(e){e.enterModEither&&e.enterModEither(this)}exitRule(e){e.exitModEither&&e.exitModEither(this)}accept(e){return e.visitModEither?e.visitModEither(this):e.visitChildren(this)}}L.ModEitherContext=vq;class hv extends ge.ParserRuleContext{OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sourceArgument(e){return e===void 0?this.getRuleContexts(pv):this.getRuleContext(e,pv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceArguments}enterRule(e){e.enterSourceArguments&&e.enterSourceArguments(this)}exitRule(e){e.exitSourceArguments&&e.exitSourceArguments(this)}accept(e){return e.visitSourceArguments?e.visitSourceArguments(this):e.visitChildren(this)}}L.SourceArgumentsContext=hv;class OO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_argumentId}enterRule(e){e.enterArgumentId&&e.enterArgumentId(this)}exitRule(e){e.exitArgumentId&&e.exitArgumentId(this)}accept(e){return e.visitArgumentId?e.visitArgumentId(this):e.visitChildren(this)}}L.ArgumentIdContext=OO;class pv extends ge.ParserRuleContext{fieldExpr(){return this.getRuleContext(0,be)}argumentId(){return this.tryGetRuleContext(0,OO)}IS(){return this.tryGetToken(x.IS,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceArgument}enterRule(e){e.enterSourceArgument&&e.enterSourceArgument(this)}exitRule(e){e.exitSourceArgument&&e.exitSourceArgument(this)}accept(e){return e.visitSourceArgument?e.visitSourceArgument(this):e.visitChildren(this)}}L.SourceArgumentContext=pv;class Zt extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqExpr}copyFrom(e){super.copyFrom(e)}}L.SqExprContext=Zt;class _q extends Zt{id(){return this.getRuleContext(0,pn)}sourceArguments(){return this.tryGetRuleContext(0,hv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQID&&e.enterSQID(this)}exitRule(e){e.exitSQID&&e.exitSQID(this)}accept(e){return e.visitSQID?e.visitSQID(this):e.visitChildren(this)}}L.SQIDContext=_q;class Sq extends Zt{OPAREN(){return this.getToken(x.OPAREN,0)}sqExpr(){return this.getRuleContext(0,Zt)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQParens&&e.enterSQParens(this)}exitRule(e){e.exitSQParens&&e.exitSQParens(this)}accept(e){return e.visitSQParens?e.visitSQParens(this):e.visitChildren(this)}}L.SQParensContext=Sq;class Cq extends Zt{COMPOSE(){return this.getToken(x.COMPOSE,0)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sqExpr(e){return e===void 0?this.getRuleContexts(Zt):this.getRuleContext(e,Zt)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQCompose&&e.enterSQCompose(this)}exitRule(e){e.exitSQCompose&&e.exitSQCompose(this)}accept(e){return e.visitSQCompose?e.visitSQCompose(this):e.visitChildren(this)}}L.SQComposeContext=Cq;class bq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}PLUS(){return this.getToken(x.PLUS,0)}segExpr(){return this.getRuleContext(0,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQRefinedQuery&&e.enterSQRefinedQuery(this)}exitRule(e){e.exitSQRefinedQuery&&e.exitSQRefinedQuery(this)}accept(e){return e.visitSQRefinedQuery?e.visitSQRefinedQuery(this):e.visitChildren(this)}}L.SQRefinedQueryContext=bq;class Tq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}ARROW(){return this.getToken(x.ARROW,0)}segExpr(){return this.getRuleContext(0,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQArrow&&e.enterSQArrow(this)}exitRule(e){e.exitSQArrow&&e.exitSQArrow(this)}accept(e){return e.visitSQArrow?e.visitSQArrow(this):e.visitChildren(this)}}L.SQArrowContext=Tq;class Rq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}EXTEND(){return this.getToken(x.EXTEND,0)}exploreProperties(){return this.getRuleContext(0,SO)}INCLUDE(){return this.tryGetToken(x.INCLUDE,0)}includeBlock(){return this.tryGetRuleContext(0,gv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQExtendedSource&&e.enterSQExtendedSource(this)}exitRule(e){e.exitSQExtendedSource&&e.exitSQExtendedSource(this)}accept(e){return e.visitSQExtendedSource?e.visitSQExtendedSource(this):e.visitChildren(this)}}L.SQExtendedSourceContext=Rq;class Oq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}INCLUDE(){return this.getToken(x.INCLUDE,0)}includeBlock(){return this.getRuleContext(0,gv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQInclude&&e.enterSQInclude(this)}exitRule(e){e.exitSQInclude&&e.exitSQInclude(this)}accept(e){return e.visitSQInclude?e.visitSQInclude(this):e.visitChildren(this)}}L.SQIncludeContext=Oq;class Dq extends Zt{exploreTable(){return this.getRuleContext(0,ig)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQTable&&e.enterSQTable(this)}exitRule(e){e.exitSQTable&&e.exitSQTable(this)}accept(e){return e.visitSQTable?e.visitSQTable(this):e.visitChildren(this)}}L.SQTableContext=Dq;class wq extends Zt{sqlSource(){return this.getRuleContext(0,gO)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQSQL&&e.enterSQSQL(this)}exitRule(e){e.exitSQSQL&&e.exitSQSQL(this)}accept(e){return e.visitSQSQL?e.visitSQSQL(this):e.visitChildren(this)}}L.SQSQLContext=wq;class gv extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}includeItem(e){return e===void 0?this.getRuleContexts(mv):this.getRuleContext(e,mv)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeBlock}enterRule(e){e.enterIncludeBlock&&e.enterIncludeBlock(this)}exitRule(e){e.exitIncludeBlock&&e.exitIncludeBlock(this)}accept(e){return e.visitIncludeBlock?e.visitIncludeBlock(this):e.visitChildren(this)}}L.IncludeBlockContext=gv;class mv extends ge.ParserRuleContext{tags(){return this.tryGetRuleContext(0,Mt)}accessLabelProp(){return this.tryGetRuleContext(0,wO)}includeList(){return this.tryGetRuleContext(0,FO)}EXCEPT(){return this.tryGetToken(x.EXCEPT,0)}includeExceptList(){return this.tryGetRuleContext(0,NO)}orphanedAnnotation(){return this.tryGetRuleContext(0,DO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeItem}enterRule(e){e.enterIncludeItem&&e.enterIncludeItem(this)}exitRule(e){e.exitIncludeItem&&e.exitIncludeItem(this)}accept(e){return e.visitIncludeItem?e.visitIncludeItem(this):e.visitChildren(this)}}L.IncludeItemContext=mv;class DO extends ge.ParserRuleContext{ANNOTATION(){return this.getToken(x.ANNOTATION,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_orphanedAnnotation}enterRule(e){e.enterOrphanedAnnotation&&e.enterOrphanedAnnotation(this)}exitRule(e){e.exitOrphanedAnnotation&&e.exitOrphanedAnnotation(this)}accept(e){return e.visitOrphanedAnnotation?e.visitOrphanedAnnotation(this):e.visitChildren(this)}}L.OrphanedAnnotationContext=DO;class wO extends ge.ParserRuleContext{PUBLIC(){return this.tryGetToken(x.PUBLIC,0)}PRIVATE(){return this.tryGetToken(x.PRIVATE,0)}INTERNAL(){return this.tryGetToken(x.INTERNAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_accessLabelProp}enterRule(e){e.enterAccessLabelProp&&e.enterAccessLabelProp(this)}exitRule(e){e.exitAccessLabelProp&&e.exitAccessLabelProp(this)}accept(e){return e.visitAccessLabelProp?e.visitAccessLabelProp(this):e.visitChildren(this)}}L.AccessLabelPropContext=wO;class NO extends ge.ParserRuleContext{includeExceptListItem(e){return e===void 0?this.getRuleContexts(yv):this.getRuleContext(e,yv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeExceptList}enterRule(e){e.enterIncludeExceptList&&e.enterIncludeExceptList(this)}exitRule(e){e.exitIncludeExceptList&&e.exitIncludeExceptList(this)}accept(e){return e.visitIncludeExceptList?e.visitIncludeExceptList(this):e.visitChildren(this)}}L.IncludeExceptListContext=NO;class yv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldName(){return this.tryGetRuleContext(0,vr)}collectionWildCard(){return this.tryGetRuleContext(0,xg)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeExceptListItem}enterRule(e){e.enterIncludeExceptListItem&&e.enterIncludeExceptListItem(this)}exitRule(e){e.exitIncludeExceptListItem&&e.exitIncludeExceptListItem(this)}accept(e){return e.visitIncludeExceptListItem?e.visitIncludeExceptListItem(this):e.visitChildren(this)}}L.IncludeExceptListItemContext=yv;class FO extends ge.ParserRuleContext{includeField(e){return e===void 0?this.getRuleContexts(Ev):this.getRuleContext(e,Ev)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeList}enterRule(e){e.enterIncludeList&&e.enterIncludeList(this)}exitRule(e){e.exitIncludeList&&e.exitIncludeList(this)}accept(e){return e.visitIncludeList?e.visitIncludeList(this):e.visitChildren(this)}}L.IncludeListContext=FO;class Ev extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}isDefine(){return this.tryGetRuleContext(0,Ma)}collectionWildCard(){return this.tryGetRuleContext(0,xg)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeField}enterRule(e){e.enterIncludeField&&e.enterIncludeField(this)}exitRule(e){e.exitIncludeField&&e.exitIncludeField(this)}accept(e){return e.visitIncludeField?e.visitIncludeField(this):e.visitChildren(this)}}L.IncludeFieldContext=Ev;class cs extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_segExpr}copyFrom(e){super.copyFrom(e)}}L.SegExprContext=cs;class Nq extends cs{fieldPath(){return this.getRuleContext(0,Cu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegField&&e.enterSegField(this)}exitRule(e){e.exitSegField&&e.exitSegField(this)}accept(e){return e.visitSegField?e.visitSegField(this):e.visitChildren(this)}}L.SegFieldContext=Nq;class Fq extends cs{queryProperties(){return this.getRuleContext(0,mO)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegOps&&e.enterSegOps(this)}exitRule(e){e.exitSegOps&&e.exitSegOps(this)}accept(e){return e.visitSegOps?e.visitSegOps(this):e.visitChildren(this)}}L.SegOpsContext=Fq;class Lq extends cs{OPAREN(){return this.getToken(x.OPAREN,0)}vExpr(){return this.getRuleContext(0,u0)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegParen&&e.enterSegParen(this)}exitRule(e){e.exitSegParen&&e.exitSegParen(this)}accept(e){return e.visitSegParen?e.visitSegParen(this):e.visitChildren(this)}}L.SegParenContext=Lq;class Iq extends cs{PLUS(){return this.getToken(x.PLUS,0)}segExpr(e){return e===void 0?this.getRuleContexts(cs):this.getRuleContext(e,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegRefine&&e.enterSegRefine(this)}exitRule(e){e.exitSegRefine&&e.exitSegRefine(this)}accept(e){return e.visitSegRefine?e.visitSegRefine(this):e.visitChildren(this)}}L.SegRefineContext=Iq;class u0 extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_vExpr}copyFrom(e){super.copyFrom(e)}}L.VExprContext=u0;class Bq extends u0{segExpr(){return this.getRuleContext(0,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterVSeg&&e.enterVSeg(this)}exitRule(e){e.exitVSeg&&e.exitVSeg(this)}accept(e){return e.visitVSeg?e.visitVSeg(this):e.visitChildren(this)}}L.VSegContext=Bq;class $q extends u0{ARROW(){return this.getToken(x.ARROW,0)}segExpr(){return this.getRuleContext(0,cs)}vExpr(){return this.getRuleContext(0,u0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterVArrow&&e.enterVArrow(this)}exitRule(e){e.exitVArrow&&e.exitVArrow(this)}accept(e){return e.visitVArrow?e.visitVArrow(this):e.visitChildren(this)}}L.VArrowContext=$q;class Av extends ge.ParserRuleContext{defDimensions(){return this.tryGetRuleContext(0,xv)}defMeasures(){return this.tryGetRuleContext(0,fv)}joinStatement(){return this.tryGetRuleContext(0,Pa)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryExtendStatement}enterRule(e){e.enterQueryExtendStatement&&e.enterQueryExtendStatement(this)}exitRule(e){e.exitQueryExtendStatement&&e.exitQueryExtendStatement(this)}accept(e){return e.visitQueryExtendStatement?e.visitQueryExtendStatement(this):e.visitChildren(this)}}L.QueryExtendStatementContext=Av;class LO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}queryExtendStatement(e){return e===void 0?this.getRuleContexts(Av):this.getRuleContext(e,Av)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryExtendStatementList}enterRule(e){e.enterQueryExtendStatementList&&e.enterQueryExtendStatementList(this)}exitRule(e){e.exitQueryExtendStatementList&&e.exitQueryExtendStatementList(this)}accept(e){return e.visitQueryExtendStatementList?e.visitQueryExtendStatementList(this):e.visitChildren(this)}}L.QueryExtendStatementListContext=LO;class ug extends ge.ParserRuleContext{joinDef(e){return e===void 0?this.getRuleContexts(Hd):this.getRuleContext(e,Hd)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinList}enterRule(e){e.enterJoinList&&e.enterJoinList(this)}exitRule(e){e.exitJoinList&&e.exitJoinList(this)}accept(e){return e.visitJoinList?e.visitJoinList(this):e.visitChildren(this)}}L.JoinListContext=ug;class IO extends ge.ParserRuleContext{IS(){return this.getToken(x.IS,0)}sqExpr(){return this.getRuleContext(0,Zt)}tags(e){return e===void 0?this.getRuleContexts(Mt):this.getRuleContext(e,Mt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_isExplore}enterRule(e){e.enterIsExplore&&e.enterIsExplore(this)}exitRule(e){e.exitIsExplore&&e.exitIsExplore(this)}accept(e){return e.visitIsExplore?e.visitIsExplore(this):e.visitChildren(this)}}L.IsExploreContext=IO;class vv extends ge.ParserRuleContext{LEFT(){return this.tryGetToken(x.LEFT,0)}RIGHT(){return this.tryGetToken(x.RIGHT,0)}FULL(){return this.tryGetToken(x.FULL,0)}INNER(){return this.tryGetToken(x.INNER,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_matrixOperation}enterRule(e){e.enterMatrixOperation&&e.enterMatrixOperation(this)}exitRule(e){e.exitMatrixOperation&&e.exitMatrixOperation(this)}accept(e){return e.visitMatrixOperation?e.visitMatrixOperation(this):e.visitChildren(this)}}L.MatrixOperationContext=vv;class _v extends ge.ParserRuleContext{joinNameDef(){return this.getRuleContext(0,TO)}sourceArguments(){return this.tryGetRuleContext(0,hv)}isExplore(){return this.tryGetRuleContext(0,IO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinFrom}enterRule(e){e.enterJoinFrom&&e.enterJoinFrom(this)}exitRule(e){e.exitJoinFrom&&e.exitJoinFrom(this)}accept(e){return e.visitJoinFrom?e.visitJoinFrom(this):e.visitChildren(this)}}L.JoinFromContext=_v;class Hd extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinDef}copyFrom(e){super.copyFrom(e)}}L.JoinDefContext=Hd;class kq extends Hd{joinFrom(){return this.getRuleContext(0,_v)}WITH(){return this.getToken(x.WITH,0)}fieldExpr(){return this.getRuleContext(0,be)}ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}matrixOperation(){return this.tryGetRuleContext(0,vv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterJoinWith&&e.enterJoinWith(this)}exitRule(e){e.exitJoinWith&&e.exitJoinWith(this)}accept(e){return e.visitJoinWith?e.visitJoinWith(this):e.visitChildren(this)}}L.JoinWithContext=kq;class Mq extends Hd{joinFrom(){return this.getRuleContext(0,_v)}ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}ON(){return this.tryGetToken(x.ON,0)}joinExpression(){return this.tryGetRuleContext(0,BO)}matrixOperation(){return this.tryGetRuleContext(0,vv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterJoinOn&&e.enterJoinOn(this)}exitRule(e){e.exitJoinOn&&e.exitJoinOn(this)}accept(e){return e.visitJoinOn?e.visitJoinOn(this):e.visitChildren(this)}}L.JoinOnContext=Mq;class BO extends ge.ParserRuleContext{fieldExpr(){return this.getRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinExpression}enterRule(e){e.enterJoinExpression&&e.enterJoinExpression(this)}exitRule(e){e.exitJoinExpression&&e.exitJoinExpression(this)}accept(e){return e.visitJoinExpression?e.visitJoinExpression(this):e.visitChildren(this)}}L.JoinExpressionContext=BO;class Pq extends ge.ParserRuleContext{whereStatement(){return this.tryGetRuleContext(0,gf)}havingStatement(){return this.tryGetRuleContext(0,Tv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_filterStatement}enterRule(e){e.enterFilterStatement&&e.enterFilterStatement(this)}exitRule(e){e.exitFilterStatement&&e.exitFilterStatement(this)}accept(e){return e.visitFilterStatement?e.visitFilterStatement(this):e.visitChildren(this)}}L.FilterStatementContext=Pq;class $O extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}fieldPropertyStatement(e){return e===void 0?this.getRuleContexts(Cv):this.getRuleContext(e,Cv)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldProperties}enterRule(e){e.enterFieldProperties&&e.enterFieldProperties(this)}exitRule(e){e.exitFieldProperties&&e.exitFieldProperties(this)}accept(e){return e.visitFieldProperties?e.visitFieldProperties(this):e.visitChildren(this)}}L.FieldPropertiesContext=$O;class kO extends ge.ParserRuleContext{aggregateOrderBySpec(e){return e===void 0?this.getRuleContexts(Sv):this.getRuleContext(e,Sv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateOrdering}enterRule(e){e.enterAggregateOrdering&&e.enterAggregateOrdering(this)}exitRule(e){e.exitAggregateOrdering&&e.exitAggregateOrdering(this)}accept(e){return e.visitAggregateOrdering?e.visitAggregateOrdering(this):e.visitChildren(this)}}L.AggregateOrderingContext=kO;class Sv extends ge.ParserRuleContext{fieldExpr(){return this.tryGetRuleContext(0,be)}ASC(){return this.tryGetToken(x.ASC,0)}DESC(){return this.tryGetToken(x.DESC,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateOrderBySpec}enterRule(e){e.enterAggregateOrderBySpec&&e.enterAggregateOrderBySpec(this)}exitRule(e){e.exitAggregateOrderBySpec&&e.exitAggregateOrderBySpec(this)}accept(e){return e.visitAggregateOrderBySpec?e.visitAggregateOrderBySpec(this):e.visitChildren(this)}}L.AggregateOrderBySpecContext=Sv;class MO extends ge.ParserRuleContext{ORDER_BY(){return this.getToken(x.ORDER_BY,0)}aggregateOrdering(){return this.getRuleContext(0,kO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateOrderByStatement}enterRule(e){e.enterAggregateOrderByStatement&&e.enterAggregateOrderByStatement(this)}exitRule(e){e.exitAggregateOrderByStatement&&e.exitAggregateOrderByStatement(this)}accept(e){return e.visitAggregateOrderByStatement?e.visitAggregateOrderByStatement(this):e.visitChildren(this)}}L.AggregateOrderByStatementContext=MO;class PO extends ge.ParserRuleContext{limitStatement(){return this.getRuleContext(0,Nv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldPropertyLimitStatement}enterRule(e){e.enterFieldPropertyLimitStatement&&e.enterFieldPropertyLimitStatement(this)}exitRule(e){e.exitFieldPropertyLimitStatement&&e.exitFieldPropertyLimitStatement(this)}accept(e){return e.visitFieldPropertyLimitStatement?e.visitFieldPropertyLimitStatement(this):e.visitChildren(this)}}L.FieldPropertyLimitStatementContext=PO;class Cv extends ge.ParserRuleContext{whereStatement(){return this.tryGetRuleContext(0,gf)}partitionByStatement(){return this.tryGetRuleContext(0,YO)}aggregateOrderByStatement(){return this.tryGetRuleContext(0,MO)}fieldPropertyLimitStatement(){return this.tryGetRuleContext(0,PO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldPropertyStatement}enterRule(e){e.enterFieldPropertyStatement&&e.enterFieldPropertyStatement(this)}exitRule(e){e.exitFieldPropertyStatement&&e.exitFieldPropertyStatement(this)}accept(e){return e.visitFieldPropertyStatement?e.visitFieldPropertyStatement(this):e.visitChildren(this)}}L.FieldPropertyStatementContext=Cv;class bv extends ge.ParserRuleContext{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_filterClauseList}enterRule(e){e.enterFilterClauseList&&e.enterFilterClauseList(this)}exitRule(e){e.exitFilterClauseList&&e.exitFilterClauseList(this)}accept(e){return e.visitFilterClauseList?e.visitFilterClauseList(this):e.visitChildren(this)}}L.FilterClauseListContext=bv;class gf extends ge.ParserRuleContext{WHERE(){return this.getToken(x.WHERE,0)}filterClauseList(){return this.getRuleContext(0,bv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_whereStatement}enterRule(e){e.enterWhereStatement&&e.enterWhereStatement(this)}exitRule(e){e.exitWhereStatement&&e.exitWhereStatement(this)}accept(e){return e.visitWhereStatement?e.visitWhereStatement(this):e.visitChildren(this)}}L.WhereStatementContext=gf;class Tv extends ge.ParserRuleContext{HAVING(){return this.getToken(x.HAVING,0)}filterClauseList(){return this.getRuleContext(0,bv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_havingStatement}enterRule(e){e.enterHavingStatement&&e.enterHavingStatement(this)}exitRule(e){e.exitHavingStatement&&e.exitHavingStatement(this)}accept(e){return e.visitHavingStatement?e.visitHavingStatement(this):e.visitChildren(this)}}L.HavingStatementContext=Tv;class UO extends ge.ParserRuleContext{exploreQueryDef(e){return e===void 0?this.getRuleContexts(Rv):this.getRuleContext(e,Rv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_subQueryDefList}enterRule(e){e.enterSubQueryDefList&&e.enterSubQueryDefList(this)}exitRule(e){e.exitSubQueryDefList&&e.exitSubQueryDefList(this)}accept(e){return e.visitSubQueryDefList?e.visitSubQueryDefList(this):e.visitChildren(this)}}L.SubQueryDefListContext=UO;class jO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreQueryNameDef}enterRule(e){e.enterExploreQueryNameDef&&e.enterExploreQueryNameDef(this)}exitRule(e){e.exitExploreQueryNameDef&&e.exitExploreQueryNameDef(this)}accept(e){return e.visitExploreQueryNameDef?e.visitExploreQueryNameDef(this):e.visitChildren(this)}}L.ExploreQueryNameDefContext=jO;class Rv extends ge.ParserRuleContext{exploreQueryNameDef(){return this.getRuleContext(0,jO)}isDefine(){return this.getRuleContext(0,Ma)}vExpr(){return this.getRuleContext(0,u0)}ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreQueryDef}enterRule(e){e.enterExploreQueryDef&&e.enterExploreQueryDef(this)}exitRule(e){e.exitExploreQueryDef&&e.exitExploreQueryDef(this)}accept(e){return e.visitExploreQueryDef?e.visitExploreQueryDef(this):e.visitChildren(this)}}L.ExploreQueryDefContext=Rv;class Ov extends ge.ParserRuleContext{groupByStatement(){return this.tryGetRuleContext(0,HO)}declareStatement(){return this.tryGetRuleContext(0,og)}queryJoinStatement(){return this.tryGetRuleContext(0,qO)}queryExtend(){return this.tryGetRuleContext(0,RO)}projectStatement(){return this.tryGetRuleContext(0,VO)}indexStatement(){return this.tryGetRuleContext(0,eD)}aggregateStatement(){return this.tryGetRuleContext(0,GO)}calculateStatement(){return this.tryGetRuleContext(0,WO)}topStatement(){return this.tryGetRuleContext(0,XO)}limitStatement(){return this.tryGetRuleContext(0,Nv)}orderByStatement(){return this.tryGetRuleContext(0,KO)}whereStatement(){return this.tryGetRuleContext(0,gf)}havingStatement(){return this.tryGetRuleContext(0,Tv)}nestStatement(){return this.tryGetRuleContext(0,zO)}sampleStatement(){return this.tryGetRuleContext(0,tD)}timezoneStatement(){return this.tryGetRuleContext(0,Lv)}queryAnnotation(){return this.tryGetRuleContext(0,nD)}ignoredModelAnnotations(){return this.tryGetRuleContext(0,sv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryStatement}enterRule(e){e.enterQueryStatement&&e.enterQueryStatement(this)}exitRule(e){e.exitQueryStatement&&e.exitQueryStatement(this)}accept(e){return e.visitQueryStatement?e.visitQueryStatement(this):e.visitChildren(this)}}L.QueryStatementContext=Ov;class qO extends ge.ParserRuleContext{joinStatement(){return this.getRuleContext(0,Pa)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryJoinStatement}enterRule(e){e.enterQueryJoinStatement&&e.enterQueryJoinStatement(this)}exitRule(e){e.exitQueryJoinStatement&&e.exitQueryJoinStatement(this)}accept(e){return e.visitQueryJoinStatement?e.visitQueryJoinStatement(this):e.visitChildren(this)}}L.QueryJoinStatementContext=qO;class HO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}GROUP_BY(){return this.getToken(x.GROUP_BY,0)}queryFieldList(){return this.getRuleContext(0,ag)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_groupByStatement}enterRule(e){e.enterGroupByStatement&&e.enterGroupByStatement(this)}exitRule(e){e.exitGroupByStatement&&e.exitGroupByStatement(this)}accept(e){return e.visitGroupByStatement?e.visitGroupByStatement(this):e.visitChildren(this)}}L.GroupByStatementContext=HO;class ag extends ge.ParserRuleContext{queryFieldEntry(e){return e===void 0?this.getRuleContexts(Dv):this.getRuleContext(e,Dv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryFieldList}enterRule(e){e.enterQueryFieldList&&e.enterQueryFieldList(this)}exitRule(e){e.exitQueryFieldList&&e.exitQueryFieldList(this)}accept(e){return e.visitQueryFieldList?e.visitQueryFieldList(this):e.visitChildren(this)}}L.QueryFieldListContext=ag;class Dv extends ge.ParserRuleContext{taggedRef(){return this.tryGetRuleContext(0,jv)}fieldDef(){return this.tryGetRuleContext(0,qd)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryFieldEntry}enterRule(e){e.enterQueryFieldEntry&&e.enterQueryFieldEntry(this)}exitRule(e){e.exitQueryFieldEntry&&e.exitQueryFieldEntry(this)}accept(e){return e.visitQueryFieldEntry?e.visitQueryFieldEntry(this):e.visitChildren(this)}}L.QueryFieldEntryContext=Dv;class zO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}NEST(){return this.getToken(x.NEST,0)}nestedQueryList(){return this.getRuleContext(0,QO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nestStatement}enterRule(e){e.enterNestStatement&&e.enterNestStatement(this)}exitRule(e){e.exitNestStatement&&e.exitNestStatement(this)}accept(e){return e.visitNestStatement?e.visitNestStatement(this):e.visitChildren(this)}}L.NestStatementContext=zO;class QO extends ge.ParserRuleContext{nestEntry(e){return e===void 0?this.getRuleContexts(lg):this.getRuleContext(e,lg)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nestedQueryList}enterRule(e){e.enterNestedQueryList&&e.enterNestedQueryList(this)}exitRule(e){e.exitNestedQueryList&&e.exitNestedQueryList(this)}accept(e){return e.visitNestedQueryList?e.visitNestedQueryList(this):e.visitChildren(this)}}L.NestedQueryListContext=QO;class lg extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nestEntry}copyFrom(e){super.copyFrom(e)}}L.NestEntryContext=lg;class Uq extends lg{tags(){return this.getRuleContext(0,Mt)}vExpr(){return this.getRuleContext(0,u0)}queryName(){return this.tryGetRuleContext(0,av)}isDefine(){return this.tryGetRuleContext(0,Ma)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterNestDef&&e.enterNestDef(this)}exitRule(e){e.exitNestDef&&e.exitNestDef(this)}accept(e){return e.visitNestDef?e.visitNestDef(this):e.visitChildren(this)}}L.NestDefContext=Uq;class GO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}AGGREGATE(){return this.getToken(x.AGGREGATE,0)}queryFieldList(){return this.getRuleContext(0,ag)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateStatement}enterRule(e){e.enterAggregateStatement&&e.enterAggregateStatement(this)}exitRule(e){e.exitAggregateStatement&&e.exitAggregateStatement(this)}accept(e){return e.visitAggregateStatement?e.visitAggregateStatement(this):e.visitChildren(this)}}L.AggregateStatementContext=GO;class WO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}CALCULATE(){return this.getToken(x.CALCULATE,0)}queryFieldList(){return this.getRuleContext(0,ag)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_calculateStatement}enterRule(e){e.enterCalculateStatement&&e.enterCalculateStatement(this)}exitRule(e){e.exitCalculateStatement&&e.exitCalculateStatement(this)}accept(e){return e.visitCalculateStatement?e.visitCalculateStatement(this):e.visitChildren(this)}}L.CalculateStatementContext=WO;class VO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldCollection(){return this.getRuleContext(0,pD)}SELECT(){return this.tryGetToken(x.SELECT,0)}PROJECT(){return this.tryGetToken(x.PROJECT,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_projectStatement}enterRule(e){e.enterProjectStatement&&e.enterProjectStatement(this)}exitRule(e){e.exitProjectStatement&&e.exitProjectStatement(this)}accept(e){return e.visitProjectStatement?e.visitProjectStatement(this):e.visitChildren(this)}}L.ProjectStatementContext=VO;class YO extends ge.ParserRuleContext{PARTITION_BY(){return this.getToken(x.PARTITION_BY,0)}id(e){return e===void 0?this.getRuleContexts(pn):this.getRuleContext(e,pn)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partitionByStatement}enterRule(e){e.enterPartitionByStatement&&e.enterPartitionByStatement(this)}exitRule(e){e.exitPartitionByStatement&&e.exitPartitionByStatement(this)}accept(e){return e.visitPartitionByStatement?e.visitPartitionByStatement(this):e.visitChildren(this)}}L.PartitionByStatementContext=YO;class KO extends ge.ParserRuleContext{ORDER_BY(){return this.getToken(x.ORDER_BY,0)}ordering(){return this.getRuleContext(0,JO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_orderByStatement}enterRule(e){e.enterOrderByStatement&&e.enterOrderByStatement(this)}exitRule(e){e.exitOrderByStatement&&e.exitOrderByStatement(this)}accept(e){return e.visitOrderByStatement?e.visitOrderByStatement(this):e.visitChildren(this)}}L.OrderByStatementContext=KO;class JO extends ge.ParserRuleContext{orderBySpec(e){return e===void 0?this.getRuleContexts(wv):this.getRuleContext(e,wv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ordering}enterRule(e){e.enterOrdering&&e.enterOrdering(this)}exitRule(e){e.exitOrdering&&e.exitOrdering(this)}accept(e){return e.visitOrdering?e.visitOrdering(this):e.visitChildren(this)}}L.OrderingContext=JO;class wv extends ge.ParserRuleContext{INTEGER_LITERAL(){return this.tryGetToken(x.INTEGER_LITERAL,0)}fieldName(){return this.tryGetRuleContext(0,vr)}ASC(){return this.tryGetToken(x.ASC,0)}DESC(){return this.tryGetToken(x.DESC,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_orderBySpec}enterRule(e){e.enterOrderBySpec&&e.enterOrderBySpec(this)}exitRule(e){e.exitOrderBySpec&&e.exitOrderBySpec(this)}accept(e){return e.visitOrderBySpec?e.visitOrderBySpec(this):e.visitChildren(this)}}L.OrderBySpecContext=wv;class Nv extends ge.ParserRuleContext{LIMIT(){return this.getToken(x.LIMIT,0)}INTEGER_LITERAL(){return this.getToken(x.INTEGER_LITERAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_limitStatement}enterRule(e){e.enterLimitStatement&&e.enterLimitStatement(this)}exitRule(e){e.exitLimitStatement&&e.exitLimitStatement(this)}accept(e){return e.visitLimitStatement?e.visitLimitStatement(this):e.visitChildren(this)}}L.LimitStatementContext=Nv;class jq extends ge.ParserRuleContext{BY(){return this.getToken(x.BY,0)}fieldName(){return this.tryGetRuleContext(0,vr)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_bySpec}enterRule(e){e.enterBySpec&&e.enterBySpec(this)}exitRule(e){e.exitBySpec&&e.exitBySpec(this)}accept(e){return e.visitBySpec?e.visitBySpec(this):e.visitChildren(this)}}L.BySpecContext=jq;class XO extends ge.ParserRuleContext{TOP(){return this.getToken(x.TOP,0)}INTEGER_LITERAL(){return this.getToken(x.INTEGER_LITERAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topStatement}enterRule(e){e.enterTopStatement&&e.enterTopStatement(this)}exitRule(e){e.exitTopStatement&&e.exitTopStatement(this)}accept(e){return e.visitTopStatement?e.visitTopStatement(this):e.visitChildren(this)}}L.TopStatementContext=XO;class Fv extends ge.ParserRuleContext{fieldPath(){return this.tryGetRuleContext(0,Cu)}DOT(){return this.tryGetToken(x.DOT,0)}STAR(){return this.tryGetToken(x.STAR,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_indexElement}enterRule(e){e.enterIndexElement&&e.enterIndexElement(this)}exitRule(e){e.exitIndexElement&&e.exitIndexElement(this)}accept(e){return e.visitIndexElement?e.visitIndexElement(this):e.visitChildren(this)}}L.IndexElementContext=Fv;class ZO extends ge.ParserRuleContext{indexElement(e){return e===void 0?this.getRuleContexts(Fv):this.getRuleContext(e,Fv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_indexFields}enterRule(e){e.enterIndexFields&&e.enterIndexFields(this)}exitRule(e){e.exitIndexFields&&e.exitIndexFields(this)}accept(e){return e.visitIndexFields?e.visitIndexFields(this):e.visitChildren(this)}}L.IndexFieldsContext=ZO;class eD extends ge.ParserRuleContext{INDEX(){return this.getToken(x.INDEX,0)}indexFields(){return this.getRuleContext(0,ZO)}BY(){return this.tryGetToken(x.BY,0)}fieldName(){return this.tryGetRuleContext(0,vr)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_indexStatement}enterRule(e){e.enterIndexStatement&&e.enterIndexStatement(this)}exitRule(e){e.exitIndexStatement&&e.exitIndexStatement(this)}accept(e){return e.visitIndexStatement?e.visitIndexStatement(this):e.visitChildren(this)}}L.IndexStatementContext=eD;class tD extends ge.ParserRuleContext{SAMPLE(){return this.getToken(x.SAMPLE,0)}sampleSpec(){return this.getRuleContext(0,rD)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sampleStatement}enterRule(e){e.enterSampleStatement&&e.enterSampleStatement(this)}exitRule(e){e.exitSampleStatement&&e.exitSampleStatement(this)}accept(e){return e.visitSampleStatement?e.visitSampleStatement(this):e.visitChildren(this)}}L.SampleStatementContext=tD;class Lv extends ge.ParserRuleContext{TIMEZONE(){return this.getToken(x.TIMEZONE,0)}string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_timezoneStatement}enterRule(e){e.enterTimezoneStatement&&e.enterTimezoneStatement(this)}exitRule(e){e.exitTimezoneStatement&&e.exitTimezoneStatement(this)}accept(e){return e.visitTimezoneStatement?e.visitTimezoneStatement(this):e.visitChildren(this)}}L.TimezoneStatementContext=Lv;class nD extends ge.ParserRuleContext{ANNOTATION(){return this.getToken(x.ANNOTATION,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryAnnotation}enterRule(e){e.enterQueryAnnotation&&e.enterQueryAnnotation(this)}exitRule(e){e.exitQueryAnnotation&&e.exitQueryAnnotation(this)}accept(e){return e.visitQueryAnnotation?e.visitQueryAnnotation(this):e.visitChildren(this)}}L.QueryAnnotationContext=nD;class rD extends ge.ParserRuleContext{PERCENT_LITERAL(){return this.tryGetToken(x.PERCENT_LITERAL,0)}INTEGER_LITERAL(){return this.tryGetToken(x.INTEGER_LITERAL,0)}TRUE(){return this.tryGetToken(x.TRUE,0)}FALSE(){return this.tryGetToken(x.FALSE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sampleSpec}enterRule(e){e.enterSampleSpec&&e.enterSampleSpec(this)}exitRule(e){e.exitSampleSpec&&e.exitSampleSpec(this)}accept(e){return e.visitSampleSpec?e.visitSampleSpec(this):e.visitChildren(this)}}L.SampleSpecContext=rD;class cg extends ge.ParserRuleContext{SUM(){return this.tryGetToken(x.SUM,0)}COUNT(){return this.tryGetToken(x.COUNT,0)}AVG(){return this.tryGetToken(x.AVG,0)}MIN(){return this.tryGetToken(x.MIN,0)}MAX(){return this.tryGetToken(x.MAX,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregate}enterRule(e){e.enterAggregate&&e.enterAggregate(this)}exitRule(e){e.exitAggregate&&e.exitAggregate(this)}accept(e){return e.visitAggregate?e.visitAggregate(this):e.visitChildren(this)}}L.AggregateContext=cg;class fg extends ge.ParserRuleContext{STRING(){return this.tryGetToken(x.STRING,0)}NUMBER(){return this.tryGetToken(x.NUMBER,0)}BOOLEAN(){return this.tryGetToken(x.BOOLEAN,0)}DATE(){return this.tryGetToken(x.DATE,0)}TIMESTAMP(){return this.tryGetToken(x.TIMESTAMP,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyType}enterRule(e){e.enterMalloyType&&e.enterMalloyType(this)}exitRule(e){e.exitMalloyType&&e.exitMalloyType(this)}accept(e){return e.visitMalloyType?e.visitMalloyType(this):e.visitChildren(this)}}L.MalloyTypeContext=fg;class Iv extends ge.ParserRuleContext{MATCH(){return this.tryGetToken(x.MATCH,0)}NOT_MATCH(){return this.tryGetToken(x.NOT_MATCH,0)}GT(){return this.tryGetToken(x.GT,0)}LT(){return this.tryGetToken(x.LT,0)}GTE(){return this.tryGetToken(x.GTE,0)}LTE(){return this.tryGetToken(x.LTE,0)}EQ(){return this.tryGetToken(x.EQ,0)}NE(){return this.tryGetToken(x.NE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_compareOp}enterRule(e){e.enterCompareOp&&e.enterCompareOp(this)}exitRule(e){e.exitCompareOp&&e.exitCompareOp(this)}accept(e){return e.visitCompareOp?e.visitCompareOp(this):e.visitChildren(this)}}L.CompareOpContext=Iv;class vu extends ge.ParserRuleContext{shortString(){return this.tryGetRuleContext(0,Bv)}sqlString(){return this.tryGetRuleContext(0,nv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_string}enterRule(e){e.enterString&&e.enterString(this)}exitRule(e){e.exitString&&e.exitString(this)}accept(e){return e.visitString?e.visitString(this):e.visitChildren(this)}}L.StringContext=vu;class Bv extends ge.ParserRuleContext{SQ_STRING(){return this.tryGetToken(x.SQ_STRING,0)}DQ_STRING(){return this.tryGetToken(x.DQ_STRING,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_shortString}enterRule(e){e.enterShortString&&e.enterShortString(this)}exitRule(e){e.exitShortString&&e.exitShortString(this)}accept(e){return e.visitShortString?e.visitShortString(this):e.visitChildren(this)}}L.ShortStringContext=Bv;class iD extends ge.ParserRuleContext{NUMERIC_LITERAL(){return this.tryGetToken(x.NUMERIC_LITERAL,0)}INTEGER_LITERAL(){return this.tryGetToken(x.INTEGER_LITERAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_numericLiteral}enterRule(e){e.enterNumericLiteral&&e.enterNumericLiteral(this)}exitRule(e){e.exitNumericLiteral&&e.exitNumericLiteral(this)}accept(e){return e.visitNumericLiteral?e.visitNumericLiteral(this):e.visitChildren(this)}}L.NumericLiteralContext=iD;class _u extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_literal}copyFrom(e){super.copyFrom(e)}}L.LiteralContext=_u;class qq extends _u{string(){return this.getRuleContext(0,vu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprString&&e.enterExprString(this)}exitRule(e){e.exitExprString&&e.exitExprString(this)}accept(e){return e.visitExprString?e.visitExprString(this):e.visitChildren(this)}}L.ExprStringContext=qq;class Hq extends _u{numericLiteral(){return this.getRuleContext(0,iD)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNumber&&e.enterExprNumber(this)}exitRule(e){e.exitExprNumber&&e.exitExprNumber(this)}accept(e){return e.visitExprNumber?e.visitExprNumber(this):e.visitChildren(this)}}L.ExprNumberContext=Hq;class zq extends _u{dateLiteral(){return this.getRuleContext(0,Su)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprTime&&e.enterExprTime(this)}exitRule(e){e.exitExprTime&&e.exitExprTime(this)}accept(e){return e.visitExprTime?e.visitExprTime(this):e.visitChildren(this)}}L.ExprTimeContext=zq;class Qq extends _u{NULL(){return this.getToken(x.NULL,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNULL&&e.enterExprNULL(this)}exitRule(e){e.exitExprNULL&&e.exitExprNULL(this)}accept(e){return e.visitExprNULL?e.visitExprNULL(this):e.visitChildren(this)}}L.ExprNULLContext=Qq;class Gq extends _u{TRUE(){return this.tryGetToken(x.TRUE,0)}FALSE(){return this.tryGetToken(x.FALSE,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprBool&&e.enterExprBool(this)}exitRule(e){e.exitExprBool&&e.exitExprBool(this)}accept(e){return e.visitExprBool?e.visitExprBool(this):e.visitChildren(this)}}L.ExprBoolContext=Gq;class Wq extends _u{HACKY_REGEX(){return this.getToken(x.HACKY_REGEX,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprRegex&&e.enterExprRegex(this)}exitRule(e){e.exitExprRegex&&e.exitExprRegex(this)}accept(e){return e.visitExprRegex?e.visitExprRegex(this):e.visitChildren(this)}}L.ExprRegexContext=Wq;class Vq extends _u{NOW(){return this.getToken(x.NOW,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNow&&e.enterExprNow(this)}exitRule(e){e.exitExprNow&&e.exitExprNow(this)}accept(e){return e.visitExprNow?e.visitExprNow(this):e.visitChildren(this)}}L.ExprNowContext=Vq;class Su extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_dateLiteral}copyFrom(e){super.copyFrom(e)}}L.DateLiteralContext=Su;class Yq extends Su{LITERAL_TIMESTAMP(){return this.getToken(x.LITERAL_TIMESTAMP,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralTimestamp&&e.enterLiteralTimestamp(this)}exitRule(e){e.exitLiteralTimestamp&&e.exitLiteralTimestamp(this)}accept(e){return e.visitLiteralTimestamp?e.visitLiteralTimestamp(this):e.visitChildren(this)}}L.LiteralTimestampContext=Yq;class Kq extends Su{LITERAL_HOUR(){return this.getToken(x.LITERAL_HOUR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralHour&&e.enterLiteralHour(this)}exitRule(e){e.exitLiteralHour&&e.exitLiteralHour(this)}accept(e){return e.visitLiteralHour?e.visitLiteralHour(this):e.visitChildren(this)}}L.LiteralHourContext=Kq;class Jq extends Su{LITERAL_DAY(){return this.getToken(x.LITERAL_DAY,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralDay&&e.enterLiteralDay(this)}exitRule(e){e.exitLiteralDay&&e.exitLiteralDay(this)}accept(e){return e.visitLiteralDay?e.visitLiteralDay(this):e.visitChildren(this)}}L.LiteralDayContext=Jq;class Xq extends Su{LITERAL_WEEK(){return this.getToken(x.LITERAL_WEEK,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralWeek&&e.enterLiteralWeek(this)}exitRule(e){e.exitLiteralWeek&&e.exitLiteralWeek(this)}accept(e){return e.visitLiteralWeek?e.visitLiteralWeek(this):e.visitChildren(this)}}L.LiteralWeekContext=Xq;class Zq extends Su{LITERAL_MONTH(){return this.getToken(x.LITERAL_MONTH,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralMonth&&e.enterLiteralMonth(this)}exitRule(e){e.exitLiteralMonth&&e.exitLiteralMonth(this)}accept(e){return e.visitLiteralMonth?e.visitLiteralMonth(this):e.visitChildren(this)}}L.LiteralMonthContext=Zq;class eH extends Su{LITERAL_QUARTER(){return this.getToken(x.LITERAL_QUARTER,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralQuarter&&e.enterLiteralQuarter(this)}exitRule(e){e.exitLiteralQuarter&&e.exitLiteralQuarter(this)}accept(e){return e.visitLiteralQuarter?e.visitLiteralQuarter(this):e.visitChildren(this)}}L.LiteralQuarterContext=eH;class tH extends Su{LITERAL_YEAR(){return this.getToken(x.LITERAL_YEAR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralYear&&e.enterLiteralYear(this)}exitRule(e){e.exitLiteralYear&&e.exitLiteralYear(this)}accept(e){return e.visitLiteralYear?e.visitLiteralYear(this):e.visitChildren(this)}}L.LiteralYearContext=tH;class sD extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_tablePath}enterRule(e){e.enterTablePath&&e.enterTablePath(this)}exitRule(e){e.exitTablePath&&e.exitTablePath(this)}accept(e){return e.visitTablePath?e.visitTablePath(this):e.visitChildren(this)}}L.TablePathContext=sD;class oD extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_tableURI}enterRule(e){e.enterTableURI&&e.enterTableURI(this)}exitRule(e){e.exitTableURI&&e.exitTableURI(this)}accept(e){return e.visitTableURI?e.visitTableURI(this):e.visitChildren(this)}}L.TableURIContext=oD;class pn extends ge.ParserRuleContext{IDENTIFIER(){return this.tryGetToken(x.IDENTIFIER,0)}BQ_STRING(){return this.tryGetToken(x.BQ_STRING,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_id}enterRule(e){e.enterId&&e.enterId(this)}exitRule(e){e.exitId&&e.exitId(this)}accept(e){return e.visitId?e.visitId(this):e.visitChildren(this)}}L.IdContext=pn;class mf extends ge.ParserRuleContext{SECOND(){return this.tryGetToken(x.SECOND,0)}MINUTE(){return this.tryGetToken(x.MINUTE,0)}HOUR(){return this.tryGetToken(x.HOUR,0)}DAY(){return this.tryGetToken(x.DAY,0)}WEEK(){return this.tryGetToken(x.WEEK,0)}MONTH(){return this.tryGetToken(x.MONTH,0)}QUARTER(){return this.tryGetToken(x.QUARTER,0)}YEAR(){return this.tryGetToken(x.YEAR,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_timeframe}enterRule(e){e.enterTimeframe&&e.enterTimeframe(this)}exitRule(e){e.exitTimeframe&&e.exitTimeframe(this)}accept(e){return e.visitTimeframe?e.visitTimeframe(this):e.visitChildren(this)}}L.TimeframeContext=mf;class uD extends ge.ParserRuleContext{ALL(){return this.tryGetToken(x.ALL,0)}EXCLUDE(){return this.tryGetToken(x.EXCLUDE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ungroup}enterRule(e){e.enterUngroup&&e.enterUngroup(this)}exitRule(e){e.exitUngroup&&e.exitUngroup(this)}accept(e){return e.visitUngroup?e.visitUngroup(this):e.visitChildren(this)}}L.UngroupContext=uD;class $v extends ge.ParserRuleContext{malloyType(){return this.tryGetRuleContext(0,fg)}string(){return this.tryGetRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyOrSQLType}enterRule(e){e.enterMalloyOrSQLType&&e.enterMalloyOrSQLType(this)}exitRule(e){e.exitMalloyOrSQLType&&e.exitMalloyOrSQLType(this)}accept(e){return e.visitMalloyOrSQLType?e.visitMalloyOrSQLType(this):e.visitChildren(this)}}L.MalloyOrSQLTypeContext=$v;class be extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldExpr}copyFrom(e){super.copyFrom(e)}}L.FieldExprContext=be;class nH extends be{fieldPath(){return this.getRuleContext(0,Cu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprFieldPath&&e.enterExprFieldPath(this)}exitRule(e){e.exitExprFieldPath&&e.exitExprFieldPath(this)}accept(e){return e.visitExprFieldPath?e.visitExprFieldPath(this):e.visitChildren(this)}}L.ExprFieldPathContext=nH;class rH extends be{literal(){return this.getRuleContext(0,_u)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLiteral&&e.enterExprLiteral(this)}exitRule(e){e.exitExprLiteral&&e.exitExprLiteral(this)}accept(e){return e.visitExprLiteral?e.visitExprLiteral(this):e.visitChildren(this)}}L.ExprLiteralContext=rH;class iH extends be{OBRACK(){return this.getToken(x.OBRACK,0)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}CBRACK(){return this.getToken(x.CBRACK,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprArrayLiteral&&e.enterExprArrayLiteral(this)}exitRule(e){e.exitExprArrayLiteral&&e.exitExprArrayLiteral(this)}accept(e){return e.visitExprArrayLiteral?e.visitExprArrayLiteral(this):e.visitChildren(this)}}L.ExprArrayLiteralContext=iH;class sH extends be{OCURLY(){return this.getToken(x.OCURLY,0)}recordElement(e){return e===void 0?this.getRuleContexts(zd):this.getRuleContext(e,zd)}CCURLY(){return this.getToken(x.CCURLY,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLiteralRecord&&e.enterExprLiteralRecord(this)}exitRule(e){e.exitExprLiteralRecord&&e.exitExprLiteralRecord(this)}accept(e){return e.visitExprLiteralRecord?e.visitExprLiteralRecord(this):e.visitChildren(this)}}L.ExprLiteralRecordContext=sH;class oH extends be{fieldExpr(){return this.getRuleContext(0,be)}fieldProperties(){return this.getRuleContext(0,$O)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprFieldProps&&e.enterExprFieldProps(this)}exitRule(e){e.exitExprFieldProps&&e.exitExprFieldProps(this)}accept(e){return e.visitExprFieldProps?e.visitExprFieldProps(this):e.visitChildren(this)}}L.ExprFieldPropsContext=oH;class uH extends be{fieldExpr(){return this.getRuleContext(0,be)}timeframe(){return this.getRuleContext(0,mf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprDuration&&e.enterExprDuration(this)}exitRule(e){e.exitExprDuration&&e.exitExprDuration(this)}accept(e){return e.visitExprDuration?e.visitExprDuration(this):e.visitChildren(this)}}L.ExprDurationContext=uH;class aH extends be{fieldExpr(){return this.getRuleContext(0,be)}DOT(){return this.getToken(x.DOT,0)}timeframe(){return this.getRuleContext(0,mf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprTimeTrunc&&e.enterExprTimeTrunc(this)}exitRule(e){e.exitExprTimeTrunc&&e.exitExprTimeTrunc(this)}accept(e){return e.visitExprTimeTrunc?e.visitExprTimeTrunc(this):e.visitChildren(this)}}L.ExprTimeTruncContext=aH;class aD extends be{fieldExpr(){return this.getRuleContext(0,be)}DOUBLECOLON(){return this.tryGetToken(x.DOUBLECOLON,0)}malloyOrSQLType(){return this.getRuleContext(0,$v)}CAST(){return this.tryGetToken(x.CAST,0)}OPAREN(){return this.tryGetToken(x.OPAREN,0)}AS(){return this.tryGetToken(x.AS,0)}CPAREN(){return this.tryGetToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCast&&e.enterExprCast(this)}exitRule(e){e.exitExprCast&&e.exitExprCast(this)}accept(e){return e.visitExprCast?e.visitExprCast(this):e.visitChildren(this)}}L.ExprCastContext=aD;class lH extends be{fieldExpr(){return this.getRuleContext(0,be)}TRIPLECOLON(){return this.getToken(x.TRIPLECOLON,0)}malloyOrSQLType(){return this.getRuleContext(0,$v)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprSafeCast&&e.enterExprSafeCast(this)}exitRule(e){e.exitExprSafeCast&&e.exitExprSafeCast(this)}accept(e){return e.visitExprSafeCast?e.visitExprSafeCast(this):e.visitChildren(this)}}L.ExprSafeCastContext=lH;class cH extends be{MINUS(){return this.getToken(x.MINUS,0)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprMinus&&e.enterExprMinus(this)}exitRule(e){e.exitExprMinus&&e.exitExprMinus(this)}accept(e){return e.visitExprMinus?e.visitExprMinus(this):e.visitChildren(this)}}L.ExprMinusContext=cH;class fH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}STAR(){return this.tryGetToken(x.STAR,0)}SLASH(){return this.tryGetToken(x.SLASH,0)}PERCENT(){return this.tryGetToken(x.PERCENT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprMulDiv&&e.enterExprMulDiv(this)}exitRule(e){e.exitExprMulDiv&&e.exitExprMulDiv(this)}accept(e){return e.visitExprMulDiv?e.visitExprMulDiv(this):e.visitChildren(this)}}L.ExprMulDivContext=fH;class xH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}PLUS(){return this.tryGetToken(x.PLUS,0)}MINUS(){return this.tryGetToken(x.MINUS,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAddSub&&e.enterExprAddSub(this)}exitRule(e){e.exitExprAddSub&&e.exitExprAddSub(this)}accept(e){return e.visitExprAddSub?e.visitExprAddSub(this):e.visitChildren(this)}}L.ExprAddSubContext=xH;class dH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}TO(){return this.getToken(x.TO,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprRange&&e.enterExprRange(this)}exitRule(e){e.exitExprRange&&e.exitExprRange(this)}accept(e){return e.visitExprRange?e.visitExprRange(this):e.visitChildren(this)}}L.ExprRangeContext=dH;class hH extends be{FOR(){return this.getToken(x.FOR,0)}timeframe(){return this.getRuleContext(0,mf)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprForRange&&e.enterExprForRange(this)}exitRule(e){e.exitExprForRange&&e.exitExprForRange(this)}accept(e){return e.visitExprForRange?e.visitExprForRange(this):e.visitChildren(this)}}L.ExprForRangeContext=hH;class pH extends be{fieldExpr(){return this.getRuleContext(0,be)}AMPER(){return this.getToken(x.AMPER,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAndTree&&e.enterExprAndTree(this)}exitRule(e){e.exitExprAndTree&&e.exitExprAndTree(this)}accept(e){return e.visitExprAndTree?e.visitExprAndTree(this):e.visitChildren(this)}}L.ExprAndTreeContext=pH;class gH extends be{fieldExpr(){return this.getRuleContext(0,be)}BAR(){return this.getToken(x.BAR,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprOrTree&&e.enterExprOrTree(this)}exitRule(e){e.exitExprOrTree&&e.exitExprOrTree(this)}accept(e){return e.visitExprOrTree?e.visitExprOrTree(this):e.visitChildren(this)}}L.ExprOrTreeContext=gH;class mH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}compareOp(){return this.getRuleContext(0,Iv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCompare&&e.enterExprCompare(this)}exitRule(e){e.exitExprCompare&&e.exitExprCompare(this)}accept(e){return e.visitExprCompare?e.visitExprCompare(this):e.visitChildren(this)}}L.ExprCompareContext=mH;class yH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}LIKE(){return this.getToken(x.LIKE,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprWarnLike&&e.enterExprWarnLike(this)}exitRule(e){e.exitExprWarnLike&&e.exitExprWarnLike(this)}accept(e){return e.visitExprWarnLike?e.visitExprWarnLike(this):e.visitChildren(this)}}L.ExprWarnLikeContext=yH;class EH extends be{fieldExpr(){return this.getRuleContext(0,be)}IS(){return this.getToken(x.IS,0)}NULL(){return this.getToken(x.NULL,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNullCheck&&e.enterExprNullCheck(this)}exitRule(e){e.exitExprNullCheck&&e.exitExprNullCheck(this)}accept(e){return e.visitExprNullCheck?e.visitExprNullCheck(this):e.visitChildren(this)}}L.ExprNullCheckContext=EH;class AH extends be{fieldExpr(){return this.getRuleContext(0,be)}IN(){return this.getToken(x.IN,0)}OPAREN(){return this.getToken(x.OPAREN,0)}fieldExprList(){return this.getRuleContext(0,fD)}CPAREN(){return this.getToken(x.CPAREN,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprWarnIn&&e.enterExprWarnIn(this)}exitRule(e){e.exitExprWarnIn&&e.exitExprWarnIn(this)}accept(e){return e.visitExprWarnIn?e.visitExprWarnIn(this):e.visitChildren(this)}}L.ExprWarnInContext=AH;class vH extends be{fieldExpr(){return this.getRuleContext(0,be)}QMARK(){return this.getToken(x.QMARK,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprApply&&e.enterExprApply(this)}exitRule(e){e.exitExprApply&&e.exitExprApply(this)}accept(e){return e.visitExprApply?e.visitExprApply(this):e.visitChildren(this)}}L.ExprApplyContext=vH;class _H extends be{NOT(){return this.getToken(x.NOT,0)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNot&&e.enterExprNot(this)}exitRule(e){e.exitExprNot&&e.exitExprNot(this)}accept(e){return e.visitExprNot?e.visitExprNot(this):e.visitChildren(this)}}L.ExprNotContext=_H;class SH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}AND(){return this.getToken(x.AND,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLogicalAnd&&e.enterExprLogicalAnd(this)}exitRule(e){e.exitExprLogicalAnd&&e.exitExprLogicalAnd(this)}accept(e){return e.visitExprLogicalAnd?e.visitExprLogicalAnd(this):e.visitChildren(this)}}L.ExprLogicalAndContext=SH;class CH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}OR(){return this.getToken(x.OR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLogicalOr&&e.enterExprLogicalOr(this)}exitRule(e){e.exitExprLogicalOr&&e.exitExprLogicalOr(this)}accept(e){return e.visitExprLogicalOr?e.visitExprLogicalOr(this):e.visitChildren(this)}}L.ExprLogicalOrContext=CH;class bH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}DOUBLE_QMARK(){return this.getToken(x.DOUBLE_QMARK,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCoalesce&&e.enterExprCoalesce(this)}exitRule(e){e.exitExprCoalesce&&e.exitExprCoalesce(this)}accept(e){return e.visitExprCoalesce?e.visitExprCoalesce(this):e.visitChildren(this)}}L.ExprCoalesceContext=bH;class TH extends be{aggregate(){return this.getRuleContext(0,cg)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}SOURCE_KW(){return this.tryGetToken(x.SOURCE_KW,0)}DOT(){return this.tryGetToken(x.DOT,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}STAR(){return this.tryGetToken(x.STAR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprPathlessAggregate&&e.enterExprPathlessAggregate(this)}exitRule(e){e.exitExprPathlessAggregate&&e.exitExprPathlessAggregate(this)}accept(e){return e.visitExprPathlessAggregate?e.visitExprPathlessAggregate(this):e.visitChildren(this)}}L.ExprPathlessAggregateContext=TH;class RH extends be{fieldPath(){return this.getRuleContext(0,Cu)}DOT(){return this.getToken(x.DOT,0)}aggregate(){return this.getRuleContext(0,cg)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAggregate&&e.enterExprAggregate(this)}exitRule(e){e.exitExprAggregate&&e.exitExprAggregate(this)}accept(e){return e.visitExprAggregate?e.visitExprAggregate(this):e.visitChildren(this)}}L.ExprAggregateContext=RH;class OH extends be{OPAREN(){return this.getToken(x.OPAREN,0)}fieldExpr(){return this.getRuleContext(0,be)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprExpr&&e.enterExprExpr(this)}exitRule(e){e.exitExprExpr&&e.exitExprExpr(this)}accept(e){return e.visitExprExpr?e.visitExprExpr(this):e.visitChildren(this)}}L.ExprExprContext=OH;class DH extends be{fieldPath(){return this.getRuleContext(0,Cu)}DOT(){return this.getToken(x.DOT,0)}id(){return this.getRuleContext(0,pn)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}argumentList(){return this.tryGetRuleContext(0,Pv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAggFunc&&e.enterExprAggFunc(this)}exitRule(e){e.exitExprAggFunc&&e.exitExprAggFunc(this)}accept(e){return e.visitExprAggFunc?e.visitExprAggFunc(this):e.visitChildren(this)}}L.ExprAggFuncContext=DH;class wH extends be{OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}timeframe(){return this.tryGetRuleContext(0,mf)}id(){return this.tryGetRuleContext(0,pn)}argumentList(){return this.tryGetRuleContext(0,Pv)}EXCLAM(){return this.tryGetToken(x.EXCLAM,0)}malloyType(){return this.tryGetRuleContext(0,fg)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprFunc&&e.enterExprFunc(this)}exitRule(e){e.exitExprFunc&&e.exitExprFunc(this)}accept(e){return e.visitExprFunc?e.visitExprFunc(this):e.visitChildren(this)}}L.ExprFuncContext=wH;class NH extends be{pickStatement(){return this.getRuleContext(0,xD)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprPick&&e.enterExprPick(this)}exitRule(e){e.exitExprPick&&e.exitExprPick(this)}accept(e){return e.visitExprPick?e.visitExprPick(this):e.visitChildren(this)}}L.ExprPickContext=NH;class FH extends be{caseStatement(){return this.getRuleContext(0,dD)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCase&&e.enterExprCase(this)}exitRule(e){e.exitExprCase&&e.exitExprCase(this)}accept(e){return e.visitExprCase?e.visitExprCase(this):e.visitChildren(this)}}L.ExprCaseContext=FH;class LH extends be{ungroup(){return this.getRuleContext(0,uD)}OPAREN(){return this.getToken(x.OPAREN,0)}fieldExpr(){return this.getRuleContext(0,be)}CPAREN(){return this.getToken(x.CPAREN,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprUngroup&&e.enterExprUngroup(this)}exitRule(e){e.exitExprUngroup&&e.exitExprUngroup(this)}accept(e){return e.visitExprUngroup?e.visitExprUngroup(this):e.visitChildren(this)}}L.ExprUngroupContext=LH;class lD extends ge.ParserRuleContext{compareOp(){return this.getRuleContext(0,Iv)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partialCompare}enterRule(e){e.enterPartialCompare&&e.enterPartialCompare(this)}exitRule(e){e.exitPartialCompare&&e.exitPartialCompare(this)}accept(e){return e.visitPartialCompare?e.visitPartialCompare(this):e.visitChildren(this)}}L.PartialCompareContext=lD;class cD extends ge.ParserRuleContext{partialCompare(){return this.tryGetRuleContext(0,lD)}IS(){return this.tryGetToken(x.IS,0)}NULL(){return this.tryGetToken(x.NULL,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partialTest}enterRule(e){e.enterPartialTest&&e.enterPartialTest(this)}exitRule(e){e.exitPartialTest&&e.exitPartialTest(this)}accept(e){return e.visitPartialTest?e.visitPartialTest(this):e.visitChildren(this)}}L.PartialTestContext=cD;class yf extends ge.ParserRuleContext{partialTest(){return this.tryGetRuleContext(0,cD)}OPAREN(){return this.tryGetToken(x.OPAREN,0)}CPAREN(){return this.tryGetToken(x.CPAREN,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partialAllowedFieldExpr}enterRule(e){e.enterPartialAllowedFieldExpr&&e.enterPartialAllowedFieldExpr(this)}exitRule(e){e.exitPartialAllowedFieldExpr&&e.exitPartialAllowedFieldExpr(this)}accept(e){return e.visitPartialAllowedFieldExpr?e.visitPartialAllowedFieldExpr(this):e.visitChildren(this)}}L.PartialAllowedFieldExprContext=yf;class fD extends ge.ParserRuleContext{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldExprList}enterRule(e){e.enterFieldExprList&&e.enterFieldExprList(this)}exitRule(e){e.exitFieldExprList&&e.exitFieldExprList(this)}accept(e){return e.visitFieldExprList?e.visitFieldExprList(this):e.visitChildren(this)}}L.FieldExprListContext=fD;class xD extends ge.ParserRuleContext{pick(e){return e===void 0?this.getRuleContexts(kv):this.getRuleContext(e,kv)}ELSE(){return this.tryGetToken(x.ELSE,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_pickStatement}enterRule(e){e.enterPickStatement&&e.enterPickStatement(this)}exitRule(e){e.exitPickStatement&&e.exitPickStatement(this)}accept(e){return e.visitPickStatement?e.visitPickStatement(this):e.visitChildren(this)}}L.PickStatementContext=xD;class kv extends ge.ParserRuleContext{PICK(){return this.getToken(x.PICK,0)}WHEN(){return this.getToken(x.WHEN,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_pick}enterRule(e){e.enterPick&&e.enterPick(this)}exitRule(e){e.exitPick&&e.exitPick(this)}accept(e){return e.visitPick?e.visitPick(this):e.visitChildren(this)}}L.PickContext=kv;class dD extends ge.ParserRuleContext{CASE(){return this.getToken(x.CASE,0)}END(){return this.getToken(x.END,0)}caseWhen(e){return e===void 0?this.getRuleContexts(Mv):this.getRuleContext(e,Mv)}ELSE(){return this.tryGetToken(x.ELSE,0)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_caseStatement}enterRule(e){e.enterCaseStatement&&e.enterCaseStatement(this)}exitRule(e){e.exitCaseStatement&&e.exitCaseStatement(this)}accept(e){return e.visitCaseStatement?e.visitCaseStatement(this):e.visitChildren(this)}}L.CaseStatementContext=dD;class Mv extends ge.ParserRuleContext{WHEN(){return this.getToken(x.WHEN,0)}THEN(){return this.getToken(x.THEN,0)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_caseWhen}enterRule(e){e.enterCaseWhen&&e.enterCaseWhen(this)}exitRule(e){e.exitCaseWhen&&e.exitCaseWhen(this)}accept(e){return e.visitCaseWhen?e.visitCaseWhen(this):e.visitChildren(this)}}L.CaseWhenContext=Mv;class hD extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_recordKey}enterRule(e){e.enterRecordKey&&e.enterRecordKey(this)}exitRule(e){e.exitRecordKey&&e.exitRecordKey(this)}accept(e){return e.visitRecordKey?e.visitRecordKey(this):e.visitChildren(this)}}L.RecordKeyContext=hD;class zd extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_recordElement}copyFrom(e){super.copyFrom(e)}}L.RecordElementContext=zd;class IH extends zd{fieldPath(){return this.getRuleContext(0,Cu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterRecordRef&&e.enterRecordRef(this)}exitRule(e){e.exitRecordRef&&e.exitRecordRef(this)}accept(e){return e.visitRecordRef?e.visitRecordRef(this):e.visitChildren(this)}}L.RecordRefContext=IH;class BH extends zd{fieldExpr(){return this.getRuleContext(0,be)}recordKey(){return this.tryGetRuleContext(0,hD)}IS(){return this.tryGetToken(x.IS,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterRecordExpr&&e.enterRecordExpr(this)}exitRule(e){e.exitRecordExpr&&e.exitRecordExpr(this)}accept(e){return e.visitRecordExpr?e.visitRecordExpr(this):e.visitChildren(this)}}L.RecordExprContext=BH;class Pv extends ge.ParserRuleContext{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_argumentList}enterRule(e){e.enterArgumentList&&e.enterArgumentList(this)}exitRule(e){e.exitArgumentList&&e.exitArgumentList(this)}accept(e){return e.visitArgumentList?e.visitArgumentList(this):e.visitChildren(this)}}L.ArgumentListContext=Pv;class Qd extends ge.ParserRuleContext{fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldNameList}enterRule(e){e.enterFieldNameList&&e.enterFieldNameList(this)}exitRule(e){e.exitFieldNameList&&e.exitFieldNameList(this)}accept(e){return e.visitFieldNameList?e.visitFieldNameList(this):e.visitChildren(this)}}L.FieldNameListContext=Qd;class pD extends ge.ParserRuleContext{collectionMember(e){return e===void 0?this.getRuleContexts(qv):this.getRuleContext(e,qv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldCollection}enterRule(e){e.enterFieldCollection&&e.enterFieldCollection(this)}exitRule(e){e.exitFieldCollection&&e.exitFieldCollection(this)}accept(e){return e.visitFieldCollection?e.visitFieldCollection(this):e.visitChildren(this)}}L.FieldCollectionContext=pD;class xg extends ge.ParserRuleContext{STAR(){return this.getToken(x.STAR,0)}fieldPath(){return this.tryGetRuleContext(0,Cu)}DOT(){return this.tryGetToken(x.DOT,0)}starQualified(){return this.tryGetRuleContext(0,Uv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_collectionWildCard}enterRule(e){e.enterCollectionWildCard&&e.enterCollectionWildCard(this)}exitRule(e){e.exitCollectionWildCard&&e.exitCollectionWildCard(this)}accept(e){return e.visitCollectionWildCard?e.visitCollectionWildCard(this):e.visitChildren(this)}}L.CollectionWildCardContext=xg;class Uv extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}EXCEPT(e){return e===void 0?this.getTokens(x.EXCEPT):this.getToken(x.EXCEPT,e)}fieldNameList(e){return e===void 0?this.getRuleContexts(Qd):this.getRuleContext(e,Qd)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_starQualified}enterRule(e){e.enterStarQualified&&e.enterStarQualified(this)}exitRule(e){e.exitStarQualified&&e.exitStarQualified(this)}accept(e){return e.visitStarQualified?e.visitStarQualified(this):e.visitChildren(this)}}L.StarQualifiedContext=Uv;class jv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldPath(){return this.getRuleContext(0,Cu)}refExpr(){return this.tryGetRuleContext(0,gD)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_taggedRef}enterRule(e){e.enterTaggedRef&&e.enterTaggedRef(this)}exitRule(e){e.exitTaggedRef&&e.exitTaggedRef(this)}accept(e){return e.visitTaggedRef?e.visitTaggedRef(this):e.visitChildren(this)}}L.TaggedRefContext=jv;class gD extends ge.ParserRuleContext{DOT(){return this.getToken(x.DOT,0)}timeframe(){return this.tryGetRuleContext(0,mf)}aggregate(){return this.tryGetRuleContext(0,cg)}OPAREN(){return this.tryGetToken(x.OPAREN,0)}CPAREN(){return this.tryGetToken(x.CPAREN,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_refExpr}enterRule(e){e.enterRefExpr&&e.enterRefExpr(this)}exitRule(e){e.exitRefExpr&&e.exitRefExpr(this)}accept(e){return e.visitRefExpr?e.visitRefExpr(this):e.visitChildren(this)}}L.RefExprContext=gD;class qv extends ge.ParserRuleContext{taggedRef(){return this.tryGetRuleContext(0,jv)}collectionWildCard(){return this.tryGetRuleContext(0,xg)}fieldDef(){return this.tryGetRuleContext(0,qd)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_collectionMember}enterRule(e){e.enterCollectionMember&&e.enterCollectionMember(this)}exitRule(e){e.exitCollectionMember&&e.exitCollectionMember(this)}accept(e){return e.visitCollectionMember?e.visitCollectionMember(this):e.visitChildren(this)}}L.CollectionMemberContext=qv;class Cu extends ge.ParserRuleContext{fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}DOT(e){return e===void 0?this.getTokens(x.DOT):this.getToken(x.DOT,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldPath}enterRule(e){e.enterFieldPath&&e.enterFieldPath(this)}exitRule(e){e.exitFieldPath&&e.exitFieldPath(this)}accept(e){return e.visitFieldPath?e.visitFieldPath(this):e.visitChildren(this)}}L.FieldPathContext=Cu;class $H extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinName}enterRule(e){e.enterJoinName&&e.enterJoinName(this)}exitRule(e){e.exitJoinName&&e.exitJoinName(this)}accept(e){return e.visitJoinName?e.visitJoinName(this):e.visitChildren(this)}}L.JoinNameContext=$H;class vr extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldName}enterRule(e){e.enterFieldName&&e.enterFieldName(this)}exitRule(e){e.exitFieldName&&e.exitFieldName(this)}accept(e){return e.visitFieldName?e.visitFieldName(this):e.visitChildren(this)}}L.FieldNameContext=vr;class kH extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlExploreNameRef}enterRule(e){e.enterSqlExploreNameRef&&e.enterSqlExploreNameRef(this)}exitRule(e){e.exitSqlExploreNameRef&&e.exitSqlExploreNameRef(this)}accept(e){return e.visitSqlExploreNameRef?e.visitSqlExploreNameRef(this):e.visitChildren(this)}}L.SqlExploreNameRefContext=kH;class MH extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nameSQLBlock}enterRule(e){e.enterNameSQLBlock&&e.enterNameSQLBlock(this)}exitRule(e){e.exitNameSQLBlock&&e.exitNameSQLBlock(this)}accept(e){return e.visitNameSQLBlock?e.visitNameSQLBlock(this):e.visitChildren(this)}}L.NameSQLBlockContext=MH;class PH extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_connectionName}enterRule(e){e.enterConnectionName&&e.enterConnectionName(this)}exitRule(e){e.exitConnectionName&&e.exitConnectionName(this)}accept(e){return e.visitConnectionName?e.visitConnectionName(this):e.visitChildren(this)}}L.ConnectionNameContext=PH;class UH extends ge.ParserRuleContext{fieldExpr(){return this.getRuleContext(0,be)}EOF(){return this.getToken(x.EOF,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_debugExpr}enterRule(e){e.enterDebugExpr&&e.enterDebugExpr(this)}exitRule(e){e.exitDebugExpr&&e.exitDebugExpr(this)}accept(e){return e.visitDebugExpr?e.visitDebugExpr(this):e.visitChildren(this)}}L.DebugExprContext=UH;class jH extends ge.ParserRuleContext{partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}EOF(){return this.getToken(x.EOF,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_debugPartial}enterRule(e){e.enterDebugPartial&&e.enterDebugPartial(this)}exitRule(e){e.exitDebugPartial&&e.exitDebugPartial(this)}accept(e){return e.visitDebugPartial?e.visitDebugPartial(this):e.visitChildren(this)}}L.DebugPartialContext=jH;class mD extends ge.ParserRuleContext{SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}OBRACK(){return this.getToken(x.OBRACK,0)}string(){return this.getRuleContext(0,vu)}CBRACK(){return this.getToken(x.CBRACK,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_experimentalStatementForTesting}enterRule(e){e.enterExperimentalStatementForTesting&&e.enterExperimentalStatementForTesting(this)}exitRule(e){e.exitExperimentalStatementForTesting&&e.exitExperimentalStatementForTesting(this)}accept(e){return e.visitExperimentalStatementForTesting?e.visitExperimentalStatementForTesting(this):e.visitChildren(this)}}L.ExperimentalStatementForTestingContext=mD;var Hv={},dg={},Gd={};Object.defineProperty(Gd,"__esModule",{value:!0}),Gd.detectAndRemovePartialStages=void 0;const Eme=ts;function Ame(t,e){const n=[];let r=!1;for(const i of t)(0,Eme.isPartialSegment)(i)?(n.push({...i,type:"reduce"}),r=!0):n.push(i);return r&&e.logError("ambiguous-view-type",{}),n}Gd.detectAndRemovePartialStages=Ame;var hg={},Ye={},pg={},at={},bu={};Object.defineProperty(bu,"__esModule",{value:!0}),bu.isNotUndefined=bu.locationContainsPosition=void 0;function vme(t,e){return t.range.start.line<=e.line&&t.range.end.line>=e.line&&(e.line!==t.range.start.line||e.character>=t.range.start.character)&&(e.line!==t.range.end.line||e.character<=t.range.end.character)}bu.locationContainsPosition=vme;function _me(t){return t!==void 0}bu.isNotUndefined=_me,Object.defineProperty(at,"__esModule",{value:!0}),at.compositeFieldUsageJoinPaths=at.joinedCompositeFieldUsage=at.compositeFieldUsageDifference=at.emptyCompositeFieldUsage=at.mergeCompositeFieldUsage=at.unique=at.formatCompositeFieldUsage=at.compositeFieldUsageIsPlural=at.isEmptyCompositeFieldUsage=at.formatCompositeFieldUsages=at.compositeFieldUsagePaths=at.resolveCompositeSources=at.narrowCompositeFieldResolution=at.emptyNarrowedCompositeFieldResolution=void 0;const qH=bu,yD=Ke;function zv(t,e,n,r=void 0){var i,s,o,u,a,l,c;let f={...e},d;const h=Nme(e);if(n.fields.length>0||e.type==="composite")if(e.type==="composite"){let g=!1;d=(i=r==null?void 0:r.source)!==null&&i!==void 0?i:e.sources.map(E=>({source:E,nested:void 0}));const y=[...d];e:for(const{source:E,nested:A}of d){const v=new Set;for(const _ of E.fields)_.accessModifier!=="private"&&v.add((s=_.as)!==null&&s!==void 0?s:_.name);for(const _ of n.fields)if(!v.has(_)){y.shift();continue e}if(E.type==="composite"){const _=zv(t,E,Fme(n,E),{source:A??E.sources.map(S=>({source:S,nested:[]})),joined:{}});if("error"in _){y.shift();continue e}f={..._.success},y[0]={source:E,nested:_.narrowedCompositeFieldResolution.source}}else f={...E};g=!0,f={...f,fields:[...h,...f.fields],filterList:[...(o=e.filterList)!==null&&o!==void 0?o:[],...(u=f.filterList)!==null&&u!==void 0?u:[]]};break}if(!g)return{error:{code:"no_suitable_composite_source_input",data:{fields:n.fields,path:t}}};d=y}else return{error:{code:"not_a_composite_source",data:{path:t}}};const p={},m=(a=r==null?void 0:r.joined)!==null&&a!==void 0?a:{};for(const g of f.fields)p[(l=g.as)!==null&&l!==void 0?l:g.name]=g;for(const[g,y]of Object.entries(n.joinedUsage)){const E=p[g],A=[...t,g];if(E===void 0)return{error:{code:"composite_source_not_defined",data:{path:A}}};if((0,yD.isJoined)(E)){if(!(0,yD.isSourceDef)(E))continue}else return{error:{code:"composite_source_not_a_join",data:{path:A}}};const v=zv(A,E,y,m[g]);if("error"in v)return v;if(!(0,yD.isJoinable)(v.success))return{error:{code:"composite_source_is_not_joinable",data:{path:A}}};p[g]={...v.success,join:E.join,as:(c=E.as)!==null&&c!==void 0?c:E.name,onExpression:E.onExpression},m[g]=v.narrowedCompositeFieldResolution}return{success:{...f,fields:Object.values(p)},narrowedCompositeFieldResolution:{source:d,joined:m}}}function Sme(){return{source:void 0,joined:{}}}at.emptyNarrowedCompositeFieldResolution=Sme;function Cme(t,e,n){const r=zv([],t,e,n);return"success"in r?{narrowedCompositeFieldResolution:r.narrowedCompositeFieldResolution,error:void 0}:{narrowedCompositeFieldResolution:void 0,error:r.error}}at.narrowCompositeFieldResolution=Cme;function bme(t,e){const n=zv([],t,e);return"success"in n?{sourceDef:n.success,error:void 0}:{sourceDef:void 0,error:n.error}}at.resolveCompositeSources=bme;function ED(t){return[...t.fields.map(e=>[e]),...Object.entries(t.joinedUsage).map(([e,n])=>ED(n).map(r=>[e,...r])).flat()]}at.compositeFieldUsagePaths=ED;function Tme(t){return ED(t).map(e=>HH(e)).join(", ")}at.formatCompositeFieldUsages=Tme;function AD(t){return Object.values(t.joinedUsage).reduce((e,n)=>e+AD(n),t.fields.length)}function Rme(t){return AD(t)===0}at.isEmptyCompositeFieldUsage=Rme;function Ome(t){return AD(t)>1}at.compositeFieldUsageIsPlural=Ome;function HH(t){return`\`${t.join(".")}\``}at.formatCompositeFieldUsage=HH;function zH(t){return Array.from(new Set(t))}at.unique=zH;function QH(...t){const e=t.filter(qH.isNotUndefined),n=new Set(e.map(i=>Object.keys(i.joinedUsage)).flat()),r={};for(const i of n)r[i]=QH(...e.map(s=>s==null?void 0:s.joinedUsage[i]).filter(qH.isNotUndefined));return{fields:zH(e.map(i=>i.fields).flat()),joinedUsage:r}}at.mergeCompositeFieldUsage=QH;function Dme(){return{fields:[],joinedUsage:{}}}at.emptyCompositeFieldUsage=Dme;function wme(t,e){const n=new Set(e),r=[];for(const i of t)n.has(i)||r.push(i);return r}function GH(t,e){return{fields:wme(t.fields,e.fields),joinedUsage:Object.fromEntries(Object.entries(t.joinedUsage).map(([n,r])=>[n,n in e.joinedUsage?GH(r,e.joinedUsage[n]):r]))}}at.compositeFieldUsageDifference=GH;function WH(t,e){return t.length===0?e:WH(t.slice(0,-1),{fields:[],joinedUsage:{[t[t.length-1]]:e}})}at.joinedCompositeFieldUsage=WH;function VH(t){const e=Object.keys(t.joinedUsage);return[...e.map(n=>[n]),...e.map(n=>VH(t.joinedUsage[n]).map(r=>[n,...r])).flat()]}at.compositeFieldUsageJoinPaths=VH;function YH(t){var e;return"e"in t&&((e=t.e)===null||e===void 0?void 0:e.node)==="compositeField"}function Nme(t){return t.fields.filter(e=>!YH(e))}function Fme(t,e){var n;const r={};for(const i of e.fields)r[(n=i.as)!==null&&n!==void 0?n:i.name]=i;return{fields:t.fields.filter(i=>YH(r[i])),joinedUsage:{}}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.makeLogMessage=t.MESSAGE_FORMATTERS=t.BaseMessageLogger=void 0;const e=at;class n{constructor(s){this.eventStream=s,this.rawLog=[]}getLog(){return this.rawLog}log(s){var o;this.rawLog.push(s),(o=this.eventStream)===null||o===void 0||o.emit(`translation-${s.severity}`,{code:s.code,data:s.data,message:s.message})}reset(){this.rawLog.length=0}noErrors(){return!this.hasErrors()}hasErrors(){return this.rawLog.find(o=>o.severity!=="warn")!==void 0}empty(){return this.rawLog.length===0}}t.BaseMessageLogger=n,t.MESSAGE_FORMATTERS={"pick-type-does-not-match":i=>({message:`pick type \`${i.pickType}\` does not match return type \`${i.returnType}\``,tag:"pick-values-must-match"}),"pick-else-type-does-not-match":i=>({message:`else type \`${i.elseType}\` does not match return type \`${i.returnType}\``,tag:"pick-values-must-match"}),"pick-default-type-does-not-match":i=>({message:`default type \`${i.defaultType}\` does not match return type \`${i.returnType}\``,tag:"pick-values-must-match"}),"experimental-dialect-not-enabled":i=>`Requires compiler flag '##! experimental.dialect.${i.dialect}'`,"pick-missing-else":"pick incomplete, missing 'else'","pick-missing-value":"pick with no value can only be used with apply","pick-illegal-partial":"pick with partial when can only be used with apply","pick-when-must-be-boolean":i=>`when expression must be boolean, not ${i.whenType}`,"sql-native-not-allowed-in-expression":i=>({message:`Unsupported SQL native type '${i.rawType}' not allowed in expression`,tag:"unsupported-sql-native-type-not-allowed-in-expression"}),"experiment-not-enabled":i=>`Experimental flag \`${i.experimentId}\` is not set, feature not available`,"ambiguous-view-type":"Can't determine view type (`group_by` / `aggregate` / `nest`, `project`, `index`)","import-error":i=>i.message.includes(i.url)?`import error: ${i.message}`:`import '${i.url}' error: ${i.message}`,"parsed-non-malloy-document":i=>`'${i.url}' did not parse to malloy document`,"parse-exception":i=>`Malloy internal parser exception [${i.message}]`,"syntax-error":i=>i.message,"internal-translator-error":i=>`Internal Translator Error: ${i.message}`,"invalid-timezone":i=>`Invalid timezone: ${i.timezone}`,"case-then-type-does-not-match":i=>`Case then type ${i.thenType} does not match return type ${i.returnType}`,"case-else-type-does-not-match":i=>`Case else type ${i.elseType} does not match return type ${i.returnType}`,"case-when-must-be-boolean":i=>`Case when expression must be boolean, not ${i.whenType}`,"case-when-type-does-not-match":i=>`Case when type ${i.whenType} does not match value type ${i.valueType}`,"invalid-composite-field-usage":i=>{const s=(0,e.formatCompositeFieldUsages)(i.newUsage),o=(0,e.formatCompositeFieldUsages)(i.allUsage);return`This operation uses composite field${(0,e.compositeFieldUsageIsPlural)(i.newUsage)?"s":""} ${s}, resulting in invalid usage of the composite source, as there is no composite input source which defines all of ${o}`}};function r(i,s,o){var u,a,l,c,f;const d=t.MESSAGE_FORMATTERS[i],h=d?d instanceof Function?d(s):d:typeof s=="string"?s:void 0;if(h===void 0)throw new Error(`No message formatter for error code \`${i}\`.`);const p=typeof h=="string"?{message:h}:h,m=((u=p.data)!==null&&u!==void 0?u:typeof s=="string")?null:s;return{code:i,data:m,message:p.message,severity:(l=(a=o==null?void 0:o.severity)!==null&&a!==void 0?a:p.severity)!==null&&l!==void 0?l:"error",errorTag:(c=o==null?void 0:o.tag)!==null&&c!==void 0?c:p.tag,replacement:(f=o==null?void 0:o.replacement)!==null&&f!==void 0?f:p.replacement,at:o==null?void 0:o.at}}t.makeLogMessage=r})(pg);var fs={};Object.defineProperty(fs,"__esModule",{value:!0}),fs.errorFor=void 0;const Lme=at;function Ime(t){return{type:"error",expressionType:"scalar",value:{node:"error",message:t},evalSpace:"constant",compositeFieldUsage:(0,Lme.emptyCompositeFieldUsage)()}}fs.errorFor=Ime;var Qv={};Object.defineProperty(Qv,"__esModule",{value:!0}),Qv.DialectNameSpace=void 0;class Bme{constructor(e){this.entries=new Map;const n=e.getDialectFunctions();for(const r in n){const i=n[r];this.entries.set(r,{type:"function",name:r,overloads:i.map(s=>({returnType:s.returnType,params:s.params,supportsOrderBy:s.supportsOrderBy,supportsLimit:s.supportsLimit,isSymmetric:s.isSymmetric,genericTypes:s.genericTypes,dialect:{[e.name]:{e:s.e,defaultOrderByArgIndex:s.defaultOrderByArgIndex,between:s.between,needsWindowOrderBy:s.needsWindowOrderBy}}}))})}}getEntry(e){const n=this.entries.get(e);if(n!==void 0)return{entry:n,exported:!1}}setEntry(e,n,r){throw new Error("The dialect namespace is immutable!")}}Qv.DialectNameSpace=Bme;var Wd={};Object.defineProperty(Wd,"__esModule",{value:!0}),Wd.getDialectFunctions=Wd.GlobalNameSpace=void 0;const $me=ed,kme=ou,Mme=ts;class Pme{constructor(){this.entries=KH()}getEntry(e){const n=this.entries.get(e);if(n!==void 0)return{entry:n,exported:!1}}setEntry(e,n,r){throw new Error("The global namespace is immutable!")}}Wd.GlobalNameSpace=Pme;function Ume(t,e){return t.params.length===e.params.length&&t.params.every((n,r)=>{const i=e.params[r];return n.isVariadic===i.isVariadic&&n.name===i.name&&n.allowedTypes.length===i.allowedTypes.length&&n.allowedTypes.every(s=>i.allowedTypes.some(o=>Mme.TD.eq(s,o)&&s.expressionType===o.expressionType))})}function KH(){var t,e;const n=(0,$me.getMalloyStandardFunctions)(),r={},i=(0,kme.getDialects)();for(const o of i)r[o.name]=o.getDialectFunctionOverrides();const s=new Map;for(const o in n){const u=n[o],a={type:"function",name:o,overloads:[]};for(const l of u){const c={returnType:l.returnType,params:l.params,dialect:{},supportsOrderBy:l.supportsOrderBy,supportsLimit:l.supportsLimit,genericTypes:l.genericTypes,isSymmetric:l.isSymmetric};for(const f of i){const h=(e=((t=r[f.name][o])!==null&&t!==void 0?t:[]).find(p=>Ume(p,c)))!==null&&e!==void 0?e:l;c.dialect[f.name]={e:h.e,needsWindowOrderBy:h.needsWindowOrderBy,between:h.between,defaultOrderByArgIndex:h.defaultOrderByArgIndex}}a.overloads.push(c)}s.set(o,a)}return s}Wd.getDialectFunctions=KH;var _r={};Object.defineProperty(_r,"__esModule",{value:!0}),_r.extendNoteHelper=_r.extendNoteMethod=_r.isNoteable=void 0;function jme(t){return t.isNoteableObj}_r.isNoteable=jme;function qme(t){JH(this,t)}_r.extendNoteMethod=qme;function JH(t,e){(e.notes&&e.notes.length>0||e.blockNotes&&e.blockNotes.length>0||e.inherits!==void 0)&&(t.note={...t.note,...e})}_r.extendNoteHelper=JH,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Document=Ye.DocStatementList=Ye.ListOf=Ye.isDocStatementOrDocStatementList=Ye.isDocStatement=Ye.ExperimentalExperiment=Ye.ModelEntryReference=Ye.Unimplemented=Ye.MalloyElement=void 0;const XH=ed,Gv=Ke,Hme=fo,zme=pg,Qme=fs,Gme=Qv,Wme=Wd,ZH=_r,Vme=xp;class Tu{constructor(e){this.children={},this.parent=null,this.logged=new Set,e&&this.has(e)}has(e){for(const n in e){const r=e[n];if(r!==void 0)if(this.children[n]=r,r instanceof Tu)r.parent=this;else for(const i of r)i.parent=this}}get location(){return this.codeLocation?this.codeLocation:this.parent?this.parent.location:{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}set location(e){this.codeLocation=e}get code(){var e,n;return(n=(e=this.translator())===null||e===void 0?void 0:e.codeAtLocation(this.location))!==null&&n!==void 0?n:""}document(){var e;return this instanceof _D?this:(e=this.parent)===null||e===void 0?void 0:e.document()}namespace(){if(this instanceof _D)return this;if(this.parent)return this.parent.namespace();throw new Error("INTERNAL ERROR: Translation without document scope")}getDialectNamespace(e){var n;return(n=this.document())===null||n===void 0?void 0:n.getDialectNamespace(e)}modelEntry(e){var n;const r=e instanceof vD?e.name:e,i=(n=this.namespace())===null||n===void 0?void 0:n.getEntry(r);return e instanceof vD&&((i==null?void 0:i.entry.type)==="query"?this.addReference({type:"queryReference",text:r,definition:i.entry,location:e.location}):i&&(0,Gv.isSourceDef)(i.entry)&&this.addReference({type:"exploreReference",text:r,definition:i.entry,location:e.location})),i}kupuna(){var e;return((e=this.parent)===null||e===void 0?void 0:e.kupuna())||this}translator(){if(this.xlate)return this.xlate;if(this.parent)return this.parent.translator()}setTranslator(e){this.xlate=e}addReference(e){var n;(n=this.translator())===null||n===void 0||n.addReference(e)}get sourceURL(){const e=this.translator();return(e==null?void 0:e.sourceURL)||"(missing)"}log(e,n,r){const i=(0,zme.makeLogMessage)(e,n,{at:this.location,...r});if(this.codeLocation){if(this.logged.has(i.message))return e;this.logged.add(i.message)}return this.logger.log(i),e}logError(e,n,r){return this.log(e,n,{severity:"error",...r})}logWarning(e,n,r){return this.log(e,n,{severity:"warn",...r})}loggedErrorExpr(e,n,r){return(0,Qme.errorFor)(this.logError(e,n,r))}get logger(){var e;const n=(e=this.translator())===null||e===void 0?void 0:e.root.logger;if(n===void 0)throw new Error("Attempted to access logger without a translator");return n}toString(){return this.stringify("",0)}stringify(e,n){const r=" ".repeat(n);let i=`${r}${e}<${this.elementType}>${this.varInfo()}`;for(const s of Object.keys(this.children)){const o=this.children[s];o instanceof Tu?i+=`
1254
+ וטЉזט\x07~חהחזטייחיךךככל\x07yלėםמ\f\x07מנАןס̎נןנססęעף\x07ףתòzפץ\x07ץצÜoצק\x07tקר\x07uרתשעשפתě׫ׯʍ׬ׯĔ‹׭ׯV,׮׫׮׬׮׭ׯĝװ׵Ģ’ױײ\x07ײ״Ģ’׳ױ״׷׵׳׵׶׶ğ׷׵׸׹ðy׹ġ׺׻ðy׻ģ׼׽ðy׽ĥ׾׿ðy׿ħ؀؁âr؁ĩ؂؃ø}؃؄\x07؄ī؅؆þ€؆؇\x07؇ĭ؈؉\x07Œ؉؊\x07Œ؊؋\x07v؋،âr،؍\x07w؍į®IJĴŀŋœŢŭŷƀƇƌƑƗƜƠƱǁLjNJǓǘǜǡǰǵǺǾȇȉȖȞȧȪȱȳȷȾɅɊɎɖɛɟɬɲɹʀʅʍʗʜʣʪʷʺʿˊˑ˓˙˛˪˲˷˻̸̖̠̩̰͔̃̇̌̐̽͂̈́͋͐ͤͩͮͶͻͿ΁·ΌΎΘΜΠΤίζκτωύϔϭϷϼЀЄЌБЕЛбемсхщьѕѝѠѤѩѰ҄ґҚҨҳҷӁӓәӢӯӶӸӻӿԌԑԢՊՏՙ՛դէկնռրք֋֐ֱֵֺֿ֣֦֭֔ׄ׈׍בחינש׮׵`,x._serializedATN=Jj.join([x._serializedATNSegment0,x._serializedATNSegment1,x._serializedATNSegment2],"");class Xj extends ge.ParserRuleContext{EOF(){return this.getToken(x.EOF,0)}malloyStatement(e){return e===void 0?this.getRuleContexts(ev):this.getRuleContext(e,ev)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyDocument}enterRule(e){e.enterMalloyDocument&&e.enterMalloyDocument(this)}exitRule(e){e.exitMalloyDocument&&e.exitMalloyDocument(this)}accept(e){return e.visitMalloyDocument?e.visitMalloyDocument(this):e.visitChildren(this)}}L.MalloyDocumentContext=Xj;class ev extends ge.ParserRuleContext{defineSourceStatement(){return this.tryGetRuleContext(0,aO)}defineQuery(){return this.tryGetRuleContext(0,rg)}importStatement(){return this.tryGetRuleContext(0,cO)}runStatement(){return this.tryGetRuleContext(0,lO)}docAnnotations(){return this.tryGetRuleContext(0,dO)}ignoredObjectAnnotations(){return this.tryGetRuleContext(0,hO)}experimentalStatementForTesting(){return this.tryGetRuleContext(0,mD)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyStatement}enterRule(e){e.enterMalloyStatement&&e.enterMalloyStatement(this)}exitRule(e){e.exitMalloyStatement&&e.exitMalloyStatement(this)}accept(e){return e.visitMalloyStatement?e.visitMalloyStatement(this):e.visitChildren(this)}}L.MalloyStatementContext=ev;class aO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}SOURCE(){return this.getToken(x.SOURCE,0)}sourcePropertyList(){return this.getRuleContext(0,yO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defineSourceStatement}enterRule(e){e.enterDefineSourceStatement&&e.enterDefineSourceStatement(this)}exitRule(e){e.exitDefineSourceStatement&&e.exitDefineSourceStatement(this)}accept(e){return e.visitDefineSourceStatement?e.visitDefineSourceStatement(this):e.visitChildren(this)}}L.DefineSourceStatementContext=aO;class rg extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defineQuery}copyFrom(e){super.copyFrom(e)}}L.DefineQueryContext=rg;class Zj extends rg{topLevelQueryDefs(){return this.getRuleContext(0,pO)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterUse_top_level_query_defs&&e.enterUse_top_level_query_defs(this)}exitRule(e){e.exitUse_top_level_query_defs&&e.exitUse_top_level_query_defs(this)}accept(e){return e.visitUse_top_level_query_defs?e.visitUse_top_level_query_defs(this):e.visitChildren(this)}}L.Use_top_level_query_defsContext=Zj;class eq extends rg{tags(){return this.getRuleContext(0,Mt)}QUERY(){return this.getToken(x.QUERY,0)}topLevelAnonQueryDef(){return this.getRuleContext(0,tv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterAnonymousQuery&&e.enterAnonymousQuery(this)}exitRule(e){e.exitAnonymousQuery&&e.exitAnonymousQuery(this)}accept(e){return e.visitAnonymousQuery?e.visitAnonymousQuery(this):e.visitChildren(this)}}L.AnonymousQueryContext=eq;class tv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}sqExpr(){return this.getRuleContext(0,Zt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topLevelAnonQueryDef}enterRule(e){e.enterTopLevelAnonQueryDef&&e.enterTopLevelAnonQueryDef(this)}exitRule(e){e.exitTopLevelAnonQueryDef&&e.exitTopLevelAnonQueryDef(this)}accept(e){return e.visitTopLevelAnonQueryDef?e.visitTopLevelAnonQueryDef(this):e.visitChildren(this)}}L.TopLevelAnonQueryDefContext=tv;class Mt extends ge.ParserRuleContext{ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_tags}enterRule(e){e.enterTags&&e.enterTags(this)}exitRule(e){e.exitTags&&e.exitTags(this)}accept(e){return e.visitTags?e.visitTags(this):e.visitChildren(this)}}L.TagsContext=Mt;class Ma extends ge.ParserRuleContext{IS(){return this.getToken(x.IS,0)}tags(e){return e===void 0?this.getRuleContexts(Mt):this.getRuleContext(e,Mt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_isDefine}enterRule(e){e.enterIsDefine&&e.enterIsDefine(this)}exitRule(e){e.exitIsDefine&&e.exitIsDefine(this)}accept(e){return e.visitIsDefine?e.visitIsDefine(this):e.visitChildren(this)}}L.IsDefineContext=Ma;class lO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}RUN(){return this.getToken(x.RUN,0)}topLevelAnonQueryDef(){return this.getRuleContext(0,tv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_runStatement}enterRule(e){e.enterRunStatement&&e.enterRunStatement(this)}exitRule(e){e.exitRunStatement&&e.exitRunStatement(this)}accept(e){return e.visitRunStatement?e.visitRunStatement(this):e.visitChildren(this)}}L.RunStatementContext=lO;class nv extends ge.ParserRuleContext{SQL_BEGIN(){return this.getToken(x.SQL_BEGIN,0)}SQL_END(){return this.getToken(x.SQL_END,0)}sqlInterpolation(e){return e===void 0?this.getRuleContexts(rv):this.getRuleContext(e,rv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlString}enterRule(e){e.enterSqlString&&e.enterSqlString(this)}exitRule(e){e.exitSqlString&&e.exitSqlString(this)}accept(e){return e.visitSqlString?e.visitSqlString(this):e.visitChildren(this)}}L.SqlStringContext=nv;class rv extends ge.ParserRuleContext{OPEN_CODE(){return this.getToken(x.OPEN_CODE,0)}sqExpr(){return this.getRuleContext(0,Zt)}CCURLY(){return this.tryGetToken(x.CCURLY,0)}CLOSE_CODE(){return this.tryGetToken(x.CLOSE_CODE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlInterpolation}enterRule(e){e.enterSqlInterpolation&&e.enterSqlInterpolation(this)}exitRule(e){e.exitSqlInterpolation&&e.exitSqlInterpolation(this)}accept(e){return e.visitSqlInterpolation?e.visitSqlInterpolation(this):e.visitChildren(this)}}L.SqlInterpolationContext=rv;class cO extends ge.ParserRuleContext{IMPORT(){return this.getToken(x.IMPORT,0)}importURL(){return this.getRuleContext(0,xO)}importSelect(){return this.tryGetRuleContext(0,fO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importStatement}enterRule(e){e.enterImportStatement&&e.enterImportStatement(this)}exitRule(e){e.exitImportStatement&&e.exitImportStatement(this)}accept(e){return e.visitImportStatement?e.visitImportStatement(this):e.visitChildren(this)}}L.ImportStatementContext=cO;class fO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}importItem(e){return e===void 0?this.getRuleContexts(iv):this.getRuleContext(e,iv)}CCURLY(){return this.getToken(x.CCURLY,0)}FROM(){return this.getToken(x.FROM,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importSelect}enterRule(e){e.enterImportSelect&&e.enterImportSelect(this)}exitRule(e){e.exitImportSelect&&e.exitImportSelect(this)}accept(e){return e.visitImportSelect?e.visitImportSelect(this):e.visitChildren(this)}}L.ImportSelectContext=fO;class iv extends ge.ParserRuleContext{id(e){return e===void 0?this.getRuleContexts(pn):this.getRuleContext(e,pn)}IS(){return this.tryGetToken(x.IS,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importItem}enterRule(e){e.enterImportItem&&e.enterImportItem(this)}exitRule(e){e.exitImportItem&&e.exitImportItem(this)}accept(e){return e.visitImportItem?e.visitImportItem(this):e.visitChildren(this)}}L.ImportItemContext=iv;class xO extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_importURL}enterRule(e){e.enterImportURL&&e.enterImportURL(this)}exitRule(e){e.exitImportURL&&e.exitImportURL(this)}accept(e){return e.visitImportURL?e.visitImportURL(this):e.visitChildren(this)}}L.ImportURLContext=xO;class dO extends ge.ParserRuleContext{DOC_ANNOTATION(e){return e===void 0?this.getTokens(x.DOC_ANNOTATION):this.getToken(x.DOC_ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_docAnnotations}enterRule(e){e.enterDocAnnotations&&e.enterDocAnnotations(this)}exitRule(e){e.exitDocAnnotations&&e.exitDocAnnotations(this)}accept(e){return e.visitDocAnnotations?e.visitDocAnnotations(this):e.visitChildren(this)}}L.DocAnnotationsContext=dO;class hO extends ge.ParserRuleContext{ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ignoredObjectAnnotations}enterRule(e){e.enterIgnoredObjectAnnotations&&e.enterIgnoredObjectAnnotations(this)}exitRule(e){e.exitIgnoredObjectAnnotations&&e.exitIgnoredObjectAnnotations(this)}accept(e){return e.visitIgnoredObjectAnnotations?e.visitIgnoredObjectAnnotations(this):e.visitChildren(this)}}L.IgnoredObjectAnnotationsContext=hO;class sv extends ge.ParserRuleContext{DOC_ANNOTATION(e){return e===void 0?this.getTokens(x.DOC_ANNOTATION):this.getToken(x.DOC_ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ignoredModelAnnotations}enterRule(e){e.enterIgnoredModelAnnotations&&e.enterIgnoredModelAnnotations(this)}exitRule(e){e.exitIgnoredModelAnnotations&&e.exitIgnoredModelAnnotations(this)}accept(e){return e.visitIgnoredModelAnnotations?e.visitIgnoredModelAnnotations(this):e.visitChildren(this)}}L.IgnoredModelAnnotationsContext=sv;class pO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}QUERY(){return this.getToken(x.QUERY,0)}topLevelQueryDef(e){return e===void 0?this.getRuleContexts(ov):this.getRuleContext(e,ov)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topLevelQueryDefs}enterRule(e){e.enterTopLevelQueryDefs&&e.enterTopLevelQueryDefs(this)}exitRule(e){e.exitTopLevelQueryDefs&&e.exitTopLevelQueryDefs(this)}accept(e){return e.visitTopLevelQueryDefs?e.visitTopLevelQueryDefs(this):e.visitChildren(this)}}L.TopLevelQueryDefsContext=pO;class ov extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}queryName(){return this.getRuleContext(0,av)}isDefine(){return this.getRuleContext(0,Ma)}sqExpr(){return this.getRuleContext(0,Zt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topLevelQueryDef}enterRule(e){e.enterTopLevelQueryDef&&e.enterTopLevelQueryDef(this)}exitRule(e){e.exitTopLevelQueryDef&&e.exitTopLevelQueryDef(this)}accept(e){return e.visitTopLevelQueryDef?e.visitTopLevelQueryDef(this):e.visitChildren(this)}}L.TopLevelQueryDefContext=ov;class tq extends ge.ParserRuleContext{PLUS(){return this.getToken(x.PLUS,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_refineOperator}enterRule(e){e.enterRefineOperator&&e.enterRefineOperator(this)}exitRule(e){e.exitRefineOperator&&e.exitRefineOperator(this)}accept(e){return e.visitRefineOperator?e.visitRefineOperator(this):e.visitChildren(this)}}L.RefineOperatorContext=tq;class nq extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_turtleName}enterRule(e){e.enterTurtleName&&e.enterTurtleName(this)}exitRule(e){e.exitTurtleName&&e.exitTurtleName(this)}accept(e){return e.visitTurtleName?e.visitTurtleName(this):e.visitChildren(this)}}L.TurtleNameContext=nq;class gO extends ge.ParserRuleContext{connectionId(){return this.getRuleContext(0,uv)}DOT(){return this.getToken(x.DOT,0)}SQL(){return this.getToken(x.SQL,0)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sqlString(){return this.tryGetRuleContext(0,nv)}shortString(){return this.tryGetRuleContext(0,Bv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlSource}enterRule(e){e.enterSqlSource&&e.enterSqlSource(this)}exitRule(e){e.exitSqlSource&&e.exitSqlSource(this)}accept(e){return e.visitSqlSource?e.visitSqlSource(this):e.visitChildren(this)}}L.SqlSourceContext=gO;class ig extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreTable}copyFrom(e){super.copyFrom(e)}}L.ExploreTableContext=ig;class rq extends ig{TABLE(){return this.getToken(x.TABLE,0)}OPAREN(){return this.getToken(x.OPAREN,0)}tableURI(){return this.getRuleContext(0,oD)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterTableFunction&&e.enterTableFunction(this)}exitRule(e){e.exitTableFunction&&e.exitTableFunction(this)}accept(e){return e.visitTableFunction?e.visitTableFunction(this):e.visitChildren(this)}}L.TableFunctionContext=rq;class iq extends ig{connectionId(){return this.getRuleContext(0,uv)}DOT(){return this.getToken(x.DOT,0)}TABLE(){return this.getToken(x.TABLE,0)}OPAREN(){return this.getToken(x.OPAREN,0)}tablePath(){return this.getRuleContext(0,sD)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterTableMethod&&e.enterTableMethod(this)}exitRule(e){e.exitTableMethod&&e.exitTableMethod(this)}accept(e){return e.visitTableMethod?e.visitTableMethod(this):e.visitChildren(this)}}L.TableMethodContext=iq;class uv extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_connectionId}enterRule(e){e.enterConnectionId&&e.enterConnectionId(this)}exitRule(e){e.exitConnectionId&&e.exitConnectionId(this)}accept(e){return e.visitConnectionId?e.visitConnectionId(this):e.visitChildren(this)}}L.ConnectionIdContext=uv;class mO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}queryStatement(e){return e===void 0?this.getRuleContexts(Ov):this.getRuleContext(e,Ov)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryProperties}enterRule(e){e.enterQueryProperties&&e.enterQueryProperties(this)}exitRule(e){e.exitQueryProperties&&e.exitQueryProperties(this)}accept(e){return e.visitQueryProperties?e.visitQueryProperties(this):e.visitChildren(this)}}L.QueryPropertiesContext=mO;class av extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryName}enterRule(e){e.enterQueryName&&e.enterQueryName(this)}exitRule(e){e.exitQueryName&&e.exitQueryName(this)}accept(e){return e.visitQueryName?e.visitQueryName(this):e.visitChildren(this)}}L.QueryNameContext=av;class yO extends ge.ParserRuleContext{sourceDefinition(e){return e===void 0?this.getRuleContexts(lv):this.getRuleContext(e,lv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourcePropertyList}enterRule(e){e.enterSourcePropertyList&&e.enterSourcePropertyList(this)}exitRule(e){e.exitSourcePropertyList&&e.exitSourcePropertyList(this)}accept(e){return e.visitSourcePropertyList?e.visitSourcePropertyList(this):e.visitChildren(this)}}L.SourcePropertyListContext=yO;class lv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}sourceNameDef(){return this.getRuleContext(0,_O)}isDefine(){return this.getRuleContext(0,Ma)}sqExplore(){return this.getRuleContext(0,EO)}sourceParameters(){return this.tryGetRuleContext(0,AO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceDefinition}enterRule(e){e.enterSourceDefinition&&e.enterSourceDefinition(this)}exitRule(e){e.exitSourceDefinition&&e.exitSourceDefinition(this)}accept(e){return e.visitSourceDefinition?e.visitSourceDefinition(this):e.visitChildren(this)}}L.SourceDefinitionContext=lv;class EO extends ge.ParserRuleContext{sqExpr(){return this.getRuleContext(0,Zt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqExplore}enterRule(e){e.enterSqExplore&&e.enterSqExplore(this)}exitRule(e){e.exitSqExplore&&e.exitSqExplore(this)}accept(e){return e.visitSqExplore?e.visitSqExplore(this):e.visitChildren(this)}}L.SqExploreContext=EO;class AO extends ge.ParserRuleContext{OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sourceParameter(e){return e===void 0?this.getRuleContexts(cv):this.getRuleContext(e,cv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceParameters}enterRule(e){e.enterSourceParameters&&e.enterSourceParameters(this)}exitRule(e){e.exitSourceParameters&&e.exitSourceParameters(this)}accept(e){return e.visitSourceParameters?e.visitSourceParameters(this):e.visitChildren(this)}}L.SourceParametersContext=AO;class cv extends ge.ParserRuleContext{parameterNameDef(){return this.getRuleContext(0,vO)}DOUBLECOLON(){return this.tryGetToken(x.DOUBLECOLON,0)}malloyType(){return this.tryGetRuleContext(0,fg)}IS(){return this.tryGetToken(x.IS,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceParameter}enterRule(e){e.enterSourceParameter&&e.enterSourceParameter(this)}exitRule(e){e.exitSourceParameter&&e.exitSourceParameter(this)}accept(e){return e.visitSourceParameter?e.visitSourceParameter(this):e.visitChildren(this)}}L.SourceParameterContext=cv;class vO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_parameterNameDef}enterRule(e){e.enterParameterNameDef&&e.enterParameterNameDef(this)}exitRule(e){e.exitParameterNameDef&&e.exitParameterNameDef(this)}accept(e){return e.visitParameterNameDef?e.visitParameterNameDef(this):e.visitChildren(this)}}L.ParameterNameDefContext=vO;class _O extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceNameDef}enterRule(e){e.enterSourceNameDef&&e.enterSourceNameDef(this)}exitRule(e){e.exitSourceNameDef&&e.exitSourceNameDef(this)}accept(e){return e.visitSourceNameDef?e.visitSourceNameDef(this):e.visitChildren(this)}}L.SourceNameDefContext=_O;class SO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}exploreStatement(e){return e===void 0?this.getRuleContexts(Pr):this.getRuleContext(e,Pr)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreProperties}enterRule(e){e.enterExploreProperties&&e.enterExploreProperties(this)}exitRule(e){e.exitExploreProperties&&e.exitExploreProperties(this)}accept(e){return e.visitExploreProperties?e.visitExploreProperties(this):e.visitChildren(this)}}L.ExplorePropertiesContext=SO;class Pr extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreStatement}copyFrom(e){super.copyFrom(e)}}L.ExploreStatementContext=Pr;class sq extends Pr{defDimensions(){return this.getRuleContext(0,xv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreDimension_stub&&e.enterDefExploreDimension_stub(this)}exitRule(e){e.exitDefExploreDimension_stub&&e.exitDefExploreDimension_stub(this)}accept(e){return e.visitDefExploreDimension_stub?e.visitDefExploreDimension_stub(this):e.visitChildren(this)}}L.DefExploreDimension_stubContext=sq;class oq extends Pr{defMeasures(){return this.getRuleContext(0,fv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreMeasure_stub&&e.enterDefExploreMeasure_stub(this)}exitRule(e){e.exitDefExploreMeasure_stub&&e.exitDefExploreMeasure_stub(this)}accept(e){return e.visitDefExploreMeasure_stub?e.visitDefExploreMeasure_stub(this):e.visitChildren(this)}}L.DefExploreMeasure_stubContext=oq;class uq extends Pr{declareStatement(){return this.getRuleContext(0,og)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefDeclare_stub&&e.enterDefDeclare_stub(this)}exitRule(e){e.exitDefDeclare_stub&&e.exitDefDeclare_stub(this)}accept(e){return e.visitDefDeclare_stub?e.visitDefDeclare_stub(this):e.visitChildren(this)}}L.DefDeclare_stubContext=uq;class aq extends Pr{joinStatement(){return this.getRuleContext(0,Pa)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoin_stub&&e.enterDefJoin_stub(this)}exitRule(e){e.exitDefJoin_stub&&e.exitDefJoin_stub(this)}accept(e){return e.visitDefJoin_stub?e.visitDefJoin_stub(this):e.visitChildren(this)}}L.DefJoin_stubContext=aq;class lq extends Pr{whereStatement(){return this.getRuleContext(0,gf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreWhere_stub&&e.enterDefExploreWhere_stub(this)}exitRule(e){e.exitDefExploreWhere_stub&&e.exitDefExploreWhere_stub(this)}accept(e){return e.visitDefExploreWhere_stub?e.visitDefExploreWhere_stub(this):e.visitChildren(this)}}L.DefExploreWhere_stubContext=lq;class cq extends Pr{PRIMARY_KEY(){return this.getToken(x.PRIMARY_KEY,0)}fieldName(){return this.getRuleContext(0,vr)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExplorePrimaryKey&&e.enterDefExplorePrimaryKey(this)}exitRule(e){e.exitDefExplorePrimaryKey&&e.exitDefExplorePrimaryKey(this)}accept(e){return e.visitDefExplorePrimaryKey?e.visitDefExplorePrimaryKey(this):e.visitChildren(this)}}L.DefExplorePrimaryKeyContext=cq;class fq extends Pr{RENAME(){return this.getToken(x.RENAME,0)}renameList(){return this.getRuleContext(0,CO)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreRename&&e.enterDefExploreRename(this)}exitRule(e){e.exitDefExploreRename&&e.exitDefExploreRename(this)}accept(e){return e.visitDefExploreRename?e.visitDefExploreRename(this):e.visitChildren(this)}}L.DefExploreRenameContext=fq;class xq extends Pr{fieldNameList(){return this.getRuleContext(0,Qd)}ACCEPT(){return this.tryGetToken(x.ACCEPT,0)}EXCEPT(){return this.tryGetToken(x.EXCEPT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreEditField&&e.enterDefExploreEditField(this)}exitRule(e){e.exitDefExploreEditField&&e.exitDefExploreEditField(this)}accept(e){return e.visitDefExploreEditField?e.visitDefExploreEditField(this):e.visitChildren(this)}}L.DefExploreEditFieldContext=xq;class dq extends Pr{tags(){return this.getRuleContext(0,Mt)}subQueryDefList(){return this.getRuleContext(0,UO)}QUERY(){return this.tryGetToken(x.QUERY,0)}VIEW(){return this.tryGetToken(x.VIEW,0)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreQuery&&e.enterDefExploreQuery(this)}exitRule(e){e.exitDefExploreQuery&&e.exitDefExploreQuery(this)}accept(e){return e.visitDefExploreQuery?e.visitDefExploreQuery(this):e.visitChildren(this)}}L.DefExploreQueryContext=dq;class hq extends Pr{timezoneStatement(){return this.getRuleContext(0,Lv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreTimezone&&e.enterDefExploreTimezone(this)}exitRule(e){e.exitDefExploreTimezone&&e.exitDefExploreTimezone(this)}accept(e){return e.visitDefExploreTimezone?e.visitDefExploreTimezone(this):e.visitChildren(this)}}L.DefExploreTimezoneContext=hq;class pq extends Pr{ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefExploreAnnotation&&e.enterDefExploreAnnotation(this)}exitRule(e){e.exitDefExploreAnnotation&&e.exitDefExploreAnnotation(this)}accept(e){return e.visitDefExploreAnnotation?e.visitDefExploreAnnotation(this):e.visitChildren(this)}}L.DefExploreAnnotationContext=pq;class gq extends Pr{ignoredModelAnnotations(){return this.getRuleContext(0,sv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefIgnoreModel_stub&&e.enterDefIgnoreModel_stub(this)}exitRule(e){e.exitDefIgnoreModel_stub&&e.exitDefIgnoreModel_stub(this)}accept(e){return e.visitDefIgnoreModel_stub?e.visitDefIgnoreModel_stub(this):e.visitChildren(this)}}L.DefIgnoreModel_stubContext=gq;class Au extends ge.ParserRuleContext{PUBLIC_KW(){return this.tryGetToken(x.PUBLIC_KW,0)}PRIVATE_KW(){return this.tryGetToken(x.PRIVATE_KW,0)}INTERNAL_KW(){return this.tryGetToken(x.INTERNAL_KW,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_accessLabel}enterRule(e){e.enterAccessLabel&&e.enterAccessLabel(this)}exitRule(e){e.exitAccessLabel&&e.exitAccessLabel(this)}accept(e){return e.visitAccessLabel?e.visitAccessLabel(this):e.visitChildren(this)}}L.AccessLabelContext=Au;class mq extends ge.ParserRuleContext{fieldNameList(){return this.tryGetRuleContext(0,Qd)}STAR(){return this.tryGetToken(x.STAR,0)}starQualified(){return this.tryGetRuleContext(0,Uv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_accessModifierList}enterRule(e){e.enterAccessModifierList&&e.enterAccessModifierList(this)}exitRule(e){e.exitAccessModifierList&&e.exitAccessModifierList(this)}accept(e){return e.visitAccessModifierList?e.visitAccessModifierList(this):e.visitChildren(this)}}L.AccessModifierListContext=mq;class fv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}MEASURE(){return this.getToken(x.MEASURE,0)}defList(){return this.getRuleContext(0,sg)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defMeasures}enterRule(e){e.enterDefMeasures&&e.enterDefMeasures(this)}exitRule(e){e.exitDefMeasures&&e.exitDefMeasures(this)}accept(e){return e.visitDefMeasures?e.visitDefMeasures(this):e.visitChildren(this)}}L.DefMeasuresContext=fv;class xv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}DIMENSION(){return this.getToken(x.DIMENSION,0)}defList(){return this.getRuleContext(0,sg)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defDimensions}enterRule(e){e.enterDefDimensions&&e.enterDefDimensions(this)}exitRule(e){e.exitDefDimensions&&e.exitDefDimensions(this)}accept(e){return e.visitDefDimensions?e.visitDefDimensions(this):e.visitChildren(this)}}L.DefDimensionsContext=xv;class CO extends ge.ParserRuleContext{exploreRenameDef(e){return e===void 0?this.getRuleContexts(dv):this.getRuleContext(e,dv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_renameList}enterRule(e){e.enterRenameList&&e.enterRenameList(this)}exitRule(e){e.exitRenameList&&e.exitRenameList(this)}accept(e){return e.visitRenameList?e.visitRenameList(this):e.visitChildren(this)}}L.RenameListContext=CO;class dv extends ge.ParserRuleContext{fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}isDefine(){return this.getRuleContext(0,Ma)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreRenameDef}enterRule(e){e.enterExploreRenameDef&&e.enterExploreRenameDef(this)}exitRule(e){e.exitExploreRenameDef&&e.exitExploreRenameDef(this)}accept(e){return e.visitExploreRenameDef?e.visitExploreRenameDef(this):e.visitChildren(this)}}L.ExploreRenameDefContext=dv;class sg extends ge.ParserRuleContext{fieldDef(e){return e===void 0?this.getRuleContexts(qd):this.getRuleContext(e,qd)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_defList}enterRule(e){e.enterDefList&&e.enterDefList(this)}exitRule(e){e.exitDefList&&e.exitDefList(this)}accept(e){return e.visitDefList?e.visitDefList(this):e.visitChildren(this)}}L.DefListContext=sg;class qd extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldNameDef(){return this.getRuleContext(0,bO)}isDefine(){return this.getRuleContext(0,Ma)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldDef}enterRule(e){e.enterFieldDef&&e.enterFieldDef(this)}exitRule(e){e.exitFieldDef&&e.exitFieldDef(this)}accept(e){return e.visitFieldDef?e.visitFieldDef(this):e.visitChildren(this)}}L.FieldDefContext=qd;class bO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldNameDef}enterRule(e){e.enterFieldNameDef&&e.enterFieldNameDef(this)}exitRule(e){e.exitFieldNameDef&&e.exitFieldNameDef(this)}accept(e){return e.visitFieldNameDef?e.visitFieldNameDef(this):e.visitChildren(this)}}L.FieldNameDefContext=bO;class TO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinNameDef}enterRule(e){e.enterJoinNameDef&&e.enterJoinNameDef(this)}exitRule(e){e.exitJoinNameDef&&e.exitJoinNameDef(this)}accept(e){return e.visitJoinNameDef?e.visitJoinNameDef(this):e.visitChildren(this)}}L.JoinNameDefContext=TO;class og extends ge.ParserRuleContext{DECLARE(){return this.getToken(x.DECLARE,0)}defList(){return this.getRuleContext(0,sg)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_declareStatement}enterRule(e){e.enterDeclareStatement&&e.enterDeclareStatement(this)}exitRule(e){e.exitDeclareStatement&&e.exitDeclareStatement(this)}accept(e){return e.visitDeclareStatement?e.visitDeclareStatement(this):e.visitChildren(this)}}L.DeclareStatementContext=og;class Pa extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinStatement}copyFrom(e){super.copyFrom(e)}}L.JoinStatementContext=Pa;class yq extends Pa{tags(){return this.getRuleContext(0,Mt)}JOIN_ONE(){return this.getToken(x.JOIN_ONE,0)}joinList(){return this.getRuleContext(0,ug)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoinOne&&e.enterDefJoinOne(this)}exitRule(e){e.exitDefJoinOne&&e.exitDefJoinOne(this)}accept(e){return e.visitDefJoinOne?e.visitDefJoinOne(this):e.visitChildren(this)}}L.DefJoinOneContext=yq;class Eq extends Pa{tags(){return this.getRuleContext(0,Mt)}JOIN_MANY(){return this.getToken(x.JOIN_MANY,0)}joinList(){return this.getRuleContext(0,ug)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoinMany&&e.enterDefJoinMany(this)}exitRule(e){e.exitDefJoinMany&&e.exitDefJoinMany(this)}accept(e){return e.visitDefJoinMany?e.visitDefJoinMany(this):e.visitChildren(this)}}L.DefJoinManyContext=Eq;class Aq extends Pa{tags(){return this.getRuleContext(0,Mt)}JOIN_CROSS(){return this.getToken(x.JOIN_CROSS,0)}joinList(){return this.getRuleContext(0,ug)}accessLabel(){return this.tryGetRuleContext(0,Au)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterDefJoinCross&&e.enterDefJoinCross(this)}exitRule(e){e.exitDefJoinCross&&e.exitDefJoinCross(this)}accept(e){return e.visitDefJoinCross?e.visitDefJoinCross(this):e.visitChildren(this)}}L.DefJoinCrossContext=Aq;class RO extends ge.ParserRuleContext{EXTENDQ(){return this.getToken(x.EXTENDQ,0)}queryExtendStatementList(){return this.getRuleContext(0,LO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryExtend}enterRule(e){e.enterQueryExtend&&e.enterQueryExtend(this)}exitRule(e){e.exitQueryExtend&&e.exitQueryExtend(this)}accept(e){return e.visitQueryExtend?e.visitQueryExtend(this):e.visitChildren(this)}}L.QueryExtendContext=RO;class vq extends ge.ParserRuleContext{joinStatement(){return this.tryGetRuleContext(0,Pa)}whereStatement(){return this.tryGetRuleContext(0,gf)}declareStatement(){return this.tryGetRuleContext(0,og)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_modEither}enterRule(e){e.enterModEither&&e.enterModEither(this)}exitRule(e){e.exitModEither&&e.exitModEither(this)}accept(e){return e.visitModEither?e.visitModEither(this):e.visitChildren(this)}}L.ModEitherContext=vq;class hv extends ge.ParserRuleContext{OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sourceArgument(e){return e===void 0?this.getRuleContexts(pv):this.getRuleContext(e,pv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceArguments}enterRule(e){e.enterSourceArguments&&e.enterSourceArguments(this)}exitRule(e){e.exitSourceArguments&&e.exitSourceArguments(this)}accept(e){return e.visitSourceArguments?e.visitSourceArguments(this):e.visitChildren(this)}}L.SourceArgumentsContext=hv;class OO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_argumentId}enterRule(e){e.enterArgumentId&&e.enterArgumentId(this)}exitRule(e){e.exitArgumentId&&e.exitArgumentId(this)}accept(e){return e.visitArgumentId?e.visitArgumentId(this):e.visitChildren(this)}}L.ArgumentIdContext=OO;class pv extends ge.ParserRuleContext{fieldExpr(){return this.getRuleContext(0,be)}argumentId(){return this.tryGetRuleContext(0,OO)}IS(){return this.tryGetToken(x.IS,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sourceArgument}enterRule(e){e.enterSourceArgument&&e.enterSourceArgument(this)}exitRule(e){e.exitSourceArgument&&e.exitSourceArgument(this)}accept(e){return e.visitSourceArgument?e.visitSourceArgument(this):e.visitChildren(this)}}L.SourceArgumentContext=pv;class Zt extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqExpr}copyFrom(e){super.copyFrom(e)}}L.SqExprContext=Zt;class _q extends Zt{id(){return this.getRuleContext(0,pn)}sourceArguments(){return this.tryGetRuleContext(0,hv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQID&&e.enterSQID(this)}exitRule(e){e.exitSQID&&e.exitSQID(this)}accept(e){return e.visitSQID?e.visitSQID(this):e.visitChildren(this)}}L.SQIDContext=_q;class Sq extends Zt{OPAREN(){return this.getToken(x.OPAREN,0)}sqExpr(){return this.getRuleContext(0,Zt)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQParens&&e.enterSQParens(this)}exitRule(e){e.exitSQParens&&e.exitSQParens(this)}accept(e){return e.visitSQParens?e.visitSQParens(this):e.visitChildren(this)}}L.SQParensContext=Sq;class Cq extends Zt{COMPOSE(){return this.getToken(x.COMPOSE,0)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}sqExpr(e){return e===void 0?this.getRuleContexts(Zt):this.getRuleContext(e,Zt)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQCompose&&e.enterSQCompose(this)}exitRule(e){e.exitSQCompose&&e.exitSQCompose(this)}accept(e){return e.visitSQCompose?e.visitSQCompose(this):e.visitChildren(this)}}L.SQComposeContext=Cq;class bq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}PLUS(){return this.getToken(x.PLUS,0)}segExpr(){return this.getRuleContext(0,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQRefinedQuery&&e.enterSQRefinedQuery(this)}exitRule(e){e.exitSQRefinedQuery&&e.exitSQRefinedQuery(this)}accept(e){return e.visitSQRefinedQuery?e.visitSQRefinedQuery(this):e.visitChildren(this)}}L.SQRefinedQueryContext=bq;class Tq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}ARROW(){return this.getToken(x.ARROW,0)}segExpr(){return this.getRuleContext(0,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQArrow&&e.enterSQArrow(this)}exitRule(e){e.exitSQArrow&&e.exitSQArrow(this)}accept(e){return e.visitSQArrow?e.visitSQArrow(this):e.visitChildren(this)}}L.SQArrowContext=Tq;class Rq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}EXTEND(){return this.getToken(x.EXTEND,0)}exploreProperties(){return this.getRuleContext(0,SO)}INCLUDE(){return this.tryGetToken(x.INCLUDE,0)}includeBlock(){return this.tryGetRuleContext(0,gv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQExtendedSource&&e.enterSQExtendedSource(this)}exitRule(e){e.exitSQExtendedSource&&e.exitSQExtendedSource(this)}accept(e){return e.visitSQExtendedSource?e.visitSQExtendedSource(this):e.visitChildren(this)}}L.SQExtendedSourceContext=Rq;class Oq extends Zt{sqExpr(){return this.getRuleContext(0,Zt)}INCLUDE(){return this.getToken(x.INCLUDE,0)}includeBlock(){return this.getRuleContext(0,gv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQInclude&&e.enterSQInclude(this)}exitRule(e){e.exitSQInclude&&e.exitSQInclude(this)}accept(e){return e.visitSQInclude?e.visitSQInclude(this):e.visitChildren(this)}}L.SQIncludeContext=Oq;class Dq extends Zt{exploreTable(){return this.getRuleContext(0,ig)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQTable&&e.enterSQTable(this)}exitRule(e){e.exitSQTable&&e.exitSQTable(this)}accept(e){return e.visitSQTable?e.visitSQTable(this):e.visitChildren(this)}}L.SQTableContext=Dq;class wq extends Zt{sqlSource(){return this.getRuleContext(0,gO)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSQSQL&&e.enterSQSQL(this)}exitRule(e){e.exitSQSQL&&e.exitSQSQL(this)}accept(e){return e.visitSQSQL?e.visitSQSQL(this):e.visitChildren(this)}}L.SQSQLContext=wq;class gv extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}includeItem(e){return e===void 0?this.getRuleContexts(mv):this.getRuleContext(e,mv)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeBlock}enterRule(e){e.enterIncludeBlock&&e.enterIncludeBlock(this)}exitRule(e){e.exitIncludeBlock&&e.exitIncludeBlock(this)}accept(e){return e.visitIncludeBlock?e.visitIncludeBlock(this):e.visitChildren(this)}}L.IncludeBlockContext=gv;class mv extends ge.ParserRuleContext{tags(){return this.tryGetRuleContext(0,Mt)}accessLabelProp(){return this.tryGetRuleContext(0,wO)}includeList(){return this.tryGetRuleContext(0,FO)}EXCEPT(){return this.tryGetToken(x.EXCEPT,0)}includeExceptList(){return this.tryGetRuleContext(0,NO)}orphanedAnnotation(){return this.tryGetRuleContext(0,DO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeItem}enterRule(e){e.enterIncludeItem&&e.enterIncludeItem(this)}exitRule(e){e.exitIncludeItem&&e.exitIncludeItem(this)}accept(e){return e.visitIncludeItem?e.visitIncludeItem(this):e.visitChildren(this)}}L.IncludeItemContext=mv;class DO extends ge.ParserRuleContext{ANNOTATION(){return this.getToken(x.ANNOTATION,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_orphanedAnnotation}enterRule(e){e.enterOrphanedAnnotation&&e.enterOrphanedAnnotation(this)}exitRule(e){e.exitOrphanedAnnotation&&e.exitOrphanedAnnotation(this)}accept(e){return e.visitOrphanedAnnotation?e.visitOrphanedAnnotation(this):e.visitChildren(this)}}L.OrphanedAnnotationContext=DO;class wO extends ge.ParserRuleContext{PUBLIC(){return this.tryGetToken(x.PUBLIC,0)}PRIVATE(){return this.tryGetToken(x.PRIVATE,0)}INTERNAL(){return this.tryGetToken(x.INTERNAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_accessLabelProp}enterRule(e){e.enterAccessLabelProp&&e.enterAccessLabelProp(this)}exitRule(e){e.exitAccessLabelProp&&e.exitAccessLabelProp(this)}accept(e){return e.visitAccessLabelProp?e.visitAccessLabelProp(this):e.visitChildren(this)}}L.AccessLabelPropContext=wO;class NO extends ge.ParserRuleContext{includeExceptListItem(e){return e===void 0?this.getRuleContexts(yv):this.getRuleContext(e,yv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeExceptList}enterRule(e){e.enterIncludeExceptList&&e.enterIncludeExceptList(this)}exitRule(e){e.exitIncludeExceptList&&e.exitIncludeExceptList(this)}accept(e){return e.visitIncludeExceptList?e.visitIncludeExceptList(this):e.visitChildren(this)}}L.IncludeExceptListContext=NO;class yv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldName(){return this.tryGetRuleContext(0,vr)}collectionWildCard(){return this.tryGetRuleContext(0,xg)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeExceptListItem}enterRule(e){e.enterIncludeExceptListItem&&e.enterIncludeExceptListItem(this)}exitRule(e){e.exitIncludeExceptListItem&&e.exitIncludeExceptListItem(this)}accept(e){return e.visitIncludeExceptListItem?e.visitIncludeExceptListItem(this):e.visitChildren(this)}}L.IncludeExceptListItemContext=yv;class FO extends ge.ParserRuleContext{includeField(e){return e===void 0?this.getRuleContexts(Ev):this.getRuleContext(e,Ev)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeList}enterRule(e){e.enterIncludeList&&e.enterIncludeList(this)}exitRule(e){e.exitIncludeList&&e.exitIncludeList(this)}accept(e){return e.visitIncludeList?e.visitIncludeList(this):e.visitChildren(this)}}L.IncludeListContext=FO;class Ev extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}isDefine(){return this.tryGetRuleContext(0,Ma)}collectionWildCard(){return this.tryGetRuleContext(0,xg)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_includeField}enterRule(e){e.enterIncludeField&&e.enterIncludeField(this)}exitRule(e){e.exitIncludeField&&e.exitIncludeField(this)}accept(e){return e.visitIncludeField?e.visitIncludeField(this):e.visitChildren(this)}}L.IncludeFieldContext=Ev;class cs extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_segExpr}copyFrom(e){super.copyFrom(e)}}L.SegExprContext=cs;class Nq extends cs{fieldPath(){return this.getRuleContext(0,Cu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegField&&e.enterSegField(this)}exitRule(e){e.exitSegField&&e.exitSegField(this)}accept(e){return e.visitSegField?e.visitSegField(this):e.visitChildren(this)}}L.SegFieldContext=Nq;class Fq extends cs{queryProperties(){return this.getRuleContext(0,mO)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegOps&&e.enterSegOps(this)}exitRule(e){e.exitSegOps&&e.exitSegOps(this)}accept(e){return e.visitSegOps?e.visitSegOps(this):e.visitChildren(this)}}L.SegOpsContext=Fq;class Lq extends cs{OPAREN(){return this.getToken(x.OPAREN,0)}vExpr(){return this.getRuleContext(0,u0)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegParen&&e.enterSegParen(this)}exitRule(e){e.exitSegParen&&e.exitSegParen(this)}accept(e){return e.visitSegParen?e.visitSegParen(this):e.visitChildren(this)}}L.SegParenContext=Lq;class Iq extends cs{PLUS(){return this.getToken(x.PLUS,0)}segExpr(e){return e===void 0?this.getRuleContexts(cs):this.getRuleContext(e,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterSegRefine&&e.enterSegRefine(this)}exitRule(e){e.exitSegRefine&&e.exitSegRefine(this)}accept(e){return e.visitSegRefine?e.visitSegRefine(this):e.visitChildren(this)}}L.SegRefineContext=Iq;class u0 extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_vExpr}copyFrom(e){super.copyFrom(e)}}L.VExprContext=u0;class Bq extends u0{segExpr(){return this.getRuleContext(0,cs)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterVSeg&&e.enterVSeg(this)}exitRule(e){e.exitVSeg&&e.exitVSeg(this)}accept(e){return e.visitVSeg?e.visitVSeg(this):e.visitChildren(this)}}L.VSegContext=Bq;class $q extends u0{ARROW(){return this.getToken(x.ARROW,0)}segExpr(){return this.getRuleContext(0,cs)}vExpr(){return this.getRuleContext(0,u0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterVArrow&&e.enterVArrow(this)}exitRule(e){e.exitVArrow&&e.exitVArrow(this)}accept(e){return e.visitVArrow?e.visitVArrow(this):e.visitChildren(this)}}L.VArrowContext=$q;class Av extends ge.ParserRuleContext{defDimensions(){return this.tryGetRuleContext(0,xv)}defMeasures(){return this.tryGetRuleContext(0,fv)}joinStatement(){return this.tryGetRuleContext(0,Pa)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryExtendStatement}enterRule(e){e.enterQueryExtendStatement&&e.enterQueryExtendStatement(this)}exitRule(e){e.exitQueryExtendStatement&&e.exitQueryExtendStatement(this)}accept(e){return e.visitQueryExtendStatement?e.visitQueryExtendStatement(this):e.visitChildren(this)}}L.QueryExtendStatementContext=Av;class LO extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}queryExtendStatement(e){return e===void 0?this.getRuleContexts(Av):this.getRuleContext(e,Av)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryExtendStatementList}enterRule(e){e.enterQueryExtendStatementList&&e.enterQueryExtendStatementList(this)}exitRule(e){e.exitQueryExtendStatementList&&e.exitQueryExtendStatementList(this)}accept(e){return e.visitQueryExtendStatementList?e.visitQueryExtendStatementList(this):e.visitChildren(this)}}L.QueryExtendStatementListContext=LO;class ug extends ge.ParserRuleContext{joinDef(e){return e===void 0?this.getRuleContexts(Hd):this.getRuleContext(e,Hd)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinList}enterRule(e){e.enterJoinList&&e.enterJoinList(this)}exitRule(e){e.exitJoinList&&e.exitJoinList(this)}accept(e){return e.visitJoinList?e.visitJoinList(this):e.visitChildren(this)}}L.JoinListContext=ug;class IO extends ge.ParserRuleContext{IS(){return this.getToken(x.IS,0)}sqExpr(){return this.getRuleContext(0,Zt)}tags(e){return e===void 0?this.getRuleContexts(Mt):this.getRuleContext(e,Mt)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_isExplore}enterRule(e){e.enterIsExplore&&e.enterIsExplore(this)}exitRule(e){e.exitIsExplore&&e.exitIsExplore(this)}accept(e){return e.visitIsExplore?e.visitIsExplore(this):e.visitChildren(this)}}L.IsExploreContext=IO;class vv extends ge.ParserRuleContext{LEFT(){return this.tryGetToken(x.LEFT,0)}RIGHT(){return this.tryGetToken(x.RIGHT,0)}FULL(){return this.tryGetToken(x.FULL,0)}INNER(){return this.tryGetToken(x.INNER,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_matrixOperation}enterRule(e){e.enterMatrixOperation&&e.enterMatrixOperation(this)}exitRule(e){e.exitMatrixOperation&&e.exitMatrixOperation(this)}accept(e){return e.visitMatrixOperation?e.visitMatrixOperation(this):e.visitChildren(this)}}L.MatrixOperationContext=vv;class _v extends ge.ParserRuleContext{joinNameDef(){return this.getRuleContext(0,TO)}sourceArguments(){return this.tryGetRuleContext(0,hv)}isExplore(){return this.tryGetRuleContext(0,IO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinFrom}enterRule(e){e.enterJoinFrom&&e.enterJoinFrom(this)}exitRule(e){e.exitJoinFrom&&e.exitJoinFrom(this)}accept(e){return e.visitJoinFrom?e.visitJoinFrom(this):e.visitChildren(this)}}L.JoinFromContext=_v;class Hd extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinDef}copyFrom(e){super.copyFrom(e)}}L.JoinDefContext=Hd;class kq extends Hd{joinFrom(){return this.getRuleContext(0,_v)}WITH(){return this.getToken(x.WITH,0)}fieldExpr(){return this.getRuleContext(0,be)}ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}matrixOperation(){return this.tryGetRuleContext(0,vv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterJoinWith&&e.enterJoinWith(this)}exitRule(e){e.exitJoinWith&&e.exitJoinWith(this)}accept(e){return e.visitJoinWith?e.visitJoinWith(this):e.visitChildren(this)}}L.JoinWithContext=kq;class Mq extends Hd{joinFrom(){return this.getRuleContext(0,_v)}ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}ON(){return this.tryGetToken(x.ON,0)}joinExpression(){return this.tryGetRuleContext(0,BO)}matrixOperation(){return this.tryGetRuleContext(0,vv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterJoinOn&&e.enterJoinOn(this)}exitRule(e){e.exitJoinOn&&e.exitJoinOn(this)}accept(e){return e.visitJoinOn?e.visitJoinOn(this):e.visitChildren(this)}}L.JoinOnContext=Mq;class BO extends ge.ParserRuleContext{fieldExpr(){return this.getRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinExpression}enterRule(e){e.enterJoinExpression&&e.enterJoinExpression(this)}exitRule(e){e.exitJoinExpression&&e.exitJoinExpression(this)}accept(e){return e.visitJoinExpression?e.visitJoinExpression(this):e.visitChildren(this)}}L.JoinExpressionContext=BO;class Pq extends ge.ParserRuleContext{whereStatement(){return this.tryGetRuleContext(0,gf)}havingStatement(){return this.tryGetRuleContext(0,Tv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_filterStatement}enterRule(e){e.enterFilterStatement&&e.enterFilterStatement(this)}exitRule(e){e.exitFilterStatement&&e.exitFilterStatement(this)}accept(e){return e.visitFilterStatement?e.visitFilterStatement(this):e.visitChildren(this)}}L.FilterStatementContext=Pq;class $O extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}fieldPropertyStatement(e){return e===void 0?this.getRuleContexts(Cv):this.getRuleContext(e,Cv)}SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldProperties}enterRule(e){e.enterFieldProperties&&e.enterFieldProperties(this)}exitRule(e){e.exitFieldProperties&&e.exitFieldProperties(this)}accept(e){return e.visitFieldProperties?e.visitFieldProperties(this):e.visitChildren(this)}}L.FieldPropertiesContext=$O;class kO extends ge.ParserRuleContext{aggregateOrderBySpec(e){return e===void 0?this.getRuleContexts(Sv):this.getRuleContext(e,Sv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateOrdering}enterRule(e){e.enterAggregateOrdering&&e.enterAggregateOrdering(this)}exitRule(e){e.exitAggregateOrdering&&e.exitAggregateOrdering(this)}accept(e){return e.visitAggregateOrdering?e.visitAggregateOrdering(this):e.visitChildren(this)}}L.AggregateOrderingContext=kO;class Sv extends ge.ParserRuleContext{fieldExpr(){return this.tryGetRuleContext(0,be)}ASC(){return this.tryGetToken(x.ASC,0)}DESC(){return this.tryGetToken(x.DESC,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateOrderBySpec}enterRule(e){e.enterAggregateOrderBySpec&&e.enterAggregateOrderBySpec(this)}exitRule(e){e.exitAggregateOrderBySpec&&e.exitAggregateOrderBySpec(this)}accept(e){return e.visitAggregateOrderBySpec?e.visitAggregateOrderBySpec(this):e.visitChildren(this)}}L.AggregateOrderBySpecContext=Sv;class MO extends ge.ParserRuleContext{ORDER_BY(){return this.getToken(x.ORDER_BY,0)}aggregateOrdering(){return this.getRuleContext(0,kO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateOrderByStatement}enterRule(e){e.enterAggregateOrderByStatement&&e.enterAggregateOrderByStatement(this)}exitRule(e){e.exitAggregateOrderByStatement&&e.exitAggregateOrderByStatement(this)}accept(e){return e.visitAggregateOrderByStatement?e.visitAggregateOrderByStatement(this):e.visitChildren(this)}}L.AggregateOrderByStatementContext=MO;class PO extends ge.ParserRuleContext{limitStatement(){return this.getRuleContext(0,Nv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldPropertyLimitStatement}enterRule(e){e.enterFieldPropertyLimitStatement&&e.enterFieldPropertyLimitStatement(this)}exitRule(e){e.exitFieldPropertyLimitStatement&&e.exitFieldPropertyLimitStatement(this)}accept(e){return e.visitFieldPropertyLimitStatement?e.visitFieldPropertyLimitStatement(this):e.visitChildren(this)}}L.FieldPropertyLimitStatementContext=PO;class Cv extends ge.ParserRuleContext{whereStatement(){return this.tryGetRuleContext(0,gf)}partitionByStatement(){return this.tryGetRuleContext(0,YO)}aggregateOrderByStatement(){return this.tryGetRuleContext(0,MO)}fieldPropertyLimitStatement(){return this.tryGetRuleContext(0,PO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldPropertyStatement}enterRule(e){e.enterFieldPropertyStatement&&e.enterFieldPropertyStatement(this)}exitRule(e){e.exitFieldPropertyStatement&&e.exitFieldPropertyStatement(this)}accept(e){return e.visitFieldPropertyStatement?e.visitFieldPropertyStatement(this):e.visitChildren(this)}}L.FieldPropertyStatementContext=Cv;class bv extends ge.ParserRuleContext{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_filterClauseList}enterRule(e){e.enterFilterClauseList&&e.enterFilterClauseList(this)}exitRule(e){e.exitFilterClauseList&&e.exitFilterClauseList(this)}accept(e){return e.visitFilterClauseList?e.visitFilterClauseList(this):e.visitChildren(this)}}L.FilterClauseListContext=bv;class gf extends ge.ParserRuleContext{WHERE(){return this.getToken(x.WHERE,0)}filterClauseList(){return this.getRuleContext(0,bv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_whereStatement}enterRule(e){e.enterWhereStatement&&e.enterWhereStatement(this)}exitRule(e){e.exitWhereStatement&&e.exitWhereStatement(this)}accept(e){return e.visitWhereStatement?e.visitWhereStatement(this):e.visitChildren(this)}}L.WhereStatementContext=gf;class Tv extends ge.ParserRuleContext{HAVING(){return this.getToken(x.HAVING,0)}filterClauseList(){return this.getRuleContext(0,bv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_havingStatement}enterRule(e){e.enterHavingStatement&&e.enterHavingStatement(this)}exitRule(e){e.exitHavingStatement&&e.exitHavingStatement(this)}accept(e){return e.visitHavingStatement?e.visitHavingStatement(this):e.visitChildren(this)}}L.HavingStatementContext=Tv;class UO extends ge.ParserRuleContext{exploreQueryDef(e){return e===void 0?this.getRuleContexts(Rv):this.getRuleContext(e,Rv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_subQueryDefList}enterRule(e){e.enterSubQueryDefList&&e.enterSubQueryDefList(this)}exitRule(e){e.exitSubQueryDefList&&e.exitSubQueryDefList(this)}accept(e){return e.visitSubQueryDefList?e.visitSubQueryDefList(this):e.visitChildren(this)}}L.SubQueryDefListContext=UO;class jO extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreQueryNameDef}enterRule(e){e.enterExploreQueryNameDef&&e.enterExploreQueryNameDef(this)}exitRule(e){e.exitExploreQueryNameDef&&e.exitExploreQueryNameDef(this)}accept(e){return e.visitExploreQueryNameDef?e.visitExploreQueryNameDef(this):e.visitChildren(this)}}L.ExploreQueryNameDefContext=jO;class Rv extends ge.ParserRuleContext{exploreQueryNameDef(){return this.getRuleContext(0,jO)}isDefine(){return this.getRuleContext(0,Ma)}vExpr(){return this.getRuleContext(0,u0)}ANNOTATION(e){return e===void 0?this.getTokens(x.ANNOTATION):this.getToken(x.ANNOTATION,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_exploreQueryDef}enterRule(e){e.enterExploreQueryDef&&e.enterExploreQueryDef(this)}exitRule(e){e.exitExploreQueryDef&&e.exitExploreQueryDef(this)}accept(e){return e.visitExploreQueryDef?e.visitExploreQueryDef(this):e.visitChildren(this)}}L.ExploreQueryDefContext=Rv;class Ov extends ge.ParserRuleContext{groupByStatement(){return this.tryGetRuleContext(0,HO)}declareStatement(){return this.tryGetRuleContext(0,og)}queryJoinStatement(){return this.tryGetRuleContext(0,qO)}queryExtend(){return this.tryGetRuleContext(0,RO)}projectStatement(){return this.tryGetRuleContext(0,VO)}indexStatement(){return this.tryGetRuleContext(0,eD)}aggregateStatement(){return this.tryGetRuleContext(0,GO)}calculateStatement(){return this.tryGetRuleContext(0,WO)}topStatement(){return this.tryGetRuleContext(0,XO)}limitStatement(){return this.tryGetRuleContext(0,Nv)}orderByStatement(){return this.tryGetRuleContext(0,KO)}whereStatement(){return this.tryGetRuleContext(0,gf)}havingStatement(){return this.tryGetRuleContext(0,Tv)}nestStatement(){return this.tryGetRuleContext(0,zO)}sampleStatement(){return this.tryGetRuleContext(0,tD)}timezoneStatement(){return this.tryGetRuleContext(0,Lv)}queryAnnotation(){return this.tryGetRuleContext(0,nD)}ignoredModelAnnotations(){return this.tryGetRuleContext(0,sv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryStatement}enterRule(e){e.enterQueryStatement&&e.enterQueryStatement(this)}exitRule(e){e.exitQueryStatement&&e.exitQueryStatement(this)}accept(e){return e.visitQueryStatement?e.visitQueryStatement(this):e.visitChildren(this)}}L.QueryStatementContext=Ov;class qO extends ge.ParserRuleContext{joinStatement(){return this.getRuleContext(0,Pa)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryJoinStatement}enterRule(e){e.enterQueryJoinStatement&&e.enterQueryJoinStatement(this)}exitRule(e){e.exitQueryJoinStatement&&e.exitQueryJoinStatement(this)}accept(e){return e.visitQueryJoinStatement?e.visitQueryJoinStatement(this):e.visitChildren(this)}}L.QueryJoinStatementContext=qO;class HO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}GROUP_BY(){return this.getToken(x.GROUP_BY,0)}queryFieldList(){return this.getRuleContext(0,ag)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_groupByStatement}enterRule(e){e.enterGroupByStatement&&e.enterGroupByStatement(this)}exitRule(e){e.exitGroupByStatement&&e.exitGroupByStatement(this)}accept(e){return e.visitGroupByStatement?e.visitGroupByStatement(this):e.visitChildren(this)}}L.GroupByStatementContext=HO;class ag extends ge.ParserRuleContext{queryFieldEntry(e){return e===void 0?this.getRuleContexts(Dv):this.getRuleContext(e,Dv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryFieldList}enterRule(e){e.enterQueryFieldList&&e.enterQueryFieldList(this)}exitRule(e){e.exitQueryFieldList&&e.exitQueryFieldList(this)}accept(e){return e.visitQueryFieldList?e.visitQueryFieldList(this):e.visitChildren(this)}}L.QueryFieldListContext=ag;class Dv extends ge.ParserRuleContext{taggedRef(){return this.tryGetRuleContext(0,jv)}fieldDef(){return this.tryGetRuleContext(0,qd)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryFieldEntry}enterRule(e){e.enterQueryFieldEntry&&e.enterQueryFieldEntry(this)}exitRule(e){e.exitQueryFieldEntry&&e.exitQueryFieldEntry(this)}accept(e){return e.visitQueryFieldEntry?e.visitQueryFieldEntry(this):e.visitChildren(this)}}L.QueryFieldEntryContext=Dv;class zO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}NEST(){return this.getToken(x.NEST,0)}nestedQueryList(){return this.getRuleContext(0,QO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nestStatement}enterRule(e){e.enterNestStatement&&e.enterNestStatement(this)}exitRule(e){e.exitNestStatement&&e.exitNestStatement(this)}accept(e){return e.visitNestStatement?e.visitNestStatement(this):e.visitChildren(this)}}L.NestStatementContext=zO;class QO extends ge.ParserRuleContext{nestEntry(e){return e===void 0?this.getRuleContexts(lg):this.getRuleContext(e,lg)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nestedQueryList}enterRule(e){e.enterNestedQueryList&&e.enterNestedQueryList(this)}exitRule(e){e.exitNestedQueryList&&e.exitNestedQueryList(this)}accept(e){return e.visitNestedQueryList?e.visitNestedQueryList(this):e.visitChildren(this)}}L.NestedQueryListContext=QO;class lg extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nestEntry}copyFrom(e){super.copyFrom(e)}}L.NestEntryContext=lg;class Uq extends lg{tags(){return this.getRuleContext(0,Mt)}vExpr(){return this.getRuleContext(0,u0)}queryName(){return this.tryGetRuleContext(0,av)}isDefine(){return this.tryGetRuleContext(0,Ma)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterNestDef&&e.enterNestDef(this)}exitRule(e){e.exitNestDef&&e.exitNestDef(this)}accept(e){return e.visitNestDef?e.visitNestDef(this):e.visitChildren(this)}}L.NestDefContext=Uq;class GO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}AGGREGATE(){return this.getToken(x.AGGREGATE,0)}queryFieldList(){return this.getRuleContext(0,ag)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregateStatement}enterRule(e){e.enterAggregateStatement&&e.enterAggregateStatement(this)}exitRule(e){e.exitAggregateStatement&&e.exitAggregateStatement(this)}accept(e){return e.visitAggregateStatement?e.visitAggregateStatement(this):e.visitChildren(this)}}L.AggregateStatementContext=GO;class WO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}CALCULATE(){return this.getToken(x.CALCULATE,0)}queryFieldList(){return this.getRuleContext(0,ag)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_calculateStatement}enterRule(e){e.enterCalculateStatement&&e.enterCalculateStatement(this)}exitRule(e){e.exitCalculateStatement&&e.exitCalculateStatement(this)}accept(e){return e.visitCalculateStatement?e.visitCalculateStatement(this):e.visitChildren(this)}}L.CalculateStatementContext=WO;class VO extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldCollection(){return this.getRuleContext(0,pD)}SELECT(){return this.tryGetToken(x.SELECT,0)}PROJECT(){return this.tryGetToken(x.PROJECT,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_projectStatement}enterRule(e){e.enterProjectStatement&&e.enterProjectStatement(this)}exitRule(e){e.exitProjectStatement&&e.exitProjectStatement(this)}accept(e){return e.visitProjectStatement?e.visitProjectStatement(this):e.visitChildren(this)}}L.ProjectStatementContext=VO;class YO extends ge.ParserRuleContext{PARTITION_BY(){return this.getToken(x.PARTITION_BY,0)}id(e){return e===void 0?this.getRuleContexts(pn):this.getRuleContext(e,pn)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partitionByStatement}enterRule(e){e.enterPartitionByStatement&&e.enterPartitionByStatement(this)}exitRule(e){e.exitPartitionByStatement&&e.exitPartitionByStatement(this)}accept(e){return e.visitPartitionByStatement?e.visitPartitionByStatement(this):e.visitChildren(this)}}L.PartitionByStatementContext=YO;class KO extends ge.ParserRuleContext{ORDER_BY(){return this.getToken(x.ORDER_BY,0)}ordering(){return this.getRuleContext(0,JO)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_orderByStatement}enterRule(e){e.enterOrderByStatement&&e.enterOrderByStatement(this)}exitRule(e){e.exitOrderByStatement&&e.exitOrderByStatement(this)}accept(e){return e.visitOrderByStatement?e.visitOrderByStatement(this):e.visitChildren(this)}}L.OrderByStatementContext=KO;class JO extends ge.ParserRuleContext{orderBySpec(e){return e===void 0?this.getRuleContexts(wv):this.getRuleContext(e,wv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ordering}enterRule(e){e.enterOrdering&&e.enterOrdering(this)}exitRule(e){e.exitOrdering&&e.exitOrdering(this)}accept(e){return e.visitOrdering?e.visitOrdering(this):e.visitChildren(this)}}L.OrderingContext=JO;class wv extends ge.ParserRuleContext{INTEGER_LITERAL(){return this.tryGetToken(x.INTEGER_LITERAL,0)}fieldName(){return this.tryGetRuleContext(0,vr)}ASC(){return this.tryGetToken(x.ASC,0)}DESC(){return this.tryGetToken(x.DESC,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_orderBySpec}enterRule(e){e.enterOrderBySpec&&e.enterOrderBySpec(this)}exitRule(e){e.exitOrderBySpec&&e.exitOrderBySpec(this)}accept(e){return e.visitOrderBySpec?e.visitOrderBySpec(this):e.visitChildren(this)}}L.OrderBySpecContext=wv;class Nv extends ge.ParserRuleContext{LIMIT(){return this.getToken(x.LIMIT,0)}INTEGER_LITERAL(){return this.getToken(x.INTEGER_LITERAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_limitStatement}enterRule(e){e.enterLimitStatement&&e.enterLimitStatement(this)}exitRule(e){e.exitLimitStatement&&e.exitLimitStatement(this)}accept(e){return e.visitLimitStatement?e.visitLimitStatement(this):e.visitChildren(this)}}L.LimitStatementContext=Nv;class jq extends ge.ParserRuleContext{BY(){return this.getToken(x.BY,0)}fieldName(){return this.tryGetRuleContext(0,vr)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_bySpec}enterRule(e){e.enterBySpec&&e.enterBySpec(this)}exitRule(e){e.exitBySpec&&e.exitBySpec(this)}accept(e){return e.visitBySpec?e.visitBySpec(this):e.visitChildren(this)}}L.BySpecContext=jq;class XO extends ge.ParserRuleContext{TOP(){return this.getToken(x.TOP,0)}INTEGER_LITERAL(){return this.getToken(x.INTEGER_LITERAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_topStatement}enterRule(e){e.enterTopStatement&&e.enterTopStatement(this)}exitRule(e){e.exitTopStatement&&e.exitTopStatement(this)}accept(e){return e.visitTopStatement?e.visitTopStatement(this):e.visitChildren(this)}}L.TopStatementContext=XO;class Fv extends ge.ParserRuleContext{fieldPath(){return this.tryGetRuleContext(0,Cu)}DOT(){return this.tryGetToken(x.DOT,0)}STAR(){return this.tryGetToken(x.STAR,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_indexElement}enterRule(e){e.enterIndexElement&&e.enterIndexElement(this)}exitRule(e){e.exitIndexElement&&e.exitIndexElement(this)}accept(e){return e.visitIndexElement?e.visitIndexElement(this):e.visitChildren(this)}}L.IndexElementContext=Fv;class ZO extends ge.ParserRuleContext{indexElement(e){return e===void 0?this.getRuleContexts(Fv):this.getRuleContext(e,Fv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_indexFields}enterRule(e){e.enterIndexFields&&e.enterIndexFields(this)}exitRule(e){e.exitIndexFields&&e.exitIndexFields(this)}accept(e){return e.visitIndexFields?e.visitIndexFields(this):e.visitChildren(this)}}L.IndexFieldsContext=ZO;class eD extends ge.ParserRuleContext{INDEX(){return this.getToken(x.INDEX,0)}indexFields(){return this.getRuleContext(0,ZO)}BY(){return this.tryGetToken(x.BY,0)}fieldName(){return this.tryGetRuleContext(0,vr)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_indexStatement}enterRule(e){e.enterIndexStatement&&e.enterIndexStatement(this)}exitRule(e){e.exitIndexStatement&&e.exitIndexStatement(this)}accept(e){return e.visitIndexStatement?e.visitIndexStatement(this):e.visitChildren(this)}}L.IndexStatementContext=eD;class tD extends ge.ParserRuleContext{SAMPLE(){return this.getToken(x.SAMPLE,0)}sampleSpec(){return this.getRuleContext(0,rD)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sampleStatement}enterRule(e){e.enterSampleStatement&&e.enterSampleStatement(this)}exitRule(e){e.exitSampleStatement&&e.exitSampleStatement(this)}accept(e){return e.visitSampleStatement?e.visitSampleStatement(this):e.visitChildren(this)}}L.SampleStatementContext=tD;class Lv extends ge.ParserRuleContext{TIMEZONE(){return this.getToken(x.TIMEZONE,0)}string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_timezoneStatement}enterRule(e){e.enterTimezoneStatement&&e.enterTimezoneStatement(this)}exitRule(e){e.exitTimezoneStatement&&e.exitTimezoneStatement(this)}accept(e){return e.visitTimezoneStatement?e.visitTimezoneStatement(this):e.visitChildren(this)}}L.TimezoneStatementContext=Lv;class nD extends ge.ParserRuleContext{ANNOTATION(){return this.getToken(x.ANNOTATION,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_queryAnnotation}enterRule(e){e.enterQueryAnnotation&&e.enterQueryAnnotation(this)}exitRule(e){e.exitQueryAnnotation&&e.exitQueryAnnotation(this)}accept(e){return e.visitQueryAnnotation?e.visitQueryAnnotation(this):e.visitChildren(this)}}L.QueryAnnotationContext=nD;class rD extends ge.ParserRuleContext{PERCENT_LITERAL(){return this.tryGetToken(x.PERCENT_LITERAL,0)}INTEGER_LITERAL(){return this.tryGetToken(x.INTEGER_LITERAL,0)}TRUE(){return this.tryGetToken(x.TRUE,0)}FALSE(){return this.tryGetToken(x.FALSE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sampleSpec}enterRule(e){e.enterSampleSpec&&e.enterSampleSpec(this)}exitRule(e){e.exitSampleSpec&&e.exitSampleSpec(this)}accept(e){return e.visitSampleSpec?e.visitSampleSpec(this):e.visitChildren(this)}}L.SampleSpecContext=rD;class cg extends ge.ParserRuleContext{SUM(){return this.tryGetToken(x.SUM,0)}COUNT(){return this.tryGetToken(x.COUNT,0)}AVG(){return this.tryGetToken(x.AVG,0)}MIN(){return this.tryGetToken(x.MIN,0)}MAX(){return this.tryGetToken(x.MAX,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_aggregate}enterRule(e){e.enterAggregate&&e.enterAggregate(this)}exitRule(e){e.exitAggregate&&e.exitAggregate(this)}accept(e){return e.visitAggregate?e.visitAggregate(this):e.visitChildren(this)}}L.AggregateContext=cg;class fg extends ge.ParserRuleContext{STRING(){return this.tryGetToken(x.STRING,0)}NUMBER(){return this.tryGetToken(x.NUMBER,0)}BOOLEAN(){return this.tryGetToken(x.BOOLEAN,0)}DATE(){return this.tryGetToken(x.DATE,0)}TIMESTAMP(){return this.tryGetToken(x.TIMESTAMP,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyType}enterRule(e){e.enterMalloyType&&e.enterMalloyType(this)}exitRule(e){e.exitMalloyType&&e.exitMalloyType(this)}accept(e){return e.visitMalloyType?e.visitMalloyType(this):e.visitChildren(this)}}L.MalloyTypeContext=fg;class Iv extends ge.ParserRuleContext{MATCH(){return this.tryGetToken(x.MATCH,0)}NOT_MATCH(){return this.tryGetToken(x.NOT_MATCH,0)}GT(){return this.tryGetToken(x.GT,0)}LT(){return this.tryGetToken(x.LT,0)}GTE(){return this.tryGetToken(x.GTE,0)}LTE(){return this.tryGetToken(x.LTE,0)}EQ(){return this.tryGetToken(x.EQ,0)}NE(){return this.tryGetToken(x.NE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_compareOp}enterRule(e){e.enterCompareOp&&e.enterCompareOp(this)}exitRule(e){e.exitCompareOp&&e.exitCompareOp(this)}accept(e){return e.visitCompareOp?e.visitCompareOp(this):e.visitChildren(this)}}L.CompareOpContext=Iv;class vu extends ge.ParserRuleContext{shortString(){return this.tryGetRuleContext(0,Bv)}sqlString(){return this.tryGetRuleContext(0,nv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_string}enterRule(e){e.enterString&&e.enterString(this)}exitRule(e){e.exitString&&e.exitString(this)}accept(e){return e.visitString?e.visitString(this):e.visitChildren(this)}}L.StringContext=vu;class Bv extends ge.ParserRuleContext{SQ_STRING(){return this.tryGetToken(x.SQ_STRING,0)}DQ_STRING(){return this.tryGetToken(x.DQ_STRING,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_shortString}enterRule(e){e.enterShortString&&e.enterShortString(this)}exitRule(e){e.exitShortString&&e.exitShortString(this)}accept(e){return e.visitShortString?e.visitShortString(this):e.visitChildren(this)}}L.ShortStringContext=Bv;class iD extends ge.ParserRuleContext{NUMERIC_LITERAL(){return this.tryGetToken(x.NUMERIC_LITERAL,0)}INTEGER_LITERAL(){return this.tryGetToken(x.INTEGER_LITERAL,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_numericLiteral}enterRule(e){e.enterNumericLiteral&&e.enterNumericLiteral(this)}exitRule(e){e.exitNumericLiteral&&e.exitNumericLiteral(this)}accept(e){return e.visitNumericLiteral?e.visitNumericLiteral(this):e.visitChildren(this)}}L.NumericLiteralContext=iD;class _u extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_literal}copyFrom(e){super.copyFrom(e)}}L.LiteralContext=_u;class qq extends _u{string(){return this.getRuleContext(0,vu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprString&&e.enterExprString(this)}exitRule(e){e.exitExprString&&e.exitExprString(this)}accept(e){return e.visitExprString?e.visitExprString(this):e.visitChildren(this)}}L.ExprStringContext=qq;class Hq extends _u{numericLiteral(){return this.getRuleContext(0,iD)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNumber&&e.enterExprNumber(this)}exitRule(e){e.exitExprNumber&&e.exitExprNumber(this)}accept(e){return e.visitExprNumber?e.visitExprNumber(this):e.visitChildren(this)}}L.ExprNumberContext=Hq;class zq extends _u{dateLiteral(){return this.getRuleContext(0,Su)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprTime&&e.enterExprTime(this)}exitRule(e){e.exitExprTime&&e.exitExprTime(this)}accept(e){return e.visitExprTime?e.visitExprTime(this):e.visitChildren(this)}}L.ExprTimeContext=zq;class Qq extends _u{NULL(){return this.getToken(x.NULL,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNULL&&e.enterExprNULL(this)}exitRule(e){e.exitExprNULL&&e.exitExprNULL(this)}accept(e){return e.visitExprNULL?e.visitExprNULL(this):e.visitChildren(this)}}L.ExprNULLContext=Qq;class Gq extends _u{TRUE(){return this.tryGetToken(x.TRUE,0)}FALSE(){return this.tryGetToken(x.FALSE,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprBool&&e.enterExprBool(this)}exitRule(e){e.exitExprBool&&e.exitExprBool(this)}accept(e){return e.visitExprBool?e.visitExprBool(this):e.visitChildren(this)}}L.ExprBoolContext=Gq;class Wq extends _u{HACKY_REGEX(){return this.getToken(x.HACKY_REGEX,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprRegex&&e.enterExprRegex(this)}exitRule(e){e.exitExprRegex&&e.exitExprRegex(this)}accept(e){return e.visitExprRegex?e.visitExprRegex(this):e.visitChildren(this)}}L.ExprRegexContext=Wq;class Vq extends _u{NOW(){return this.getToken(x.NOW,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNow&&e.enterExprNow(this)}exitRule(e){e.exitExprNow&&e.exitExprNow(this)}accept(e){return e.visitExprNow?e.visitExprNow(this):e.visitChildren(this)}}L.ExprNowContext=Vq;class Su extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_dateLiteral}copyFrom(e){super.copyFrom(e)}}L.DateLiteralContext=Su;class Yq extends Su{LITERAL_TIMESTAMP(){return this.getToken(x.LITERAL_TIMESTAMP,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralTimestamp&&e.enterLiteralTimestamp(this)}exitRule(e){e.exitLiteralTimestamp&&e.exitLiteralTimestamp(this)}accept(e){return e.visitLiteralTimestamp?e.visitLiteralTimestamp(this):e.visitChildren(this)}}L.LiteralTimestampContext=Yq;class Kq extends Su{LITERAL_HOUR(){return this.getToken(x.LITERAL_HOUR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralHour&&e.enterLiteralHour(this)}exitRule(e){e.exitLiteralHour&&e.exitLiteralHour(this)}accept(e){return e.visitLiteralHour?e.visitLiteralHour(this):e.visitChildren(this)}}L.LiteralHourContext=Kq;class Jq extends Su{LITERAL_DAY(){return this.getToken(x.LITERAL_DAY,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralDay&&e.enterLiteralDay(this)}exitRule(e){e.exitLiteralDay&&e.exitLiteralDay(this)}accept(e){return e.visitLiteralDay?e.visitLiteralDay(this):e.visitChildren(this)}}L.LiteralDayContext=Jq;class Xq extends Su{LITERAL_WEEK(){return this.getToken(x.LITERAL_WEEK,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralWeek&&e.enterLiteralWeek(this)}exitRule(e){e.exitLiteralWeek&&e.exitLiteralWeek(this)}accept(e){return e.visitLiteralWeek?e.visitLiteralWeek(this):e.visitChildren(this)}}L.LiteralWeekContext=Xq;class Zq extends Su{LITERAL_MONTH(){return this.getToken(x.LITERAL_MONTH,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralMonth&&e.enterLiteralMonth(this)}exitRule(e){e.exitLiteralMonth&&e.exitLiteralMonth(this)}accept(e){return e.visitLiteralMonth?e.visitLiteralMonth(this):e.visitChildren(this)}}L.LiteralMonthContext=Zq;class eH extends Su{LITERAL_QUARTER(){return this.getToken(x.LITERAL_QUARTER,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralQuarter&&e.enterLiteralQuarter(this)}exitRule(e){e.exitLiteralQuarter&&e.exitLiteralQuarter(this)}accept(e){return e.visitLiteralQuarter?e.visitLiteralQuarter(this):e.visitChildren(this)}}L.LiteralQuarterContext=eH;class tH extends Su{LITERAL_YEAR(){return this.getToken(x.LITERAL_YEAR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterLiteralYear&&e.enterLiteralYear(this)}exitRule(e){e.exitLiteralYear&&e.exitLiteralYear(this)}accept(e){return e.visitLiteralYear?e.visitLiteralYear(this):e.visitChildren(this)}}L.LiteralYearContext=tH;class sD extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_tablePath}enterRule(e){e.enterTablePath&&e.enterTablePath(this)}exitRule(e){e.exitTablePath&&e.exitTablePath(this)}accept(e){return e.visitTablePath?e.visitTablePath(this):e.visitChildren(this)}}L.TablePathContext=sD;class oD extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_tableURI}enterRule(e){e.enterTableURI&&e.enterTableURI(this)}exitRule(e){e.exitTableURI&&e.exitTableURI(this)}accept(e){return e.visitTableURI?e.visitTableURI(this):e.visitChildren(this)}}L.TableURIContext=oD;class pn extends ge.ParserRuleContext{IDENTIFIER(){return this.tryGetToken(x.IDENTIFIER,0)}BQ_STRING(){return this.tryGetToken(x.BQ_STRING,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_id}enterRule(e){e.enterId&&e.enterId(this)}exitRule(e){e.exitId&&e.exitId(this)}accept(e){return e.visitId?e.visitId(this):e.visitChildren(this)}}L.IdContext=pn;class mf extends ge.ParserRuleContext{SECOND(){return this.tryGetToken(x.SECOND,0)}MINUTE(){return this.tryGetToken(x.MINUTE,0)}HOUR(){return this.tryGetToken(x.HOUR,0)}DAY(){return this.tryGetToken(x.DAY,0)}WEEK(){return this.tryGetToken(x.WEEK,0)}MONTH(){return this.tryGetToken(x.MONTH,0)}QUARTER(){return this.tryGetToken(x.QUARTER,0)}YEAR(){return this.tryGetToken(x.YEAR,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_timeframe}enterRule(e){e.enterTimeframe&&e.enterTimeframe(this)}exitRule(e){e.exitTimeframe&&e.exitTimeframe(this)}accept(e){return e.visitTimeframe?e.visitTimeframe(this):e.visitChildren(this)}}L.TimeframeContext=mf;class uD extends ge.ParserRuleContext{ALL(){return this.tryGetToken(x.ALL,0)}EXCLUDE(){return this.tryGetToken(x.EXCLUDE,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_ungroup}enterRule(e){e.enterUngroup&&e.enterUngroup(this)}exitRule(e){e.exitUngroup&&e.exitUngroup(this)}accept(e){return e.visitUngroup?e.visitUngroup(this):e.visitChildren(this)}}L.UngroupContext=uD;class $v extends ge.ParserRuleContext{malloyType(){return this.tryGetRuleContext(0,fg)}string(){return this.tryGetRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_malloyOrSQLType}enterRule(e){e.enterMalloyOrSQLType&&e.enterMalloyOrSQLType(this)}exitRule(e){e.exitMalloyOrSQLType&&e.exitMalloyOrSQLType(this)}accept(e){return e.visitMalloyOrSQLType?e.visitMalloyOrSQLType(this):e.visitChildren(this)}}L.MalloyOrSQLTypeContext=$v;class be extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldExpr}copyFrom(e){super.copyFrom(e)}}L.FieldExprContext=be;class nH extends be{fieldPath(){return this.getRuleContext(0,Cu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprFieldPath&&e.enterExprFieldPath(this)}exitRule(e){e.exitExprFieldPath&&e.exitExprFieldPath(this)}accept(e){return e.visitExprFieldPath?e.visitExprFieldPath(this):e.visitChildren(this)}}L.ExprFieldPathContext=nH;class rH extends be{literal(){return this.getRuleContext(0,_u)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLiteral&&e.enterExprLiteral(this)}exitRule(e){e.exitExprLiteral&&e.exitExprLiteral(this)}accept(e){return e.visitExprLiteral?e.visitExprLiteral(this):e.visitChildren(this)}}L.ExprLiteralContext=rH;class iH extends be{OBRACK(){return this.getToken(x.OBRACK,0)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}CBRACK(){return this.getToken(x.CBRACK,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprArrayLiteral&&e.enterExprArrayLiteral(this)}exitRule(e){e.exitExprArrayLiteral&&e.exitExprArrayLiteral(this)}accept(e){return e.visitExprArrayLiteral?e.visitExprArrayLiteral(this):e.visitChildren(this)}}L.ExprArrayLiteralContext=iH;class sH extends be{OCURLY(){return this.getToken(x.OCURLY,0)}recordElement(e){return e===void 0?this.getRuleContexts(zd):this.getRuleContext(e,zd)}CCURLY(){return this.getToken(x.CCURLY,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLiteralRecord&&e.enterExprLiteralRecord(this)}exitRule(e){e.exitExprLiteralRecord&&e.exitExprLiteralRecord(this)}accept(e){return e.visitExprLiteralRecord?e.visitExprLiteralRecord(this):e.visitChildren(this)}}L.ExprLiteralRecordContext=sH;class oH extends be{fieldExpr(){return this.getRuleContext(0,be)}fieldProperties(){return this.getRuleContext(0,$O)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprFieldProps&&e.enterExprFieldProps(this)}exitRule(e){e.exitExprFieldProps&&e.exitExprFieldProps(this)}accept(e){return e.visitExprFieldProps?e.visitExprFieldProps(this):e.visitChildren(this)}}L.ExprFieldPropsContext=oH;class uH extends be{fieldExpr(){return this.getRuleContext(0,be)}timeframe(){return this.getRuleContext(0,mf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprDuration&&e.enterExprDuration(this)}exitRule(e){e.exitExprDuration&&e.exitExprDuration(this)}accept(e){return e.visitExprDuration?e.visitExprDuration(this):e.visitChildren(this)}}L.ExprDurationContext=uH;class aH extends be{fieldExpr(){return this.getRuleContext(0,be)}DOT(){return this.getToken(x.DOT,0)}timeframe(){return this.getRuleContext(0,mf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprTimeTrunc&&e.enterExprTimeTrunc(this)}exitRule(e){e.exitExprTimeTrunc&&e.exitExprTimeTrunc(this)}accept(e){return e.visitExprTimeTrunc?e.visitExprTimeTrunc(this):e.visitChildren(this)}}L.ExprTimeTruncContext=aH;class aD extends be{fieldExpr(){return this.getRuleContext(0,be)}DOUBLECOLON(){return this.tryGetToken(x.DOUBLECOLON,0)}malloyOrSQLType(){return this.getRuleContext(0,$v)}CAST(){return this.tryGetToken(x.CAST,0)}OPAREN(){return this.tryGetToken(x.OPAREN,0)}AS(){return this.tryGetToken(x.AS,0)}CPAREN(){return this.tryGetToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCast&&e.enterExprCast(this)}exitRule(e){e.exitExprCast&&e.exitExprCast(this)}accept(e){return e.visitExprCast?e.visitExprCast(this):e.visitChildren(this)}}L.ExprCastContext=aD;class lH extends be{fieldExpr(){return this.getRuleContext(0,be)}TRIPLECOLON(){return this.getToken(x.TRIPLECOLON,0)}malloyOrSQLType(){return this.getRuleContext(0,$v)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprSafeCast&&e.enterExprSafeCast(this)}exitRule(e){e.exitExprSafeCast&&e.exitExprSafeCast(this)}accept(e){return e.visitExprSafeCast?e.visitExprSafeCast(this):e.visitChildren(this)}}L.ExprSafeCastContext=lH;class cH extends be{MINUS(){return this.getToken(x.MINUS,0)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprMinus&&e.enterExprMinus(this)}exitRule(e){e.exitExprMinus&&e.exitExprMinus(this)}accept(e){return e.visitExprMinus?e.visitExprMinus(this):e.visitChildren(this)}}L.ExprMinusContext=cH;class fH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}STAR(){return this.tryGetToken(x.STAR,0)}SLASH(){return this.tryGetToken(x.SLASH,0)}PERCENT(){return this.tryGetToken(x.PERCENT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprMulDiv&&e.enterExprMulDiv(this)}exitRule(e){e.exitExprMulDiv&&e.exitExprMulDiv(this)}accept(e){return e.visitExprMulDiv?e.visitExprMulDiv(this):e.visitChildren(this)}}L.ExprMulDivContext=fH;class xH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}PLUS(){return this.tryGetToken(x.PLUS,0)}MINUS(){return this.tryGetToken(x.MINUS,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAddSub&&e.enterExprAddSub(this)}exitRule(e){e.exitExprAddSub&&e.exitExprAddSub(this)}accept(e){return e.visitExprAddSub?e.visitExprAddSub(this):e.visitChildren(this)}}L.ExprAddSubContext=xH;class dH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}TO(){return this.getToken(x.TO,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprRange&&e.enterExprRange(this)}exitRule(e){e.exitExprRange&&e.exitExprRange(this)}accept(e){return e.visitExprRange?e.visitExprRange(this):e.visitChildren(this)}}L.ExprRangeContext=dH;class hH extends be{FOR(){return this.getToken(x.FOR,0)}timeframe(){return this.getRuleContext(0,mf)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprForRange&&e.enterExprForRange(this)}exitRule(e){e.exitExprForRange&&e.exitExprForRange(this)}accept(e){return e.visitExprForRange?e.visitExprForRange(this):e.visitChildren(this)}}L.ExprForRangeContext=hH;class pH extends be{fieldExpr(){return this.getRuleContext(0,be)}AMPER(){return this.getToken(x.AMPER,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAndTree&&e.enterExprAndTree(this)}exitRule(e){e.exitExprAndTree&&e.exitExprAndTree(this)}accept(e){return e.visitExprAndTree?e.visitExprAndTree(this):e.visitChildren(this)}}L.ExprAndTreeContext=pH;class gH extends be{fieldExpr(){return this.getRuleContext(0,be)}BAR(){return this.getToken(x.BAR,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprOrTree&&e.enterExprOrTree(this)}exitRule(e){e.exitExprOrTree&&e.exitExprOrTree(this)}accept(e){return e.visitExprOrTree?e.visitExprOrTree(this):e.visitChildren(this)}}L.ExprOrTreeContext=gH;class mH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}compareOp(){return this.getRuleContext(0,Iv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCompare&&e.enterExprCompare(this)}exitRule(e){e.exitExprCompare&&e.exitExprCompare(this)}accept(e){return e.visitExprCompare?e.visitExprCompare(this):e.visitChildren(this)}}L.ExprCompareContext=mH;class yH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}LIKE(){return this.getToken(x.LIKE,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprWarnLike&&e.enterExprWarnLike(this)}exitRule(e){e.exitExprWarnLike&&e.exitExprWarnLike(this)}accept(e){return e.visitExprWarnLike?e.visitExprWarnLike(this):e.visitChildren(this)}}L.ExprWarnLikeContext=yH;class EH extends be{fieldExpr(){return this.getRuleContext(0,be)}IS(){return this.getToken(x.IS,0)}NULL(){return this.getToken(x.NULL,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNullCheck&&e.enterExprNullCheck(this)}exitRule(e){e.exitExprNullCheck&&e.exitExprNullCheck(this)}accept(e){return e.visitExprNullCheck?e.visitExprNullCheck(this):e.visitChildren(this)}}L.ExprNullCheckContext=EH;class AH extends be{fieldExpr(){return this.getRuleContext(0,be)}IN(){return this.getToken(x.IN,0)}OPAREN(){return this.getToken(x.OPAREN,0)}fieldExprList(){return this.getRuleContext(0,fD)}CPAREN(){return this.getToken(x.CPAREN,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprWarnIn&&e.enterExprWarnIn(this)}exitRule(e){e.exitExprWarnIn&&e.exitExprWarnIn(this)}accept(e){return e.visitExprWarnIn?e.visitExprWarnIn(this):e.visitChildren(this)}}L.ExprWarnInContext=AH;class vH extends be{fieldExpr(){return this.getRuleContext(0,be)}QMARK(){return this.getToken(x.QMARK,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprApply&&e.enterExprApply(this)}exitRule(e){e.exitExprApply&&e.exitExprApply(this)}accept(e){return e.visitExprApply?e.visitExprApply(this):e.visitChildren(this)}}L.ExprApplyContext=vH;class _H extends be{NOT(){return this.getToken(x.NOT,0)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprNot&&e.enterExprNot(this)}exitRule(e){e.exitExprNot&&e.exitExprNot(this)}accept(e){return e.visitExprNot?e.visitExprNot(this):e.visitChildren(this)}}L.ExprNotContext=_H;class SH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}AND(){return this.getToken(x.AND,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLogicalAnd&&e.enterExprLogicalAnd(this)}exitRule(e){e.exitExprLogicalAnd&&e.exitExprLogicalAnd(this)}accept(e){return e.visitExprLogicalAnd?e.visitExprLogicalAnd(this):e.visitChildren(this)}}L.ExprLogicalAndContext=SH;class CH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}OR(){return this.getToken(x.OR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprLogicalOr&&e.enterExprLogicalOr(this)}exitRule(e){e.exitExprLogicalOr&&e.exitExprLogicalOr(this)}accept(e){return e.visitExprLogicalOr?e.visitExprLogicalOr(this):e.visitChildren(this)}}L.ExprLogicalOrContext=CH;class bH extends be{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}DOUBLE_QMARK(){return this.getToken(x.DOUBLE_QMARK,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCoalesce&&e.enterExprCoalesce(this)}exitRule(e){e.exitExprCoalesce&&e.exitExprCoalesce(this)}accept(e){return e.visitExprCoalesce?e.visitExprCoalesce(this):e.visitChildren(this)}}L.ExprCoalesceContext=bH;class TH extends be{aggregate(){return this.getRuleContext(0,cg)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}SOURCE_KW(){return this.tryGetToken(x.SOURCE_KW,0)}DOT(){return this.tryGetToken(x.DOT,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}STAR(){return this.tryGetToken(x.STAR,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprPathlessAggregate&&e.enterExprPathlessAggregate(this)}exitRule(e){e.exitExprPathlessAggregate&&e.exitExprPathlessAggregate(this)}accept(e){return e.visitExprPathlessAggregate?e.visitExprPathlessAggregate(this):e.visitChildren(this)}}L.ExprPathlessAggregateContext=TH;class RH extends be{fieldPath(){return this.getRuleContext(0,Cu)}DOT(){return this.getToken(x.DOT,0)}aggregate(){return this.getRuleContext(0,cg)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAggregate&&e.enterExprAggregate(this)}exitRule(e){e.exitExprAggregate&&e.exitExprAggregate(this)}accept(e){return e.visitExprAggregate?e.visitExprAggregate(this):e.visitChildren(this)}}L.ExprAggregateContext=RH;class OH extends be{OPAREN(){return this.getToken(x.OPAREN,0)}fieldExpr(){return this.getRuleContext(0,be)}CPAREN(){return this.getToken(x.CPAREN,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprExpr&&e.enterExprExpr(this)}exitRule(e){e.exitExprExpr&&e.exitExprExpr(this)}accept(e){return e.visitExprExpr?e.visitExprExpr(this):e.visitChildren(this)}}L.ExprExprContext=OH;class DH extends be{fieldPath(){return this.getRuleContext(0,Cu)}DOT(){return this.getToken(x.DOT,0)}id(){return this.getRuleContext(0,pn)}OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}argumentList(){return this.tryGetRuleContext(0,Pv)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprAggFunc&&e.enterExprAggFunc(this)}exitRule(e){e.exitExprAggFunc&&e.exitExprAggFunc(this)}accept(e){return e.visitExprAggFunc?e.visitExprAggFunc(this):e.visitChildren(this)}}L.ExprAggFuncContext=DH;class wH extends be{OPAREN(){return this.getToken(x.OPAREN,0)}CPAREN(){return this.getToken(x.CPAREN,0)}timeframe(){return this.tryGetRuleContext(0,mf)}id(){return this.tryGetRuleContext(0,pn)}argumentList(){return this.tryGetRuleContext(0,Pv)}EXCLAM(){return this.tryGetToken(x.EXCLAM,0)}malloyType(){return this.tryGetRuleContext(0,fg)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprFunc&&e.enterExprFunc(this)}exitRule(e){e.exitExprFunc&&e.exitExprFunc(this)}accept(e){return e.visitExprFunc?e.visitExprFunc(this):e.visitChildren(this)}}L.ExprFuncContext=wH;class NH extends be{pickStatement(){return this.getRuleContext(0,xD)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprPick&&e.enterExprPick(this)}exitRule(e){e.exitExprPick&&e.exitExprPick(this)}accept(e){return e.visitExprPick?e.visitExprPick(this):e.visitChildren(this)}}L.ExprPickContext=NH;class FH extends be{caseStatement(){return this.getRuleContext(0,dD)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprCase&&e.enterExprCase(this)}exitRule(e){e.exitExprCase&&e.exitExprCase(this)}accept(e){return e.visitExprCase?e.visitExprCase(this):e.visitChildren(this)}}L.ExprCaseContext=FH;class LH extends be{ungroup(){return this.getRuleContext(0,uD)}OPAREN(){return this.getToken(x.OPAREN,0)}fieldExpr(){return this.getRuleContext(0,be)}CPAREN(){return this.getToken(x.CPAREN,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterExprUngroup&&e.enterExprUngroup(this)}exitRule(e){e.exitExprUngroup&&e.exitExprUngroup(this)}accept(e){return e.visitExprUngroup?e.visitExprUngroup(this):e.visitChildren(this)}}L.ExprUngroupContext=LH;class lD extends ge.ParserRuleContext{compareOp(){return this.getRuleContext(0,Iv)}fieldExpr(){return this.getRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partialCompare}enterRule(e){e.enterPartialCompare&&e.enterPartialCompare(this)}exitRule(e){e.exitPartialCompare&&e.exitPartialCompare(this)}accept(e){return e.visitPartialCompare?e.visitPartialCompare(this):e.visitChildren(this)}}L.PartialCompareContext=lD;class cD extends ge.ParserRuleContext{partialCompare(){return this.tryGetRuleContext(0,lD)}IS(){return this.tryGetToken(x.IS,0)}NULL(){return this.tryGetToken(x.NULL,0)}NOT(){return this.tryGetToken(x.NOT,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partialTest}enterRule(e){e.enterPartialTest&&e.enterPartialTest(this)}exitRule(e){e.exitPartialTest&&e.exitPartialTest(this)}accept(e){return e.visitPartialTest?e.visitPartialTest(this):e.visitChildren(this)}}L.PartialTestContext=cD;class yf extends ge.ParserRuleContext{partialTest(){return this.tryGetRuleContext(0,cD)}OPAREN(){return this.tryGetToken(x.OPAREN,0)}CPAREN(){return this.tryGetToken(x.CPAREN,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_partialAllowedFieldExpr}enterRule(e){e.enterPartialAllowedFieldExpr&&e.enterPartialAllowedFieldExpr(this)}exitRule(e){e.exitPartialAllowedFieldExpr&&e.exitPartialAllowedFieldExpr(this)}accept(e){return e.visitPartialAllowedFieldExpr?e.visitPartialAllowedFieldExpr(this):e.visitChildren(this)}}L.PartialAllowedFieldExprContext=yf;class fD extends ge.ParserRuleContext{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldExprList}enterRule(e){e.enterFieldExprList&&e.enterFieldExprList(this)}exitRule(e){e.exitFieldExprList&&e.exitFieldExprList(this)}accept(e){return e.visitFieldExprList?e.visitFieldExprList(this):e.visitChildren(this)}}L.FieldExprListContext=fD;class xD extends ge.ParserRuleContext{pick(e){return e===void 0?this.getRuleContexts(kv):this.getRuleContext(e,kv)}ELSE(){return this.tryGetToken(x.ELSE,0)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_pickStatement}enterRule(e){e.enterPickStatement&&e.enterPickStatement(this)}exitRule(e){e.exitPickStatement&&e.exitPickStatement(this)}accept(e){return e.visitPickStatement?e.visitPickStatement(this):e.visitChildren(this)}}L.PickStatementContext=xD;class kv extends ge.ParserRuleContext{PICK(){return this.getToken(x.PICK,0)}WHEN(){return this.getToken(x.WHEN,0)}partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}fieldExpr(){return this.tryGetRuleContext(0,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_pick}enterRule(e){e.enterPick&&e.enterPick(this)}exitRule(e){e.exitPick&&e.exitPick(this)}accept(e){return e.visitPick?e.visitPick(this):e.visitChildren(this)}}L.PickContext=kv;class dD extends ge.ParserRuleContext{CASE(){return this.getToken(x.CASE,0)}END(){return this.getToken(x.END,0)}caseWhen(e){return e===void 0?this.getRuleContexts(Mv):this.getRuleContext(e,Mv)}ELSE(){return this.tryGetToken(x.ELSE,0)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_caseStatement}enterRule(e){e.enterCaseStatement&&e.enterCaseStatement(this)}exitRule(e){e.exitCaseStatement&&e.exitCaseStatement(this)}accept(e){return e.visitCaseStatement?e.visitCaseStatement(this):e.visitChildren(this)}}L.CaseStatementContext=dD;class Mv extends ge.ParserRuleContext{WHEN(){return this.getToken(x.WHEN,0)}THEN(){return this.getToken(x.THEN,0)}fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_caseWhen}enterRule(e){e.enterCaseWhen&&e.enterCaseWhen(this)}exitRule(e){e.exitCaseWhen&&e.exitCaseWhen(this)}accept(e){return e.visitCaseWhen?e.visitCaseWhen(this):e.visitChildren(this)}}L.CaseWhenContext=Mv;class hD extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_recordKey}enterRule(e){e.enterRecordKey&&e.enterRecordKey(this)}exitRule(e){e.exitRecordKey&&e.exitRecordKey(this)}accept(e){return e.visitRecordKey?e.visitRecordKey(this):e.visitChildren(this)}}L.RecordKeyContext=hD;class zd extends ge.ParserRuleContext{constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_recordElement}copyFrom(e){super.copyFrom(e)}}L.RecordElementContext=zd;class IH extends zd{fieldPath(){return this.getRuleContext(0,Cu)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterRecordRef&&e.enterRecordRef(this)}exitRule(e){e.exitRecordRef&&e.exitRecordRef(this)}accept(e){return e.visitRecordRef?e.visitRecordRef(this):e.visitChildren(this)}}L.RecordRefContext=IH;class BH extends zd{fieldExpr(){return this.getRuleContext(0,be)}recordKey(){return this.tryGetRuleContext(0,hD)}IS(){return this.tryGetToken(x.IS,0)}constructor(e){super(e.parent,e.invokingState),this.copyFrom(e)}enterRule(e){e.enterRecordExpr&&e.enterRecordExpr(this)}exitRule(e){e.exitRecordExpr&&e.exitRecordExpr(this)}accept(e){return e.visitRecordExpr?e.visitRecordExpr(this):e.visitChildren(this)}}L.RecordExprContext=BH;class Pv extends ge.ParserRuleContext{fieldExpr(e){return e===void 0?this.getRuleContexts(be):this.getRuleContext(e,be)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_argumentList}enterRule(e){e.enterArgumentList&&e.enterArgumentList(this)}exitRule(e){e.exitArgumentList&&e.exitArgumentList(this)}accept(e){return e.visitArgumentList?e.visitArgumentList(this):e.visitChildren(this)}}L.ArgumentListContext=Pv;class Qd extends ge.ParserRuleContext{fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldNameList}enterRule(e){e.enterFieldNameList&&e.enterFieldNameList(this)}exitRule(e){e.exitFieldNameList&&e.exitFieldNameList(this)}accept(e){return e.visitFieldNameList?e.visitFieldNameList(this):e.visitChildren(this)}}L.FieldNameListContext=Qd;class pD extends ge.ParserRuleContext{collectionMember(e){return e===void 0?this.getRuleContexts(qv):this.getRuleContext(e,qv)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldCollection}enterRule(e){e.enterFieldCollection&&e.enterFieldCollection(this)}exitRule(e){e.exitFieldCollection&&e.exitFieldCollection(this)}accept(e){return e.visitFieldCollection?e.visitFieldCollection(this):e.visitChildren(this)}}L.FieldCollectionContext=pD;class xg extends ge.ParserRuleContext{STAR(){return this.getToken(x.STAR,0)}fieldPath(){return this.tryGetRuleContext(0,Cu)}DOT(){return this.tryGetToken(x.DOT,0)}starQualified(){return this.tryGetRuleContext(0,Uv)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_collectionWildCard}enterRule(e){e.enterCollectionWildCard&&e.enterCollectionWildCard(this)}exitRule(e){e.exitCollectionWildCard&&e.exitCollectionWildCard(this)}accept(e){return e.visitCollectionWildCard?e.visitCollectionWildCard(this):e.visitChildren(this)}}L.CollectionWildCardContext=xg;class Uv extends ge.ParserRuleContext{OCURLY(){return this.getToken(x.OCURLY,0)}CCURLY(){return this.getToken(x.CCURLY,0)}COMMA(e){return e===void 0?this.getTokens(x.COMMA):this.getToken(x.COMMA,e)}EXCEPT(e){return e===void 0?this.getTokens(x.EXCEPT):this.getToken(x.EXCEPT,e)}fieldNameList(e){return e===void 0?this.getRuleContexts(Qd):this.getRuleContext(e,Qd)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_starQualified}enterRule(e){e.enterStarQualified&&e.enterStarQualified(this)}exitRule(e){e.exitStarQualified&&e.exitStarQualified(this)}accept(e){return e.visitStarQualified?e.visitStarQualified(this):e.visitChildren(this)}}L.StarQualifiedContext=Uv;class jv extends ge.ParserRuleContext{tags(){return this.getRuleContext(0,Mt)}fieldPath(){return this.getRuleContext(0,Cu)}refExpr(){return this.tryGetRuleContext(0,gD)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_taggedRef}enterRule(e){e.enterTaggedRef&&e.enterTaggedRef(this)}exitRule(e){e.exitTaggedRef&&e.exitTaggedRef(this)}accept(e){return e.visitTaggedRef?e.visitTaggedRef(this):e.visitChildren(this)}}L.TaggedRefContext=jv;class gD extends ge.ParserRuleContext{DOT(){return this.getToken(x.DOT,0)}timeframe(){return this.tryGetRuleContext(0,mf)}aggregate(){return this.tryGetRuleContext(0,cg)}OPAREN(){return this.tryGetToken(x.OPAREN,0)}CPAREN(){return this.tryGetToken(x.CPAREN,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_refExpr}enterRule(e){e.enterRefExpr&&e.enterRefExpr(this)}exitRule(e){e.exitRefExpr&&e.exitRefExpr(this)}accept(e){return e.visitRefExpr?e.visitRefExpr(this):e.visitChildren(this)}}L.RefExprContext=gD;class qv extends ge.ParserRuleContext{taggedRef(){return this.tryGetRuleContext(0,jv)}collectionWildCard(){return this.tryGetRuleContext(0,xg)}fieldDef(){return this.tryGetRuleContext(0,qd)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_collectionMember}enterRule(e){e.enterCollectionMember&&e.enterCollectionMember(this)}exitRule(e){e.exitCollectionMember&&e.exitCollectionMember(this)}accept(e){return e.visitCollectionMember?e.visitCollectionMember(this):e.visitChildren(this)}}L.CollectionMemberContext=qv;class Cu extends ge.ParserRuleContext{fieldName(e){return e===void 0?this.getRuleContexts(vr):this.getRuleContext(e,vr)}DOT(e){return e===void 0?this.getTokens(x.DOT):this.getToken(x.DOT,e)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldPath}enterRule(e){e.enterFieldPath&&e.enterFieldPath(this)}exitRule(e){e.exitFieldPath&&e.exitFieldPath(this)}accept(e){return e.visitFieldPath?e.visitFieldPath(this):e.visitChildren(this)}}L.FieldPathContext=Cu;class $H extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_joinName}enterRule(e){e.enterJoinName&&e.enterJoinName(this)}exitRule(e){e.exitJoinName&&e.exitJoinName(this)}accept(e){return e.visitJoinName?e.visitJoinName(this):e.visitChildren(this)}}L.JoinNameContext=$H;class vr extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_fieldName}enterRule(e){e.enterFieldName&&e.enterFieldName(this)}exitRule(e){e.exitFieldName&&e.exitFieldName(this)}accept(e){return e.visitFieldName?e.visitFieldName(this):e.visitChildren(this)}}L.FieldNameContext=vr;class kH extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_sqlExploreNameRef}enterRule(e){e.enterSqlExploreNameRef&&e.enterSqlExploreNameRef(this)}exitRule(e){e.exitSqlExploreNameRef&&e.exitSqlExploreNameRef(this)}accept(e){return e.visitSqlExploreNameRef?e.visitSqlExploreNameRef(this):e.visitChildren(this)}}L.SqlExploreNameRefContext=kH;class MH extends ge.ParserRuleContext{id(){return this.getRuleContext(0,pn)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_nameSQLBlock}enterRule(e){e.enterNameSQLBlock&&e.enterNameSQLBlock(this)}exitRule(e){e.exitNameSQLBlock&&e.exitNameSQLBlock(this)}accept(e){return e.visitNameSQLBlock?e.visitNameSQLBlock(this):e.visitChildren(this)}}L.NameSQLBlockContext=MH;class PH extends ge.ParserRuleContext{string(){return this.getRuleContext(0,vu)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_connectionName}enterRule(e){e.enterConnectionName&&e.enterConnectionName(this)}exitRule(e){e.exitConnectionName&&e.exitConnectionName(this)}accept(e){return e.visitConnectionName?e.visitConnectionName(this):e.visitChildren(this)}}L.ConnectionNameContext=PH;class UH extends ge.ParserRuleContext{fieldExpr(){return this.getRuleContext(0,be)}EOF(){return this.getToken(x.EOF,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_debugExpr}enterRule(e){e.enterDebugExpr&&e.enterDebugExpr(this)}exitRule(e){e.exitDebugExpr&&e.exitDebugExpr(this)}accept(e){return e.visitDebugExpr?e.visitDebugExpr(this):e.visitChildren(this)}}L.DebugExprContext=UH;class jH extends ge.ParserRuleContext{partialAllowedFieldExpr(){return this.getRuleContext(0,yf)}EOF(){return this.getToken(x.EOF,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_debugPartial}enterRule(e){e.enterDebugPartial&&e.enterDebugPartial(this)}exitRule(e){e.exitDebugPartial&&e.exitDebugPartial(this)}accept(e){return e.visitDebugPartial?e.visitDebugPartial(this):e.visitChildren(this)}}L.DebugPartialContext=jH;class mD extends ge.ParserRuleContext{SEMI(e){return e===void 0?this.getTokens(x.SEMI):this.getToken(x.SEMI,e)}OBRACK(){return this.getToken(x.OBRACK,0)}string(){return this.getRuleContext(0,vu)}CBRACK(){return this.getToken(x.CBRACK,0)}constructor(e,n){super(e,n)}get ruleIndex(){return x.RULE_experimentalStatementForTesting}enterRule(e){e.enterExperimentalStatementForTesting&&e.enterExperimentalStatementForTesting(this)}exitRule(e){e.exitExperimentalStatementForTesting&&e.exitExperimentalStatementForTesting(this)}accept(e){return e.visitExperimentalStatementForTesting?e.visitExperimentalStatementForTesting(this):e.visitChildren(this)}}L.ExperimentalStatementForTestingContext=mD;var Hv={},dg={},Gd={};Object.defineProperty(Gd,"__esModule",{value:!0}),Gd.detectAndRemovePartialStages=void 0;const Eme=ts;function Ame(t,e){const n=[];let r=!1;for(const i of t)(0,Eme.isPartialSegment)(i)?(n.push({...i,type:"reduce"}),r=!0):n.push(i);return r&&e.logError("ambiguous-view-type",{}),n}Gd.detectAndRemovePartialStages=Ame;var hg={},Ye={},pg={},at={},bu={};Object.defineProperty(bu,"__esModule",{value:!0}),bu.isNotUndefined=bu.locationContainsPosition=void 0;function vme(t,e){return t.range.start.line<=e.line&&t.range.end.line>=e.line&&(e.line!==t.range.start.line||e.character>=t.range.start.character)&&(e.line!==t.range.end.line||e.character<=t.range.end.character)}bu.locationContainsPosition=vme;function _me(t){return t!==void 0}bu.isNotUndefined=_me,Object.defineProperty(at,"__esModule",{value:!0}),at.compositeFieldUsageJoinPaths=at.joinedCompositeFieldUsage=at.compositeFieldUsageDifference=at.emptyCompositeFieldUsage=at.mergeCompositeFieldUsage=at.unique=at.formatCompositeFieldUsage=at.compositeFieldUsageIsPlural=at.isEmptyCompositeFieldUsage=at.formatCompositeFieldUsages=at.compositeFieldUsagePaths=at.resolveCompositeSources=at.narrowCompositeFieldResolution=at.emptyNarrowedCompositeFieldResolution=void 0;const qH=bu,yD=Ke;function zv(t,e,n,r=void 0){var i,s,o,u,a,l,c;let f={...e},d;const h=Nme(e);if(n.fields.length>0||e.type==="composite")if(e.type==="composite"){let g=!1;d=(i=r==null?void 0:r.source)!==null&&i!==void 0?i:e.sources.map(E=>({source:E,nested:void 0}));const y=[...d];e:for(const{source:E,nested:A}of d){const v=new Set;for(const _ of E.fields)_.accessModifier!=="private"&&v.add((s=_.as)!==null&&s!==void 0?s:_.name);for(const _ of n.fields)if(!v.has(_)){y.shift();continue e}if(E.type==="composite"){const _=zv(t,E,Fme(n,E),{source:A??E.sources.map(S=>({source:S,nested:[]})),joined:{}});if("error"in _){y.shift();continue e}f={..._.success},y[0]={source:E,nested:_.narrowedCompositeFieldResolution.source}}else f={...E};g=!0,f={...f,fields:[...h,...f.fields],filterList:[...(o=e.filterList)!==null&&o!==void 0?o:[],...(u=f.filterList)!==null&&u!==void 0?u:[]]};break}if(!g)return{error:{code:"no_suitable_composite_source_input",data:{fields:n.fields,path:t}}};d=y}else return{error:{code:"not_a_composite_source",data:{path:t}}};f.arguments=e.arguments;const p={},m=(a=r==null?void 0:r.joined)!==null&&a!==void 0?a:{};for(const g of f.fields)p[(l=g.as)!==null&&l!==void 0?l:g.name]=g;for(const[g,y]of Object.entries(n.joinedUsage)){const E=p[g],A=[...t,g];if(E===void 0)return{error:{code:"composite_source_not_defined",data:{path:A}}};if((0,yD.isJoined)(E)){if(!(0,yD.isSourceDef)(E))continue}else return{error:{code:"composite_source_not_a_join",data:{path:A}}};const v=zv(A,E,y,m[g]);if("error"in v)return v;if(!(0,yD.isJoinable)(v.success))return{error:{code:"composite_source_is_not_joinable",data:{path:A}}};p[g]={...v.success,join:E.join,as:(c=E.as)!==null&&c!==void 0?c:E.name,onExpression:E.onExpression},m[g]=v.narrowedCompositeFieldResolution}return{success:{...f,fields:Object.values(p)},narrowedCompositeFieldResolution:{source:d,joined:m}}}function Sme(){return{source:void 0,joined:{}}}at.emptyNarrowedCompositeFieldResolution=Sme;function Cme(t,e,n){const r=zv([],t,e,n);return"success"in r?{narrowedCompositeFieldResolution:r.narrowedCompositeFieldResolution,error:void 0}:{narrowedCompositeFieldResolution:void 0,error:r.error}}at.narrowCompositeFieldResolution=Cme;function bme(t,e){const n=zv([],t,e);return"success"in n?{sourceDef:n.success,error:void 0}:{sourceDef:void 0,error:n.error}}at.resolveCompositeSources=bme;function ED(t){return[...t.fields.map(e=>[e]),...Object.entries(t.joinedUsage).map(([e,n])=>ED(n).map(r=>[e,...r])).flat()]}at.compositeFieldUsagePaths=ED;function Tme(t){return ED(t).map(e=>HH(e)).join(", ")}at.formatCompositeFieldUsages=Tme;function AD(t){return Object.values(t.joinedUsage).reduce((e,n)=>e+AD(n),t.fields.length)}function Rme(t){return AD(t)===0}at.isEmptyCompositeFieldUsage=Rme;function Ome(t){return AD(t)>1}at.compositeFieldUsageIsPlural=Ome;function HH(t){return`\`${t.join(".")}\``}at.formatCompositeFieldUsage=HH;function zH(t){return Array.from(new Set(t))}at.unique=zH;function QH(...t){const e=t.filter(qH.isNotUndefined),n=new Set(e.map(i=>Object.keys(i.joinedUsage)).flat()),r={};for(const i of n)r[i]=QH(...e.map(s=>s==null?void 0:s.joinedUsage[i]).filter(qH.isNotUndefined));return{fields:zH(e.map(i=>i.fields).flat()),joinedUsage:r}}at.mergeCompositeFieldUsage=QH;function Dme(){return{fields:[],joinedUsage:{}}}at.emptyCompositeFieldUsage=Dme;function wme(t,e){const n=new Set(e),r=[];for(const i of t)n.has(i)||r.push(i);return r}function GH(t,e){return{fields:wme(t.fields,e.fields),joinedUsage:Object.fromEntries(Object.entries(t.joinedUsage).map(([n,r])=>[n,n in e.joinedUsage?GH(r,e.joinedUsage[n]):r]))}}at.compositeFieldUsageDifference=GH;function WH(t,e){return t.length===0?e:WH(t.slice(0,-1),{fields:[],joinedUsage:{[t[t.length-1]]:e}})}at.joinedCompositeFieldUsage=WH;function VH(t){const e=Object.keys(t.joinedUsage);return[...e.map(n=>[n]),...e.map(n=>VH(t.joinedUsage[n]).map(r=>[n,...r])).flat()]}at.compositeFieldUsageJoinPaths=VH;function YH(t){var e;return"e"in t&&((e=t.e)===null||e===void 0?void 0:e.node)==="compositeField"}function Nme(t){return t.fields.filter(e=>!YH(e))}function Fme(t,e){var n;const r={};for(const i of e.fields)r[(n=i.as)!==null&&n!==void 0?n:i.name]=i;return{fields:t.fields.filter(i=>YH(r[i])),joinedUsage:{}}}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.makeLogMessage=t.MESSAGE_FORMATTERS=t.BaseMessageLogger=void 0;const e=at;class n{constructor(s){this.eventStream=s,this.rawLog=[]}getLog(){return this.rawLog}log(s){var o;this.rawLog.push(s),(o=this.eventStream)===null||o===void 0||o.emit(`translation-${s.severity}`,{code:s.code,data:s.data,message:s.message})}reset(){this.rawLog.length=0}noErrors(){return!this.hasErrors()}hasErrors(){return this.rawLog.find(o=>o.severity!=="warn")!==void 0}empty(){return this.rawLog.length===0}}t.BaseMessageLogger=n,t.MESSAGE_FORMATTERS={"pick-type-does-not-match":i=>({message:`pick type \`${i.pickType}\` does not match return type \`${i.returnType}\``,tag:"pick-values-must-match"}),"pick-else-type-does-not-match":i=>({message:`else type \`${i.elseType}\` does not match return type \`${i.returnType}\``,tag:"pick-values-must-match"}),"pick-default-type-does-not-match":i=>({message:`default type \`${i.defaultType}\` does not match return type \`${i.returnType}\``,tag:"pick-values-must-match"}),"experimental-dialect-not-enabled":i=>`Requires compiler flag '##! experimental.dialect.${i.dialect}'`,"pick-missing-else":"pick incomplete, missing 'else'","pick-missing-value":"pick with no value can only be used with apply","pick-illegal-partial":"pick with partial when can only be used with apply","pick-when-must-be-boolean":i=>`when expression must be boolean, not ${i.whenType}`,"sql-native-not-allowed-in-expression":i=>({message:`Unsupported SQL native type '${i.rawType}' not allowed in expression`,tag:"unsupported-sql-native-type-not-allowed-in-expression"}),"experiment-not-enabled":i=>`Experimental flag \`${i.experimentId}\` is not set, feature not available`,"ambiguous-view-type":"Can't determine view type (`group_by` / `aggregate` / `nest`, `project`, `index`)","import-error":i=>i.message.includes(i.url)?`import error: ${i.message}`:`import '${i.url}' error: ${i.message}`,"parsed-non-malloy-document":i=>`'${i.url}' did not parse to malloy document`,"parse-exception":i=>`Malloy internal parser exception [${i.message}]`,"syntax-error":i=>i.message,"internal-translator-error":i=>`Internal Translator Error: ${i.message}`,"invalid-timezone":i=>`Invalid timezone: ${i.timezone}`,"case-then-type-does-not-match":i=>`Case then type ${i.thenType} does not match return type ${i.returnType}`,"case-else-type-does-not-match":i=>`Case else type ${i.elseType} does not match return type ${i.returnType}`,"case-when-must-be-boolean":i=>`Case when expression must be boolean, not ${i.whenType}`,"case-when-type-does-not-match":i=>`Case when type ${i.whenType} does not match value type ${i.valueType}`,"invalid-composite-field-usage":i=>{const s=(0,e.formatCompositeFieldUsages)(i.newUsage),o=(0,e.formatCompositeFieldUsages)(i.allUsage);return`This operation uses composite field${(0,e.compositeFieldUsageIsPlural)(i.newUsage)?"s":""} ${s}, resulting in invalid usage of the composite source, as there is no composite input source which defines all of ${o}`}};function r(i,s,o){var u,a,l,c,f;const d=t.MESSAGE_FORMATTERS[i],h=d?d instanceof Function?d(s):d:typeof s=="string"?s:void 0;if(h===void 0)throw new Error(`No message formatter for error code \`${i}\`.`);const p=typeof h=="string"?{message:h}:h,m=((u=p.data)!==null&&u!==void 0?u:typeof s=="string")?null:s;return{code:i,data:m,message:p.message,severity:(l=(a=o==null?void 0:o.severity)!==null&&a!==void 0?a:p.severity)!==null&&l!==void 0?l:"error",errorTag:(c=o==null?void 0:o.tag)!==null&&c!==void 0?c:p.tag,replacement:(f=o==null?void 0:o.replacement)!==null&&f!==void 0?f:p.replacement,at:o==null?void 0:o.at}}t.makeLogMessage=r})(pg);var fs={};Object.defineProperty(fs,"__esModule",{value:!0}),fs.errorFor=void 0;const Lme=at;function Ime(t){return{type:"error",expressionType:"scalar",value:{node:"error",message:t},evalSpace:"constant",compositeFieldUsage:(0,Lme.emptyCompositeFieldUsage)()}}fs.errorFor=Ime;var Qv={};Object.defineProperty(Qv,"__esModule",{value:!0}),Qv.DialectNameSpace=void 0;class Bme{constructor(e){this.entries=new Map;const n=e.getDialectFunctions();for(const r in n){const i=n[r];this.entries.set(r,{type:"function",name:r,overloads:i.map(s=>({returnType:s.returnType,params:s.params,supportsOrderBy:s.supportsOrderBy,supportsLimit:s.supportsLimit,isSymmetric:s.isSymmetric,genericTypes:s.genericTypes,dialect:{[e.name]:{e:s.e,defaultOrderByArgIndex:s.defaultOrderByArgIndex,between:s.between,needsWindowOrderBy:s.needsWindowOrderBy}}}))})}}getEntry(e){const n=this.entries.get(e);if(n!==void 0)return{entry:n,exported:!1}}setEntry(e,n,r){throw new Error("The dialect namespace is immutable!")}}Qv.DialectNameSpace=Bme;var Wd={};Object.defineProperty(Wd,"__esModule",{value:!0}),Wd.getDialectFunctions=Wd.GlobalNameSpace=void 0;const $me=ed,kme=ou,Mme=ts;class Pme{constructor(){this.entries=KH()}getEntry(e){const n=this.entries.get(e);if(n!==void 0)return{entry:n,exported:!1}}setEntry(e,n,r){throw new Error("The global namespace is immutable!")}}Wd.GlobalNameSpace=Pme;function Ume(t,e){return t.params.length===e.params.length&&t.params.every((n,r)=>{const i=e.params[r];return n.isVariadic===i.isVariadic&&n.name===i.name&&n.allowedTypes.length===i.allowedTypes.length&&n.allowedTypes.every(s=>i.allowedTypes.some(o=>Mme.TD.eq(s,o)&&s.expressionType===o.expressionType))})}function KH(){var t,e;const n=(0,$me.getMalloyStandardFunctions)(),r={},i=(0,kme.getDialects)();for(const o of i)r[o.name]=o.getDialectFunctionOverrides();const s=new Map;for(const o in n){const u=n[o],a={type:"function",name:o,overloads:[]};for(const l of u){const c={returnType:l.returnType,params:l.params,dialect:{},supportsOrderBy:l.supportsOrderBy,supportsLimit:l.supportsLimit,genericTypes:l.genericTypes,isSymmetric:l.isSymmetric};for(const f of i){const h=(e=((t=r[f.name][o])!==null&&t!==void 0?t:[]).find(p=>Ume(p,c)))!==null&&e!==void 0?e:l;c.dialect[f.name]={e:h.e,needsWindowOrderBy:h.needsWindowOrderBy,between:h.between,defaultOrderByArgIndex:h.defaultOrderByArgIndex}}a.overloads.push(c)}s.set(o,a)}return s}Wd.getDialectFunctions=KH;var _r={};Object.defineProperty(_r,"__esModule",{value:!0}),_r.extendNoteHelper=_r.extendNoteMethod=_r.isNoteable=void 0;function jme(t){return t.isNoteableObj}_r.isNoteable=jme;function qme(t){JH(this,t)}_r.extendNoteMethod=qme;function JH(t,e){(e.notes&&e.notes.length>0||e.blockNotes&&e.blockNotes.length>0||e.inherits!==void 0)&&(t.note={...t.note,...e})}_r.extendNoteHelper=JH,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.Document=Ye.DocStatementList=Ye.ListOf=Ye.isDocStatementOrDocStatementList=Ye.isDocStatement=Ye.ExperimentalExperiment=Ye.ModelEntryReference=Ye.Unimplemented=Ye.MalloyElement=void 0;const XH=ed,Gv=Ke,Hme=fo,zme=pg,Qme=fs,Gme=Qv,Wme=Wd,ZH=_r,Vme=xp;class Tu{constructor(e){this.children={},this.parent=null,this.logged=new Set,e&&this.has(e)}has(e){for(const n in e){const r=e[n];if(r!==void 0)if(this.children[n]=r,r instanceof Tu)r.parent=this;else for(const i of r)i.parent=this}}get location(){return this.codeLocation?this.codeLocation:this.parent?this.parent.location:{url:this.sourceURL,range:{start:{line:0,character:0},end:{line:0,character:0}}}}set location(e){this.codeLocation=e}get code(){var e,n;return(n=(e=this.translator())===null||e===void 0?void 0:e.codeAtLocation(this.location))!==null&&n!==void 0?n:""}document(){var e;return this instanceof _D?this:(e=this.parent)===null||e===void 0?void 0:e.document()}namespace(){if(this instanceof _D)return this;if(this.parent)return this.parent.namespace();throw new Error("INTERNAL ERROR: Translation without document scope")}getDialectNamespace(e){var n;return(n=this.document())===null||n===void 0?void 0:n.getDialectNamespace(e)}modelEntry(e){var n;const r=e instanceof vD?e.name:e,i=(n=this.namespace())===null||n===void 0?void 0:n.getEntry(r);return e instanceof vD&&((i==null?void 0:i.entry.type)==="query"?this.addReference({type:"queryReference",text:r,definition:i.entry,location:e.location}):i&&(0,Gv.isSourceDef)(i.entry)&&this.addReference({type:"exploreReference",text:r,definition:i.entry,location:e.location})),i}kupuna(){var e;return((e=this.parent)===null||e===void 0?void 0:e.kupuna())||this}translator(){if(this.xlate)return this.xlate;if(this.parent)return this.parent.translator()}setTranslator(e){this.xlate=e}addReference(e){var n;(n=this.translator())===null||n===void 0||n.addReference(e)}get sourceURL(){const e=this.translator();return(e==null?void 0:e.sourceURL)||"(missing)"}log(e,n,r){const i=(0,zme.makeLogMessage)(e,n,{at:this.location,...r});if(this.codeLocation){if(this.logged.has(i.message))return e;this.logged.add(i.message)}return this.logger.log(i),e}logError(e,n,r){return this.log(e,n,{severity:"error",...r})}logWarning(e,n,r){return this.log(e,n,{severity:"warn",...r})}loggedErrorExpr(e,n,r){return(0,Qme.errorFor)(this.logError(e,n,r))}get logger(){var e;const n=(e=this.translator())===null||e===void 0?void 0:e.root.logger;if(n===void 0)throw new Error("Attempted to access logger without a translator");return n}toString(){return this.stringify("",0)}stringify(e,n){const r=" ".repeat(n);let i=`${r}${e}<${this.elementType}>${this.varInfo()}`;for(const s of Object.keys(this.children)){const o=this.children[s];o instanceof Tu?i+=`
1255
1255
  `+o.stringify(`${s}: `,n+2):(i+=`
1256
1256
  ${r} ${s}: [`,o.length>0&&(i+=`
1257
1257
  `+o.map(u=>u.stringify("",n+4)).join(`
@@ -1259,7 +1259,7 @@ ${r} ${s}: [`,o.length>0&&(i+=`
1259
1259
  ${r} `),i+="]")}return i}*walk(){for(const e of Object.keys(this.children)){const n=this.children[e];if(n instanceof Tu)yield n;else for(const r of n)yield r}}varInfo(){let e="";for(const[n,r]of Object.entries(this))n!=="elementType"&&(typeof r=="boolean"?e+=r?` ${n}`:` !${n}`:(typeof r=="string"||typeof r=="number")&&(e+=` ${n}=${r}`));return e}internalError(e){return new Error(`INTERNAL ERROR IN TRANSLATION: ${e}`)}needs(e){for(const n of this.walk()){const r=n.needs(e);if(r)return r}}inExperiment(e,n=!1){var r;const i=(r=this.translator())===null||r===void 0?void 0:r.compilerFlags.tag("experimental");return i&&(i.bare()||i.has(e))?!0:(n||this.logError("experiment-not-enabled",{experimentId:e}),!1)}}Ye.MalloyElement=Tu;class Yme extends Tu{constructor(){super(...arguments),this.elementType="unimplemented",this.reported=!1}}Ye.Unimplemented=Yme;class vD extends Tu{constructor(e){super(),this.name=e,this.elementType="modelEntryReference"}get refString(){return this.name}toString(){return this.refString}getNamed(){var e;return(e=this.modelEntry(this))===null||e===void 0?void 0:e.entry}}Ye.ModelEntryReference=vD;class Kme extends Tu{constructor(e){super(),this.id=e,this.elementType="experimentalExperiment"}execute(e){this.inExperiment(this.id)}}Ye.ExperimentalExperiment=Kme;function ez(t){return t.execute!==void 0}Ye.isDocStatement=ez;function Jme(t){return t instanceof gg||ez(t)}Ye.isDocStatementOrDocStatementList=Jme;class tz extends Tu{constructor(e){super(),this.elements=e,this.newContents()}newContents(){this.has({listOf:this.elements})}get list(){return this.elements}empty(){return this.elements.length===0}notEmpty(){return this.elements.length>0}push(...e){return this.elements.push(...e),this.newContents(),this.elements}needs(e){for(const n of this.elements){const r=n.needs(e);if(r)return r}}}Ye.ListOf=tz;class gg extends tz{constructor(){super(...arguments),this.elementType="topLevelStatements",this.execCursor=0,this.isNoteableObj=!0,this.extendNote=ZH.extendNoteMethod,this.noteCursor=0}executeList(e){for(;this.execCursor<this.elements.length;){const n=this.elements[this.execCursor];if(this.noteCursor===this.execCursor&&(this.note&&(0,ZH.isNoteable)(n)&&n.extendNote(this.note),this.noteCursor+=1),n instanceof gg){const r=n.executeList(e);if(r)return r}else{const r=n.needs(e);if(r)return r;n.execute(e)}this.execCursor+=1}}}Ye.DocStatementList=gg;const Xme="5a79a191-06bc-43cf-9b12-58741cd82970";function nz(t){const e=t.inherits?nz(t.inherits):[];return t.blockNotes&&e.push(...t.blockNotes.map(n=>n.text)),t.notes&&e.push(...t.notes.map(n=>n.text)),e}function Zme(t){const e=nz(t).join("");return(0,Vme.v5)(e,Xme)}class _D extends Tu{constructor(e){super(),this.elementType="document",this.globalNameSpace=new Wme.GlobalNameSpace,this.documentModel={},this.queryList=[],this.didInitModel=!1,this.annotation={},this.experiments=new Hme.Tag({}),this.modelAnnotationTodoList=[],this.dialectNameSpaces=new Map,this.statements=new gg(e),this.has({statements:e})}initModelDef(e){if(!this.didInitModel){if(this.documentModel={},this.queryList=[],e){e.annotation&&(this.annotation.inherits=e.annotation);for(const[n,r]of Object.entries(e.contents)){const i=structuredClone(r);if((0,Gv.isSourceDef)(i)||i.type==="query"||i.type==="function"){const s=e.exports.includes(n);this.setEntry(n,{entry:i,exported:s})}}}this.didInitModel=!0}}compile(){const e=this.statements.executeList(this),n=this.modelDef();if(e===void 0)for(const i of this.queryList)i.modelAnnotation===void 0&&n.annotation&&(i.modelAnnotation=n.annotation);if(n.annotation)for(const i of this.modelAnnotationTodoList)i.modelAnnotation||(i.modelAnnotation=n.annotation);return{modelDef:{...n,queryList:this.queryList},needs:e}}rememberToAddModelAnnotations(e){this.modelAnnotationTodoList.push(e)}hasAnnotation(){return this.annotation.notes&&this.annotation.notes.length>0||this.annotation.inherits!==void 0}currentModelAnnotation(){if(this.hasAnnotation()){const e={...this.annotation,id:""};return e.id=Zme(e),e}}modelDef(){const e={name:"",exports:[],contents:{},queryList:[],dependencies:{}};this.hasAnnotation()&&(e.annotation=this.currentModelAnnotation());for(const n in this.documentModel){const r=this.documentModel[n].entry;if((0,Gv.isSourceDef)(r)||r.type==="query"){this.documentModel[n].exported&&e.exports.push(n);const i=structuredClone(r);i.modelAnnotation===void 0&&e.annotation&&(i.modelAnnotation=e.annotation),e.contents[n]=i}}return e}getEntry(e){var n;return(n=this.globalNameSpace.getEntry(e))!==null&&n!==void 0?n:this.documentModel[e]}setEntry(e,n){this.globalNameSpace.getEntry(e)!==void 0&&this.logError("name-conflict-with-global",`Cannot redefine '${e}', which is in global namespace`),(0,Gv.isSourceDef)(n.entry)&&this.checkExperimentalDialect(this,n.entry.dialect),this.documentModel[e]=n}checkExperimentalDialect(e,n){const r=this.translator();r&&r.firstReferenceToDialect(n)&&(0,XH.getDialect)(n).experimental&&!r.experimentalDialectEnabled(n)&&e.logError("experimental-dialect-not-enabled",{dialect:n})}getDialectNamespace(e){if(this.dialectNameSpaces.has(e))return this.dialectNameSpaces.get(e);const n=(0,XH.getDialect)(e),r=new Gme.DialectNameSpace(n);return this.dialectNameSpaces.set(e,r),r}}Ye.Document=_D;var Wv={},Vd={},Wt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.atomicDef=t.inspect=t.typeEq=t.typeIn=t.eq=t.any=t.anyAtomicT=t.aggregateBoolT=t.viewT=t.errorT=t.boolT=t.timestampT=t.dateT=t.stringT=t.numberT=t.nullT=void 0;const e=ts,n=at;function r(c,f="scalar",d="constant"){return{type:c,expressionType:f,evalSpace:d,compositeFieldUsage:(0,n.emptyCompositeFieldUsage)()}}t.nullT=r("null"),t.numberT=r("number"),t.stringT=r("string"),t.dateT=r("date"),t.timestampT=r("timestamp"),t.boolT=r("boolean"),t.errorT=r("error"),t.viewT=r("turtle"),t.aggregateBoolT=r("boolean","aggregate"),t.anyAtomicT=[t.numberT,t.stringT,t.dateT,t.timestampT,t.boolT];function i(c,f){return c?f.find(h=>s(h,c))!==void 0:!1}t.any=i;function s(c,f){return f!==void 0&&e.TD.eq(c,f)&&c.expressionType===f.expressionType}t.eq=s;function o(c,f){return c?f.find(h=>u(h,c))!==void 0:!1}t.typeIn=o;function u(c,f,d=!1,h=!0){const p=e.TD.eq(c,f),m=d&&(c.type==="null"||f.type==="null"),g=h&&(c.type==="error"||f.type==="error");return p||m||g}t.typeEq=u;function a(...c){return c.map(d=>{if(d){let h=d.type;return(0,e.expressionIsScalar)(d.expressionType)||(h=`${d.expressionType} ${h}`),h}return"undefined"}).join(",")}t.inspect=a;function l(c){if(e.TD.isAtomic(c))switch(c.type){case"array":return(0,e.isRepeatedRecord)(c)?{type:"array",elementTypeDef:c.elementTypeDef,fields:c.fields}:{type:"array",elementTypeDef:c.elementTypeDef};case"record":return{type:"record",fields:c.fields};case"number":return c.numberType?{type:"number",numberType:c.numberType}:{type:"number"};case"sql native":return c.rawType?{type:"sql native",rawType:c.rawType}:{type:"sql native"};default:return{type:c.type}}return{type:"error"}}t.atomicDef=l})(Wt);var Sr={},a0={};Object.defineProperty(a0,"__esModule",{value:!0}),a0.canMakeEntry=a0.SpaceEntry=void 0;class e3e{}a0.SpaceEntry=e3e;function t3e(t){return"makeEntry"in t}a0.canMakeEntry=t3e,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.SpaceField=void 0;const n3e=a0,r3e=at;class i3e extends n3e.SpaceEntry{constructor(){super(...arguments),this.refType="field"}fieldTypeFromFieldDef(e){var n,r,i;const s=e.expressionType||"scalar";return{...e,expressionType:s,evalSpace:"input",compositeFieldUsage:(n=e.compositeFieldUsage)!==null&&n!==void 0?n:((r=e.e)===null||r===void 0?void 0:r.node)==="compositeField"?{fields:[(i=e.as)!==null&&i!==void 0?i:e.name],joinedUsage:{}}:(0,r3e.emptyCompositeFieldUsage)()}}getQueryFieldDef(e){}fieldDef(){}constructorFieldDef(){}}Sr.SpaceField=i3e;var s3e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),o3e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),u3e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&s3e(e,t,n);return o3e(e,t),e};Object.defineProperty(Vd,"__esModule",{value:!0}),Vd.ViewField=void 0;const a3e=at,l3e=u3e(Wt),c3e=Sr;class f3e extends c3e.SpaceField{constructor(e){super(),this.inSpace=e}typeDesc(){var e;const n=this.fieldDef();return{...l3e.viewT,compositeFieldUsage:(e=n.compositeFieldUsage)!==null&&e!==void 0?e:(0,a3e.emptyCompositeFieldUsage)()}}}Vd.ViewField=f3e,Object.defineProperty(Wv,"__esModule",{value:!0}),Wv.ASTViewField=void 0;const x3e=Vd;class d3e extends x3e.ViewField{constructor(e,n,r){super(e),this.view=n,this.name=r,this.turtleDef=void 0}getQueryFieldDef(e){return this.view.getFieldDef(e)}fieldDef(){return this.turtleDef===void 0&&(this.turtleDef=this.view.getFieldDef(this.inSpace)),this.turtleDef}}Wv.ASTViewField=d3e,Object.defineProperty(hg,"__esModule",{value:!0}),hg.ViewFieldDeclaration=void 0;const h3e=Ye,p3e=_r,g3e=Gd,m3e=Wv;class y3e extends h3e.MalloyElement{constructor(e,n){super({view:n}),this.name=e,this.view=n,this.elementType="view-field-declaration",this.isNoteableObj=!0,this.extendNote=p3e.extendNoteMethod}makeEntry(e){const n=new m3e.ASTViewField(e,this,this.name);e.newEntry(this.name,this,n)}getName(){return this.name}getFieldDef(e){const{pipeline:n,annotation:r}=this.view.pipelineComp(e),i=(0,g3e.detectAndRemovePartialStages)(n,this);return{type:"turtle",name:this.name,pipeline:i,annotation:{...this.note,inherits:r},location:this.location}}}hg.ViewFieldDeclaration=y3e;var wn={};Object.defineProperty(wn,"__esModule",{value:!0}),wn.LegalRefinementStage=wn.QueryClass=void 0;var rz;(function(t){t.Index="index",t.Project="project",t.Grouping="grouping"})(rz||(wn.QueryClass=rz={}));var iz;(function(t){t[t.Single=0]="Single",t[t.Head=1]="Head",t[t.Tail=2]="Tail"})(iz||(wn.LegalRefinementStage=iz={}));var E3e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),A3e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),v3e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&E3e(e,t,n);return A3e(e,t),e};Object.defineProperty(dg,"__esModule",{value:!0}),dg.NestFieldDeclaration=void 0;const _3e=v3e(Ke),S3e=Gd,C3e=hg,sz=wn;class b3e extends C3e.ViewFieldDeclaration{constructor(){super(...arguments),this.elementType="nest-field-declaration",this.queryRefinementStage=sz.LegalRefinementStage.Single,this.forceQueryClass=sz.QueryClass.Grouping,this.turtleDef=void 0}queryExecute(e){e.resultFS.pushFields(this)}getFieldDef(e){if(this.turtleDef)return this.turtleDef;if(e.isQueryFieldSpace()){const{pipeline:n,annotation:r}=this.view.pipelineComp(e,e.outputSpace()),i=n[0]&&_3e.isQuerySegment(n[0])?n[0].compositeFieldUsage:void 0,s=(0,S3e.detectAndRemovePartialStages)(n,this);return this.turtleDef={type:"turtle",name:this.name,pipeline:s,annotation:{...this.note,inherits:r},location:this.location,compositeFieldUsage:i},this.turtleDef}throw this.internalError("Unexpected namespace for nest")}}dg.NestFieldDeclaration=b3e;var Yd={},Ur={};Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.ErrorFactory=void 0;const oz="~malformed~";class SD{static get structDef(){return{type:"table",name:oz,dialect:"~malformed~",connection:"~unknown~",tablePath:"//undefined_error_table_path",fields:[],errorFactory:!0}}static get joinDef(){return{type:"table",name:oz,dialect:"~malformed~",connection:"~unknown~",tablePath:"//undefined_error_table_path",fields:[],join:"one",matrixOperation:"left",errorFactory:!0}}static didCreate(e){return e.type==="table"&&"errorFactory"in e}static get query(){return{structRef:SD.structDef,pipeline:[]}}static get reduceSegment(){return{type:"reduce",queryFields:[]}}static get projectSegment(){return{type:"project",queryFields:[]}}static get indexSegment(){return{type:"index",indexFields:[]}}}Ur.ErrorFactory=SD,Object.defineProperty(Yd,"__esModule",{value:!0}),Yd.DefineSourceList=Yd.DefineSource=void 0;const T3e=Ur,uz=Ye,R3e=_r;class O3e extends uz.MalloyElement{constructor(e,n,r,i){super(),this.name=e,this.sourceExpr=n,this.exported=r,this.parameters=i,this.elementType="defineSource",this.isNoteableObj=!0,this.extendNote=R3e.extendNoteMethod,n&&this.has({sourceExpr:n}),i&&this.has({parameters:i})}execute(e){var n;if(e.modelEntry(this.name))this.logError("source-definition-name-conflict",`Cannot redefine '${this.name}'`);else{const r=(n=this.sourceExpr)===null||n===void 0?void 0:n.getSource();if(r===void 0)return;const i=this.deduplicatedParameters(),s=r.withParameters(void 0,this.parameters);if(this.validateParameterShadowing(i,s),T3e.ErrorFactory.didCreate(s))return;const o={...s,as:this.name,location:this.location};this.note&&(o.annotation=s.annotation?{...this.note,inherits:s.annotation}:this.note),e.setEntry(this.name,{entry:o,exported:this.exported})}}deduplicatedParameters(){if(this.parameters===void 0)return[];const e={},n=[];for(const r of this.parameters)r.name in e&&r.logError("parameter-name-conflict",`Cannot redefine parameter \`${r.name}\``),e[r.name]=!0,n.push(r);return n}validateParameterShadowing(e,n){for(const r of e)n.fields.find(i=>{var s;return((s=i.as)!==null&&s!==void 0?s:i.name)===r.name})&&r.logError("parameter-shadowing-field",`Illegal shadowing of field \`${r.name}\` by parameter with the same name`)}}Yd.DefineSource=O3e;class D3e extends uz.DocStatementList{constructor(e){super(e),this.elementType="defineSources"}}Yd.DefineSourceList=D3e;var Kd={};Object.defineProperty(Kd,"__esModule",{value:!0}),Kd.DefineQueryList=Kd.DefineQuery=void 0;const az=Ye,w3e=_r;class N3e extends az.MalloyElement{constructor(e,n){super({queryExpr:n}),this.name=e,this.queryExpr=n,this.elementType="defineQuery",this.isNoteableObj=!0,this.extendNote=w3e.extendNoteMethod}execute(e){if(e.getEntry(this.name)){this.logError("query-definition-name-conflict",`'${this.name}' is already defined, cannot redefine`);return}const r=this.queryExpr.getQuery();if(!r){this.queryExpr.sqLog("query-definition-from-non-query","Cannot define a query from this expression");return}const i={...r.query(),type:"query",name:this.name,location:this.location};this.note&&(i.annotation=i.annotation?{...this.note,inherits:i.annotation}:this.note),e.setEntry(this.name,{entry:i,exported:!0})}}Kd.DefineQuery=N3e;class F3e extends az.DocStatementList{constructor(e){super(e),this.elementType="defineQueries"}}Kd.DefineQueryList=F3e;var Ms={};Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.Source=void 0;const L3e=Ye;class I3e extends L3e.MalloyElement{structRef(e){return{structRef:this.getSourceDef(e)}}packParameters(e){if(e===void 0)return;const n={};for(const r of e){const i=r.parameter();n[i.name]=i}return n}withParameters(e,n){return{...this.getSourceDef(e),parameters:this.packParameters(n)}}}Ms.Source=I3e;var mg={},Jd={},Vv={},l0={};Object.defineProperty(l0,"__esModule",{value:!0}),l0.mergeFields=l0.nameFromDef=void 0;function CD(t){var e;return t.type==="fieldref"?t.path[t.path.length-1]:(e=t.as)!==null&&e!==void 0?e:t.name}l0.nameFromDef=CD;function B3e(t,e){if(t===void 0)return e;const n=new Set(e.map(i=>CD(i))),r=t.filter(i=>!n.has(CD(i)));return r.push(...e),r}l0.mergeFields=B3e;var yg={},Cr={},Ru={},$3e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),k3e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),M3e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&$3e(e,t,n);return k3e(e,t),e};Object.defineProperty(Ru,"__esModule",{value:!0}),Ru.DefinedParameter=Ru.AbstractParameter=Ru.SpaceParam=void 0;const P3e=a0,lz=M3e(Wt),cz=at;class bD extends P3e.SpaceEntry{constructor(){super(...arguments),this.refType="parameter"}}Ru.SpaceParam=bD;class U3e extends bD{constructor(e){super(),this.astParam=e,this._parameter=void 0}parameter(){return this._parameter!==void 0?this._parameter:(this._parameter=this.astParam.parameter(),this._parameter)}typeDesc(){return{...lz.atomicDef(this.parameter()),expressionType:"scalar",evalSpace:"constant",compositeFieldUsage:(0,cz.emptyCompositeFieldUsage)()}}entryType(){return this.parameter().type}}Ru.AbstractParameter=U3e;class j3e extends bD{constructor(e){super(),this.paramDef=e}parameter(){return this.paramDef}typeDesc(){return{...lz.atomicDef(this.paramDef),expressionType:"scalar",evalSpace:"input",compositeFieldUsage:(0,cz.emptyCompositeFieldUsage)()}}entryType(){return this.paramDef.type}}Ru.DefinedParameter=j3e;var Ef={},q3e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),H3e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),z3e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&q3e(e,t,n);return H3e(e,t),e};Object.defineProperty(Ef,"__esModule",{value:!0}),Ef.StructSpaceFieldBase=void 0;const fz=at,Q3e=Ke,G3e=z3e(Wt),W3e=Sr;class V3e extends W3e.SpaceField{constructor(e){super(),this.structDef=e}fieldDef(){return this.structDef}get joinPathElement(){return{name:this.structDef.as||this.structDef.name,joinType:this.structDef.join,joinElementType:this.structDef.type}}typeDesc(){var e,n;return(0,Q3e.isSourceDef)(this.structDef)?{type:this.structDef.type,evalSpace:"input",expressionType:"scalar",compositeFieldUsage:(e=this.structDef.onCompositeFieldUsage)!==null&&e!==void 0?e:(0,fz.emptyCompositeFieldUsage)()}:{...G3e.atomicDef(this.structDef),evalSpace:"input",expressionType:"scalar",compositeFieldUsage:(n=this.structDef.onCompositeFieldUsage)!==null&&n!==void 0?n:(0,fz.emptyCompositeFieldUsage)()}}}Ef.StructSpaceFieldBase=V3e;var Eg={};Object.defineProperty(Eg,"__esModule",{value:!0}),Eg.ColumnSpaceField=void 0;const Y3e=Sr;class K3e extends Y3e.SpaceField{constructor(e){super(),this.sourceFieldDef=e}fieldDef(){return this.sourceFieldDef}typeDesc(){return this.fieldTypeFromFieldDef(this.sourceFieldDef)}constructorFieldDef(){return this.sourceFieldDef}}Eg.ColumnSpaceField=K3e;var Yv={};Object.defineProperty(Yv,"__esModule",{value:!0}),Yv.IRViewField=void 0;const J3e=Vd;class X3e extends J3e.ViewField{constructor(e,n){super(e),this.turtleDef=n}rename(e){this.turtleDef={...this.turtleDef,as:e}}fieldDef(){return this.turtleDef}constructorFieldDef(){return this.turtleDef}getQueryFieldDef(e){return this.fieldDef()}}Yv.IRViewField=X3e,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.StaticSourceSpace=Cr.StructSpaceField=Cr.StaticSpace=void 0;const Z3e=ou,Xd=Ke,eye=Ru,tye=Sr,Ag=Ef,nye=Eg,rye=Yv;class TD{constructor(e,n){this.type="fieldSpace",this.fromStruct=e,this.structDialect=n}dialectName(){return this.structDialect}dialectObj(){try{return(0,Z3e.getDialect)(this.structDialect)}catch{return}}defToSpaceField(e){return(0,Xd.isJoined)(e)?new RD(e,this.structDialect):(0,Xd.isTurtle)(e)?new rye.IRViewField(this,e):new nye.ColumnSpaceField(e)}get map(){if(this.memoMap===void 0){this.memoMap={};for(const e of this.fromStruct.fields){const n=e.as||e.name;this.memoMap[n]=this.defToSpaceField(e)}if((0,Xd.isSourceDef)(this.fromStruct)&&this.fromStruct.parameters)for(const[e,n]of Object.entries(this.fromStruct.parameters))e in this.memoMap||(this.memoMap[e]=new eye.DefinedParameter(n))}return this.memoMap}isProtectedAccessSpace(){return!1}dropEntries(){this.memoMap={}}dropEntry(e){delete this.map[e]}entry(e){return this.map[e]}setEntry(e,n){this.map[e]=n}entries(){return Object.entries(this.map)}structDef(){return this.fromStruct}emptyStructDef(){const e={...this.fromStruct};return(0,Xd.isSourceDef)(e)&&(e.parameters={}),e.fields=[],e}lookup(e){const n=e[0],r=e.slice(1);let i=this.entry(n.refString);if(!i)return{error:{message:`'${n}' is not defined`,code:"field-not-found"},found:i};if(i instanceof tye.SpaceField){const o=i.fieldDef();if(o&&(!(i instanceof Ag.StructSpaceFieldBase)&&(0,Xd.isJoined)(o)&&(i=new RD(o,this.structDialect)),n.addReference({type:i instanceof Ag.StructSpaceFieldBase?"joinReference":"fieldReference",definition:o,location:n.location,text:n.refString})),o!=null&&o.accessModifier&&!(this.isProtectedAccessSpace()&&o.accessModifier==="internal"&&e.length===1))return{error:{message:`'${n}' is ${o==null?void 0:o.accessModifier}`,code:"field-not-accessible"},found:void 0}}const s=i instanceof Ag.StructSpaceFieldBase?[{...i.joinPathElement,name:n.refString}]:[];if(r.length){if(i instanceof Ag.StructSpaceFieldBase){const o=i.fieldSpace.lookup(r);return o.found?{...o,joinPath:[...s,...o.joinPath]}:o}return{error:{message:`'${n}' cannot contain a '${r[0]}'`,code:"invalid-property-access-in-field-reference"},found:void 0}}return{found:i,error:void 0,joinPath:s,isOutputField:!1}}isQueryFieldSpace(){return!1}}Cr.StaticSpace=TD;class RD extends Ag.StructSpaceFieldBase{constructor(e,n){super(e),this.forDialect=n}get fieldSpace(){return(0,Xd.isSourceDef)(this.structDef)?new xz(this.structDef):new TD(this.structDef,this.forDialect)}}Cr.StructSpaceField=RD;class xz extends TD{constructor(e){super(e,e.dialect),this.source=e}structDef(){return this.source}emptyStructDef(){const e={...this.source};return e.parameters={},e.fields=[],e}}Cr.StaticSourceSpace=xz,Object.defineProperty(yg,"__esModule",{value:!0}),yg.JoinSpaceField=void 0;const iye=Cr;class sye extends iye.StructSpaceField{constructor(e,n,r){super(n.structDef(e),r),this.parameterSpace=e,this.join=n}}yg.JoinSpaceField=sye;var Zd={};Object.defineProperty(Zd,"__esModule",{value:!0}),Zd.ParameterSpace=void 0;const oye=Ru;class uye{constructor(e){this.type="fieldSpace",this._map={};for(const n of e)this._map[n.name]=new oye.AbstractParameter(n)}structDef(){throw new Error("Parameter space does not have a structDef")}emptyStructDef(){throw new Error("Parameter space does not have an emptyStructDef")}entry(e){return this._map[e]}lookup(e){const n=e[0];if(n===void 0)return{error:{message:"Invalid reference",code:"invalid-parameter-reference"},found:void 0};const r=this.entry(n.refString);return r===void 0?{error:{message:`\`${n}\` is not defined`,code:"parameter-not-found"},found:void 0}:e.length>1?{error:{message:`\`${n}\` cannot contain a \`${e.slice(1).join(".")}\``,code:"invalid-parameter-reference"},found:void 0}:{found:r,error:void 0,joinPath:[],isOutputField:!1}}entries(){return Object.entries(this._map)}dialectName(){return"~parameter-space-unknown-dialect~"}dialectObj(){}isQueryFieldSpace(){return!1}isProtectedAccessSpace(){return!1}}Zd.ParameterSpace=uye;var aye=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),lye=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),cye=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&aye(e,t,n);return lye(e,t),e};Object.defineProperty(Vv,"__esModule",{value:!0}),Vv.DynamicSpace=void 0;const fye=cye(Ke),xye=l0,dye=Ur,hye=Sr,pye=yg,gye=Vd,dz=Ru,mye=Cr,yye=Ef,Eye=Zd;class Aye extends mye.StaticSpace{constructor(e){super(structuredClone(e),e.dialect),this.complete=!1,this.parameters=[],this.newAccessModifiers=new Map,this.newNotes=new Map,this.fromSource=e,this.sourceDef=void 0}setEntry(e,n){if(this.complete)throw new Error("Space already final");super.setEntry(e,n)}addParameters(e){for(const n of e)this.entry(n.name)===void 0&&(this.parameters.push(n),this.setEntry(n.name,new dz.AbstractParameter(n)));return this}parameterSpace(){return new Eye.ParameterSpace(this.parameters)}newEntry(e,n,r){if(this.entry(e)){n.logError("definition-name-conflict",`Cannot redefine '${e}'`);return}this.setEntry(e,r)}renameEntry(e,n,r){this.dropEntry(e),this.setEntry(n,r)}addFieldDef(e){this.setEntry((0,xye.nameFromDef)(e),this.defToSpaceField(e))}setTimezone(e){this.newTimezone=e}structDef(){if(this.complete=!0,this.sourceDef===void 0){const e={};for(const[a,l]of this.entries())l instanceof dz.SpaceParam&&(e[a]=l.parameter());this.sourceDef={...this.fromSource,fields:[]},this.sourceDef.parameters=e;const n=new Map,r=[],i=[],s=[];for(const[a,l]of this.entries())l instanceof yye.StructSpaceFieldBase?i.push([a,l]):l instanceof gye.ViewField?s.push([a,l]):l instanceof hye.SpaceField&&r.push([a,l]);const o=[...r,...i,...s],u=this.parameterSpace();for(const[a,l]of o)if(l instanceof pye.JoinSpaceField){const c=l.join.structDef(u);dye.ErrorFactory.didCreate(c)||(n.set(a,this.sourceDef.fields.length),this.sourceDef.fields.push(c),l.join.fixupJoinOn(this,c))}else{const c=l.fieldDef();c&&(n.set(a,this.sourceDef.fields.length),this.sourceDef.fields.push(c))}for(const[a,l]of this.newAccessModifiers){const c=this.sourceDef.fields.findIndex(f=>{var d;return(d=f.as)!==null&&d!==void 0?d:f.name===a});if(c===-1)throw new Error(`Can't find field '${a}' to set access modifier`);l==="public"?delete this.sourceDef.fields[c].accessModifier:this.sourceDef.fields[c]={...this.sourceDef.fields[c],accessModifier:l}}for(const[a,l]of this.newNotes){const c=this.sourceDef.fields.findIndex(d=>{var h;return(h=d.as)!==null&&h!==void 0?h:d.name===a});if(c===-1)throw new Error(`Can't find field '${a}' to set access modifier`);const f=this.sourceDef.fields[c];this.sourceDef.fields[c]={...f,annotation:{...l,inherits:f.annotation}}}}return this.newTimezone&&fye.isSourceDef(this.sourceDef)&&(this.sourceDef.queryTimezone=this.newTimezone),this.sourceDef}emptyStructDef(){const e={...this.fromSource};return e.fields=[],e}}Vv.DynamicSpace=Aye;var vg={};Object.defineProperty(vg,"__esModule",{value:!0}),vg.RenameSpaceField=void 0;const vye=Sr;class _ye extends vye.SpaceField{constructor(e,n,r){super(),this.otherField=e,this.newName=n,this.location=r}fieldDef(){const e=this.otherField.fieldDef();if(e!==void 0)return{...e,as:this.newName,location:this.location}}typeDesc(){return this.otherField.typeDesc()}}vg.RenameSpaceField=_ye,Object.defineProperty(Jd,"__esModule",{value:!0}),Jd.RefinedSpace=void 0;const Sye=Vv,Cye=a0,bye=vg,Tye=Sr;class OD extends Sye.DynamicSpace{static filteredFrom(e,n,r,i,s){const o=new OD(e),u=new Map;for(const a of i??[])u.has(a.name.refString)?a.name.logError("already-renamed",`${a.name.refString} already renamed to ${a.as}`):u.set(a.name.refString,{as:a.as,location:a.location,logTo:a.name});if(r!==void 0){const a=o.entries();o.dropEntries();for(const[l,c]of a)if(r.has(l)){const f=u.get(l);f?c instanceof Tye.SpaceField?o.setEntry(f.as,new bye.RenameSpaceField(c,f.as,f.location)):f.logTo.logError("cannot-rename-non-field",`Cannot rename \`${l}\` which is not a field`):o.setEntry(l,c)}n!==void 0&&n.logError("accept-except-not-compatible-with-include","Can't use `accept:` or `except:` with `include`")}else if(n){const a=n.refs.list,l=o.entries();for(const c of a)l.find(([d])=>d===c.refString)===void 0&&(s!=null&&s.entry(c.refString)?c.logError(`${n.edit}-parameter`,`Illegal \`${n.edit}:\` of parameter`):c.logError("field-list-edit-not-found",`\`${c.refString}\` is not defined`));o.dropEntries();for(const[c,f]of l){const d=!!a.find(p=>p.refString===c),h=n.edit==="accept";d===h&&o.setEntry(c,f)}}return o}pushFields(...e){for(const n of e)this.addField(n)}addField(e){(0,Cye.canMakeEntry)(e)?e.makeEntry(this):e.logError("unexpected-element-type",`Internal error, ${e.elementType} not expected in this context`)}addAccessModifiers(e){for(const[n,r]of e)this.newAccessModifiers.set(n,r)}addNotes(e){for(const[n,r]of e)this.newNotes.set(n,r)}isProtectedAccessSpace(){return!0}}Jd.RefinedSpace=OD;var c0={},xs={};Object.defineProperty(xs,"__esModule",{value:!0}),xs.DefinitionList=void 0;const Rye=Ye,hz=_r;class Oye extends Rye.ListOf{constructor(){super(...arguments),this.isNoteableObj=!0}extendNote(e){(0,hz.extendNoteHelper)(this,e),this.distributeAnnotation()}distributeAnnotation(){if(this.note)for(const e of this.elements)(0,hz.isNoteable)(e)&&e.extendNote(this.note)}newContents(){super.newContents(),this.distributeAnnotation()}}xs.DefinitionList=Oye,Object.defineProperty(c0,"__esModule",{value:!0}),c0.DeclareFields=void 0;const Dye=xs,wye=wn;class Nye extends Dye.DefinitionList{constructor(e,n){super(e),this.accessModifier=n,this.elementType="declareFields",this.queryRefinementStage=wye.LegalRefinementStage.Single,this.forceQueryClass=void 0}queryExecute(e){for(const n of this.list)e.inputFS.extendSource(n)}get delarationNames(){return this.list.map(e=>e.defineName)}}c0.DeclareFields=Nye;var Ou={};Object.defineProperty(Ou,"__esModule",{value:!0}),Ou.Filter=Ou.FilterElement=void 0;const pz=Ke,Fye=bu,gz=Ye,DD=wn;class Lye extends gz.MalloyElement{constructor(e,n){super({expr:e}),this.expr=e,this.exprSrc=n,this.elementType="filterElement"}filterCondition(e){const n=this.expr.getExpression(e);return n.type!=="boolean"?(this.expr.logError("non-boolean-filter","Filter expression must have boolean value"),{node:"filterCondition",code:this.exprSrc,e:{node:"false"},expressionType:"scalar",compositeFieldUsage:n.compositeFieldUsage}):{node:"filterCondition",code:this.exprSrc,e:n.value,expressionType:n.expressionType,compositeFieldUsage:n.compositeFieldUsage}}}Ou.FilterElement=Lye;let Iye=class extends gz.ListOf{constructor(){super(...arguments),this.elementType="filter",this.forceQueryClass=void 0,this.queryRefinementStage=DD.LegalRefinementStage.Head}set having(e){this.elementType=e?"having":"where",this.havingClause=e,this.queryRefinementStage=e?DD.LegalRefinementStage.Tail:DD.LegalRefinementStage.Head}checkedFilterCondition(e,n){const r=n.filterCondition(e);if(this.havingClause!==void 0){const i=(0,pz.expressionIsAggregate)(r.expressionType),s=(0,pz.expressionIsAnalytic)(r.expressionType);if(this.havingClause){if(s){n.logError("analytic-in-having","Analytic expressions are not allowed in `having:`");return}}else if(s){n.logError("analytic-in-where","Analytic expressions are not allowed in `where:`");return}else i&&n.logError("aggregate-in-where","Aggregate expressions are not allowed in `where:`; use `having:`")}return r}getFilterList(e){return this.list.map(n=>this.checkedFilterCondition(e,n)).filter(Fye.isNotUndefined)}queryExecute(e){const n=this.havingClause?e.resultFS:e.inputFS;for(const r of this.list){const i=this.checkedFilterCondition(n,r);i!==void 0&&(e.filters.push(i),e.resultFS.addCompositeFieldUserFromFilter(i,r))}}};Ou.Filter=Iye;var eh={};Object.defineProperty(eh,"__esModule",{value:!0}),eh.FieldListEdit=void 0;const Bye=Ye;class $ye extends Bye.MalloyElement{constructor(e,n){super({refs:n}),this.edit=e,this.refs=n,this.elementType="fieldListEdit"}}eh.FieldListEdit=$ye;var th={};Object.defineProperty(th,"__esModule",{value:!0}),th.PrimaryKey=void 0;const kye=Ye;class Mye extends kye.MalloyElement{constructor(e){super({field:e}),this.field=e,this.elementType="primary key"}}th.PrimaryKey=Mye;var nh={};Object.defineProperty(nh,"__esModule",{value:!0}),nh.Views=void 0;const Pye=xs;class Uye extends Pye.DefinitionList{constructor(e,n){super(e),this.accessModifier=n,this.elementType="turtleDefList"}get delarationNames(){return this.list.map(e=>e.name)}}nh.Views=Uye;var rh={},ri={};Object.defineProperty(ri,"__esModule",{value:!0});class Af extends Error{}class jye extends Af{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}}class qye extends Af{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}}class Hye extends Af{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}}class _g extends Af{}class mz extends Af{constructor(e){super(`Invalid unit ${e}`)}}class Ps extends Af{}class f0 extends Af{constructor(){super("Zone is an abstract class")}}const Ue="numeric",Co="short",ds="long",wD={year:Ue,month:Ue,day:Ue},yz={year:Ue,month:Co,day:Ue},zye={year:Ue,month:Co,day:Ue,weekday:Co},Ez={year:Ue,month:ds,day:Ue},Az={year:Ue,month:ds,day:Ue,weekday:ds},vz={hour:Ue,minute:Ue},_z={hour:Ue,minute:Ue,second:Ue},Sz={hour:Ue,minute:Ue,second:Ue,timeZoneName:Co},Cz={hour:Ue,minute:Ue,second:Ue,timeZoneName:ds},bz={hour:Ue,minute:Ue,hourCycle:"h23"},Tz={hour:Ue,minute:Ue,second:Ue,hourCycle:"h23"},Rz={hour:Ue,minute:Ue,second:Ue,hourCycle:"h23",timeZoneName:Co},Oz={hour:Ue,minute:Ue,second:Ue,hourCycle:"h23",timeZoneName:ds},Dz={year:Ue,month:Ue,day:Ue,hour:Ue,minute:Ue},wz={year:Ue,month:Ue,day:Ue,hour:Ue,minute:Ue,second:Ue},Nz={year:Ue,month:Co,day:Ue,hour:Ue,minute:Ue},Fz={year:Ue,month:Co,day:Ue,hour:Ue,minute:Ue,second:Ue},Qye={year:Ue,month:Co,day:Ue,weekday:Co,hour:Ue,minute:Ue},Lz={year:Ue,month:ds,day:Ue,hour:Ue,minute:Ue,timeZoneName:Co},Iz={year:Ue,month:ds,day:Ue,hour:Ue,minute:Ue,second:Ue,timeZoneName:Co},Bz={year:Ue,month:ds,day:Ue,weekday:ds,hour:Ue,minute:Ue,timeZoneName:ds},$z={year:Ue,month:ds,day:Ue,weekday:ds,hour:Ue,minute:Ue,second:Ue,timeZoneName:ds};function Tt(t){return typeof t>"u"}function vf(t){return typeof t=="number"}function Kv(t){return typeof t=="number"&&t%1===0}function Gye(t){return typeof t=="string"}function Wye(t){return Object.prototype.toString.call(t)==="[object Date]"}function kz(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Vye(t){return Array.isArray(t)?t:[t]}function Mz(t,e,n){if(t.length!==0)return t.reduce((r,i)=>{const s=[e(i),i];return r&&n(r[0],s[0])===r[0]?r:s},null)[1]}function Yye(t,e){return e.reduce((n,r)=>(n[r]=t[r],n),{})}function ih(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ua(t,e,n){return Kv(t)&&t>=e&&t<=n}function Kye(t,e){return t-e*Math.floor(t/e)}function Bn(t,e=2){const n=t<0;let r;return n?r="-"+(""+-t).padStart(e,"0"):r=(""+t).padStart(e,"0"),r}function x0(t){if(!(Tt(t)||t===null||t===""))return parseInt(t,10)}function _f(t){if(!(Tt(t)||t===null||t===""))return parseFloat(t)}function ND(t){if(!(Tt(t)||t===null||t==="")){const e=parseFloat("0."+t)*1e3;return Math.floor(e)}}function FD(t,e,n=!1){const r=10**e;return(n?Math.trunc:Math.round)(t*r)/r}function Sg(t){return t%4===0&&(t%100!==0||t%400===0)}function Cg(t){return Sg(t)?366:365}function Jv(t,e){const n=Kye(e-1,12)+1,r=t+(e-n)/12;return n===2?Sg(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function LD(t){let e=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond);return t.year<100&&t.year>=0&&(e=new Date(e),e.setUTCFullYear(e.getUTCFullYear()-1900)),+e}function Xv(t){const e=(t+Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))%7,n=t-1,r=(n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400))%7;return e===4||r===3?53:52}function ID(t){return t>99?t:t>60?1900+t:2e3+t}function Pz(t,e,n,r=null){const i=new Date(t),s={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};r&&(s.timeZone=r);const o={timeZoneName:e,...s},u=new Intl.DateTimeFormat(n,o).formatToParts(i).find(a=>a.type.toLowerCase()==="timezonename");return u?u.value:null}function Zv(t,e){let n=parseInt(t,10);Number.isNaN(n)&&(n=0);const r=parseInt(e,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function Uz(t){const e=Number(t);if(typeof t=="boolean"||t===""||Number.isNaN(e))throw new Ps(`Invalid unit value ${t}`);return e}function e_(t,e){const n={};for(const r in t)if(ih(t,r)){const i=t[r];if(i==null)continue;n[e(r)]=Uz(i)}return n}function bg(t,e){const n=Math.trunc(Math.abs(t/60)),r=Math.trunc(Math.abs(t%60)),i=t>=0?"+":"-";switch(e){case"short":return`${i}${Bn(n,2)}:${Bn(r,2)}`;case"narrow":return`${i}${n}${r>0?`:${r}`:""}`;case"techie":return`${i}${Bn(n,2)}${Bn(r,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function t_(t){return Yye(t,["hour","minute","second","millisecond"])}const jz=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/,Jye=["January","February","March","April","May","June","July","August","September","October","November","December"],qz=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Xye=["J","F","M","A","M","J","J","A","S","O","N","D"];function Hz(t){switch(t){case"narrow":return[...Xye];case"short":return[...qz];case"long":return[...Jye];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}const zz=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Qz=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Zye=["M","T","W","T","F","S","S"];function Gz(t){switch(t){case"narrow":return[...Zye];case"short":return[...Qz];case"long":return[...zz];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}const Wz=["AM","PM"],eEe=["Before Christ","Anno Domini"],tEe=["BC","AD"],nEe=["B","A"];function Vz(t){switch(t){case"narrow":return[...nEe];case"short":return[...tEe];case"long":return[...eEe];default:return null}}function rEe(t){return Wz[t.hour<12?0:1]}function iEe(t,e){return Gz(e)[t.weekday-1]}function sEe(t,e){return Hz(e)[t.month-1]}function oEe(t,e){return Vz(e)[t.year<0?0:1]}function uEe(t,e,n="always",r=!1){const i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},s=["hours","minutes","seconds"].indexOf(t)===-1;if(n==="auto"&&s){const f=t==="days";switch(e){case 1:return f?"tomorrow":`next ${i[t][0]}`;case-1:return f?"yesterday":`last ${i[t][0]}`;case 0:return f?"today":`this ${i[t][0]}`}}const o=Object.is(e,-0)||e<0,u=Math.abs(e),a=u===1,l=i[t],c=r?a?l[1]:l[2]||l[1]:a?i[t][0]:t;return o?`${u} ${c} ago`:`in ${u} ${c}`}function Yz(t,e){let n="";for(const r of t)r.literal?n+=r.val:n+=e(r.val);return n}const aEe={D:wD,DD:yz,DDD:Ez,DDDD:Az,t:vz,tt:_z,ttt:Sz,tttt:Cz,T:bz,TT:Tz,TTT:Rz,TTTT:Oz,f:Dz,ff:Nz,fff:Lz,ffff:Bz,F:wz,FF:Fz,FFF:Iz,FFFF:$z};class Ni{static create(e,n={}){return new Ni(e,n)}static parseFormat(e){let n=null,r="",i=!1;const s=[];for(let o=0;o<e.length;o++){const u=e.charAt(o);u==="'"?(r.length>0&&s.push({literal:i,val:r}),n=null,r="",i=!i):i||u===n?r+=u:(r.length>0&&s.push({literal:!1,val:r}),r=u,n=u)}return r.length>0&&s.push({literal:i,val:r}),s}static macroTokenToFormatOpts(e){return aEe[e]}constructor(e,n){this.opts=n,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,n){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...n}).format()}formatDateTime(e,n={}){return this.loc.dtFormatter(e,{...this.opts,...n}).format()}formatDateTimeParts(e,n={}){return this.loc.dtFormatter(e,{...this.opts,...n}).formatToParts()}resolvedOptions(e,n={}){return this.loc.dtFormatter(e,{...this.opts,...n}).resolvedOptions()}num(e,n=0){if(this.opts.forceSimple)return Bn(e,n);const r={...this.opts};return n>0&&(r.padTo=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(e,n){const r=this.loc.listingMode()==="en",i=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",s=(h,p)=>this.loc.extract(e,h,p),o=h=>e.isOffsetFixed&&e.offset===0&&h.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,h.format):"",u=()=>r?rEe(e):s({hour:"numeric",hourCycle:"h12"},"dayperiod"),a=(h,p)=>r?sEe(e,h):s(p?{month:h}:{month:h,day:"numeric"},"month"),l=(h,p)=>r?iEe(e,h):s(p?{weekday:h}:{weekday:h,month:"long",day:"numeric"},"weekday"),c=h=>{const p=Ni.macroTokenToFormatOpts(h);return p?this.formatWithSystemDefault(e,p):h},f=h=>r?oEe(e,h):s({era:h},"era"),d=h=>{switch(h){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return o({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return o({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return o({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return u();case"d":return i?s({day:"numeric"},"day"):this.num(e.day);case"dd":return i?s({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return l("short",!0);case"cccc":return l("long",!0);case"ccccc":return l("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return l("short",!1);case"EEEE":return l("long",!1);case"EEEEE":return l("narrow",!1);case"L":return i?s({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return i?s({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return a("short",!0);case"LLLL":return a("long",!0);case"LLLLL":return a("narrow",!0);case"M":return i?s({month:"numeric"},"month"):this.num(e.month);case"MM":return i?s({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return a("short",!1);case"MMMM":return a("long",!1);case"MMMMM":return a("narrow",!1);case"y":return i?s({year:"numeric"},"year"):this.num(e.year);case"yy":return i?s({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return i?s({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return i?s({year:"numeric"},"year"):this.num(e.year,6);case"G":return f("short");case"GG":return f("long");case"GGGGG":return f("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return c(h)}};return Yz(Ni.parseFormat(n),d)}formatDurationFromString(e,n){const r=a=>{switch(a[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},i=a=>l=>{const c=r(l);return c?this.num(a.get(c),l.length):l},s=Ni.parseFormat(n),o=s.reduce((a,{literal:l,val:c})=>l?a:a.concat(c),[]),u=e.shiftTo(...o.map(r).filter(a=>a));return Yz(s,i(u))}}class bo{constructor(e,n){this.reason=e,this.explanation=n}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}}let sh=class{get type(){throw new f0}get name(){throw new f0}get ianaName(){return this.name}get isUniversal(){throw new f0}offsetName(e,n){throw new f0}formatOffset(e,n){throw new f0}offset(e){throw new f0}equals(e){throw new f0}get isValid(){throw new f0}},BD=null;class n_ extends sh{static get instance(){return BD===null&&(BD=new n_),BD}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:n,locale:r}){return Pz(e,n,r)}formatOffset(e,n){return bg(this.offset(e),n)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}}let r_={};function lEe(t){return r_[t]||(r_[t]=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"})),r_[t]}const cEe={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function fEe(t,e){const n=t.format(e).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n),[,i,s,o,u,a,l,c]=r;return[o,i,s,u,a,l,c]}function xEe(t,e){const n=t.formatToParts(e),r=[];for(let i=0;i<n.length;i++){const{type:s,value:o}=n[i],u=cEe[s];s==="era"?r[u]=o:Tt(u)||(r[u]=parseInt(o,10))}return r}let i_={};class Du extends sh{static create(e){return i_[e]||(i_[e]=new Du(e)),i_[e]}static resetCache(){i_={},r_={}}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=Du.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:n,locale:r}){return Pz(e,n,r,this.name)}formatOffset(e,n){return bg(this.offset(e),n)}offset(e){const n=new Date(e);if(isNaN(n))return NaN;const r=lEe(this.name);let[i,s,o,u,a,l,c]=r.formatToParts?xEe(r,n):fEe(r,n);u==="BC"&&(i=-Math.abs(i)+1);const d=LD({year:i,month:s,day:o,hour:a===24?0:a,minute:l,second:c,millisecond:0});let h=+n;const p=h%1e3;return h-=p>=0?p:1e3+p,(d-h)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}let $D=null;class jr extends sh{static get utcInstance(){return $D===null&&($D=new jr(0)),$D}static instance(e){return e===0?jr.utcInstance:new jr(e)}static parseSpecifier(e){if(e){const n=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new jr(Zv(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${bg(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${bg(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,n){return bg(this.fixed,n)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}}class Kz extends sh{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}}function d0(t,e){if(Tt(t)||t===null)return e;if(t instanceof sh)return t;if(Gye(t)){const n=t.toLowerCase();return n==="local"||n==="system"?e:n==="utc"||n==="gmt"?jr.utcInstance:jr.parseSpecifier(n)||Du.create(t)}else return vf(t)?jr.instance(t):typeof t=="object"&&t.offset&&typeof t.offset=="number"?t:new Kz(t)}let Jz=()=>Date.now(),Xz="system",Zz=null,eQ=null,tQ=null,nQ;class $n{static get now(){return Jz}static set now(e){Jz=e}static set defaultZone(e){Xz=e}static get defaultZone(){return d0(Xz,n_.instance)}static get defaultLocale(){return Zz}static set defaultLocale(e){Zz=e}static get defaultNumberingSystem(){return eQ}static set defaultNumberingSystem(e){eQ=e}static get defaultOutputCalendar(){return tQ}static set defaultOutputCalendar(e){tQ=e}static get throwOnInvalid(){return nQ}static set throwOnInvalid(e){nQ=e}static resetCaches(){gn.resetCache(),Du.resetCache()}}let rQ={};function dEe(t,e={}){const n=JSON.stringify([t,e]);let r=rQ[n];return r||(r=new Intl.ListFormat(t,e),rQ[n]=r),r}let kD={};function MD(t,e={}){const n=JSON.stringify([t,e]);let r=kD[n];return r||(r=new Intl.DateTimeFormat(t,e),kD[n]=r),r}let PD={};function hEe(t,e={}){const n=JSON.stringify([t,e]);let r=PD[n];return r||(r=new Intl.NumberFormat(t,e),PD[n]=r),r}let UD={};function pEe(t,e={}){const{base:n,...r}=e,i=JSON.stringify([t,r]);let s=UD[i];return s||(s=new Intl.RelativeTimeFormat(t,e),UD[i]=s),s}let Tg=null;function gEe(){return Tg||(Tg=new Intl.DateTimeFormat().resolvedOptions().locale,Tg)}function mEe(t){const e=t.indexOf("-u-");if(e===-1)return[t];{let n;const r=t.substring(0,e);try{n=MD(t).resolvedOptions()}catch{n=MD(r).resolvedOptions()}const{numberingSystem:i,calendar:s}=n;return[r,i,s]}}function yEe(t,e,n){return(n||e)&&(t+="-u",n&&(t+=`-ca-${n}`),e&&(t+=`-nu-${e}`)),t}function EEe(t){const e=[];for(let n=1;n<=12;n++){const r=ft.utc(2016,n,1);e.push(t(r))}return e}function AEe(t){const e=[];for(let n=1;n<=7;n++){const r=ft.utc(2016,11,13+n);e.push(t(r))}return e}function s_(t,e,n,r,i){const s=t.listingMode(n);return s==="error"?null:s==="en"?r(e):i(e)}function vEe(t){return t.numberingSystem&&t.numberingSystem!=="latn"?!1:t.numberingSystem==="latn"||!t.locale||t.locale.startsWith("en")||new Intl.DateTimeFormat(t.intl).resolvedOptions().numberingSystem==="latn"}class _Ee{constructor(e,n,r){this.padTo=r.padTo||0,this.floor=r.floor||!1;const{padTo:i,floor:s,...o}=r;if(!n||Object.keys(o).length>0){const u={useGrouping:!1,...r};r.padTo>0&&(u.minimumIntegerDigits=r.padTo),this.inf=hEe(e,u)}}format(e){if(this.inf){const n=this.floor?Math.floor(e):e;return this.inf.format(n)}else{const n=this.floor?Math.floor(e):FD(e,3);return Bn(n,this.padTo)}}}class SEe{constructor(e,n,r){this.opts=r;let i;if(e.zone.isUniversal){const o=-1*(e.offset/60),u=o>=0?`Etc/GMT+${o}`:`Etc/GMT${o}`;e.offset!==0&&Du.create(u).valid?(i=u,this.dt=e):(i="UTC",r.timeZoneName?this.dt=e:this.dt=e.offset===0?e:ft.fromMillis(e.ts+e.offset*60*1e3))}else e.zone.type==="system"?this.dt=e:(this.dt=e,i=e.zone.name);const s={...this.opts};i&&(s.timeZone=i),this.dtf=MD(n,s)}format(){return this.dtf.format(this.dt.toJSDate())}formatToParts(){return this.dtf.formatToParts(this.dt.toJSDate())}resolvedOptions(){return this.dtf.resolvedOptions()}}class CEe{constructor(e,n,r){this.opts={style:"long",...r},!n&&kz()&&(this.rtf=pEe(e,r))}format(e,n){return this.rtf?this.rtf.format(e,n):uEe(n,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,n){return this.rtf?this.rtf.formatToParts(e,n):[]}}class gn{static fromOpts(e){return gn.create(e.locale,e.numberingSystem,e.outputCalendar,e.defaultToEN)}static create(e,n,r,i=!1){const s=e||$n.defaultLocale,o=s||(i?"en-US":gEe()),u=n||$n.defaultNumberingSystem,a=r||$n.defaultOutputCalendar;return new gn(o,u,a,s)}static resetCache(){Tg=null,kD={},PD={},UD={}}static fromObject({locale:e,numberingSystem:n,outputCalendar:r}={}){return gn.create(e,n,r)}constructor(e,n,r,i){const[s,o,u]=mEe(e);this.locale=s,this.numberingSystem=n||o||null,this.outputCalendar=r||u||null,this.intl=yEe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=vEe(this)),this.fastNumbersCached}listingMode(){const e=this.isEnglish(),n=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&n?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:gn.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,n=!1,r=!0){return s_(this,e,r,Hz,()=>{const i=n?{month:e,day:"numeric"}:{month:e},s=n?"format":"standalone";return this.monthsCache[s][e]||(this.monthsCache[s][e]=EEe(o=>this.extract(o,i,"month"))),this.monthsCache[s][e]})}weekdays(e,n=!1,r=!0){return s_(this,e,r,Gz,()=>{const i=n?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},s=n?"format":"standalone";return this.weekdaysCache[s][e]||(this.weekdaysCache[s][e]=AEe(o=>this.extract(o,i,"weekday"))),this.weekdaysCache[s][e]})}meridiems(e=!0){return s_(this,void 0,e,()=>Wz,()=>{if(!this.meridiemCache){const n={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[ft.utc(2016,11,13,9),ft.utc(2016,11,13,19)].map(r=>this.extract(r,n,"dayperiod"))}return this.meridiemCache})}eras(e,n=!0){return s_(this,e,n,Vz,()=>{const r={era:e};return this.eraCache[e]||(this.eraCache[e]=[ft.utc(-40,1,1),ft.utc(2017,1,1)].map(i=>this.extract(i,r,"era"))),this.eraCache[e]})}extract(e,n,r){const i=this.dtFormatter(e,n),s=i.formatToParts(),o=s.find(u=>u.type.toLowerCase()===r);return o?o.value:null}numberFormatter(e={}){return new _Ee(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,n={}){return new SEe(e,this.intl,n)}relFormatter(e={}){return new CEe(this.intl,this.isEnglish(),e)}listFormatter(e={}){return dEe(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}}function oh(...t){const e=t.reduce((n,r)=>n+r.source,"");return RegExp(`^${e}$`)}function uh(...t){return e=>t.reduce(([n,r,i],s)=>{const[o,u,a]=s(e,i);return[{...n,...o},u||r,a]},[{},null,1]).slice(0,2)}function ah(t,...e){if(t==null)return[null,null];for(const[n,r]of e){const i=n.exec(t);if(i)return r(i)}return[null,null]}function iQ(...t){return(e,n)=>{const r={};let i;for(i=0;i<t.length;i++)r[t[i]]=x0(e[n+i]);return[r,null,n+i]}}const sQ=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,bEe=`(?:${sQ.source}?(?:\\[(${jz.source})\\])?)?`,jD=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,oQ=RegExp(`${jD.source}${bEe}`),qD=RegExp(`(?:T${oQ.source})?`),TEe=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,REe=/(\d{4})-?W(\d\d)(?:-?(\d))?/,OEe=/(\d{4})-?(\d{3})/,DEe=iQ("weekYear","weekNumber","weekDay"),wEe=iQ("year","ordinal"),NEe=/(\d{4})-(\d\d)-(\d\d)/,uQ=RegExp(`${jD.source} ?(?:${sQ.source}|(${jz.source}))?`),FEe=RegExp(`(?: ${uQ.source})?`);function lh(t,e,n){const r=t[e];return Tt(r)?n:x0(r)}function LEe(t,e){return[{year:lh(t,e),month:lh(t,e+1,1),day:lh(t,e+2,1)},null,e+3]}function ch(t,e){return[{hours:lh(t,e,0),minutes:lh(t,e+1,0),seconds:lh(t,e+2,0),milliseconds:ND(t[e+3])},null,e+4]}function Rg(t,e){const n=!t[e]&&!t[e+1],r=Zv(t[e+1],t[e+2]),i=n?null:jr.instance(r);return[{},i,e+3]}function Og(t,e){const n=t[e]?Du.create(t[e]):null;return[{},n,e+1]}const IEe=RegExp(`^T?${jD.source}$`),BEe=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function $Ee(t){const[e,n,r,i,s,o,u,a,l]=t,c=e[0]==="-",f=a&&a[0]==="-",d=(h,p=!1)=>h!==void 0&&(p||h&&c)?-h:h;return[{years:d(_f(n)),months:d(_f(r)),weeks:d(_f(i)),days:d(_f(s)),hours:d(_f(o)),minutes:d(_f(u)),seconds:d(_f(a),a==="-0"),milliseconds:d(ND(l),f)}]}const kEe={GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function HD(t,e,n,r,i,s,o){const u={year:e.length===2?ID(x0(e)):x0(e),month:qz.indexOf(n)+1,day:x0(r),hour:x0(i),minute:x0(s)};return o&&(u.second=x0(o)),t&&(u.weekday=t.length>3?zz.indexOf(t)+1:Qz.indexOf(t)+1),u}const MEe=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function PEe(t){const[,e,n,r,i,s,o,u,a,l,c,f]=t,d=HD(e,i,r,n,s,o,u);let h;return a?h=kEe[a]:l?h=0:h=Zv(c,f),[d,new jr(h)]}function UEe(t){return t.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}const jEe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,qEe=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,HEe=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function aQ(t){const[,e,n,r,i,s,o,u]=t;return[HD(e,i,r,n,s,o,u),jr.utcInstance]}function zEe(t){const[,e,n,r,i,s,o,u]=t;return[HD(e,u,n,r,i,s,o),jr.utcInstance]}const QEe=oh(TEe,qD),GEe=oh(REe,qD),WEe=oh(OEe,qD),VEe=oh(oQ),lQ=uh(LEe,ch,Rg,Og),YEe=uh(DEe,ch,Rg,Og),KEe=uh(wEe,ch,Rg,Og),JEe=uh(ch,Rg,Og);function XEe(t){return ah(t,[QEe,lQ],[GEe,YEe],[WEe,KEe],[VEe,JEe])}function ZEe(t){return ah(UEe(t),[MEe,PEe])}function eAe(t){return ah(t,[jEe,aQ],[qEe,aQ],[HEe,zEe])}function tAe(t){return ah(t,[BEe,$Ee])}const nAe=uh(ch);function rAe(t){return ah(t,[IEe,nAe])}const iAe=oh(NEe,FEe),sAe=oh(uQ),oAe=uh(ch,Rg,Og);function uAe(t){return ah(t,[iAe,lQ],[sAe,oAe])}const aAe="Invalid Duration",cQ={weeks:{days:7,hours:7*24,minutes:7*24*60,seconds:7*24*60*60,milliseconds:7*24*60*60*1e3},days:{hours:24,minutes:24*60,seconds:24*60*60,milliseconds:24*60*60*1e3},hours:{minutes:60,seconds:60*60,milliseconds:60*60*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},lAe={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:91*24,minutes:91*24*60,seconds:91*24*60*60,milliseconds:91*24*60*60*1e3},months:{weeks:4,days:30,hours:30*24,minutes:30*24*60,seconds:30*24*60*60,milliseconds:30*24*60*60*1e3},...cQ},Us=146097/400,fh=146097/4800,cAe={years:{quarters:4,months:12,weeks:Us/7,days:Us,hours:Us*24,minutes:Us*24*60,seconds:Us*24*60*60,milliseconds:Us*24*60*60*1e3},quarters:{months:3,weeks:Us/28,days:Us/4,hours:Us*24/4,minutes:Us*24*60/4,seconds:Us*24*60*60/4,milliseconds:Us*24*60*60*1e3/4},months:{weeks:fh/7,days:fh,hours:fh*24,minutes:fh*24*60,seconds:fh*24*60*60,milliseconds:fh*24*60*60*1e3},...cQ},Sf=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],fAe=Sf.slice(0).reverse();function Cf(t,e,n=!1){const r={values:n?e.values:{...t.values,...e.values||{}},loc:t.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||t.conversionAccuracy};return new Rt(r)}function xAe(t){return t<0?Math.floor(t):Math.ceil(t)}function fQ(t,e,n,r,i){const s=t[i][n],o=e[n]/s,u=Math.sign(o)===Math.sign(r[i]),a=!u&&r[i]!==0&&Math.abs(o)<=1?xAe(o):Math.trunc(o);r[i]+=a,e[n]-=a*s}function dAe(t,e){fAe.reduce((n,r)=>Tt(e[r])?n:(n&&fQ(t,e,n,e,r),r),null)}class Rt{constructor(e){const n=e.conversionAccuracy==="longterm"||!1;this.values=e.values,this.loc=e.loc||gn.create(),this.conversionAccuracy=n?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n?cAe:lAe,this.isLuxonDuration=!0}static fromMillis(e,n){return Rt.fromObject({milliseconds:e},n)}static fromObject(e,n={}){if(e==null||typeof e!="object")throw new Ps(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new Rt({values:e_(e,Rt.normalizeUnit),loc:gn.fromObject(n),conversionAccuracy:n.conversionAccuracy})}static fromDurationLike(e){if(vf(e))return Rt.fromMillis(e);if(Rt.isDuration(e))return e;if(typeof e=="object")return Rt.fromObject(e);throw new Ps(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,n){const[r]=tAe(e);return r?Rt.fromObject(r,n):Rt.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,n){const[r]=rAe(e);return r?Rt.fromObject(r,n):Rt.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,n=null){if(!e)throw new Ps("need to specify a reason the Duration is invalid");const r=e instanceof bo?e:new bo(e,n);if($n.throwOnInvalid)throw new Hye(r);return new Rt({invalid:r})}static normalizeUnit(e){const n={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!n)throw new mz(e);return n}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,n={}){const r={...n,floor:n.round!==!1&&n.floor!==!1};return this.isValid?Ni.create(this.loc,r).formatDurationFromString(this,e):aAe}toHuman(e={}){const n=Sf.map(r=>{const i=this.values[r];return Tt(i)?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:r.slice(0,-1)}).format(i)}).filter(r=>r);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=FD(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;const n=this.toMillis();if(n<0||n>=864e5)return null;e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e};const r=this.shiftTo("hours","minutes","seconds","milliseconds");let i=e.format==="basic"?"hhmm":"hh:mm";(!e.suppressSeconds||r.seconds!==0||r.milliseconds!==0)&&(i+=e.format==="basic"?"ss":":ss",(!e.suppressMilliseconds||r.milliseconds!==0)&&(i+=".SSS"));let s=r.toFormat(i);return e.includePrefix&&(s="T"+s),s}toJSON(){return this.toISO()}toString(){return this.toISO()}toMillis(){return this.as("milliseconds")}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;const n=Rt.fromDurationLike(e),r={};for(const i of Sf)(ih(n.values,i)||ih(this.values,i))&&(r[i]=n.get(i)+this.get(i));return Cf(this,{values:r},!0)}minus(e){if(!this.isValid)return this;const n=Rt.fromDurationLike(e);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;const n={};for(const r of Object.keys(this.values))n[r]=Uz(e(this.values[r],r));return Cf(this,{values:n},!0)}get(e){return this[Rt.normalizeUnit(e)]}set(e){if(!this.isValid)return this;const n={...this.values,...e_(e,Rt.normalizeUnit)};return Cf(this,{values:n})}reconfigure({locale:e,numberingSystem:n,conversionAccuracy:r}={}){const i=this.loc.clone({locale:e,numberingSystem:n}),s={loc:i};return r&&(s.conversionAccuracy=r),Cf(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;const e=this.toObject();return dAe(this.matrix,e),Cf(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(o=>Rt.normalizeUnit(o));const n={},r={},i=this.toObject();let s;for(const o of Sf)if(e.indexOf(o)>=0){s=o;let u=0;for(const l in r)u+=this.matrix[l][o]*r[l],r[l]=0;vf(i[o])&&(u+=i[o]);const a=Math.trunc(u);n[o]=a,r[o]=(u*1e3-a*1e3)/1e3;for(const l in i)Sf.indexOf(l)>Sf.indexOf(o)&&fQ(this.matrix,i,l,n,o)}else vf(i[o])&&(r[o]=i[o]);for(const o in r)r[o]!==0&&(n[s]+=o===s?r[o]:r[o]/this.matrix[s][o]);return Cf(this,{values:n},!0).normalize()}negate(){if(!this.isValid)return this;const e={};for(const n of Object.keys(this.values))e[n]=this.values[n]===0?0:-this.values[n];return Cf(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function n(r,i){return r===void 0||r===0?i===void 0||i===0:r===i}for(const r of Sf)if(!n(this.values[r],e.values[r]))return!1;return!0}}const Dg="Invalid Interval";function hAe(t,e){return!t||!t.isValid?mn.invalid("missing or invalid start"):!e||!e.isValid?mn.invalid("missing or invalid end"):e<t?mn.invalid("end before start",`The end of an interval must be after its start, but you had start=${t.toISO()} and end=${e.toISO()}`):null}class mn{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,n=null){if(!e)throw new Ps("need to specify a reason the Interval is invalid");const r=e instanceof bo?e:new bo(e,n);if($n.throwOnInvalid)throw new qye(r);return new mn({invalid:r})}static fromDateTimes(e,n){const r=Lg(e),i=Lg(n),s=hAe(r,i);return s??new mn({start:r,end:i})}static after(e,n){const r=Rt.fromDurationLike(n),i=Lg(e);return mn.fromDateTimes(i,i.plus(r))}static before(e,n){const r=Rt.fromDurationLike(n),i=Lg(e);return mn.fromDateTimes(i.minus(r),i)}static fromISO(e,n){const[r,i]=(e||"").split("/",2);if(r&&i){let s,o;try{s=ft.fromISO(r,n),o=s.isValid}catch{o=!1}let u,a;try{u=ft.fromISO(i,n),a=u.isValid}catch{a=!1}if(o&&a)return mn.fromDateTimes(s,u);if(o){const l=Rt.fromISO(i,n);if(l.isValid)return mn.after(s,l)}else if(a){const l=Rt.fromISO(r,n);if(l.isValid)return mn.before(u,l)}}return mn.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds"){if(!this.isValid)return NaN;const n=this.start.startOf(e),r=this.end.startOf(e);return Math.floor(r.diff(n,e).get(e))+1}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:n}={}){return this.isValid?mn.fromDateTimes(e||this.s,n||this.e):this}splitAt(...e){if(!this.isValid)return[];const n=e.map(Lg).filter(o=>this.contains(o)).sort(),r=[];let{s:i}=this,s=0;for(;i<this.e;){const o=n[s]||this.e,u=+o>+this.e?this.e:o;r.push(mn.fromDateTimes(i,u)),i=u,s+=1}return r}splitBy(e){const n=Rt.fromDurationLike(e);if(!this.isValid||!n.isValid||n.as("milliseconds")===0)return[];let{s:r}=this,i=1,s;const o=[];for(;r<this.e;){const u=this.start.plus(n.mapUnits(a=>a*i));s=+u>+this.e?this.e:u,o.push(mn.fromDateTimes(r,s)),r=s,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;const n=this.s>e.s?this.s:e.s,r=this.e<e.e?this.e:e.e;return n>=r?null:mn.fromDateTimes(n,r)}union(e){if(!this.isValid)return this;const n=this.s<e.s?this.s:e.s,r=this.e>e.e?this.e:e.e;return mn.fromDateTimes(n,r)}static merge(e){const[n,r]=e.sort((i,s)=>i.s-s.s).reduce(([i,s],o)=>s?s.overlaps(o)||s.abutsStart(o)?[i,s.union(o)]:[i.concat([s]),o]:[i,o],[[],null]);return r&&n.push(r),n}static xor(e){let n=null,r=0;const i=[],s=e.map(a=>[{time:a.s,type:"s"},{time:a.e,type:"e"}]),o=Array.prototype.concat(...s),u=o.sort((a,l)=>a.time-l.time);for(const a of u)r+=a.type==="s"?1:-1,r===1?n=a.time:(n&&+n!=+a.time&&i.push(mn.fromDateTimes(n,a.time)),n=null);return mn.merge(i)}difference(...e){return mn.xor([this].concat(e)).map(n=>this.intersection(n)).filter(n=>n&&!n.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Dg}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Dg}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Dg}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Dg}toFormat(e,{separator:n=" – "}={}){return this.isValid?`${this.s.toFormat(e)}${n}${this.e.toFormat(e)}`:Dg}toDuration(e,n){return this.isValid?this.e.diff(this.s,e,n):Rt.invalid(this.invalidReason)}mapEndpoints(e){return mn.fromDateTimes(e(this.s),e(this.e))}}let wg=class{static hasDST(e=$n.defaultZone){const n=ft.now().setZone(e).set({month:12});return!e.isUniversal&&n.offset!==n.set({month:6}).offset}static isValidIANAZone(e){return Du.isValidZone(e)}static normalizeZone(e){return d0(e,$n.defaultZone)}static months(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null,outputCalendar:s="gregory"}={}){return(i||gn.create(n,r,s)).months(e)}static monthsFormat(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null,outputCalendar:s="gregory"}={}){return(i||gn.create(n,r,s)).months(e,!0)}static weekdays(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null}={}){return(i||gn.create(n,r,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:n=null,numberingSystem:r=null,locObj:i=null}={}){return(i||gn.create(n,r,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return gn.create(e).meridiems()}static eras(e="short",{locale:n=null}={}){return gn.create(n,null,"gregory").eras(e)}static features(){return{relative:kz()}}};function xQ(t,e){const n=i=>i.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),r=n(e)-n(t);return Math.floor(Rt.fromMillis(r).as("days"))}function pAe(t,e,n){const r=[["years",(u,a)=>a.year-u.year],["quarters",(u,a)=>a.quarter-u.quarter],["months",(u,a)=>a.month-u.month+(a.year-u.year)*12],["weeks",(u,a)=>{const l=xQ(u,a);return(l-l%7)/7}],["days",xQ]],i={};let s,o;for(const[u,a]of r)if(n.indexOf(u)>=0){s=u;let l=a(t,e);o=t.plus({[u]:l}),o>e?(t=t.plus({[u]:l-1}),l-=1):t=o,i[u]=l}return[t,i,o,s]}function gAe(t,e,n,r){let[i,s,o,u]=pAe(t,e,n);const a=e-i,l=n.filter(f=>["hours","minutes","seconds","milliseconds"].indexOf(f)>=0);l.length===0&&(o<e&&(o=i.plus({[u]:1})),o!==i&&(s[u]=(s[u]||0)+a/(o-i)));const c=Rt.fromObject(s,r);return l.length>0?Rt.fromMillis(a,r).shiftTo(...l).plus(c):c}const zD={arab:"[٠-٩]",arabext:"[۰-۹]",bali:"[᭐-᭙]",beng:"[০-৯]",deva:"[०-९]",fullwide:"[0-9]",gujr:"[૦-૯]",hanidec:"[〇|一|二|三|四|五|六|七|八|九]",khmr:"[០-៩]",knda:"[೦-೯]",laoo:"[໐-໙]",limb:"[᥆-᥏]",mlym:"[൦-൯]",mong:"[᠐-᠙]",mymr:"[၀-၉]",orya:"[୦-୯]",tamldec:"[௦-௯]",telu:"[౦-౯]",thai:"[๐-๙]",tibt:"[༠-༩]",latn:"\\d"},dQ={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},mAe=zD.hanidec.replace(/[\[|\]]/g,"").split("");function yAe(t){let e=parseInt(t,10);if(isNaN(e)){e="";for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);if(t[n].search(zD.hanidec)!==-1)e+=mAe.indexOf(t[n]);else for(const i in dQ){const[s,o]=dQ[i];r>=s&&r<=o&&(e+=r-s)}}return parseInt(e,10)}else return e}function To({numberingSystem:t},e=""){return new RegExp(`${zD[t||"latn"]}${e}`)}const EAe="missing Intl.DateTimeFormat.formatToParts support";function kt(t,e=n=>n){return{regex:t,deser:([n])=>e(yAe(n))}}const hQ="[  ]",pQ=new RegExp(hQ,"g");function AAe(t){return t.replace(/\./g,"\\.?").replace(pQ,hQ)}function gQ(t){return t.replace(/\./g,"").replace(pQ," ").toLowerCase()}function Ro(t,e){return t===null?null:{regex:RegExp(t.map(AAe).join("|")),deser:([n])=>t.findIndex(r=>gQ(n)===gQ(r))+e}}function mQ(t,e){return{regex:t,deser:([,n,r])=>Zv(n,r),groups:e}}function QD(t){return{regex:t,deser:([e])=>e}}function vAe(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function _Ae(t,e){const n=To(e),r=To(e,"{2}"),i=To(e,"{3}"),s=To(e,"{4}"),o=To(e,"{6}"),u=To(e,"{1,2}"),a=To(e,"{1,3}"),l=To(e,"{1,6}"),c=To(e,"{1,9}"),f=To(e,"{2,4}"),d=To(e,"{4,6}"),h=g=>({regex:RegExp(vAe(g.val)),deser:([y])=>y,literal:!0}),m=(g=>{if(t.literal)return h(g);switch(g.val){case"G":return Ro(e.eras("short",!1),0);case"GG":return Ro(e.eras("long",!1),0);case"y":return kt(l);case"yy":return kt(f,ID);case"yyyy":return kt(s);case"yyyyy":return kt(d);case"yyyyyy":return kt(o);case"M":return kt(u);case"MM":return kt(r);case"MMM":return Ro(e.months("short",!0,!1),1);case"MMMM":return Ro(e.months("long",!0,!1),1);case"L":return kt(u);case"LL":return kt(r);case"LLL":return Ro(e.months("short",!1,!1),1);case"LLLL":return Ro(e.months("long",!1,!1),1);case"d":return kt(u);case"dd":return kt(r);case"o":return kt(a);case"ooo":return kt(i);case"HH":return kt(r);case"H":return kt(u);case"hh":return kt(r);case"h":return kt(u);case"mm":return kt(r);case"m":return kt(u);case"q":return kt(u);case"qq":return kt(r);case"s":return kt(u);case"ss":return kt(r);case"S":return kt(a);case"SSS":return kt(i);case"u":return QD(c);case"uu":return QD(u);case"uuu":return kt(n);case"a":return Ro(e.meridiems(),0);case"kkkk":return kt(s);case"kk":return kt(f,ID);case"W":return kt(u);case"WW":return kt(r);case"E":case"c":return kt(n);case"EEE":return Ro(e.weekdays("short",!1,!1),1);case"EEEE":return Ro(e.weekdays("long",!1,!1),1);case"ccc":return Ro(e.weekdays("short",!0,!1),1);case"cccc":return Ro(e.weekdays("long",!0,!1),1);case"Z":case"ZZ":return mQ(new RegExp(`([+-]${u.source})(?::(${r.source}))?`),2);case"ZZZ":return mQ(new RegExp(`([+-]${u.source})(${r.source})?`),2);case"z":return QD(/[a-z_+-/]{1,256}?/i);default:return h(g)}})(t)||{invalidReason:EAe};return m.token=t,m}const SAe={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour:{numeric:"h","2-digit":"hh"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"}};function CAe(t,e,n){const{type:r,value:i}=t;if(r==="literal")return{literal:!0,val:i};const s=n[r];let o=SAe[r];if(typeof o=="object"&&(o=o[s]),o)return{literal:!1,val:o}}function bAe(t){return[`^${t.map(n=>n.regex).reduce((n,r)=>`${n}(${r.source})`,"")}$`,t]}function TAe(t,e,n){const r=t.match(e);if(r){const i={};let s=1;for(const o in n)if(ih(n,o)){const u=n[o],a=u.groups?u.groups+1:1;!u.literal&&u.token&&(i[u.token.val[0]]=u.deser(r.slice(s,s+a))),s+=a}return[r,i]}else return[r,{}]}function RAe(t){const e=s=>{switch(s){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}};let n=null,r;return Tt(t.z)||(n=Du.create(t.z)),Tt(t.Z)||(n||(n=new jr(t.Z)),r=t.Z),Tt(t.q)||(t.M=(t.q-1)*3+1),Tt(t.h)||(t.h<12&&t.a===1?t.h+=12:t.h===12&&t.a===0&&(t.h=0)),t.G===0&&t.y&&(t.y=-t.y),Tt(t.u)||(t.S=ND(t.u)),[Object.keys(t).reduce((s,o)=>{const u=e(o);return u&&(s[u]=t[o]),s},{}),n,r]}let GD=null;function OAe(){return GD||(GD=ft.fromMillis(1555555555555)),GD}function DAe(t,e){if(t.literal)return t;const n=Ni.macroTokenToFormatOpts(t.val);if(!n)return t;const s=Ni.create(e,n).formatDateTimeParts(OAe()).map(o=>CAe(o,e,n));return s.includes(void 0)?t:s}function wAe(t,e){return Array.prototype.concat(...t.map(n=>DAe(n,e)))}function yQ(t,e,n){const r=wAe(Ni.parseFormat(n),t),i=r.map(o=>_Ae(o,t)),s=i.find(o=>o.invalidReason);if(s)return{input:e,tokens:r,invalidReason:s.invalidReason};{const[o,u]=bAe(i),a=RegExp(o,"i"),[l,c]=TAe(e,a,u),[f,d,h]=c?RAe(c):[null,null,void 0];if(ih(c,"a")&&ih(c,"H"))throw new _g("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:r,regex:a,rawMatches:l,matches:c,result:f,zone:d,specificOffset:h}}}function NAe(t,e,n){const{result:r,zone:i,specificOffset:s,invalidReason:o}=yQ(t,e,n);return[r,i,s,o]}const EQ=[0,31,59,90,120,151,181,212,243,273,304,334],AQ=[0,31,60,91,121,152,182,213,244,274,305,335];function js(t,e){return new bo("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${t}, which is invalid`)}function vQ(t,e,n){const r=new Date(Date.UTC(t,e-1,n));t<100&&t>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);const i=r.getUTCDay();return i===0?7:i}function _Q(t,e,n){return n+(Sg(t)?AQ:EQ)[e-1]}function SQ(t,e){const n=Sg(t)?AQ:EQ,r=n.findIndex(s=>s<e),i=e-n[r];return{month:r+1,day:i}}function WD(t){const{year:e,month:n,day:r}=t,i=_Q(e,n,r),s=vQ(e,n,r);let o=Math.floor((i-s+10)/7),u;return o<1?(u=e-1,o=Xv(u)):o>Xv(e)?(u=e+1,o=1):u=e,{weekYear:u,weekNumber:o,weekday:s,...t_(t)}}function CQ(t){const{weekYear:e,weekNumber:n,weekday:r}=t,i=vQ(e,1,4),s=Cg(e);let o=n*7+r-i-3,u;o<1?(u=e-1,o+=Cg(u)):o>s?(u=e+1,o-=Cg(e)):u=e;const{month:a,day:l}=SQ(u,o);return{year:u,month:a,day:l,...t_(t)}}function VD(t){const{year:e,month:n,day:r}=t,i=_Q(e,n,r);return{year:e,ordinal:i,...t_(t)}}function bQ(t){const{year:e,ordinal:n}=t,{month:r,day:i}=SQ(e,n);return{year:e,month:r,day:i,...t_(t)}}function FAe(t){const e=Kv(t.weekYear),n=Ua(t.weekNumber,1,Xv(t.weekYear)),r=Ua(t.weekday,1,7);return e?n?r?!1:js("weekday",t.weekday):js("week",t.week):js("weekYear",t.weekYear)}function LAe(t){const e=Kv(t.year),n=Ua(t.ordinal,1,Cg(t.year));return e?n?!1:js("ordinal",t.ordinal):js("year",t.year)}function TQ(t){const e=Kv(t.year),n=Ua(t.month,1,12),r=Ua(t.day,1,Jv(t.year,t.month));return e?n?r?!1:js("day",t.day):js("month",t.month):js("year",t.year)}function RQ(t){const{hour:e,minute:n,second:r,millisecond:i}=t,s=Ua(e,0,23)||e===24&&n===0&&r===0&&i===0,o=Ua(n,0,59),u=Ua(r,0,59),a=Ua(i,0,999);return s?o?u?a?!1:js("millisecond",i):js("second",r):js("minute",n):js("hour",e)}const YD="Invalid DateTime",OQ=864e13;function o_(t){return new bo("unsupported zone",`the zone "${t.name}" is not supported`)}function KD(t){return t.weekData===null&&(t.weekData=WD(t.c)),t.weekData}function Ng(t,e){const n={ts:t.ts,zone:t.zone,c:t.c,o:t.o,loc:t.loc,invalid:t.invalid};return new ft({...n,...e,old:n})}function DQ(t,e,n){let r=t-e*60*1e3;const i=n.offset(r);if(e===i)return[r,e];r-=(i-e)*60*1e3;const s=n.offset(r);return i===s?[r,i]:[t-Math.min(i,s)*60*1e3,Math.max(i,s)]}function wQ(t,e){t+=e*60*1e3;const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function u_(t,e,n){return DQ(LD(t),e,n)}function NQ(t,e){const n=t.o,r=t.c.year+Math.trunc(e.years),i=t.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,s={...t.c,year:r,month:i,day:Math.min(t.c.day,Jv(r,i))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},o=Rt.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),u=LD(s);let[a,l]=DQ(u,n,t.zone);return o!==0&&(a+=o,l=t.zone.offset(a)),{ts:a,o:l}}function Fg(t,e,n,r,i,s){const{setZone:o,zone:u}=n;if(t&&Object.keys(t).length!==0){const a=e||u,l=ft.fromObject(t,{...n,zone:a,specificOffset:s});return o?l:l.setZone(u)}else return ft.invalid(new bo("unparsable",`the input "${i}" can't be parsed as ${r}`))}function a_(t,e,n=!0){return t.isValid?Ni.create(gn.create("en-US"),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(t,e):null}function JD(t,e){const n=t.c.year>9999||t.c.year<0;let r="";return n&&t.c.year>=0&&(r+="+"),r+=Bn(t.c.year,n?6:4),e?(r+="-",r+=Bn(t.c.month),r+="-",r+=Bn(t.c.day)):(r+=Bn(t.c.month),r+=Bn(t.c.day)),r}function FQ(t,e,n,r,i,s){let o=Bn(t.c.hour);return e?(o+=":",o+=Bn(t.c.minute),(t.c.second!==0||!n)&&(o+=":")):o+=Bn(t.c.minute),(t.c.second!==0||!n)&&(o+=Bn(t.c.second),(t.c.millisecond!==0||!r)&&(o+=".",o+=Bn(t.c.millisecond,3))),i&&(t.isOffsetFixed&&t.offset===0&&!s?o+="Z":t.o<0?(o+="-",o+=Bn(Math.trunc(-t.o/60)),o+=":",o+=Bn(Math.trunc(-t.o%60))):(o+="+",o+=Bn(Math.trunc(t.o/60)),o+=":",o+=Bn(Math.trunc(t.o%60)))),s&&(o+="["+t.zone.ianaName+"]"),o}const LQ={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},IAe={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},BAe={ordinal:1,hour:0,minute:0,second:0,millisecond:0},IQ=["year","month","day","hour","minute","second","millisecond"],$Ae=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],kAe=["year","ordinal","hour","minute","second","millisecond"];function BQ(t){const e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[t.toLowerCase()];if(!e)throw new mz(t);return e}function $Q(t,e){const n=d0(e.zone,$n.defaultZone),r=gn.fromObject(e),i=$n.now();let s,o;if(Tt(t.year))s=i;else{for(const l of IQ)Tt(t[l])&&(t[l]=LQ[l]);const u=TQ(t)||RQ(t);if(u)return ft.invalid(u);const a=n.offset(i);[s,o]=u_(t,a,n)}return new ft({ts:s,zone:n,loc:r,o})}function kQ(t,e,n){const r=Tt(n.round)?!0:n.round,i=(o,u)=>(o=FD(o,r||n.calendary?0:2,!0),e.loc.clone(n).relFormatter(n).format(o,u)),s=o=>n.calendary?e.hasSame(t,o)?0:e.startOf(o).diff(t.startOf(o),o).get(o):e.diff(t,o).get(o);if(n.unit)return i(s(n.unit),n.unit);for(const o of n.units){const u=s(o);if(Math.abs(u)>=1)return i(u,o)}return i(t>e?-0:0,n.units[n.units.length-1])}function MQ(t){let e={},n;return t.length>0&&typeof t[t.length-1]=="object"?(e=t[t.length-1],n=Array.from(t).slice(0,t.length-1)):n=Array.from(t),[e,n]}class ft{constructor(e){const n=e.zone||$n.defaultZone;let r=e.invalid||(Number.isNaN(e.ts)?new bo("invalid input"):null)||(n.isValid?null:o_(n));this.ts=Tt(e.ts)?$n.now():e.ts;let i=null,s=null;if(!r)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(n))[i,s]=[e.old.c,e.old.o];else{const u=n.offset(this.ts);i=wQ(this.ts,u),r=Number.isNaN(i.year)?new bo("invalid input"):null,i=r?null:i,s=r?null:u}this._zone=n,this.loc=e.loc||gn.create(),this.invalid=r,this.weekData=null,this.c=i,this.o=s,this.isLuxonDateTime=!0}static now(){return new ft({})}static local(){const[e,n]=MQ(arguments),[r,i,s,o,u,a,l]=n;return $Q({year:r,month:i,day:s,hour:o,minute:u,second:a,millisecond:l},e)}static utc(){const[e,n]=MQ(arguments),[r,i,s,o,u,a,l]=n;return e.zone=jr.utcInstance,$Q({year:r,month:i,day:s,hour:o,minute:u,second:a,millisecond:l},e)}static fromJSDate(e,n={}){const r=Wye(e)?e.valueOf():NaN;if(Number.isNaN(r))return ft.invalid("invalid input");const i=d0(n.zone,$n.defaultZone);return i.isValid?new ft({ts:r,zone:i,loc:gn.fromObject(n)}):ft.invalid(o_(i))}static fromMillis(e,n={}){if(vf(e))return e<-OQ||e>OQ?ft.invalid("Timestamp out of range"):new ft({ts:e,zone:d0(n.zone,$n.defaultZone),loc:gn.fromObject(n)});throw new Ps(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,n={}){if(vf(e))return new ft({ts:e*1e3,zone:d0(n.zone,$n.defaultZone),loc:gn.fromObject(n)});throw new Ps("fromSeconds requires a numerical input")}static fromObject(e,n={}){e=e||{};const r=d0(n.zone,$n.defaultZone);if(!r.isValid)return ft.invalid(o_(r));const i=$n.now(),s=Tt(n.specificOffset)?r.offset(i):n.specificOffset,o=e_(e,BQ),u=!Tt(o.ordinal),a=!Tt(o.year),l=!Tt(o.month)||!Tt(o.day),c=a||l,f=o.weekYear||o.weekNumber,d=gn.fromObject(n);if((c||u)&&f)throw new _g("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(l&&u)throw new _g("Can't mix ordinal dates with month/day");const h=f||o.weekday&&!c;let p,m,g=wQ(i,s);h?(p=$Ae,m=IAe,g=WD(g)):u?(p=kAe,m=BAe,g=VD(g)):(p=IQ,m=LQ);let y=!1;for(const b of p){const w=o[b];Tt(w)?y?o[b]=m[b]:o[b]=g[b]:y=!0}const E=h?FAe(o):u?LAe(o):TQ(o),A=E||RQ(o);if(A)return ft.invalid(A);const v=h?CQ(o):u?bQ(o):o,[_,S]=u_(v,s,r),C=new ft({ts:_,zone:r,o:S,loc:d});return o.weekday&&c&&e.weekday!==C.weekday?ft.invalid("mismatched weekday",`you can't specify both a weekday of ${o.weekday} and a date of ${C.toISO()}`):C}static fromISO(e,n={}){const[r,i]=XEe(e);return Fg(r,i,n,"ISO 8601",e)}static fromRFC2822(e,n={}){const[r,i]=ZEe(e);return Fg(r,i,n,"RFC 2822",e)}static fromHTTP(e,n={}){const[r,i]=eAe(e);return Fg(r,i,n,"HTTP",n)}static fromFormat(e,n,r={}){if(Tt(e)||Tt(n))throw new Ps("fromFormat requires an input string and a format");const{locale:i=null,numberingSystem:s=null}=r,o=gn.fromOpts({locale:i,numberingSystem:s,defaultToEN:!0}),[u,a,l,c]=NAe(o,e,n);return c?ft.invalid(c):Fg(u,a,r,`format ${n}`,e,l)}static fromString(e,n,r={}){return ft.fromFormat(e,n,r)}static fromSQL(e,n={}){const[r,i]=uAe(e);return Fg(r,i,n,"SQL",e)}static invalid(e,n=null){if(!e)throw new Ps("need to specify a reason the DateTime is invalid");const r=e instanceof bo?e:new bo(e,n);if($n.throwOnInvalid)throw new jye(r);return new ft({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?KD(this).weekYear:NaN}get weekNumber(){return this.isValid?KD(this).weekNumber:NaN}get weekday(){return this.isValid?KD(this).weekday:NaN}get ordinal(){return this.isValid?VD(this.c).ordinal:NaN}get monthShort(){return this.isValid?wg.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?wg.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?wg.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?wg.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}get isInLeapYear(){return Sg(this.year)}get daysInMonth(){return Jv(this.year,this.month)}get daysInYear(){return this.isValid?Cg(this.year):NaN}get weeksInWeekYear(){return this.isValid?Xv(this.weekYear):NaN}resolvedLocaleOptions(e={}){const{locale:n,numberingSystem:r,calendar:i}=Ni.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:n,numberingSystem:r,outputCalendar:i}}toUTC(e=0,n={}){return this.setZone(jr.instance(e),n)}toLocal(){return this.setZone($n.defaultZone)}setZone(e,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(e=d0(e,$n.defaultZone),e.equals(this.zone))return this;if(e.isValid){let i=this.ts;if(n||r){const s=e.offset(this.ts),o=this.toObject();[i]=u_(o,s,e)}return Ng(this,{ts:i,zone:e})}else return ft.invalid(o_(e))}reconfigure({locale:e,numberingSystem:n,outputCalendar:r}={}){const i=this.loc.clone({locale:e,numberingSystem:n,outputCalendar:r});return Ng(this,{loc:i})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;const n=e_(e,BQ),r=!Tt(n.weekYear)||!Tt(n.weekNumber)||!Tt(n.weekday),i=!Tt(n.ordinal),s=!Tt(n.year),o=!Tt(n.month)||!Tt(n.day),u=s||o,a=n.weekYear||n.weekNumber;if((u||i)&&a)throw new _g("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(o&&i)throw new _g("Can't mix ordinal dates with month/day");let l;r?l=CQ({...WD(this.c),...n}):Tt(n.ordinal)?(l={...this.toObject(),...n},Tt(n.day)&&(l.day=Math.min(Jv(l.year,l.month),l.day))):l=bQ({...VD(this.c),...n});const[c,f]=u_(l,this.o,this.zone);return Ng(this,{ts:c,o:f})}plus(e){if(!this.isValid)return this;const n=Rt.fromDurationLike(e);return Ng(this,NQ(this,n))}minus(e){if(!this.isValid)return this;const n=Rt.fromDurationLike(e).negate();return Ng(this,NQ(this,n))}startOf(e){if(!this.isValid)return this;const n={},r=Rt.normalizeUnit(e);switch(r){case"years":n.month=1;case"quarters":case"months":n.day=1;case"weeks":case"days":n.hour=0;case"hours":n.minute=0;case"minutes":n.second=0;case"seconds":n.millisecond=0;break}if(r==="weeks"&&(n.weekday=1),r==="quarters"){const i=Math.ceil(this.month/3);n.month=(i-1)*3+1}return this.set(n)}endOf(e){return this.isValid?this.plus({[e]:1}).startOf(e).minus(1):this}toFormat(e,n={}){return this.isValid?Ni.create(this.loc.redefaultToEN(n)).formatDateTimeFromString(this,e):YD}toLocaleString(e=wD,n={}){return this.isValid?Ni.create(this.loc.clone(n),e).formatDateTime(this):YD}toLocaleParts(e={}){return this.isValid?Ni.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:n=!1,suppressMilliseconds:r=!1,includeOffset:i=!0,extendedZone:s=!1}={}){if(!this.isValid)return null;const o=e==="extended";let u=JD(this,o);return u+="T",u+=FQ(this,o,n,r,i,s),u}toISODate({format:e="extended"}={}){return this.isValid?JD(this,e==="extended"):null}toISOWeekDate(){return a_(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:n=!1,includeOffset:r=!0,includePrefix:i=!1,extendedZone:s=!1,format:o="extended"}={}){return this.isValid?(i?"T":"")+FQ(this,o==="extended",n,e,r,s):null}toRFC2822(){return a_(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return a_(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?JD(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:n=!1,includeOffsetSpace:r=!0}={}){let i="HH:mm:ss.SSS";return(n||e)&&(r&&(i+=" "),n?i+="z":e&&(i+="ZZ")),a_(this,i,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():YD}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};const n={...this.c};return e.includeConfig&&(n.outputCalendar=this.outputCalendar,n.numberingSystem=this.loc.numberingSystem,n.locale=this.loc.locale),n}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,n="milliseconds",r={}){if(!this.isValid||!e.isValid)return Rt.invalid("created by diffing an invalid DateTime");const i={locale:this.locale,numberingSystem:this.numberingSystem,...r},s=Vye(n).map(Rt.normalizeUnit),o=e.valueOf()>this.valueOf(),u=o?this:e,a=o?e:this,l=gAe(u,a,s,i);return o?l.negate():l}diffNow(e="milliseconds",n={}){return this.diff(ft.now(),e,n)}until(e){return this.isValid?mn.fromDateTimes(this,e):this}hasSame(e,n){if(!this.isValid)return!1;const r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(n)<=r&&r<=i.endOf(n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;const n=e.base||ft.fromObject({},{zone:this.zone}),r=e.padding?this<n?-e.padding:e.padding:0;let i=["years","months","days","hours","minutes","seconds"],s=e.unit;return Array.isArray(e.unit)&&(i=e.unit,s=void 0),kQ(n,this.plus(r),{...e,numeric:"always",units:i,unit:s})}toRelativeCalendar(e={}){return this.isValid?kQ(e.base||ft.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(ft.isDateTime))throw new Ps("min requires all arguments be DateTimes");return Mz(e,n=>n.valueOf(),Math.min)}static max(...e){if(!e.every(ft.isDateTime))throw new Ps("max requires all arguments be DateTimes");return Mz(e,n=>n.valueOf(),Math.max)}static fromFormatExplain(e,n,r={}){const{locale:i=null,numberingSystem:s=null}=r,o=gn.fromOpts({locale:i,numberingSystem:s,defaultToEN:!0});return yQ(o,e,n)}static fromStringExplain(e,n,r={}){return ft.fromFormatExplain(e,n,r)}static get DATE_SHORT(){return wD}static get DATE_MED(){return yz}static get DATE_MED_WITH_WEEKDAY(){return zye}static get DATE_FULL(){return Ez}static get DATE_HUGE(){return Az}static get TIME_SIMPLE(){return vz}static get TIME_WITH_SECONDS(){return _z}static get TIME_WITH_SHORT_OFFSET(){return Sz}static get TIME_WITH_LONG_OFFSET(){return Cz}static get TIME_24_SIMPLE(){return bz}static get TIME_24_WITH_SECONDS(){return Tz}static get TIME_24_WITH_SHORT_OFFSET(){return Rz}static get TIME_24_WITH_LONG_OFFSET(){return Oz}static get DATETIME_SHORT(){return Dz}static get DATETIME_SHORT_WITH_SECONDS(){return wz}static get DATETIME_MED(){return Nz}static get DATETIME_MED_WITH_SECONDS(){return Fz}static get DATETIME_MED_WITH_WEEKDAY(){return Qye}static get DATETIME_FULL(){return Lz}static get DATETIME_FULL_WITH_SECONDS(){return Iz}static get DATETIME_HUGE(){return Bz}static get DATETIME_HUGE_WITH_SECONDS(){return $z}}function Lg(t){if(ft.isDateTime(t))return t;if(t&&t.valueOf&&vf(t.valueOf()))return ft.fromJSDate(t);if(t&&typeof t=="object")return ft.fromObject(t);throw new Ps(`Unknown datetime argument: ${t}, of type ${typeof t}`)}const MAe="2.5.2";var PAe=ri.DateTime=ft;ri.Duration=Rt,ri.FixedOffsetZone=jr,ri.IANAZone=Du,ri.Info=wg,ri.Interval=mn,ri.InvalidZone=Kz,ri.Settings=$n,ri.SystemZone=n_,ri.VERSION=MAe,ri.Zone=sh,Object.defineProperty(rh,"__esModule",{value:!0}),rh.TimezoneStatement=void 0;const UAe=Ye,jAe=ri;class qAe extends UAe.MalloyElement{constructor(e){super(),this.tz=e,this.elementType="timezone",this.forceQueryClass=void 0,this.queryRefinementStage=void 0}get isValid(){try{return jAe.DateTime.fromISO("2020-02-19T00:00:00",{zone:this.tz}),!0}catch{return!1}}queryExecute(e){e.resultFS.setTimezone(this.tz)}}rh.TimezoneStatement=qAe;var h0={};Object.defineProperty(h0,"__esModule",{value:!0}),h0.ModelAnnotation=h0.ObjectAnnotation=void 0;const HAe=fo,zAe=Ye;class PQ extends zAe.MalloyElement{constructor(e){super(),this.notes=e,this.elementType="annotation",this.forceQueryClass=void 0,this.queryRefinementStage=void 0}queryExecute(){}}h0.ObjectAnnotation=PQ;class QAe extends PQ{constructor(){super(...arguments),this.elementType="modelAnnotation"}getCompilerFlags(e,n){const r=HAe.Tag.annotationToTag({notes:this.notes},{prefix:/^##! /,extending:e});return r.log.forEach(i=>n.log(i)),r.tag}execute(e){e.annotation.notes===void 0&&(e.annotation.notes=[]),e.annotation.notes.push(...this.notes)}}h0.ModelAnnotation=QAe;var p0={};Object.defineProperty(p0,"__esModule",{value:!0}),p0.Renames=p0.RenameField=void 0;const GAe=vg,UQ=Ye,WAe=Sr;class VAe extends UQ.MalloyElement{constructor(e,n){super(),this.newName=e,this.oldName=n,this.elementType="renameField",this.has({oldName:n})}makeEntry(e){if(this.oldName.refString===this.newName){this.logError("invalid-rename-with-same-name","Can't rename field to itself");return}const n=this.oldName.getField(e);n.found?n.found instanceof WAe.SpaceField?e.renameEntry(this.oldName.refString,this.newName,new GAe.RenameSpaceField(n.found,this.newName,this.location)):this.logError("failed-rename",`'${this.oldName}' cannot be renamed`):this.logError("rename-field-not-found",`Can't rename '${this.oldName}', no such field`)}getName(){return this.newName}}p0.RenameField=VAe;class YAe extends UQ.ListOf{constructor(e,n){super(e),this.accessModifier=n,this.elementType="renameFields"}get delarationNames(){return this.list.map(e=>e.getName())}}p0.Renames=YAe;var Fi={};Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.JoinStatement=Fi.ExpressionJoin=Fi.KeyJoin=Fi.Join=void 0;const XD=Ke,KAe=yg,JAe=xs,XAe=Ye,ZAe=_r,jQ=Ur,eve=wn;class ZD extends XAe.MalloyElement{constructor(){super(...arguments),this.isNoteableObj=!0,this.extendNote=ZAe.extendNoteMethod}makeEntry(e){e.newEntry(this.name.refString,this,new KAe.JoinSpaceField(e.parameterSpace(),this,e.dialectName()))}getName(){return this.name.refString}getStructDefFromExpr(e){const n=this.sourceExpr.getSource();return n?n.getSourceDef(e):(this.sourceExpr.sqLog("invalid-join-source","Cannot create a source to join from"),jQ.ErrorFactory.structDef)}}Fi.Join=ZD;class tve extends ZD{constructor(e,n,r){super({name:e,sourceExpr:n,keyExpr:r}),this.name=e,this.sourceExpr=n,this.keyExpr=r,this.elementType="joinOnKey"}structDef(e){var n;const r=this.getStructDefFromExpr(e);if(!(0,XD.isJoinable)(r))throw this.internalError(`Cannot join struct type '${r.type}'`);const i={...r,name:this.name.refString,join:"one",matrixOperation:"left",onExpression:{node:"error",message:"('join fixup'='not done yet')"},location:this.location};return delete i.as,this.note&&(i.annotation=this.note),(n=this.document())===null||n===void 0||n.rememberToAddModelAnnotations(i),i}fixupJoinOn(e,n){const r=this.keyExpr.getExpression(e);if((0,XD.isSourceDef)(n)&&n.primaryKey){const i=n.fields.find(s=>(s.as||s.name)===n.primaryKey);if(i)if(i.type===r.type){n.join="one",n.onExpression={node:"=",kids:{left:{node:"field",path:[this.name.refString,n.primaryKey]},right:r.value}},n.onCompositeFieldUsage=r.compositeFieldUsage;return}else this.logError("join-on-primary-key-type-mismatch",`join_one: with type mismatch with primary key: ${r.type}/${i.type}`);else this.logError("join-primary-key-not-found",`join_one: Primary key '${i}' not found in source`)}else this.logError("join-with-without-primary-key","join_one: Cannot use with unless source has a primary key")}}Fi.KeyJoin=tve;class nve extends ZD{constructor(e,n){super({name:e,sourceExpr:n}),this.name=e,this.sourceExpr=n,this.elementType="joinOnExpr",this.joinType="one",this.matrixOperation="left"}set joinOn(e){this.expr=e,this.has({on:e})}get joinOn(){return this.expr}fixupJoinOn(e,n){if(this.expr===void 0)return;const r=this.expr.getExpression(e);if(r.type!=="boolean"){this.logError("non-boolean-join-on","join conditions must be boolean expressions");return}n.onExpression=r.value,n.onCompositeFieldUsage=r.compositeFieldUsage}structDef(e){var n;const r=this.sourceExpr.getSource();if(!r)return this.sourceExpr.sqLog("invalid-join-source","Cannot create a source to join from"),jQ.ErrorFactory.joinDef;const i=r.getSourceDef(e);let s="left";if(this.inExperiment("join_types",!0)&&(s=this.matrixOperation),!(0,XD.isJoinable)(i))throw this.internalError(`Can't join struct type ${i.type}`);const o={...i,name:this.name.refString,join:this.joinType,matrixOperation:s,location:this.location};return delete o.as,this.note&&(o.annotation=this.note),(n=this.document())===null||n===void 0||n.rememberToAddModelAnnotations(o),o}}Fi.ExpressionJoin=nve;class rve extends JAe.DefinitionList{constructor(e,n){super(e),this.accessModifier=n,this.elementType="joinStatement",this.forceQueryClass=void 0,this.queryRefinementStage=eve.LegalRefinementStage.Single}queryExecute(e){for(const n of this.list)e.inputFS.extendSource(n),e.alwaysJoins.push(n.name.refString)}get delarationNames(){return this.list.map(e=>e.name.refString)}}Fi.JoinStatement=rve;var Oo={};Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.IncludeListItem=Oo.IncludeExceptItem=Oo.IncludeAccessItem=Oo.IncludeItem=void 0;const qQ=Ye,HQ=_r;class e7 extends qQ.MalloyElement{}Oo.IncludeItem=e7;class ive extends e7{constructor(e,n){super(),this.kind=e,this.fields=n,this.elementType="include-access-item",this.isNoteableObj=!0,this.extendNote=HQ.extendNoteMethod,this.has({fields:n})}}Oo.IncludeAccessItem=ive;class sve extends e7{constructor(e){super(),this.fields=e,this.elementType="include-except-item",this.kind="except",this.has({fields:e})}}Oo.IncludeExceptItem=sve;class ove extends qQ.MalloyElement{constructor(e,n){super({name:e}),this.name=e,this.as=n,this.elementType="include-list-item",this.isNoteableObj=!0,this.extendNote=HQ.extendNoteMethod}}Oo.IncludeListItem=ove;var pt={},Ig={},uve=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),ave=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),lve=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&uve(e,t,n);return ave(e,t),e};Object.defineProperty(Ig,"__esModule",{value:!0}),Ig.ReferenceField=void 0;const zQ=Ke,QQ=lve(Wt),GQ=Sr,cve=at;class fve extends GQ.SpaceField{constructor(e,n){super(),this.fieldRef=e,this.inFS=n,this.didLookup=!1}get referenceTo(){return this.didLookup||(this.memoReference=this.inFS.lookup(this.fieldRef.list).found,this.didLookup=!0),this.memoReference}getQueryFieldDef(e){if(!this.queryFieldDef){const n=this.fieldRef.getField(e);n.error&&this.fieldRef.logError(n.error.code,n.error.message);const r=this.fieldRef.path;if(n.found&&n.found.refType==="parameter"){const s=n.found.typeDesc();if(zQ.TD.isAtomic(s))this.queryFieldDef={...(0,zQ.mkFieldDef)(QQ.atomicDef(s),r[0]),e:{node:"parameter",path:r}};else throw new Error("impossible turtle/join parameter")}else this.queryFieldDef={type:"fieldref",path:r};const i=this.referenceTo;if(i instanceof GQ.SpaceField){const s=i.constructorFieldDef();if(s){const o=this.fieldRef.note;if(s.annotation||o){const u=o||{};s.annotation&&(u.inherits=s.annotation),this.queryFieldDef.annotation=u}}}}return this.queryFieldDef}typeDesc(){if(this.memoTypeDesc)return this.memoTypeDesc;const e=this.referenceTo;if(e){const n=this.fieldRef.list.slice(0,-1).map(i=>i.refString),r=e.typeDesc();return this.memoTypeDesc={...r,compositeFieldUsage:(0,cve.joinedCompositeFieldUsage)(n,r.compositeFieldUsage)},this.memoTypeDesc}return QQ.errorT}}Ig.ReferenceField=fve;var jn={};Object.defineProperty(jn,"__esModule",{value:!0}),jn.typecheckGroupBy=jn.typecheckAggregate=jn.typecheckCalculate=jn.typecheckDeclare=jn.typecheckMeasure=jn.typecheckDimension=jn.typecheckIndex=jn.typecheckProject=void 0;const Sn=ts;function xve(t,e){if(t.type==="turtle"||!(0,Sn.expressionIsScalar)(t.expressionType)){let n,r,i;if(t.type==="turtle")n="a nest",r="a view",i="select-of-view";else if((0,Sn.expressionIsAnalytic)(t.expressionType))n="a calculate",r="an analytic",i="select-of-analytic";else if((0,Sn.expressionIsAggregate)(t.expressionType))n="an aggregate",r="an aggregate",i="select-of-aggregate";else throw new Error(`Unexpected expression type ${t.expressionType} not handled here`);e.logError(i,`Cannot use ${r} field in a select operation, did you mean to use ${n} operation instead?`)}}jn.typecheckProject=xve;function dve(t,e){if(t.type==="turtle"||!(0,Sn.expressionIsScalar)(t.expressionType)){let n,r;if(t.type==="turtle")n="a view",r="index-of-view";else if((0,Sn.expressionIsAnalytic)(t.expressionType))n="an analytic",r="index-of-analytic";else if((0,Sn.expressionIsAggregate)(t.expressionType))n="an aggregate",r="index-of-aggregate";else throw new Error(`Unexpected expression type ${t.expressionType} not handled here`);e.logError(r,`Cannot use ${n} field in an index operation`)}}jn.typecheckIndex=dve;function hve(t,e){if(!(0,Sn.expressionIsScalar)(t.expressionType))if((0,Sn.expressionIsAggregate)(t.expressionType))e.logError("aggregate-in-dimension","Cannot use an aggregate field in a dimension declaration, did you mean to use a measure declaration instead?");else if((0,Sn.expressionIsAnalytic)(t.expressionType))e.logError("analytic-in-dimension","Cannot use an analytic field in a dimension declaration");else throw new Error(`Unexpected expression type ${t.expressionType} not handled here`)}jn.typecheckDimension=hve;function pve(t,e){if(!(0,Sn.expressionIsAggregate)(t.expressionType))if((0,Sn.expressionIsScalar)(t.expressionType))e.logError("scalar-in-measure","Cannot use a scalar field in a measure declaration, did you mean to use a dimension declaration instead?");else if((0,Sn.expressionIsAnalytic)(t.expressionType))e.logError("analytic-in-measure","Cannot use an analytic field in a measure declaration");else throw new Error(`Unexpected expression type ${t.expressionType} not handled here`)}jn.typecheckMeasure=pve;function gve(t,e){t.type==="turtle"?e.logError("view-in-declare","Views cannot be used in a declare block"):(0,Sn.expressionIsAnalytic)(t.expressionType)&&e.logError("analytic-in-declare","Analytic expressions can not be used in a declare block")}jn.typecheckDeclare=gve;function mve(t,e){if(t.type==="turtle"||!(0,Sn.expressionIsAnalytic)(t.expressionType)){let n,r,i;if(t.type==="turtle")n="a nest",r="a view",i="calculate-of-view";else if((0,Sn.expressionIsAggregate)(t.expressionType))n="an aggregate",r="an aggregate",i="calculate-of-aggregate";else if((0,Sn.expressionIsScalar)(t.expressionType))n="a group_by or select",r="a scalar",i="calculate-of-scalar";else throw new Error(`Unexpected expression type ${t.expressionType} not handled here`);e.logError(i,`Cannot use ${r} field in a calculate operation, did you mean to use ${n} operation instead?`)}}jn.typecheckCalculate=mve;function yve(t,e){if(t.type==="turtle"||!(0,Sn.expressionIsAggregate)(t.expressionType)){let n,r,i;if(t.type==="turtle")n="a nest",r="a view",i="aggregate-of-view";else if((0,Sn.expressionIsAnalytic)(t.expressionType))n="a calculate",r="an analytic",i="aggregate-of-analytic";else if((0,Sn.expressionIsScalar)(t.expressionType))n="a group_by or select",r="a scalar",i="aggregate-of-scalar";else throw new Error(`Unexpected expression type ${t} not handled here`);e.logError(i,`Cannot use ${r} field in an aggregate operation, did you mean to use ${n} operation instead?`)}}jn.typecheckAggregate=yve;function Eve(t,e){if(t.type==="turtle"||!(0,Sn.expressionIsScalar)(t.expressionType)){let n,r,i;if(t.type==="turtle")n="a nest",r="a view",i="group-by-view";else if((0,Sn.expressionIsAnalytic)(t.expressionType))n="a calculate",r="an analytic",i="group-by-analytic";else if((0,Sn.expressionIsAggregate)(t.expressionType))n="an aggregate",r="an aggregate",i="group-by-aggregate";else throw new Error(`Unexpected expression type ${t.expressionType} not handled here`);e.logError(i,`Cannot use ${r} field in a group_by operation, did you mean to use ${n} operation instead?`)}}jn.typecheckGroupBy=Eve,Object.defineProperty(pt,"__esModule",{value:!0}),pt.FieldReferences=pt.WildcardFieldReference=pt.ViewOrScalarFieldReference=pt.DimensionFieldReference=pt.MeasureFieldReference=pt.DeclareFieldReference=pt.ProjectFieldReference=pt.GroupByFieldReference=pt.AggregateFieldReference=pt.IndexFieldReference=pt.CalculateFieldReference=pt.ParameterFieldReference=pt.PartitionByFieldReference=pt.ExpressionFieldReference=pt.AccessModifierFieldReference=pt.AcceptExceptFieldReference=pt.FieldReference=void 0;const Ave=Ig,vve=xs,WQ=Ye,VQ=_r,g0=jn;class ii extends WQ.ListOf{constructor(e){super(e),this.isNoteableObj=!0,this.extendNote=VQ.extendNoteMethod}makeEntry(e){const n=this.outputName;if(e.entry(n))this.logError("output-name-conflict",`Output already has a field named '${n}'`);else{const r=e.isQueryFieldSpace()?e.inputSpace():e;e.newEntry(n,this,new Ave.ReferenceField(this,r))}}getName(){return this.nameString}get refToField(){return{type:"fieldref",path:this.list.map(e=>e.refString)}}get refString(){return this.path.join(".")}get path(){return this.list.map(e=>e.refString)}get outputName(){return this.list[this.list.length-1].refString}get sourceString(){if(this.list.length>1)return this.list.slice(0,-1).map(e=>e.refString).join(".")}get nameString(){return this.list[this.list.length-1].refString}getField(e){const n=e.lookup(this.list);if(n.found){const r=n.found.typeDesc();this.typecheck(r)}return n}}pt.FieldReference=ii;class _ve extends ii{constructor(){super(...arguments),this.elementType="acceptExceptFieldReference"}typecheck(){}}pt.AcceptExceptFieldReference=_ve;class Sve extends ii{constructor(){super(...arguments),this.elementType="accessModifierFieldReference"}typecheck(){}}pt.AccessModifierFieldReference=Sve;class Cve extends ii{constructor(){super(...arguments),this.elementType="expressionFieldReference"}typecheck(){}}pt.ExpressionFieldReference=Cve;class bve extends ii{constructor(){super(...arguments),this.elementType="partitionByFieldReference"}typecheck(){}}pt.PartitionByFieldReference=bve;class Tve extends ii{constructor(){super(...arguments),this.elementType="parameterFieldReference"}typecheck(){}}pt.ParameterFieldReference=Tve;class Rve extends ii{constructor(){super(...arguments),this.elementType="calculateFieldReference"}typecheck(e){(0,g0.typecheckCalculate)(e,this)}}pt.CalculateFieldReference=Rve;class t7 extends ii{constructor(){super(...arguments),this.elementType="indexFieldReference"}typecheck(e){(0,g0.typecheckIndex)(e,this)}static indexOutputName(e){return e.map(n=>encodeURIComponent(n)).join("/")}get outputName(){return t7.indexOutputName(this.path)}}pt.IndexFieldReference=t7;class Ove extends ii{constructor(){super(...arguments),this.elementType="aggregateFieldReference"}typecheck(e){(0,g0.typecheckAggregate)(e,this)}}pt.AggregateFieldReference=Ove;class Dve extends ii{constructor(){super(...arguments),this.elementType="groupByFieldReference"}typecheck(e){(0,g0.typecheckGroupBy)(e,this)}}pt.GroupByFieldReference=Dve;class wve extends ii{constructor(){super(...arguments),this.elementType="projectFieldReference"}typecheck(e){(0,g0.typecheckProject)(e,this)}}pt.ProjectFieldReference=wve;class Nve extends ii{constructor(){super(...arguments),this.elementType="declareFieldReference"}typecheck(e){(0,g0.typecheckDeclare)(e,this)}}pt.DeclareFieldReference=Nve;class Fve extends ii{constructor(){super(...arguments),this.elementType="measureFieldReference"}typecheck(e){(0,g0.typecheckMeasure)(e,this)}}pt.MeasureFieldReference=Fve;class Lve extends ii{constructor(){super(...arguments),this.elementType="dimensionFieldReference"}typecheck(e){(0,g0.typecheckDimension)(e,this)}}pt.DimensionFieldReference=Lve;class Ive extends ii{constructor(){super(...arguments),this.elementType="viewOrScalarFieldReference"}typecheck(e){}}pt.ViewOrScalarFieldReference=Ive;class Bve extends WQ.MalloyElement{constructor(e){super(),this.joinPath=e,this.elementType="wildcardFieldReference",this.isNoteableObj=!0,this.extendNote=VQ.extendNoteMethod,this.except=new Set,this.has({joinPath:e})}getFieldDef(){throw this.internalError("fielddef request from wildcard reference")}get refString(){return this.joinPath?`${this.joinPath.refString}.*`:"*"}}pt.WildcardFieldReference=Bve;class $ve extends vve.DefinitionList{constructor(e){super(e),this.elementType="fieldReferenceList"}}pt.FieldReferences=$ve,Object.defineProperty(mg,"__esModule",{value:!0}),mg.RefinedSource=void 0;const kve=Ke,Mve=Jd,Pve=c0,Uve=Ou,jve=eh,qve=th,Hve=nh,zve=Ms,Qve=rh,Gve=h0,Wve=p0,Vve=Zd,Yve=Fi,YQ=Oo,n7=pt;class Kve extends zve.Source{constructor(e,n,r){super({source:e,refinement:n}),this.source=e,this.refinement=n,this.includeList=r,this.elementType="refinedSource",r&&this.has({includeList:r})}getSourceDef(e){return this.withParameters(e,[])}withParameters(e,n){var r;let i,s;const o=[],u=[];let a;const l=[];for(const v of this.refinement.list){if(v instanceof Gve.ObjectAnnotation)continue;const _=v;if(v instanceof qve.PrimaryKey){if(i){const S="multiple-primary-keys";i.logError(S,"Primary key already defined"),v.logError(S,"Primary key redefined")}i=v}else if(v instanceof jve.FieldListEdit){if(s){const S="multiple-field-list-edits";s.logError(S,"Too many accept/except statements"),v.logError(S,"Too many accept/except statements")}s=v}else v instanceof Pve.DeclareFields||v instanceof Yve.JoinStatement||v instanceof Hve.Views||v instanceof Wve.Renames?(o.push(...v.list),v.accessModifier&&l.push({fields:v.delarationNames,access:v.accessModifier})):v instanceof Uve.Filter?u.push(v):v instanceof Qve.TimezoneStatement?a=v.tz:_.logError("unexpected-source-property",`Unexpected source property: '${_.elementType}'`)}const c=n?new Vve.ParameterSpace(n):void 0,f=structuredClone(this.source.getSourceDef(c)),{fieldsToInclude:d,modifiers:h,renames:p,notes:m}=Jve(this.includeList,f);for(const v of l)for(const _ of v.fields)h.set(_,v.access);i&&(f.primaryKey=i.field.name);const g=Mve.RefinedSpace.filteredFrom(f,s,d,p,c);if(a&&g.setTimezone(a),n&&g.addParameters(n),g.pushFields(...o),i){const v=i.field.getField(g);v.error&&i.logError(v.error.code,v.error.message)}g.addAccessModifiers(h),g.addNotes(m);const y=g.structDef(),E=y.filterList||[];let A=!1;for(const v of u)for(const _ of v.list){const S=_.filterCondition(g);(0,kve.expressionIsCalculation)(S.expressionType)?_.logError("aggregate-in-source-filter","Can't use aggregate computations in top level filters"):(E.push(S),A=!0)}return A?{...y,filterList:E}:((r=this.document())===null||r===void 0||r.rememberToAddModelAnnotations(y),y)}}mg.RefinedSource=Kve;function Jve(t,e){var n,r,i,s,o,u,a,l,c;const f=new Set(e.fields.map(S=>S.name)),d=new Set(e.fields.filter(S=>S.accessModifier==="private").map(S=>S.name));let h;const p=new Set;let m,g;const y=new Map,E=[],A=new Map;if(t===void 0)return{fieldsToInclude:void 0,modifiers:y,renames:E,notes:A};for(const S of t)if(S instanceof YQ.IncludeAccessItem)for(const C of S.fields)if(C.name instanceof n7.WildcardFieldReference)C.name.joinPath&&C.logError("unsupported-path-in-include","Wildcards with paths are not supported in `include` blocks"),m!==void 0?S.logError("already-used-star-in-include","Wildcard already used in this include block"):(m=(n=S.kind)!==null&&n!==void 0?n:"inherit",g={notes:(i=(r=C.note)===null||r===void 0?void 0:r.notes)!==null&&i!==void 0?i:[],blockNotes:(o=(s=S.note)===null||s===void 0?void 0:s.blockNotes)!==null&&o!==void 0?o:[]});else{if(h==="exclude"){S.logError("include-after-exclude","Cannot include specific fields if specific fields are already excluded");continue}h="include";const b=C.name.refString;d.has(b)&&C.logError("cannot-expand-access",`Cannot expand access of \`${b}\` from private to ${S.kind}`),y.has(b)?C.logError("duplicate-include",`Field \`${b}\` already referenced in include list`):(S.kind!==void 0&&y.set(b,S.kind),p.add(b),(C.note||S.note)&&A.set(b,{notes:(a=(u=C.note)===null||u===void 0?void 0:u.notes)!==null&&a!==void 0?a:[],blockNotes:(c=(l=S.note)===null||l===void 0?void 0:l.blockNotes)!==null&&c!==void 0?c:[]})),C.as&&(C.name instanceof n7.WildcardFieldReference?C.logError("wildcard-include-rename","Cannot rename a wildcard field in an `include` block"):E.push({name:C.name,as:C.as,location:C.location}))}else if(S instanceof YQ.IncludeExceptItem)for(const C of S.fields)C instanceof n7.WildcardFieldReference?C.joinPath?C.logError("unsupported-path-in-include","Wildcards with paths are not supported in `include` blocks"):C.logWarning("wildcard-except-redundant","`except: *` is implied, unless another clause uses *"):h==="include"?S.logError("exclude-after-include","Cannot exclude specific fields if specific fields are already included"):(h="exclude",m="inherit",p.add(C.refString));const v=new Set(f);p.forEach(S=>v.delete(S)),d.forEach(S=>v.delete(S));let _;if(m!==void 0)for(const S of v)m!=="inherit"&&y.set(S,m),g&&A.set(S,{...g});return h!=="exclude"?m!==void 0?_=f:_=p:_=v,{fieldsToInclude:_,modifiers:y,renames:E,notes:A}}var Do={};Object.defineProperty(Do,"__esModule",{value:!0}),Do.SourceQueryElement=void 0;const Xve=Ye;class r7 extends Xve.MalloyElement{constructor(){super(...arguments),this.errored=!1}getSource(){}getQuery(){}isSource(){return!1}sqLog(e,n,r){return this.isErrorFree()&&this.logError(e,n,r),this.errored=!0,e}isErrorFree(){if(this.errored)return!1;let e=!0;for(const n of this.walk())if(n instanceof r7&&n.errored){e=!1;break}return e}}Do.SourceQueryElement=r7;var l_={},bf={};Object.defineProperty(bf,"__esModule",{value:!0}),bf.QuerySource=void 0;const Zve=Ms,e_e=xp;class t_e extends Zve.Source{constructor(e){super({query:e}),this.query=e,this.elementType="querySource"}getSourceDef(e){return this.withParameters(e,void 0)}withParameters(e,n){var r;const i=this.query.queryComp(!1),s={...i.outputStruct,name:`QuerySource-${(0,e_e.v4)()}`,type:"query_source",query:i.query};return(r=this.document())===null||r===void 0||r.rememberToAddModelAnnotations(s),{...s,parameters:this.packParameters(n)}}}bf.QuerySource=t_e;var xh={},Bg={};Object.defineProperty(Bg,"__esModule",{value:!0}),Bg.QueryBase=void 0;const i7=at,KQ=Ke,n_e=Gd,r_e=Ye;class i_e extends r_e.MalloyElement{resolveCompositeSource(e,n){var r;const i=n.pipeline[0];if(i&&((0,KQ.isQuerySegment)(i)||(0,KQ.isIndexSegment)(i))){const s=(r=i.compositeFieldUsage)!==null&&r!==void 0?r:(0,i7.emptyCompositeFieldUsage)();if(!(0,i7.isEmptyCompositeFieldUsage)(s)||e.type==="composite")return(0,i7.resolveCompositeSources)(e,s).sourceDef}}query(){const{query:e}=this.queryComp(!0);return{...e,pipeline:(0,n_e.detectAndRemovePartialStages)(e.pipeline,this)}}}Bg.QueryBase=i_e,Object.defineProperty(xh,"__esModule",{value:!0}),xh.QueryArrow=void 0;const s_e=Ke,o_e=Ms,JQ=Cr,u_e=Bg;class a_e extends u_e.QueryBase{constructor(e,n){super({source:e,view:n}),this.source=e,this.view=n,this.elementType="arrow"}queryComp(e){var n;let r,i,s;if(this.source instanceof o_e.Source){const d=e?this.source.structRef(void 0):{structRef:this.source.getSourceDef(void 0)};i={type:"query",...d,pipeline:[],location:this.location},r=(0,s_e.refIsStructDef)(d.structRef)?d.structRef:this.source.getSourceDef(void 0),s=new JQ.StaticSourceSpace(r)}else{const d=this.source.queryComp(e);i=d.query,r=d.outputStruct,s=new JQ.StaticSourceSpace(d.outputStruct)}const{pipeline:o,annotation:u,outputStruct:a,name:l}=this.view.pipelineComp(s),c={...i,name:l,annotation:u,pipeline:[...i.pipeline,...o]},f=(n=c.compositeResolvedSourceDef)!==null&&n!==void 0?n:this.resolveCompositeSource(r,c);return{query:{...c,compositeResolvedSourceDef:f},outputStruct:a,inputStruct:r}}}xh.QueryArrow=a_e,Object.defineProperty(l_,"__esModule",{value:!0}),l_.SQArrow=void 0;const l_e=Do,c_e=bf,f_e=xh;class x_e extends l_e.SourceQueryElement{constructor(e,n){super({applyTo:e,operation:n}),this.applyTo=e,this.operation=n,this.elementType="sq-arrow"}getQuery(){const e=this.applyTo.isSource()?this.applyTo.getSource():this.applyTo.getQuery();if(e===void 0){this.sqLog("failed-to-compute-arrow-source","Could not get LHS of arrow operation");return}const n=new f_e.QueryArrow(e,this.operation);return this.has({query:n}),n}getSource(){const e=this.getQuery();if(!e){this.sqLog("failed-to-compute-source-from-query","Couldn't comprehend query well enough to make a source");return}const n=new c_e.QuerySource(e);return this.has({asSource:n}),n}}l_.SQArrow=x_e;var c_={},dh={},hs={};Object.defineProperty(hs,"__esModule",{value:!0}),hs.getStructFieldDef=hs.getFinalStruct=hs.opOutputStruct=void 0;const XQ=Wl,d_e=Bc,f_=Ke,ZQ=Ur;function eG(t,e,n){const r=ZQ.ErrorFactory.didCreate(e)||(0,f_.structHasErrors)(e);(0,f_.isPartialSegment)(n)&&(n={...n,type:"reduce"});const i=(0,f_.segmentHasErrors)(n);if(!r&&!i)try{const s=d_e.Segment.nextStructDef(e,n);if((0,f_.isSourceDef)(s))return s;t.logError("failed-to-compute-output-schema",`INTERNAL ERROR model/Segment.nextStructDef: RETURNED A NON SOURCE
1260
1260
  STRUCTDEF: ${(0,XQ.inspect)(s,{breakLength:72,depth:1/0})}`)}catch(s){t.logError("failed-to-compute-output-schema",`INTERNAL ERROR model/Segment.nextStructDef: ${s.message}
1261
1261
  QUERY: ${(0,XQ.inspect)(n,{breakLength:72,depth:1/0})}`)}return ZQ.ErrorFactory.structDef}hs.opOutputStruct=eG;function h_e(t,e,n){for(const r of n)e=eG(t,e,r);return e}hs.getFinalStruct=h_e;function p_e(t,e){return t.fields.find(n=>(n.as||n.name)===e)}hs.getStructFieldDef=p_e,Object.defineProperty(dh,"__esModule",{value:!0}),dh.QueryRefine=void 0;const g_e=Cr,m_e=hs,y_e=Bg;class E_e extends y_e.QueryBase{constructor(e,n){super({base:e,refinement:n}),this.base=e,this.refinement=n,this.elementType="query-refine"}queryComp(e){const n=this.base.queryComp(e),r=new g_e.StaticSourceSpace(n.inputStruct),i=this.refinement.refine(r,n.query.pipeline,void 0),s={...n.query,pipeline:i},o=this.resolveCompositeSource(n.inputStruct,s);return{query:{...s,compositeResolvedSourceDef:o},outputStruct:(0,m_e.getFinalStruct)(this.refinement,n.inputStruct,i),inputStruct:n.inputStruct}}}dh.QueryRefine=E_e;var $g={},hh={},Li={};Object.defineProperty(Li,"__esModule",{value:!0}),Li.mkTimeResult=Li.resolution=Li.castTo=Li.timeOffset=void 0;const s7=Ke;function A_e(t,e,n,r,i){return{node:"delta",kids:{base:(0,s7.mkTemporal)(e,t),delta:r},op:n,units:i}}Li.timeOffset=A_e;function v_e(t,e,n,r=!1){let i;return typeof t!="string"?i={node:"cast",dstSQLType:t.raw,e,safe:r}:i={node:"cast",dstType:{type:t},e,safe:r},(0,s7.isCastType)(n)&&(i.srcType={type:n}),i}Li.castTo=v_e;function __e(t){switch(t){case"hour":case"minute":case"second":case"microsecond":case"millisecond":return"timestamp"}return"date"}Li.resolution=__e;function S_e(t,e){if(e){if(t.type==="timestamp")return{...t,timeframe:e};if((0,s7.isDateUnit)(e))return{...t,timeframe:e}}return t}Li.mkTimeResult=S_e;var Tf={},ct={},Pt={};Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.literalTimeResult=Pt.literalExprValue=Pt.computedErrorExprValue=Pt.computedTimeResult=Pt.computedExprValue=void 0;const tG=ts,o7=at;function kg({value:t,dataType:e,from:n}){return{...e,value:t,expressionType:(0,tG.maxOfExpressionTypes)(n.map(r=>r.expressionType)),evalSpace:(0,tG.mergeEvalSpaces)(...n.map(r=>r.evalSpace)),compositeFieldUsage:(0,o7.mergeCompositeFieldUsage)(...n.map(r=>r.compositeFieldUsage))}}Pt.computedExprValue=kg;function C_e({value:t,dataType:e,from:n,timeframe:r}){const i=kg({value:t,dataType:e,from:n}),s={...e,expressionType:i.expressionType,evalSpace:i.evalSpace,value:i.value,compositeFieldUsage:(0,o7.mergeCompositeFieldUsage)(...n.map(o=>o.compositeFieldUsage))};return r&&(s.timeframe=r),s}Pt.computedTimeResult=C_e;function b_e({dataType:t,from:e,error:n}){return kg({dataType:t??{type:"error"},value:{node:"error",message:n},from:e})}Pt.computedErrorExprValue=b_e;function T_e(t){return kg({...t,from:[]})}Pt.literalExprValue=T_e;function R_e({value:t,dataType:e,timeframe:n}){const r=kg({value:t,dataType:e,from:[]}),i={...e,expressionType:r.expressionType,evalSpace:r.evalSpace,value:r.value,compositeFieldUsage:(0,o7.emptyCompositeFieldUsage)()};return n&&(i.timeframe=n),i}Pt.literalTimeResult=R_e;var ph={};Object.defineProperty(ph,"__esModule",{value:!0}),ph.isGranularResult=void 0;function O_e(t){return t.type==="date"||t.type==="timestamp"?t.timeframe!==void 0:!1}ph.isGranularResult=O_e;var wo={};Object.defineProperty(wo,"__esModule",{value:!0}),wo.isComparison=wo.isEquality=wo.getExprNode=void 0;function D_e(t){switch(t){case"~":return"like";case"!~":return"!like"}return t}wo.getExprNode=D_e;function nG(t){return t==="="||t==="!="||t==="~"||t==="!~"}wo.isEquality=nG;function w_e(t){return nG(t)||t===">="||t==="<="||t===">"||t==="<"}wo.isComparison=w_e;var N_e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),F_e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),L_e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&N_e(e,t,n);return F_e(e,t),e};Object.defineProperty(ct,"__esModule",{value:!0}),ct.applyBinary=ct.getMorphicValue=ct.ExprDuration=ct.ExpressionDef=ct.ATNodeType=void 0;const m0=Ke,Rf=L_e(Wt),u7=fs,ja=Pt,I_e=Li,rG=ph,B_e=Ye,Mg=wo;class $_e extends Error{}var a7;(function(t){t[t.And=0]="And",t[t.Or=1]="Or",t[t.Value=2]="Value",t[t.Partial=3]="Partial"})(a7||(ct.ATNodeType=a7={}));class iG extends B_e.MalloyElement{constructor(){super(...arguments),this.legalChildTypes=Rf.anyAtomicT}granular(){return!1}requestExpression(e){return this.getExpression(e)}defaultFieldName(){}typeCheck(e,n){return n.type!=="error"&&!Rf.any(n,this.legalChildTypes)?(n.type==="sql native"?e.logError("sql-native-not-allowed-in-expression",{rawType:n.rawType}):e.logError("expression-type-error",`'${this.elementType}' Can't use type ${Rf.inspect(n)}`),!1):!0}apply(e,n,r,i=!1){return aG(e,r,n,this)}canSupportPartitionBy(){return!1}canSupportOrderBy(){return!1}canSupportLimit(){return!1}supportsWhere(e){return(0,m0.expressionIsAggregate)(e.expressionType)}atNodeType(){return a7.Value}atExpr(){return this}}ct.ExpressionDef=iG;class l7 extends iG{constructor(e,n){super({n:e}),this.n=e,this.timeframe=n,this.elementType="duration",this.legalChildTypes=[Rf.timestampT,Rf.dateT]}apply(e,n,r){const i=r.getExpression(e);if(this.typeCheck(this,i),(0,m0.isTemporalType)(i.type)&&(n==="+"||n==="-")){const s=this.n.getExpression(e);if(!Rf.typeEq(s,Rf.numberT))return this.logError("invalid-duration-quantity",`Duration quantity needs number not '${s.type}`),(0,u7.errorFor)("illegal unit expression");let o;return(0,rG.isGranularResult)(i)&&i.timeframe===this.timeframe&&(o=i.timeframe),i.type==="date"&&!(0,m0.isDateUnit)(this.timeframe)?this.loggedErrorExpr("invalid-timeframe-for-time-offset",`Cannot offset date by ${this.timeframe}`):(0,ja.computedTimeResult)({dataType:{type:i.type},value:(0,I_e.timeOffset)(i.type,i.value,n,s.value,this.timeframe),timeframe:o,from:[i,s]})}return super.apply(e,n,r)}getExpression(e){const n=this.n.getExpression(e);return(0,ja.computedErrorExprValue)({dataType:{type:"duration"},error:"Duration is not a value",from:[n]})}}ct.ExprDuration=l7;function sG(t,e){return t.type===e?t.value:t.morphic&&t.morphic[e]}function k_e(t,e){if(t.type===e)return t;if(t.morphic&&t.morphic[e])return(0,ja.computedExprValue)({dataType:{type:e},value:t.morphic[e],from:[t]})}ct.getMorphicValue=k_e;function oG(t,e,n,r){const i=(0,m0.isTemporalType)(e.type),s=(0,m0.isTemporalType)(r.type),o=(0,Mg.getExprNode)(n);if(i&&s)if(e.type!==r.type){const u=sG(e,"timestamp"),a=sG(r,"timestamp");if(u&&a)return{node:o,kids:{left:u,right:u}}}else return{node:o,kids:{left:e.value,right:r.value}};if((i||s)&&e.type!=="null"&&r.type!=="null")return t.logError("time-comparison-type-mismatch",`Cannot compare a ${e.type} to a ${r.type}`),{node:"false"}}function M_e(t,e){if(t.type==="string"){if(e.type==="regular expression")return{node:"regexpMatch",kids:{expr:t.value,regex:e.value}}}else if(e.type==="string"&&t.type==="regular expression")return{node:"regexpMatch",kids:{expr:e.value,regex:t.value}}}function P_e(t,e,n,r){const i=e.getExpression(t),s=r.getExpression(t),o=(0,Mg.getExprNode)(n),u=Pg("boolean",i,s);if(u)return u;const a=m0.TD.isSQL(i)?i.rawType||"typeless-left":void 0,l=m0.TD.isSQL(s)?s.rawType||"typeless-right":void 0;if((a||l)&&!(i.type==="null"||s.type==="null"||a===l)){const d=Ug(e,i,r,s);if(d)return{...d,type:"boolean"}}let c=oG(e,i,n,s)||{node:o,kids:{left:i.value,right:s.value}};if(i.type!=="error"&&s.type!=="error"&&(n==="~"||n==="!~")&&(i.type!=="string"||s.type!=="string")){let f=M_e(i,s);if(f)n[0]==="!"&&(f={node:"not",e:{...f}});else throw new $_e("Incompatible types for match('~') operator");c=f}return(0,ja.computedExprValue)({dataType:{type:"boolean"},value:c,from:[i,s]})}function U_e(t,e,n,r){const i=e.getExpression(t),s=r.getExpression(t),o=Pg("boolean",i,s);if(o)return o;const u=Ug(e,i,r,s);if(u)return{...u,type:"boolean"};const a=oG(e,i,n,s)||{node:(0,Mg.getExprNode)(n),kids:{left:i.value,right:s.value}};return(0,ja.computedExprValue)({dataType:{type:"boolean"},value:a,from:[i,s]})}function uG(t,e,n,r){const i=e.getExpression(t),s=r.getExpression(t),o=Pg("number",i,s);if(o)return o;const u=Ug(e,i,r,s);if(u)return u;if(i.type!=="number")e.logError("arithmetic-operation-type-mismatch",`The '${n}' operator requires a number, not a '${i.type}'`);else if(s.type!=="number")r.logError("arithmetic-operation-type-mismatch",`The '${n}' operator requires a number, not a '${s.type}'`);else return(0,ja.computedExprValue)({dataType:{type:"number"},value:{node:n,kids:{left:i.value,right:s.value}},from:[i,s]});return(0,u7.errorFor)("numbers required")}function j_e(t,e,n,r){const i=e.getExpression(t),s=r.getExpression(t),o=Ug(e,i,r,s);if(o)return o;const u=(0,m0.isTemporalType)(i.type),a=Pg(u?"error":"number",i,s);if(a)return a;if(u){let l=r;if(s.type!=="duration")if((0,rG.isGranularResult)(i))l=new l7(r,i.timeframe);else if(i.type==="date")l=new l7(r,"day");else return e.loggedErrorExpr("time-offset-type-mismatch",`Can not offset time by '${s.type}'`);return l.apply(t,n,e)}return uG(t,e,n,r)}function aG(t,e,n,r){if((0,Mg.isEquality)(n))return P_e(t,e,n,r);if((0,Mg.isComparison)(n))return U_e(t,e,n,r);if(n==="+"||n==="-")return j_e(t,e,n,r);if(n==="*")return uG(t,e,n,r);if(n==="/"||n==="%"){const i=e.getExpression(t),s=r.getExpression(t),o=Ug(e,i,r,s);if(o)return o;const u=Pg("number",i,s);if(u)return u;if(i.type!=="number")e.logError("arithmetic-operation-type-mismatch","Numerator must be a number");else if(s.type!=="number")r.logError("arithmetic-operation-type-mismatch","Denominator must be a number");else{const a={node:n,kids:{left:i.value,right:s.value}};return(0,ja.computedExprValue)({dataType:{type:"number"},value:a,from:[i,s]})}return(0,u7.errorFor)("divide type mismatch")}return e.loggedErrorExpr("unexpected-binary-operator",`Cannot use ${n} operator here`)}ct.applyBinary=aG;function Pg(t,...e){if(e.some(n=>n.type==="error"))return(0,ja.computedExprValue)({dataType:{type:t},value:{node:"error",message:"cascading error"},from:e})}function Ug(t,e,n,r){const i=(0,ja.computedExprValue)({dataType:e,value:{node:"error",message:"sql-native unsupported"},from:[e,r]});if(e.type==="sql native")return t.logError("sql-native-not-allowed-in-expression",{rawType:e.rawType}),i.type=r.type,i;if(r.type==="sql native")return n.logError("sql-native-not-allowed-in-expression",{rawType:r.rawType}),i}Object.defineProperty(Tf,"__esModule",{value:!0}),Tf.ExprIdReference=void 0;const q_e=Ke,H_e=ct,z_e=at;class Q_e extends H_e.ExpressionDef{constructor(e){super(),this.fieldReference=e,this.elementType="ExpressionIdReference",this.has({fieldPath:e})}get refString(){return this.fieldReference.refString}getExpression(e){const n=this.fieldReference.getField(e),r=this.fieldReference.list.map(i=>i.name).slice(0,-1);if(n.found){const i=n.found.typeDesc(),s=(0,z_e.joinedCompositeFieldUsage)(r,i.compositeFieldUsage);if(n.isOutputField)return{...i,evalSpace:i.evalSpace==="constant"?"constant":"output",value:{node:"outputField",name:this.refString},compositeFieldUsage:s};const o={node:n.found.refType,path:this.fieldReference.path},u=(0,q_e.expressionIsAggregate)(i.expressionType)?"output":i.evalSpace;return{...i,value:o,evalSpace:u,compositeFieldUsage:s}}return this.loggedErrorExpr(n.error.code,n.error.message)}}Tf.ExprIdReference=Q_e,Object.defineProperty(hh,"__esModule",{value:!0}),hh.NamedSource=void 0;const c7=Ke,G_e=Ms,W_e=Ur,V_e=Li,lG=Ye,Y_e=Tf,K_e=Zd;class J_e extends G_e.Source{constructor(e,n,r){super(),this.ref=e,this.sourceArguments=n,this.args=r,this.elementType="namedSource",r&&this.has({args:r}),e instanceof lG.ModelEntryReference&&this.has({ref:e})}get refName(){return this.ref instanceof lG.ModelEntryReference?this.ref.name:this.ref}structRef(e){const n=this.modelEntry(this.ref);return n&&!n.exported?{structRef:this.getSourceDef(e)}:{structRef:this.refName,sourceArguments:this.evaluateArgumentsForRef(e)}}refLogError(e,n,r){typeof this.ref=="string"?this.logError(e,n,r):this.ref.logError(e,n,r)}modelStruct(){var e;const n=this.modelEntry(this.ref),r=n==null?void 0:n.entry;if(!r){this.refLogError("source-not-found",`Undefined source '${this.refName}'`);return}if(r.type==="query"){this.logError("invalid-source-from-query",`Cannot construct a source from query '${this.refName}'`);return}else if(r.type==="function"){this.logError("invalid-source-from-function",`Cannot construct a source from a function '${this.refName}'`);return}else if(r.type==="connection"){this.logError("invalid-source-from-connection",`Cannot construct a source from a connection '${this.refName}'`);return}else if((e=this.document())===null||e===void 0||e.checkExperimentalDialect(this,r.dialect),(0,c7.isSourceDef)(r))return{...r};this.logError("invalid-source-source","Cannot construct a source from a never type")}evaluateArgumentsForRef(e){const n=this.modelStruct();return n===void 0?{}:this.evaluateArguments(e,n.parameters,[])}evaluateArguments(e,n,r){var i,s;const o={...this.sourceArguments},u=new Set;for(const a of(i=this.args)!==null&&i!==void 0?i:[]){const l=(s=a.id)!==null&&s!==void 0?s:a.value instanceof Y_e.ExprIdReference?a.value.fieldReference:void 0;if(l===void 0){a.value.logError("unnamed-source-argument","Parameterized source arguments must be named with `parameter_name is`");continue}const c=l.outputName;if(u.has(c)){a.logError("duplicate-source-argument",`Cannot pass argument for \`${c}\` more than once`);continue}u.add(c);const f=(n??{})[c];if(!f)l.logError("source-parameter-not-found",`\`${this.refName}\` has no declared parameter named \`${l.refString}\``);else{const d=e??new K_e.ParameterSpace(r??[]),h=a.value.getExpression(d);let p=h.value;h.type!==f.type&&(0,c7.isCastType)(f.type)&&(p=(0,V_e.castTo)(f.type,h.value,h.type,!0)),o[c]={...f,value:p}}}for(const a in n)a in o||((0,c7.paramHasValue)(n[a])?o[a]={...n[a]}:this.refLogError("missing-source-argument",`Argument not provided for required parameter \`${a}\``));return o}getSourceDef(e){return this.withParameters(e,[])}withParameters(e,n){var r;const i=this.modelStruct();if(!i){const a=W_e.ErrorFactory.structDef,l=`${this.refName}-undefined`;return a.name=a.name+l,a.dialect=a.dialect+l,a}const s={};for(const a of n??[]){const l=a.parameter();s[l.name]=l}const o=this.evaluateArguments(e,i.parameters,n),u={...i,parameters:s,arguments:o};return(r=this.document())===null||r===void 0||r.rememberToAddModelAnnotations(u),u}}hh.NamedSource=J_e;var jg={},x_={};Object.defineProperty(x_,"__esModule",{value:!0}),x_.QueryHeadStruct=void 0;const X_e=Ke,Z_e=Ms,eSe=hh;class tSe extends Z_e.Source{constructor(e,n){super(),this.fromRef=e,this.sourceArguments=n,this.elementType="internalOnlyQueryHead"}structRef(){return{structRef:this.fromRef}}getSourceDef(e){if((0,X_e.refIsStructDef)(this.fromRef))return this.fromRef;const n=new eSe.NamedSource(this.fromRef,this.sourceArguments,void 0);return this.has({exploreReference:n}),n.getSourceDef(e)}}x_.QueryHeadStruct=tSe,Object.defineProperty(jg,"__esModule",{value:!0}),jg.QueryReference=void 0;const f7=Ur,nSe=Ye,rSe=x_,iSe=Ke,sSe=hs;class oSe extends nSe.MalloyElement{constructor(e){super(),this.name=e,this.elementType="query-reference"}queryComp(e){const n=this.modelEntry(this.name),r=n==null?void 0:n.entry,i=function(){return{inputStruct:f7.ErrorFactory.structDef,outputStruct:f7.ErrorFactory.structDef,query:f7.ErrorFactory.query}};if(!r)return this.logError("query-reference-not-found",`Reference to undefined query '${this.name.refString}'`),i();if(r.type==="query"){const s=new rSe.QueryHeadStruct(r.structRef,r.sourceArguments);this.has({queryHead:s});const o=s.getSourceDef(void 0),u=(0,sSe.getFinalStruct)(this,o,r.pipeline);return{query:e||(0,iSe.refIsStructDef)(r.structRef)?r:{...r,structRef:o},outputStruct:u,inputStruct:o}}return this.logError("non-query-used-as-query",`Illegal reference to '${this.name}', query expected`),i()}query(){return this.queryComp(!0).query}}jg.QueryReference=oSe,Object.defineProperty($g,"__esModule",{value:!0}),$g.SQReference=void 0;const uSe=Do,aSe=bf,lSe=hh,cG=jg,fG=ts;class cSe extends uSe.SourceQueryElement{constructor(e,n){super({ref:e}),this.ref=e,this.args=n,this.elementType="sq-reference",n!==void 0&&this.has({args:n})}getQuery(){const e=this.ref.getNamed();if(e)if(e.type==="query"){const n=new cG.QueryReference(this.ref);return this.has({query:n}),n}else this.sqLog("cannot-use-as-query",`Illegal reference to '${e.as||e.name}', query expected`);else this.ref.logError("source-or-query-not-found",`Reference to undefined object '${this.ref.refString}'`),this.errored=!0}isSource(){const e=this.ref.getNamed();return e!==void 0&&(0,fG.isSourceDef)(e)}getSource(){if(this.asSource)return this.asSource;const e=this.ref.getNamed();if(!e){this.ref.logError("source-not-found",`Reference to undefined object '${this.ref.refString}'`),this.errored=!0;return}if(e.type==="query"){this.args!==void 0&&this.ref.logError("illegal-query-argument","Arguments cannot be passed to queries");const n=new cG.QueryReference(this.ref);this.asSource=new aSe.QuerySource(n)}else if((0,fG.isSourceDef)(e))this.asSource=new lSe.NamedSource(this.ref,void 0,this.args);else{this.sqLog("cannot-use-struct-as-source",`Expected '${this.ref.refString}' to be of type query or source, not '${e.type}'`);return}return this.has({asSource:this.asSource}),this.asSource}}$g.SQReference=cSe,Object.defineProperty(c_,"__esModule",{value:!0}),c_.SQRefine=void 0;const fSe=Do,xSe=bf,dSe=dh,hSe=$g;class pSe extends fSe.SourceQueryElement{constructor(e,n){super({toRefine:e,refine:n}),this.toRefine=e,this.refine=n,this.elementType="sq-refine"}getQuery(){if(this.toRefine.isSource()){this.toRefine instanceof hSe.SQReference?this.sqLog("illegal-refinement-of-source",`Cannot add view refinements to '${this.toRefine.ref.refString}' because it is a source`):this.sqLog("illegal-refinement-of-source","Cannot add view refinements to a source");return}const e=this.toRefine.getQuery();if(e){const n=new dSe.QueryRefine(e,this.refine);return this.has({query:n}),n}}getSource(){const e=this.getQuery();if(e){const n=new xSe.QuerySource(e);return this.has({queryAsSource:n}),n}}}c_.SQRefine=pSe;var d_={},qg={};Object.defineProperty(qg,"__esModule",{value:!0}),qg.QueryRaw=void 0;const gSe=Ke,mSe=Ye;class ySe extends mSe.MalloyElement{constructor(e){super({source:e}),this.source=e,this.elementType="query-raw"}queryComp(e){const n=e?this.source.structRef(void 0):{structRef:this.source.getSourceDef(void 0)},r=(0,gSe.refIsStructDef)(n.structRef)?n.structRef:this.source.getSourceDef(void 0);return{query:{type:"query",...n,pipeline:[{type:"raw",fields:[]}],location:this.location},outputStruct:r,inputStruct:r}}query(){return this.queryComp(!0).query}}qg.QueryRaw=ySe;var Hg={},h_={};Object.defineProperty(h_,"__esModule",{value:!0}),h_.makeSQLSentence=void 0;const ESe=Ke,ASe=Ft;function vSe(t,e){return{name:`sql://${e}/${_Se(t)}`,connection:e,select:t}}h_.makeSQLSentence=vSe;function _Se(t){const e=t.map(n=>(0,ESe.isSegmentSQL)(n)?n.sql:JSON.stringify(n));return(0,ASe.generateHash)(e.join(";"))}Object.defineProperty(Hg,"__esModule",{value:!0}),Hg.SQLSource=void 0;const SSe=h_,CSe=Ms,p_=Ur;class bSe extends CSe.Source{constructor(e,n){super({connectionName:e,select:n}),this.connectionName=e,this.select=n,this.elementType="sqlSource",this.connectionNameInvalid=!1}sqlSentence(){return this.requestBlock||(this.requestBlock=(0,SSe.makeSQLSentence)(this.select.sqlPhrases(),this.connectionName.refString)),this.requestBlock}structRef(){return{structRef:this.getSourceDef()}}validateConnectionName(){var e;const n=this.modelEntry(this.connectionName),r=this.connectionName.refString;if(this.connectionNameInvalid)return!1;if(n===void 0)(e=this.namespace())===null||e===void 0||e.setEntry(r,{entry:{type:"connection",name:r},exported:!0},!0);else if(n.entry.type!=="connection")return this.connectionName.logError("invalid-connection-for-sql-source",`${this.connectionName.refString} is not a connection`),this.connectionNameInvalid=!0,!1;return!0}needs(e){var n;if(!this.validateConnectionName())return;const r=super.needs(e);if(r)return r;const i=this.sqlSentence(),s=(n=this.translator())===null||n===void 0?void 0:n.root.sqlQueryZone;if(!s){this.logError("failed-to-fetch-sql-source-schema","Cant't look up schema for sql block");return}s.reference(i.name,this.location);const o=s.getEntry(i.name);if(o.status==="reference")return{compileSQL:i,partialModel:this.select.containsQueries?e.modelDef():void 0};o.status==="present"&&e.checkExperimentalDialect(this,o.value.dialect)}getSourceDef(){var e;if(!this.validateConnectionName())return p_.ErrorFactory.structDef;const n=(e=this.translator())===null||e===void 0?void 0:e.root.sqlQueryZone;if(!n)return this.logError("failed-to-fetch-sql-source-schema","Cant't look up schema for sql block"),p_.ErrorFactory.structDef;const r=this.sqlSentence();n.reference(r.name,this.location);const i=n.getEntry(r.name);if(i.status==="error"){const s=i.message.split(/\r?\n/);return this.select.logError("invalid-sql-source","Invalid SQL, "+s.join(`
1262
- `)),p_.ErrorFactory.structDef}else if(i.status==="present"){const s=this.select.location,o={...i.value,fields:i.value.fields.map(l=>({...l,location:s})),location:this.location},u=this.document(),a=u==null?void 0:u.currentModelAnnotation();return a&&(o.modelAnnotation=a),o}else return this.logError("non-top-level-sql-source","`connection_name.sql(...)` can currently only be used in top level source/query definitions"),p_.ErrorFactory.structDef}}Hg.SQLSource=bSe,Object.defineProperty(d_,"__esModule",{value:!0}),d_.SQSource=void 0;const TSe=Do,RSe=qg,OSe=Hg;class DSe extends TSe.SourceQueryElement{constructor(e){super({theSource:e}),this.theSource=e,this.elementType="sq-source"}isSource(){return!0}getSource(){return this.theSource}getQuery(){if(this.theSource instanceof OSe.SQLSource){const e=new RSe.QueryRaw(this.theSource);return this.has({rawQuery:e}),e}else this.sqLog("invalid-source-as-query","This source cannot be used as a query")}}d_.SQSource=DSe;var g_={};Object.defineProperty(g_,"__esModule",{value:!0}),g_.SQExtend=void 0;const wSe=mg,NSe=Do;class FSe extends NSe.SourceQueryElement{constructor(e,n,r){super({sqSrc:e,extend:n}),this.sqSrc=e,this.extend=n,this.includeList=r,this.elementType="sq-extend"}getSource(){if(this.asSource)return this.asSource;const e=this.sqSrc.getSource();if(e)return this.asSource=new wSe.RefinedSource(e,this.extend,this.includeList),this.has({asSource:this.asSource}),this.asSource;this.sqLog("failed-to-compute-source-to-extend","Could not compute source to extend")}isSource(){return!0}}g_.SQExtend=FSe;var m_={},y_={};Object.defineProperty(y_,"__esModule",{value:!0}),y_.CompositeSource=void 0;const LSe=Ke,ISe=Ms;class BSe extends ISe.Source{constructor(e){super({sources:e}),this.sources=e,this.elementType="compositeSource"}getSourceDef(e){return this.withParameters(e,[])}withParameters(e,n){const r=this.sources.map(l=>l.withParameters(e,n)),i=r[0].connection,s=r[0].dialect,o="composite_source",u=[],a=new Map;return this.sources.forEach((l,c)=>{var f;const d=r[c];d.connection!==i&&l.logError("composite-source-connection-mismatch",`All sources in a composite source must share the same connection; connection \`${d.connection}\` differs from previous connection \`${i}\``);for(const h of d.fields){if(!(0,LSe.isAtomic)(h)){l.logWarning("composite-source-atomic-fields-only",`Only atomic fields are supported in composite sources; field \`${h.name}\` is not atomic and will be ignored`);continue}if(h.accessModifier==="private")continue;const p=(f=h.as)!==null&&f!==void 0?f:h.name,m=a.get(p);if(m===void 0){const g={...h,name:p,as:void 0,e:{node:"compositeField"},compositeFieldUsage:{fields:[p],joinedUsage:{}},code:this.code,location:this.codeLocation};a.set(p,g),u.push(g)}else h.accessModifier==="internal"&&(m.accessModifier="internal")}}),{type:"composite",sources:r,connection:i,fields:u,dialect:s,name:o,parameters:r[0].parameters}}}y_.CompositeSource=BSe,Object.defineProperty(m_,"__esModule",{value:!0}),m_.SQCompose=void 0;const $Se=y_,kSe=Do;class MSe extends kSe.SourceQueryElement{constructor(e){super({sources:e}),this.sources=e,this.elementType="sq-compose"}getSource(){if(this.asSource)return this.asSource;const e=this.sources.map(n=>n.getSource());if(e.length===0){this.sqLog("empty-composite-source","Composite source must have at least one input source");return}else e.length===1&&this.sqLog("unnecessary-composite-source","A composite source with one input is equivalent to that input",{severity:"warn"});if(PSe(e))return this.asSource=new $Se.CompositeSource(e),this.has({asSource:this.asSource}),this.asSource;this.sqLog("invalid-composite-source-input","All composite source inputs must be valid sources")}isSource(){return!0}}m_.SQCompose=MSe;function PSe(t){return t.every(e=>e!==void 0)}var E_={},qa={},zg={},USe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),jSe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),qSe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&USe(e,t,n);return jSe(e,t),e};Object.defineProperty(zg,"__esModule",{value:!0}),zg.BinaryBoolean=void 0;const HSe=fs,zSe=qSe(Wt),QSe=wo,GSe=Pt,WSe=ct;class VSe extends WSe.ExpressionDef{constructor(e,n,r){super({left:e,right:r}),this.left=e,this.op=n,this.right=r,this.elementType="abstract boolean binary",this.legalChildTypes=[zSe.boolT]}getExpression(e){const n=this.left.getExpression(e),r=this.right.getExpression(e);return this.typeCheck(this.left,n)&&this.typeCheck(this.right,r)?(0,GSe.computedExprValue)({dataType:{type:"boolean"},value:{node:(0,QSe.getExprNode)(this.op),kids:{left:n.value,right:r.value}},from:[n,r]}):(0,HSe.errorFor)("logical-op expected boolean")}}zg.BinaryBoolean=VSe;var YSe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),KSe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),JSe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&YSe(e,t,n);return KSe(e,t),e};Object.defineProperty(qa,"__esModule",{value:!0}),qa.ExprLegacyIn=qa.ExprEquality=qa.ExprCompare=void 0;const tn=JSe(Wt),XSe=Pt,ZSe=ct,eCe=zg,tCe={"~":[tn.stringT],"!~":[tn.stringT],"<":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],"<=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],"=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],"!=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],">=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],">":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT]};class xG extends eCe.BinaryBoolean{constructor(e,n,r){super(e,n,r),this.elementType="a<=>b",this.legalChildTypes=tCe[n]}getExpression(e){return this.right.apply(e,this.op,this.left)}}qa.ExprCompare=xG;class nCe extends xG{constructor(e,n,r){super(e,n,r),this.elementType="a~=b"}getExpression(e){return this.right.apply(e,this.op,this.left,!0)}apply(e,n,r){return super.apply(e,n,r,!0)}}qa.ExprEquality=nCe;class rCe extends ZSe.ExpressionDef{constructor(e,n,r){super(),this.expr=e,this.notIn=n,this.choices=r,this.elementType="in",this.has({expr:e,choices:r})}getExpression(e){const n=this.expr.getExpression(e),r=this.choices.map(i=>i.getExpression(e));return(0,XSe.computedExprValue)({dataType:{type:"boolean"},value:{node:"in",not:this.notIn,kids:{e:n.value,oneOf:r.map(i=>i.value)}},from:[n,...r]})}}qa.ExprLegacyIn=rCe;var Qg={},gh={};Object.defineProperty(gh,"__esModule",{value:!0}),gh.ExprTime=void 0;const iCe=Ke,sCe=Pt,oCe=ct;class x7 extends oCe.ExpressionDef{constructor(e,n,r){super(),this.elementType="timestampOrDate",this.elementType=e,this.translationValue=(0,sCe.computedExprValue)({dataType:{type:e},value:n,from:r??[]})}getExpression(e){return this.translationValue}static fromValue(e,n){let r=n.value;if(e!==n.type){const i={node:"cast",safe:!1,dstType:{type:e},e:n.value};(0,iCe.isTemporalType)(n.type)&&(i.srcType={type:n.type}),r=i}return new x7(e,r,[n])}}gh.ExprTime=x7;var y0={};Object.defineProperty(y0,"__esModule",{value:!0}),y0.Range=void 0;const uCe=fs,aCe=Pt,lCe=ct;class cCe extends lCe.ExpressionDef{constructor(e,n){super({first:e,last:n}),this.first=e,this.last=n,this.elementType="range"}apply(e,n,r){switch(n){case"=":case"!=":{const i=n==="="?">=":"<",s=n==="="?"and":"or",o=n==="="?"<":">=",u=this.first.apply(e,i,r),a=this.last.apply(e,o,r);return(0,aCe.computedExprValue)({dataType:{type:"boolean"},value:{node:s,kids:{left:u.value,right:a.value}},from:[u,a]})}case">":return this.last.apply(e,">=",r);case">=":return this.first.apply(e,">=",r);case"<":return this.first.apply(e,"<",r);case"<=":return this.last.apply(e,"<",r)}throw new Error("mysterious error in range computation")}requestExpression(e){}getExpression(e){return this.logError("range-as-value","A Range is not a value"),(0,uCe.errorFor)("a range is not a value")}}y0.Range=cCe;var fCe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),xCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dCe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&fCe(e,t,n);return xCe(e,t),e};Object.defineProperty(Qg,"__esModule",{value:!0}),Qg.ExprGranularTime=void 0;const d7=Ke,hCe=fs,dG=dCe(Wt),hG=Li,pCe=ct,A_=gh,pG=y0;class gCe extends pCe.ExpressionDef{constructor(e,n,r){super({expr:e}),this.expr=e,this.units=n,this.truncate=r,this.elementType="granularTime",this.legalChildTypes=[dG.timestampT,dG.dateT]}granular(){return!0}getExpression(e){const n=this.units,r=this.expr.getExpression(e);if(d7.TD.isTemporal(r)){const s={...r,timeframe:n};return this.truncate&&(s.value={node:"trunc",e:(0,d7.mkTemporal)(r.value,r.type),units:n}),s}r.type!=="error"&&this.logError("unsupported-type-for-time-truncation",`Cannot do time truncation on type '${r.type}'`);const i={...r};return r.type==="error"&&(i.type=(0,d7.isDateUnit)(n)?"date":"timestamp"),{...i,value:(0,hCe.errorFor)("granularity typecheck").value,evalSpace:"constant"}}toRange(e){const n=this.getExpression(e),r={node:"numberLiteral",literal:"1"};if(n.type==="timestamp"){const u=A_.ExprTime.fromValue("timestamp",n),a=new A_.ExprTime("timestamp",(0,hG.timeOffset)("timestamp",n.value,"+",r,this.units),[n]);return new pG.Range(u,a)}const i=new A_.ExprTime("date",n.value,[n]),s=(0,hG.timeOffset)("date",n.value,"+",r,this.units),o=new A_.ExprTime("date",s,[n]);return new pG.Range(i,o)}}Qg.ExprGranularTime=gCe,Object.defineProperty(E_,"__esModule",{value:!0}),E_.Apply=void 0;const mCe=qa,yCe=ph,gG=Qg;class ECe extends mCe.ExprCompare{constructor(e,n){super(e,"=",n),this.left=e,this.right=n,this.elementType="apply"}getExpression(e){let n=this.right;if(!this.right.granular()){const r=this.right.requestExpression(e);r&&(0,yCe.isGranularResult)(r)&&(n=new gG.ExprGranularTime(this.right,r.timeframe,!1))}return n instanceof gG.ExprGranularTime?n.toRange(e).apply(e,this.op,this.left):super.getExpression(e)}}E_.Apply=ECe;var mh={},ACe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),vCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),_Ce=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&ACe(e,t,n);return vCe(e,t),e};Object.defineProperty(mh,"__esModule",{value:!0}),mh.BinaryNumeric=void 0;const SCe=_Ce(Wt),CCe=ct;class bCe extends CCe.ExpressionDef{constructor(e,n,r){super({left:e,right:r}),this.left=e,this.op=n,this.right=r,this.elementType="numeric binary abstract",this.legalChildTypes=[SCe.numberT]}getExpression(e){return this.right.apply(e,this.op,this.left)}}mh.BinaryNumeric=bCe;var v_={},TCe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),RCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),OCe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&TCe(e,t,n);return RCe(e,t),e};Object.defineProperty(v_,"__esModule",{value:!0}),v_.Boolean=void 0;const DCe=ct,wCe=OCe(Wt);let NCe=class extends DCe.ExpressionDef{constructor(e){super(),this.value=e,this.elementType="boolean literal"}getExpression(){return{...wCe.boolT,value:{node:this.value}}}};v_.Boolean=NCe;var E0={};Object.defineProperty(E0,"__esModule",{value:!0}),E0.FunctionOrdering=E0.FunctionOrderBy=void 0;const h7=Ke,mG=Ye,FCe=Tf;class LCe extends mG.MalloyElement{constructor(e,n){super(),this.field=e,this.dir=n,this.elementType="orderBy",e&&this.has({field:e})}getAnalyticOrderBy(e){if(!this.field)return this.logError("analytic-order-by-missing-field","analytic `order_by` must specify an aggregate expression or output field reference"),{node:"functionOrderBy",e:{node:"error"},dir:this.dir};const n=this.field.getExpression(e);return(0,h7.expressionIsAggregate)(n.expressionType)||((0,h7.expressionIsScalar)(n.expressionType)?(!(this.field instanceof FCe.ExprIdReference)||n.evalSpace==="input")&&this.field.logError("analytic-order-by-not-output","analytic `order_by` must be an aggregate or an output field reference"):this.field.logError("analytic-order-by-not-aggregate-or-output","analytic `order_by` must be scalar or aggregate")),{node:"functionOrderBy",e:n.value,dir:this.dir}}getAggregateOrderBy(e,n){if(this.field){const r=this.field.getExpression(e);return(0,h7.expressionIsScalar)(r.expressionType)||this.field.logError("aggregate-order-by-not-scalar","aggregate `order_by` must be scalar"),n||this.field.logError("aggregate-order-by-expression-not-allowed","`order_by` must be only `asc` or `desc` with no expression"),{node:"functionOrderBy",e:r.value,dir:this.dir}}else return this.dir===void 0?(this.logError("aggregate-order-by-without-field-or-direction","field or order direction must be specified"),{node:"functionDefaultOrderBy",dir:"asc"}):{node:"functionDefaultOrderBy",dir:this.dir}}}E0.FunctionOrderBy=LCe;class ICe extends mG.ListOf{constructor(e){super(e),this.elementType="function-ordering"}getAnalyticOrderBy(e){return this.list.map(n=>n.getAnalyticOrderBy(e))}getAggregateOrderBy(e,n){return this.list.map(r=>r.getAggregateOrderBy(e,n))}}E0.FunctionOrdering=ICe;var __={};Object.defineProperty(__,"__esModule",{value:!0}),__.ExprAddSub=void 0;const BCe=mh;class $Ce extends BCe.BinaryNumeric{constructor(){super(...arguments),this.elementType="+-"}}__.ExprAddSub=$Ce;var Ha={},kCe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),MCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),PCe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&kCe(e,t,n);return MCe(e,t),e};Object.defineProperty(Ha,"__esModule",{value:!0}),Ha.ExprAggregateFunction=void 0;const Gg=Ke,UCe=Ft,jCe=fs,yG=Cr,EG=PCe(Wt),qCe=pt,HCe=ct,zCe=Sr,QCe=Tf;class GCe extends HCe.ExpressionDef{constructor(e,n,r){super(),this.func=e,this.legalChildTypes=[EG.numberT],this.elementType=e,this.explicitSource=r,n&&(this.expr=n,this.has({expr:n}))}getExpression(e){var n,r,i;const s=e.isQueryFieldSpace()?e.inputSpace():e;let o=this.expr,u=(n=this.expr)===null||n===void 0?void 0:n.getExpression(s),a=(r=this.source)===null||r===void 0?void 0:r.path,l=[];if(this.source){const f=this.source.getField(s);if(f.found){l=f.joinPath;const d=f.found,h=d.typeDesc();if(!(d instanceof yG.StructSpaceField))if((0,Gg.isAtomicFieldType)(h.type)){o=this.source,u={...EG.atomicDef(h),expressionType:h.expressionType,value:h.evalSpace==="output"?{node:"outputField",name:this.source.refString}:{node:"field",path:this.source.path},evalSpace:h.evalSpace,compositeFieldUsage:h.compositeFieldUsage},a=this.source.path.slice(0,-1);const p=this.getJoinUsage(s);(p.length===1||p.length>1&&p.slice(1).every(g=>WCe(g,p[0])))&&(a=p[0].map(g=>g.name),l=p[0])}else return this.loggedErrorExpr("invalid-aggregate-source",`Aggregate source cannot be a ${h.type}`)}else return this.loggedErrorExpr("aggregate-source-not-found",`Reference to undefined value ${this.source.refString}`)}if(u===void 0)return this.loggedErrorExpr("missing-aggregate-expression","Missing expression for aggregate function");if((0,Gg.expressionIsAggregate)(u.expressionType))return this.loggedErrorExpr("aggregate-of-aggregate","Aggregate expression cannot be aggregate");if(!(u.type==="error")){const f=this.getJoinUsage(s),d=this.source!==void 0||this.explicitSource;if(o&&!(!this.source&&f.every(p=>p.length===0))&&!this.isSymmetricFunction()){const p=g7(l,f),m=m7(this.elementType,p),g=d?m==null?void 0:m.message:"Join path is required for this calculation";if(g){const y=VCe(g,f,o,this.elementType),E=(i=m==null?void 0:m.code)!==null&&i!==void 0?i:"bad-join-usage";m?this.logError(E,y):this.logWarning(E,y)}}}if(this.typeCheck(this.expr||this,{...u,expressionType:"scalar"})){const f={node:"aggregate",function:this.func,e:u.value};return a&&a.length>0&&(f.structPath=a),{...this.returns(u),expressionType:"aggregate",value:f,evalSpace:"output"}}return(0,jCe.errorFor)("aggregate type check")}isSymmetricFunction(){return!0}getJoinUsage(e){const n=[];if(this.source&&this.source.getField(e).found){const i={node:"field",path:this.source.path};n.push(...p7(e,i))}if(this.expr){const r=this.expr.getExpression(e).value;n.push(...p7(e,r))}return n}}Ha.ExprAggregateFunction=GCe;function WCe(t,e){let n=t.length;if(n!==e.length)return!1;for(;n>0;)if(n-=1,t[n].name!==e[n].name)return!1;return!0}function p7(t,e){const n=[],r=(i,s)=>{const o=s[0],u=s.slice(1),a=i.entry(o);if(a===void 0)throw new Error(`Invalid field lookup ${o}`);if(a instanceof yG.StructSpaceField&&u.length>0){const l=r(a.fieldSpace,u);return{...l,joinPath:[{...a.joinPathElement,name:o},...l.joinPath]}}else if(a instanceof zCe.SpaceField){if(u.length!==0)throw new Error(`${o} cannot contain a ${u.join(".")}`);const l=a.fieldDef();if(l)return{fs:i,def:l,joinPath:[]};throw new Error("No field def")}else throw new Error("expected a field def or struct")};for(const i of(0,UCe.exprWalk)(e))if(i.node==="field"){const s=r(t,i.path),o=s.def;if((0,Gg.isAtomic)(o)&&!(0,Gg.isJoined)(o))if((0,Gg.hasExpression)(o)){const u=p7(s.fs,o.e);n.push(...u.map(a=>[...s.joinPath,...a]))}else n.push(s.joinPath)}else if(i.node==="source-reference")if(i.path){const s=r(t,i.path);n.push(s.joinPath)}else n.push([]);return n}function g7(t,e){const n=[];for(const r of e){let i=0;for(let a=0;a<t.length&&a<r.length&&t[a].name===r[a].name;a++)i=a+1;const s=t.slice(i),o=r.slice(i),u=[...s.map(a=>({...a,reverse:!0})),...o.map(a=>({...a,reverse:!1}))];n.push(u)}return n}function m7(t,e){for(const n of e)for(const r of n){if(r.joinType==="cross")return{code:"aggregate-traverses-join-cross",message:`Cannot compute \`${t}\` across \`join_cross\` relationship \`${r.name}\``};if(r.joinElementType==="array"&&!r.reverse)return{code:"aggregate-traverses-repeated-relationship",message:`Cannot compute \`${t}\` across repeated relationship \`${r.name}\``};if(r.joinType==="many"&&!r.reverse)return{code:"aggregate-traverses-join-many",message:`Cannot compute \`${t}\` across \`join_many\` relationship \`${r.name}\``}}}function VCe(t,e,n,r){if(e.length===0)return t;let i=e[0];for(const p of e.slice(1))for(let m=0;m<i.length;m++){const g=i[m],y=p[m];if(g.name!==y.name){i=i.slice(0,m);break}}const s=g7(i,e),o=m7(r,s),u=i.slice().reverse().findIndex(p=>p.joinType==="many"||p.joinType==="cross"),a=u===-1?0:i.length-u,l=i.slice(0,a),c=g7(l,e),f=m7(r,c),d=i.length>0?i.map(p=>p.name).join("."):"source",h=l.length>0?l.map(p=>p.name).join("."):"source";if(o)return"Aggregated dimensional expression contains multiple join paths; rewrite, for example `sum(first_join.field + second_join.field)` as `first_join.field.sum() + second_join.field.sum()`";{const p=n instanceof qCe.FieldReference?`${n.refString}.${r}()`:n instanceof QCe.ExprIdReference?`${n.fieldReference.refString}.${r}()`:`${d}.${r}(${n.code})`,m=`${h}.${r}(${n.code})`;let g=`${t}; use \`${p}\``;return f===void 0&&h!==d&&(g+=` or \`${m}\` to get a result weighted with respect to \`${h}\``),g}}var S_={};Object.defineProperty(S_,"__esModule",{value:!0}),S_.ExprAlternationTree=void 0;const AG=Pt,yh=ct,YCe=wo;function y7(t){const e=t.atExpr();switch(e.atNodeType()){case yh.ATNodeType.And:case yh.ATNodeType.Partial:return;case yh.ATNodeType.Or:{if(e instanceof vG){const n=y7(e.left);if(n){const r=y7(e.right);if(r)return[...n,...r]}}return}default:return e.granular()?void 0:[e]}}class vG extends yh.ExpressionDef{constructor(e,n,r){super({left:e,right:r}),this.left=e,this.op=n,this.right=r,this.elementType="alternation",this.elementType=`${n}alternation${n}`}equalityList(){return this.inList===void 0&&(this.inList=y7(this)||[]),this.inList}apply(e,n,r,i){if((0,YCe.isEquality)(n)){const u=this.equalityList();if(u.length>0&&(n==="="||n==="!=")){const a=r.getExpression(e),l=u.map(c=>c.getExpression(e));return(0,AG.computedExprValue)({dataType:{type:"boolean"},value:{node:"in",not:n==="!=",kids:{e:a.value,oneOf:l.map(c=>c.value)}},from:[a,...l]})}u.length===0&&i&&this.logWarning("or-choices-only",`Only | seperated values are legal when used with ${n} operator`)}const s=this.left.apply(e,n,r),o=this.right.apply(e,n,r);return(0,AG.computedExprValue)({dataType:{type:"boolean"},value:{node:this.op==="&"?"and":"or",kids:{left:s.value,right:o.value}},from:[s,o]})}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("alternation-as-value","Alternation tree has no value")}atNodeType(){return this.op==="|"?yh.ATNodeType.Or:yh.ATNodeType.And}}S_.ExprAlternationTree=vG;var Eh={};Object.defineProperty(Eh,"__esModule",{value:!0}),Eh.ExprAsymmetric=void 0;const KCe=Ha;class JCe extends KCe.ExprAggregateFunction{constructor(e,n,r,i){super(e,n,i),this.func=e,this.expr=n,this.source=r,this.has({source:r})}isSymmetricFunction(){return!1}returns(e){return e}defaultFieldName(){if(this.source&&this.expr===void 0){const e=this.source.nameString;switch(this.func){case"sum":return`total_${e}`;case"avg":return`avg_${e}`}}}}Eh.ExprAsymmetric=JCe;var C_={};Object.defineProperty(C_,"__esModule",{value:!0}),C_.ExprAvg=void 0;const XCe=Eh;class ZCe extends XCe.ExprAsymmetric{constructor(e,n,r){super("avg",e,n,r),this.has({source:n})}}C_.ExprAvg=ZCe;var b_={};Object.defineProperty(b_,"__esModule",{value:!0}),b_.ExprCast=void 0;const e5e=Li,t5e=Pt,n5e=ct;class r5e extends n5e.ExpressionDef{constructor(e,n,r=!1){super({expr:e}),this.expr=e,this.castType=n,this.safe=r,this.elementType="cast"}getExpression(e){const n=this.expr.getExpression(e);let r={type:"error"};if(typeof this.castType=="string")r={type:this.castType};else{const i=e.dialectObj();i&&(i.validateTypeName(this.castType.raw)?r=i.sqlTypeToMalloyType(this.castType.raw):this.logError("invalid-sql-native-type",`Cast type \`${this.castType.raw}\` is invalid for ${i.name} dialect`),this.safe&&!i.supportsSafeCast&&this.logError("dialect-cast-unsafe-only",`The SQL dialect '${e.dialectName()}' does not supply a safe cast operator`))}return(0,t5e.computedExprValue)({dataType:r,value:(0,e5e.castTo)(this.castType,n.value,n.type,this.safe),from:[n]})}}b_.ExprCast=r5e;var T_={},i5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),s5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&i5e(e,t,n);return s5e(e,t),e};Object.defineProperty(T_,"__esModule",{value:!0}),T_.ExprCoalesce=void 0;const _G=ts,SG=o5e(Wt),u5e=ct;class a5e extends u5e.ExpressionDef{constructor(e,n){super({expr:e,altExpr:n}),this.expr=e,this.altExpr=n,this.elementType="coalesce expression",this.legalChildTypes=SG.anyAtomicT}getExpression(e){const n=this.expr.getExpression(e),r=this.altExpr.getExpression(e);return n.type==="null"?r:(SG.typeEq(n,r)||this.logError("mismatched-coalesce-types",`Mismatched types for coalesce (${n.type}, ${r.type})`),{...n.type==="error"?r:n,expressionType:(0,_G.maxExpressionType)(n.expressionType,r.expressionType),value:{node:"coalesce",kids:{left:n.value,right:r.value}},evalSpace:(0,_G.mergeEvalSpaces)(n.evalSpace,r.evalSpace)})}}T_.ExprCoalesce=a5e;var R_={};Object.defineProperty(R_,"__esModule",{value:!0}),R_.ExprCount=void 0;const l5e=at,c5e=Ha;class f5e extends c5e.ExprAggregateFunction{constructor(e){super("count"),this.source=e,this.elementType="count",this.has({source:e})}defaultFieldName(){if(this.source)return"count_"+this.source.nameString}returns(e){return{type:"number",numberType:"integer",evalSpace:e.evalSpace,expressionType:"aggregate",value:e.value,compositeFieldUsage:e.compositeFieldUsage}}getExpression(e){const n={node:"aggregate",function:"count",e:{node:""}};return this.source&&(n.structPath=this.source.path),{type:"number",numberType:"integer",expressionType:"aggregate",value:n,evalSpace:"output",compositeFieldUsage:(0,l5e.emptyCompositeFieldUsage)()}}}R_.ExprCount=f5e;var O_={},x5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),d5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),h5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&x5e(e,t,n);return d5e(e,t),e};Object.defineProperty(O_,"__esModule",{value:!0}),O_.ExprCountDistinct=void 0;const D_=h5e(Wt),p5e=Ha;class g5e extends p5e.ExprAggregateFunction{constructor(e){super("distinct",e),this.legalChildTypes=[D_.numberT,D_.stringT,D_.dateT,D_.timestampT]}returns(e){return{type:"number",numberType:"integer",evalSpace:e.evalSpace,expressionType:"aggregate",value:e.value,compositeFieldUsage:e.compositeFieldUsage}}}O_.ExprCountDistinct=g5e;var w_={},A0={};Object.defineProperty(A0,"__esModule",{value:!0}),A0.Limit=void 0;const m5e=Ye,y5e=wn;class E5e extends m5e.MalloyElement{constructor(e){super(),this.limit=e,this.elementType="limit",this.queryRefinementStage=y5e.LegalRefinementStage.Tail,this.forceQueryClass=void 0}}A0.Limit=E5e;var Ah={};Object.defineProperty(Ah,"__esModule",{value:!0}),Ah.PartitionBy=void 0;const A5e=Ye;class v5e extends A5e.ListOf{constructor(e){super(e),this.partitionFields=e,this.elementType="partition_by"}}Ah.PartitionBy=v5e;var Wg={},v0={};Object.defineProperty(v0,"__esModule",{value:!0}),v0.FieldName=void 0;const _5e=Ye;class S5e extends _5e.MalloyElement{constructor(e){super(),this.name=e,this.elementType="fieldName"}get refString(){return this.name}toString(){return this.refString}getField(e){return e.lookup([this])}}v0.FieldName=S5e;var C5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),b5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),T5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&C5e(e,t,n);return b5e(e,t),e};Object.defineProperty(Wg,"__esModule",{value:!0}),Wg.ExprFunc=void 0;const tr=Ke,R5e=fs,O5e=Ef,D5e=Pt,w5e=ct,N5e=v0,CG=Ft,bG=T5e(Wt),F5e=at;class L5e extends w5e.ExpressionDef{constructor(e,n,r,i,s){super({args:n}),this.name=e,this.args=n,this.isRaw=r,this.rawType=i,this.source=s,this.elementType="function call()",this.has({source:s})}canSupportPartitionBy(){return!0}canSupportOrderBy(){return!0}canSupportLimit(){return!0}getExpression(e){return this.getPropsExpression(e)}findFunctionDef(e){var n,r,i;const s=this.name.toLowerCase(),o=e?(r=(n=this.getDialectNamespace(e))===null||n===void 0?void 0:n.getEntry(s))===null||r===void 0?void 0:r.entry:void 0,u=o??((i=this.modelEntry(s))===null||i===void 0?void 0:i.entry);return u===void 0?(this.logError("function-not-found",`Unknown function '${this.name}'. Use '${this.name}!(...)' to call a SQL function directly.`),{found:void 0,error:"unknown function"}):u.type!=="function"?(this.logError("call-of-non-function",`'${this.name}' (with type ${u.type}) is not a function`),{found:void 0,error:"called non function"}):(u.name!==this.name&&this.logWarning("case-insensitive-function",`Case insensitivity for function names is deprecated, use '${u.name}' instead`),{found:u,error:void 0})}getPropsExpression(e,n){var r,i,s,o;const u=this.args.map(F=>F.getExpression(e));if(this.isRaw){const F=[`${this.name}(`];u.forEach((U,J)=>{J!==0&&F.push(","),F.push(U.value)}),F.push(")");const I=(r=u[0])!==null&&r!==void 0?r:{type:"number"},M=this.rawType?{type:this.rawType}:I;return(0,D5e.computedExprValue)({dataType:M,value:(0,CG.composeSQLExpr)(F),from:u})}const a=(i=e.dialectObj())===null||i===void 0?void 0:i.name,{found:l,error:c}=this.findFunctionDef(a);if(l===void 0)return(0,R5e.errorFor)(c);let f,d=(s=this.source)===null||s===void 0?void 0:s.path;if(this.source){const I=this.source.getField(e).found;if(I){const M=I.typeDesc();if((0,tr.isAtomicFieldType)(M.type))f={...bG.atomicDef(M),expressionType:M.expressionType,value:{node:"field",path:this.source.path},evalSpace:M.evalSpace,compositeFieldUsage:M.compositeFieldUsage},d=this.source.path.slice(0,-1);else if(!(I instanceof O5e.StructSpaceFieldBase))return this.loggedErrorExpr("invalid-aggregate-source",`Aggregate source cannot be a ${M.type}`)}else this.loggedErrorExpr("aggregate-source-not-found",`Reference to undefined value ${this.source.refString}`)}const h=[...f?[f]:[],...u],p=I5e(l,h);if(p===void 0)return this.loggedErrorExpr("no-matching-function-overload",`No matching overload for function ${this.name}(${h.map(F=>F.type).join(", ")})`);const{overload:m,expressionTypeErrors:g,evalSpaceErrors:y,nullabilityErrors:E,returnType:A}=p;for(const F of g){const I=F.argIndex-(f?1:0),M=(0,tr.expressionIsScalar)(F.maxExpressionType)?"scalar":"scalar or aggregate";this.args[I].logError("invalid-function-argument-expression-type",`Parameter ${F.argIndex+1} ('${F.param.name}') of ${this.name} must be ${M}, but received ${F.actualExpressionType}`)}for(const F of y){const I=F.argIndex-(f?1:0),M=F.maxEvalSpace==="literal"?"literal":F.maxEvalSpace==="constant"?"literal or constant":"literal, constant or output";this.args[I].logError("invalid-function-argument-evaluation-space",`Parameter ${F.argIndex+1} ('${F.param.name}') of ${this.name} must be ${M}, but received ${F.actualEvalSpace}`)}for(const F of E){const I=F.argIndex-(f?1:0);this.args[I].logError("literal-null-function-argument",`Parameter ${F.argIndex+1} ('${F.param.name}') of ${this.name} must not be a literal null`)}p.returnTypeError&&this.logError(p.returnTypeError.code,p.returnTypeError.parameters);const v=m.returnType,_=(0,tr.maxOfExpressionTypes)([(o=v.expressionType)!==null&&o!==void 0?o:"scalar",...h.map(F=>F.expressionType)]);if(!(0,tr.expressionIsAggregate)(m.returnType.expressionType)&&this.source!==void 0)return this.loggedErrorExpr("non-aggregate-function-with-source",`Cannot call function ${this.name}(${h.map(F=>F.type).join(", ")}) with source`);const S={node:"function_call",overload:m,name:this.name,kids:{args:h.map(F=>F.value)},expressionType:_,structPath:d};let C=S;if(n!=null&&n.orderBys&&n.orderBys.length>0){const F=(0,tr.expressionIsAnalytic)(m.returnType.expressionType);if(F||this.inExperiment("aggregate_order_by",!0)||n.orderBys[0].logError("aggregate-order-by-experiment-not-enabled","Enable experiment `aggregate_order_by` to use `order_by` with an aggregate function"),m.supportsOrderBy||F){const I=m.supportsOrderBy!=="only_default",M=n.orderBys.flatMap(U=>F?U.getAnalyticOrderBy(e):U.getAggregateOrderBy(e,I));S.kids.orderBy=M}else n.orderBys[0].logError("function-does-not-support-order-by",`Function \`${this.name}\` does not support \`order_by\``)}if((n==null?void 0:n.limit)!==void 0&&(m.supportsLimit?S.limit=n.limit.limit:this.logError("function-does-not-support-limit",`Function ${this.name} does not support limit`)),n!=null&&n.partitionBys&&n.partitionBys.length>0){const F=[];for(const I of n.partitionBys)for(const M of I.partitionFields){const U=M.getField(e);U.found===void 0?M.logError("partition-by-not-found",`${M.refString} is not defined`):(0,tr.expressionIsAnalytic)(U.found.typeDesc().expressionType)||(0,tr.expressionIsUngroupedAggregate)(U.found.typeDesc().expressionType)?M.logError("non-scalar-or-aggregate-partition-by","Partition expression must be scalar or aggregate"):F.push(M.nameString)}S.partitionBy=F}if(["sql_number","sql_string","sql_date","sql_timestamp","sql_boolean"].includes(l.name)){if(!this.inExperiment("sql_functions",!0))return this.loggedErrorExpr("sql-functions-experiment-not-enabled",`Cannot use sql_function \`${l.name}\`; use \`sql_functions\` experiment to enable this behavior`);const F=h[0].value;if(F.node!=="stringLiteral")this.logError("invalid-sql-function-argument",`Invalid string literal for \`${l.name}\``);else{const I=F.literal,M=B5e(I),U=M.filter(Q=>Q.type==="interpolation"&&Q.name.includes(".")).map(Q=>Q.type==="interpolation"?`\${${Q.name}}`:`\${${Q.value}}`);if(U.length>0){const Q=U.length===1?`'.' paths are not yet supported in sql interpolations, found ${U.at(0)}`:`'.' paths are not yet supported in sql interpolations, found (${U.join(", ")})`;return this.loggedErrorExpr("unsupported-sql-function-interpolation",Q)}const J=[];for(const Q of M)if(Q.type==="string")J.push(Q.value);else if(Q.name==="TABLE")J.push({node:"source-reference"});else{const ue=new N5e.FieldName(Q.name);this.has({name:ue});const he=e.lookup([ue]);if(he.found===void 0)return this.loggedErrorExpr("sql-function-interpolation-not-found",`Invalid interpolation: ${he.error.message}`);he.found.refType==="parameter"?J.push({node:"parameter",path:[Q.name]}):J.push({node:"field",path:[Q.name]})}C=(0,CG.composeSQLExpr)(J)}}const b=(0,tr.mergeEvalSpaces)(...h.map(F=>F.evalSpace)),w=b==="constant"?"constant":(0,tr.expressionIsScalar)(_)?b:"output";return{...(0,tr.isAtomic)(A)?bG.atomicDef(A):A,expressionType:_,value:C,evalSpace:w,compositeFieldUsage:(0,F5e.mergeCompositeFieldUsage)(...h.map(F=>F.compositeFieldUsage))}}}Wg.ExprFunc=L5e;function I5e(t,e){var n;for(const r of t.overloads){const i=new Map;let s=0,o=!0,u=!1;const a=[],l=[],c=[];for(let h=0;h<e.length;h++){const p=e[h],m=r.params[s];if(m===void 0){o=!1;break}if(!m.allowedTypes.some(y=>{var E;const{dataTypeMatch:A,genericsSet:v}=vh(i,(E=r.genericTypes)!==null&&E!==void 0?E:[],p,y);for(const _ of v)i.set(_.name,_.type);return y.expressionType&&((0,tr.isExpressionTypeLEQ)(p.expressionType,y.expressionType)||a.push({argIndex:h,maxExpressionType:y.expressionType,actualExpressionType:p.expressionType,param:m})),(y.evalSpace==="literal"&&p.evalSpace!=="literal"||y.evalSpace==="constant"&&(p.evalSpace==="input"||p.evalSpace==="output")||(0,tr.expressionIsAnalytic)(r.returnType.expressionType)&&p.evalSpace==="input")&&l.push({argIndex:h,param:m,maxEvalSpace:y.evalSpace,actualEvalSpace:p.evalSpace}),y.evalSpace==="literal"&&p.type==="null"&&c.push({argIndex:h,param:m}),A})){o=!1;break}m.isVariadic?h===e.length-1&&(u=!0):s++}if(!u&&(s!==e.length||s!==r.params.length))continue;const f=N_(r.returnType,i),d=(n=f.returnType)!==null&&n!==void 0?n:{type:"number"};if(o)return{overload:r,expressionTypeErrors:a,evalSpaceErrors:l,nullabilityErrors:c,returnTypeError:f.error,returnType:d}}}function B5e(t){const e=[];let n=t;for(;n.length;){const r=n.indexOf("${");if(r===-1){e.push({type:"string",value:n});break}else{const i=n.slice(r).indexOf("}");if(i===-1){e.push({type:"string",value:n});break}r>0&&e.push({type:"string",value:n.slice(0,r)}),e.push({type:"interpolation",name:n.slice(r+2,i+r)}),n=n.slice(i+r+1)}}return e}function vh(t,e,n,r){var i,s,o,u;if(tr.TD.eq(r,n)||r.type==="any"||r.type!=="generic"&&(n.type==="null"||n.type==="error"))return{dataTypeMatch:!0,genericsSet:[]};if(r.type==="array"&&n.type==="array"){if((0,tr.isScalarArray)(n))return(0,tr.isRepeatedRecordFunctionParam)(r)?{dataTypeMatch:!1,genericsSet:[]}:vh(t,e,n.elementTypeDef,r.elementTypeDef);if((0,tr.isRepeatedRecordFunctionParam)(r)){const a={type:"record",fields:r.fields},l={type:"record",fields:n.fields};return vh(t,e,l,a)}else return{dataTypeMatch:!1,genericsSet:[]}}else if(r.type==="record"&&n.type==="record"){const a=[],l=new Map;for(const c of r.fields)l.set((i=c.as)!==null&&i!==void 0?i:c.name,c);for(const c of n.fields){const f=l.get((s=c.as)!==null&&s!==void 0?s:c.name);if(f===void 0)return{dataTypeMatch:!1,genericsSet:[]};const d=vh(new Map([...t.entries(),...a.map(h=>[h.name,h.type])]),e,c,f);a.push(...d.genericsSet)}return{dataTypeMatch:!0,genericsSet:a}}else if(r.type==="generic"){const a=t.get(r.generic);if(a!==void 0&&a.type!=="null"&&a.type!=="error")return vh(t,e,n,a);const l=(u=(o=e.find(c=>c.name===r.generic))===null||o===void 0?void 0:o.acceptibleTypes)!==null&&u!==void 0?u:[];for(const c of l){const f=vh(t,e,n,c);if(f.dataTypeMatch){if(!(0,tr.isAtomic)(n)&&n.type!=="null")continue;const d={name:r.generic,type:n};return{dataTypeMatch:!0,genericsSet:[...f.genericsSet,d]}}}}return{dataTypeMatch:!1,genericsSet:[]}}function N_(t,e){switch(t.type){case"array":{if("fields"in t){const i=t.fields.map(s=>{const o=N_(s,e);return{...s,...o}});return{error:void 0,returnType:{type:"array",elementTypeDef:t.elementTypeDef,fields:i}}}const n=N_(t.elementTypeDef,e);if(n.error)return n;const r=n.returnType;return r.type==="record"?{error:void 0,returnType:{type:"array",elementTypeDef:{type:"record_element"},fields:r.fields}}:(0,tr.isAtomic)(r)?{error:void 0,returnType:{type:"array",elementTypeDef:r}}:{error:{code:"invalid-resolved-type-for-array",parameters:"Invalid resolved type for array; cannot be non-atomic"},returnType:void 0}}case"record":return{error:void 0,returnType:{type:"record",fields:t.fields.map(r=>{const i=N_(r,e);return{...r,...i}})}};case"generic":{const n=e.get(t.generic);return n===void 0?{error:{code:"generic-not-resolved",parameters:`Generic ${t.generic} in return type could not be resolved`},returnType:void 0}:{error:void 0,returnType:n}}default:return{error:void 0,returnType:t}}}var $5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),k5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),M5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&$5e(e,t,n);return k5e(e,t),e};Object.defineProperty(w_,"__esModule",{value:!0}),w_.ExprProps=void 0;const P5e=Ke,U5e=fs,j5e=M5e(Wt),q5e=E0,H5e=A0,z5e=Ah,Q5e=ct,G5e=Wg,W5e=at;class V5e extends Q5e.ExpressionDef{constructor(e,n){super({expr:e,statements:n}),this.expr=e,this.statements=n,this.elementType="expression with props",this.legalChildTypes=j5e.anyAtomicT}getFilteredExpression(e,n,r){if(r.length>0){if(!this.expr.supportsWhere(n))return this.expr.logError("filter-of-non-aggregate","Filtered expression requires an aggregate computation"),n;const i=[];for(const s of r){const o=s.getFilterList(e);if(o.find(u=>(0,P5e.expressionIsCalculation)(u.expressionType)))return s.logError("aggregate-filter-expression-not-scalar","Cannot filter an expresion with an aggregate or analytical computation"),n;i.push(...o)}return this.typeCheck(this.expr,{...n,expressionType:"scalar"})?{...n,compositeFieldUsage:(0,W5e.mergeCompositeFieldUsage)(n.compositeFieldUsage,...i.map(s=>s.compositeFieldUsage)),value:{node:"filteredExpr",kids:{e:n.value,filterList:i}}}:(this.expr.logError("filter-of-non-aggregate",`Cannot filter '${n.expressionType}' data`),(0,U5e.errorFor)("cannot filter type"))}return n}getExpression(e){const n=[];let r;const i=[],s=[];for(const u of this.statements)u instanceof z5e.PartitionBy?this.expr.canSupportPartitionBy()?n.push(u):u.logError("partition-by-of-non-window-function","`partition_by` is not supported for this kind of expression"):u instanceof H5e.Limit?r?u.logError("expression-limit-already-specified","limit already specified"):this.expr.canSupportLimit()?r=u:u.logError("limit-of-non-aggregate-function","`limit` is not supported for this kind of expression"):u instanceof q5e.FunctionOrdering?this.expr.canSupportOrderBy()?i.push(u):u.logError("order-by-of-non-aggregate-function","`order_by` is not supported for this kind of expression"):s.push(u);const o=this.expr instanceof G5e.ExprFunc?this.expr.getPropsExpression(e,{partitionBys:n,limit:r,orderBys:i}):this.expr.getExpression(e);return this.getFilteredExpression(e,o,s)}}w_.ExprProps=V5e;var F_={},Y5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),K5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),J5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Y5e(e,t,n);return K5e(e,t),e};Object.defineProperty(F_,"__esModule",{value:!0}),F_.ExprLogicalOp=void 0;const X5e=zg,TG=J5e(Wt);class Z5e extends X5e.BinaryBoolean{constructor(){super(...arguments),this.elementType="logical operator",this.legalChildTypes=[TG.boolT,TG.aggregateBoolT]}}F_.ExprLogicalOp=Z5e;var L_={},e4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),t4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&e4e(e,t,n);return t4e(e,t),e};Object.defineProperty(L_,"__esModule",{value:!0}),L_.ExprMax=void 0;const I_=n4e(Wt),r4e=Ha;class i4e extends r4e.ExprAggregateFunction{constructor(e){super("max",e),this.legalChildTypes=[I_.numberT,I_.stringT,I_.dateT,I_.timestampT]}returns(e){return e}}L_.ExprMax=i4e;var B_={},s4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),o4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),u4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&s4e(e,t,n);return o4e(e,t),e};Object.defineProperty(B_,"__esModule",{value:!0}),B_.ExprMin=void 0;const $_=u4e(Wt),a4e=Ha;class l4e extends a4e.ExprAggregateFunction{constructor(e){super("min",e),this.legalChildTypes=[$_.numberT,$_.stringT,$_.dateT,$_.timestampT]}returns(e){return e}}B_.ExprMin=l4e;var k_={},c4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),f4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),x4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&c4e(e,t,n);return f4e(e,t),e};Object.defineProperty(k_,"__esModule",{value:!0}),k_.ExprMinus=void 0;const d4e=fs,RG=x4e(Wt),h4e=ct;class p4e extends h4e.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="unary minus",this.legalChildTypes=[RG.numberT]}getExpression(e){const n=this.expr.getExpression(e);return RG.typeIn(n,this.legalChildTypes)?{...n,type:"number",value:{node:"unary-",e:n.value}}:(0,d4e.errorFor)("negate requires number")}}k_.ExprMinus=p4e;var M_={};Object.defineProperty(M_,"__esModule",{value:!0}),M_.ExprMulDiv=void 0;const g4e=mh;class m4e extends g4e.BinaryNumeric{constructor(){super(...arguments),this.elementType="*/%"}}M_.ExprMulDiv=m4e;var P_={},Vg={};Object.defineProperty(Vg,"__esModule",{value:!0}),Vg.Unary=void 0;const y4e=ct;class E4e extends y4e.ExpressionDef{constructor(e){super({expr:e}),this.expr=e}}Vg.Unary=E4e;var A4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),v4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),_4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&A4e(e,t,n);return v4e(e,t),e};Object.defineProperty(P_,"__esModule",{value:!0}),P_.ExprNot=void 0;const E7=_4e(Wt),S4e=Vg;class C4e extends S4e.Unary{constructor(e){super(e),this.elementType="not",this.legalChildTypes=[E7.boolT,E7.nullT]}getExpression(e){var n;const r=this.expr.getExpression(e);!((n=e.dialectObj())===null||n===void 0)&&n.booleanAsNumbers&&this.legalChildTypes.find(s=>s.type==="number")===void 0&&this.legalChildTypes.push(E7.numberT);const i=this.typeCheck(this.expr,r);return{...r,type:"boolean",value:{node:"not",e:i?r.value:{node:"false"}}}}}P_.ExprNot=C4e;var U_={};Object.defineProperty(U_,"__esModule",{value:!0}),U_.ExprNow=void 0;const b4e=ct,T4e=at;class R4e extends b4e.ExpressionDef{constructor(){super(...arguments),this.elementType="timestamp"}getExpression(e){return{type:"timestamp",expressionType:"scalar",evalSpace:"constant",value:{node:"now"},compositeFieldUsage:(0,T4e.emptyCompositeFieldUsage)()}}}U_.ExprNow=R4e;var _0={};Object.defineProperty(_0,"__esModule",{value:!0}),_0.ExprIsNull=_0.PartialIsNull=_0.ExprNULL=void 0;const O4e=Pt,j_=ct;function A7(t,e,n){const r=n.getExpression(t);return r.type="boolean",r.value={node:e==="="?"is-null":"is-not-null",e:r.value},r}class D4e extends j_.ExpressionDef{constructor(){super(...arguments),this.elementType="NULL"}getExpression(){return(0,O4e.literalExprValue)({dataType:{type:"null"},value:{node:"null"}})}apply(e,n,r){return n==="!="||n==="="?A7(e,n,r):super.apply(e,n,r,!0)}}_0.ExprNULL=D4e;class w4e extends j_.ExpressionDef{constructor(e){super(),this.op=e,this.elementType="<=> NULL"}apply(e,n,r){return A7(e,this.op,r)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("partial-as-value","Partial null check does not have a value")}atNodeType(){return j_.ATNodeType.Partial}}_0.PartialIsNull=w4e;class N4e extends j_.ExpressionDef{constructor(e,n){super(),this.expr=e,this.op=n,this.elementType="is null",this.has({expr:e})}getExpression(e){return A7(e,this.op,this.expr)}}_0.ExprIsNull=N4e;var q_={};Object.defineProperty(q_,"__esModule",{value:!0}),q_.ExprNumber=void 0;const F4e=Pt,L4e=ct;class I4e extends L4e.ExpressionDef{constructor(e){super(),this.n=e,this.elementType="numeric literal"}getExpression(e){return this.constantExpression()}constantExpression(){const e=Number(this.n),n=Number.isNaN(e)?{type:"number"}:{type:"number",numberType:Number.isInteger(e)?"integer":"float"};return(0,F4e.literalExprValue)({dataType:n,value:{node:"numberLiteral",literal:this.n}})}}q_.ExprNumber=I4e;var H_={};Object.defineProperty(H_,"__esModule",{value:!0}),H_.ExprParens=void 0;const v7=ct;class B4e extends v7.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="(expression)"}requestExpression(e){return this.expr.requestExpression(e)}getExpression(e){const n=this.expr.getExpression(e);return{...n,value:{node:"()",e:n.value}}}apply(e,n,r,i){return this.expr.atNodeType()===v7.ATNodeType.Or?this.expr.apply(e,n,r,i):(0,v7.applyBinary)(e,r,n,this)}atNodeType(){return this.expr.atNodeType()}atExpr(){return this.expr}}H_.ExprParens=B4e;var z_={};Object.defineProperty(z_,"__esModule",{value:!0}),z_.ExprRegEx=void 0;const $4e=Pt,k4e=ct;class M4e extends k4e.ExpressionDef{constructor(e){super(),this.regex=e,this.elementType="regular expression literal"}getExpression(){return(0,$4e.literalExprValue)({dataType:{type:"regular expression"},value:{node:"regexpLiteral",literal:this.regex}})}}z_.ExprRegEx=M4e;var Q_={};Object.defineProperty(Q_,"__esModule",{value:!0}),Q_.ExprString=void 0;const P4e=ct,U4e=Pt;class j4e extends P4e.ExpressionDef{constructor(e){super(),this.elementType="string literal",this.value=e}getExpression(e){return(0,U4e.literalExprValue)({dataType:{type:"string"},value:{node:"stringLiteral",literal:this.value}})}}Q_.ExprString=j4e;var G_={};Object.defineProperty(G_,"__esModule",{value:!0}),G_.ExprSum=void 0;const q4e=Eh;class H4e extends q4e.ExprAsymmetric{constructor(e,n,r){super("sum",e,n,r),this.has({source:n})}}G_.ExprSum=H4e;var W_={};Object.defineProperty(W_,"__esModule",{value:!0}),W_.ExprTimeExtract=void 0;const za=Ke,V_=Pt,_7=ct,z4e=y0;class Yg extends _7.ExpressionDef{static extractor(e){const n=Yg.pluralMap[e];if(n)return n;if((0,za.isExtractUnit)(e))return e}constructor(e,n){super({args:n}),this.extractText=e,this.args=n,this.elementType="timeExtract"}getExpression(e){const n=Yg.extractor(this.extractText);if(n){if(this.args.length!==1)return this.loggedErrorExpr("too-many-arguments-for-time-extraction",`Extraction function ${n} requires one argument`);const r=this.args[0];if(r instanceof z4e.Range){let i=r.first.getExpression(e),s=r.last.getExpression(e);if(i.type==="error"||s.type==="error")return(0,V_.computedErrorExprValue)({dataType:{type:"number"},error:"extract from error",from:[i,s]});if(!(0,za.isTemporalType)(i.type))return r.first.loggedErrorExpr("invalid-type-for-time-extraction",`Can't extract ${n} from '${i.type}'`);if(!(0,za.isTemporalType)(s.type))return r.last.loggedErrorExpr("invalid-type-for-time-extraction",`Cannot extract ${n} from '${s.type}'`);let o=i.type;if(!za.TD.eq(i,s)){let u=!0;if(o="timestamp",i.type==="date"){const a=(0,_7.getMorphicValue)(i,"timestamp");a&&(i=a,u=!1)}else{const a=(0,_7.getMorphicValue)(s,"timestamp");a&&(s=a,u=!1)}if(u)return r.first.loggedErrorExpr("invalid-types-for-time-measurement",`Cannot measure from ${i.type} to ${s.type}`)}return["week","month","quarter","year"].includes(n)?this.loggedErrorExpr("invalid-timeframe-for-time-measurement",`Cannot measure interval using '${n}'`):(0,za.isTimestampUnit)(n)?(0,V_.computedExprValue)({dataType:{type:"number",numberType:"integer"},value:{node:"timeDiff",units:n,kids:{left:(0,za.mkTemporal)(i.value,o),right:(0,za.mkTemporal)(s.value,o)}},from:[i,s]}):this.loggedErrorExpr("invalid-time-extraction-unit",`Cannot extract ${n} from a range`)}else{const i=r.getExpression(e);return(0,za.isTemporalType)(i.type)?(0,V_.computedExprValue)({dataType:{type:"number",numberType:"integer"},value:{node:"extract",e:(0,za.mkTemporal)(i.value,i.type),units:n},from:[i]}):(i.type!=="error"&&this.logError("unsupported-type-for-time-extraction",`${this.extractText}() requires time type, not '${i.type}'`),(0,V_.computedErrorExprValue)({dataType:{type:"number",numberType:"integer"},error:`${this.extractText} bad type ${i.type}`,from:[i]}))}}throw this.internalError(`Illegal extraction unit '${this.extractText}'`)}}W_.ExprTimeExtract=Yg,Yg.pluralMap={years:"year",quarters:"quarter",months:"month",weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second"};var Y_={},No={},K_={};Object.defineProperty(K_,"__esModule",{value:!0}),K_.QueryInputSpace=void 0;const Q4e=Fi,G4e=Jd;class W4e extends G4e.RefinedSpace{constructor(e,n,r){super(e),this.queryOutput=n,this._isProtectedAccessSpace=r,this.extendList=[]}extendSource(e){this.pushFields(e),e instanceof Q4e.Join?this.extendList.push(e.name.refString):this.extendList.push(e.defineName)}isQueryFieldSpace(){return!0}outputSpace(){return this.queryOutput}inputSpace(){return this}isProtectedAccessSpace(){return this._isProtectedAccessSpace}}K_.QueryInputSpace=W4e;var V4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Y4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),K4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&V4e(e,t,n);return Y4e(e,t),e};Object.defineProperty(No,"__esModule",{value:!0}),No.ReduceFieldSpace=No.QuerySpace=No.QueryOperationSpace=void 0;const J_=K4e(Ke),S7=l0,OG=v0,DG=Sr,J4e=pt,X4e=Jd,Z4e=Eg,ebe=Cr,tbe=K_,wu=at,nbe=Ef;class wG extends X4e.RefinedSpace{get compositeFieldUsage(){if(this._compositeFieldUsage===void 0)throw new Error("Composite field usage accessed before computed");return this._compositeFieldUsage}constructor(e,n,r,i){super(e.emptyStructDef()),this.queryInputSpace=e,this.nestParent=r,this.astEl=i,this.expandedWild={},this.compositeFieldUsers=[],this._compositeFieldUsage=void 0,this.exprSpace=new tbe.QueryInputSpace(e.structDef(),this,e.isProtectedAccessSpace()),n&&this.addRefineFromFields(n)}logError(e,n,r){return this.astEl&&this.astEl.logError(e,n,r),e}inputSpace(){return this.exprSpace}outputSpace(){return this}addWild(e){var n;let r=this.exprSpace;const i=[];if(e.joinPath)for(const u of e.joinPath.list){const a=u.refString;i.push(a);const l=r.entry(a);if(l)if(l instanceof ebe.StructSpaceField)r=l.fieldSpace;else{u.logError("invalid-wildcard-source",`Field '${a}' does not contain rows and cannot be expanded with '*'`);return}else{u.logError("wildcard-source-not-defined",`No such field as '${a}'`);return}}const s=this.dialectObj(),o=[];for(const[u,a]of r.entries())if(!e.except.has(u)&&a.refType!=="parameter")if(this.entry(u)){const l=(n=this.expandedWild[u])===null||n===void 0?void 0:n.path.join(".");e.logError("name-conflict-in-wildcard-expansion",`Cannot expand '${u}' in '${e.refString}' because a field with that name already exists${l?` (conflicts with ${l})`:""}`)}else{const l=a.typeDesc();J_.TD.isAtomic(l)&&J_.expressionIsScalar(l.expressionType)&&(s===void 0||!s.ignoreInProject(u))&&(o.push({name:u,entry:a}),this.expandedWild[u]={path:i.concat(u),entry:a})}for(const u of o.sort((a,l)=>a.name.localeCompare(l.name)))this.newEntry(u.name,e,u.entry)}addValidatedCompositeFieldUserFromEntry(e,n){n instanceof DG.SpaceField&&this.compositeFieldUsers.push({type:"field",name:e,field:n,logTo:void 0})}getJoinOnCompositeFieldUsage(e){var n;const r=e.map(s=>new OG.FieldName(s));this.astEl.has({reference:r});const i=this.exprSpace.lookup(r);if(i.found&&i.found instanceof nbe.StructSpaceFieldBase)return(0,wu.joinedCompositeFieldUsage)(e.slice(0,-1),(n=i.found.fieldDef().onCompositeFieldUsage)!==null&&n!==void 0?n:(0,wu.emptyCompositeFieldUsage)());throw new Error("Unexpected join lookup was not found or not a struct")}getCompositeFieldUsageIncludingJoinOns(e){let n=e;const r=(0,wu.compositeFieldUsageJoinPaths)(e);for(const i of r)n=(0,wu.mergeCompositeFieldUsage)(this.getJoinOnCompositeFieldUsage(i),n);return n}addCompositeFieldUserFromFilter(e,n){e.compositeFieldUsage!==void 0&&this.compositeFieldUsers.push({type:"filter",filter:e,logTo:n})}newEntry(e,n,r){r instanceof DG.SpaceField&&this.compositeFieldUsers.push({type:"field",name:e,field:r,logTo:n}),super.newEntry(e,n,r)}applyNextCompositeFieldUsage(e,n,r,i,s){if(i){const o=this.getCompositeFieldUsageIncludingJoinOns((0,wu.compositeFieldUsageDifference)(i,n));if(n=(0,wu.mergeCompositeFieldUsage)(n,o),!(0,wu.isEmptyCompositeFieldUsage)(o)){const u=(0,wu.narrowCompositeFieldResolution)(e,n,r);u.error?(s??this).logError("invalid-composite-field-usage",{newUsage:o,allUsage:n}):r=u.narrowedCompositeFieldResolution}}return{compositeFieldUsage:n,narrowedCompositeFieldResolution:r}}}No.QueryOperationSpace=wG;class NG extends wG{addRefineFromFields(e){var n;if(J_.isQuerySegment(e)){if(e!=null&&e.extendSource)for(const r of e.extendSource)this.exprSpace.addFieldDef(r);for(const r of e.queryFields)if(r.type==="fieldref"){const i=this.exprSpace.lookup(r.path.map(s=>new OG.FieldName(s)));if(i.found){const s=r.path[r.path.length-1];this.setEntry(s,i.found),this.addValidatedCompositeFieldUserFromEntry(s,i.found)}}else if(r.type!=="turtle"){const i=new Z4e.ColumnSpaceField(r),s=(n=r.as)!==null&&n!==void 0?n:r.name;this.setEntry(s,i),this.addValidatedCompositeFieldUserFromEntry(s,i)}}}pushFields(...e){for(const n of e)n instanceof J4e.WildcardFieldReference?this.addWild(n):super.pushFields(n)}canContain(e){return!0}queryFieldDefs(){const e=[];let n=(0,wu.emptyCompositeFieldUsage)(),r=(0,wu.emptyNarrowedCompositeFieldResolution)();const i=this.inputSpace().structDef();for(const s of this.compositeFieldUsers){let o;if(s.type==="filter")s.filter.compositeFieldUsage&&(o=s.filter.compositeFieldUsage);else{const{name:a,field:l}=s,c=this.expandedWild[a];if(c)e.push({type:"fieldref",path:c.path}),o=c.entry.typeDesc().compositeFieldUsage;else{const f=l.getQueryFieldDef(this.exprSpace);if(f){const d=l.typeDesc();o=d.compositeFieldUsage,d&&d.type!=="error"&&this.canContain(d)&&!ibe(f)&&e.push(f)}}}const u=this.applyNextCompositeFieldUsage(i,n,r,o,s.logTo);n=u.compositeFieldUsage,r=u.narrowedCompositeFieldResolution}return this._compositeFieldUsage=n,e}getQuerySegment(e){const n=this.getPipeSegment(e);if(J_.isQuerySegment(n))return n;throw new Error("TODO NOT POSSIBLE")}getPipeSegment(e){if(this.segmentType==="index")return this.logError("unexpected-index-segment","internal error generating index segment from non index query"),{type:"reduce",queryFields:[]};const n={type:this.segmentType,queryFields:this.queryFieldDefs()};if(n.queryFields=(0,S7.mergeFields)(e==null?void 0:e.queryFields,n.queryFields),e!=null&&e.extendSource&&(n.extendSource=e.extendSource),this.exprSpace.extendList.length>0){const r=[],i=this.exprSpace.structDef();for(const s of this.exprSpace.extendList){const o=i.fields.find(u=>(0,S7.nameFromDef)(u)===s);o&&r.push(o)}n.extendSource=(0,S7.mergeFields)(n.extendSource,r)}return this.newTimezone&&(n.queryTimezone=this.newTimezone),n}lookup(e){const n=super.lookup(e);return n.found?{...n,isOutputField:!0}:this.exprSpace.lookup(e)}isQueryFieldSpace(){return!0}}No.QuerySpace=NG;class rbe extends NG{constructor(){super(...arguments),this.segmentType="reduce"}}No.ReduceFieldSpace=rbe;function ibe(t){return typeof t!="string"&&t.type==="turtle"&&t.pipeline.length===0}var sbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),obe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ube=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&sbe(e,t,n);return obe(e,t),e};Object.defineProperty(Y_,"__esModule",{value:!0}),Y_.ExprUngroup=void 0;const FG=Ke,abe=No,LG=ube(Wt),lbe=ct;class cbe extends lbe.ExpressionDef{constructor(e,n,r){super({expr:n,fields:r}),this.control=e,this.expr=n,this.fields=r,this.legalChildTypes=LG.anyAtomicT,this.elementType="ungroup"}getExpression(e){const n=this.expr.getExpression(e);if(!(0,FG.expressionIsAggregate)(n.expressionType))return this.expr.loggedErrorExpr("ungroup-of-non-aggregate",`${this.control}() expression must be an aggregate`);if((0,FG.expressionIsUngroupedAggregate)(n.expressionType))return this.expr.loggedErrorExpr("ungroup-of-ungrouped-aggregate",`${this.control}() expression must not already be ungrouped`);const r={node:this.control,e:n.value};if(this.typeCheck(this.expr,{...n,expressionType:"scalar"})){if(e.isQueryFieldSpace()&&this.fields.length>0){const i=[],s=this.control==="exclude";for(const o of this.fields){let u=e.outputSpace(),a=!0;for(;u;){const l=u.lookup([o]);if(l.found&&l.isOutputField)i.push(o.refString),a=!1;else if(u instanceof abe.QuerySpace){u=u.nestParent;continue}break}if(a){const l=s?"exclude()":"all()";o.logError("ungroup-field-not-in-output",`${l} '${o.refString}' is missing from query output`)}}r.fields=i}return{...LG.atomicDef(n),expressionType:"ungrouped_aggregate",value:r,evalSpace:"output",compositeFieldUsage:n.compositeFieldUsage}}return this.loggedErrorExpr("ungroup-with-non-scalar",`${this.control}() incompatible type`)}}Y_.ExprUngroup=cbe;var X_={},fbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),xbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dbe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&fbe(e,t,n);return xbe(e,t),e};Object.defineProperty(X_,"__esModule",{value:!0}),X_.ForRange=void 0;const hbe=fs,IG=dbe(Wt),Z_=Li,pbe=Pt,gbe=ct,eS=gh,BG=y0;class mbe extends gbe.ExpressionDef{constructor(e,n,r){super({from:e,duration:n,timeframe:r}),this.from=e,this.duration=n,this.timeframe=r,this.elementType="forRange",this.legalChildTypes=[IG.timestampT,IG.dateT]}apply(e,n,r){const i=this.from.getExpression(e),s=r.getExpression(e);if(!this.typeCheck(r,s))return(0,hbe.errorFor)("no time for range");const o=this.duration.getExpression(e);if(o.type!=="number")return o.type!=="error"&&this.logError("invalid-duration-quantity",`FOR duration count must be a number, not '${o.type}'`),(0,pbe.computedErrorExprValue)({dataType:{type:"boolean"},error:"for not number",from:[i,s]});const u=this.timeframe.text;let a=(0,Z_.resolution)(u);if(i.type==="timestamp"&&(a="timestamp"),s.type==="date"&&a==="date"){const p=this.from,m=(0,Z_.timeOffset)("date",i.value,"+",o.value,u),g=new eS.ExprTime("date",m);return new BG.Range(p,g).apply(e,n,r)}const l=eS.ExprTime.fromValue("timestamp",s);let c=this.from,f=i.value;if(i.type==="date"){const p=i.morphic&&i.morphic.timestamp;p?f=p:f=(0,Z_.castTo)("timestamp",f,"date"),c=new eS.ExprTime("timestamp",f,[i])}const d=(0,Z_.timeOffset)("timestamp",f,"+",o.value,u),h=new eS.ExprTime("timestamp",d,[i,o]);return new BG.Range(c,h).apply(e,n,l)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("range-as-value","A Range is not a value")}}X_.ForRange=mbe;var nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.LiteralYear=nr.LiteralQuarter=nr.LiteralMonth=nr.LiteralWeek=nr.LiteralDay=nr.LiteralHour=nr.LiteralTimestamp=nr.TimeFormatError=void 0;const S0=ri,ybe=Ke,Ebe=Pt,Abe=y0,$G=gh,C7=ct;class vbe extends Error{}nr.TimeFormatError=vbe;function Of(t,e){const n=t.slice(1);if(e){const r=n.match(/\[[^\]]+]$/);if(r)return{tzSpec:r[0].slice(1,-1),text:n.slice(0,-r[0].length)}}return{text:n}}const kG="yyyy",MG=`${kG}-LL`,qs=`${MG}-dd`,PG=`${qs} HH`,UG=`${PG}:mm`,b7=`${UG}:ss`;class jG extends C7.ExpressionDef{constructor(e,n,r){super(),this.units=n,this.timeType=r,this.literalPart=e.text,e.tzSpec&&(this.timeZone=e.tzSpec)}makeLiteral(e,n){const r={node:"timeLiteral",literal:e,typeDef:{type:n}};return this.timeZone&&(r.timezone=this.timeZone),r}makeValue(e,n){const r=this.makeLiteral(e,n);return(0,Ebe.literalTimeResult)({value:r,dataType:{type:n},timeframe:this.units})}getExpression(e){return this.makeValue(this.literalPart,this.timeType)}getNext(){if(this.nextLit)return this.makeValue(this.nextLit,this.timeType)}granular(){return this.nextLit!==void 0}}class T7 extends jG{constructor(e,n){super(e,n,"timestamp"),this.elementType="literal:timestamp"}static parse(e){let n;const r=Of(e,!0);e=r.text,e[10]==="T"&&(e=e.slice(0,10)+" "+e.slice(11),r.text=e);const i=e.match(/^([^.,]+)[,.](\d+)$/);i&&(e=i[1]);let s=S0.DateTime.fromFormat(e,b7);if(s.isValid)return new T7(r,n);if(s=S0.DateTime.fromFormat(e,UG),s.isValid){r.text=r.text+":00",n="minute";const o=s.plus({minute:1}).toFormat(b7);return new R7(r,n,"timestamp",o)}}}nr.LiteralTimestamp=T7;class R7 extends jG{constructor(e,n,r,i){super(e,n,r),this.nextLit=i,this.elementType="granularTimeLiteral"}apply(e,n,r){let i=this.getExpression(e),s=this.getNext();if(s){const o=r.getExpression(e);if(o.type==="timestamp"){const u=(0,C7.getMorphicValue)(i,"timestamp"),a=(0,C7.getMorphicValue)(s,"timestamp");if(u&&a)i=u,s=a;else return super.apply(e,n,r)}if(s&&(0,ybe.isTemporalType)(o.type)){const u=o.type;return new Abe.Range(new $G.ExprTime(u,i.value),new $G.ExprTime(u,s.value)).apply(e,n,r)}}return super.apply(e,n,r)}}class O7 extends R7{constructor(e,n){super(e,"hour","timestamp",n),this.elementType="literal:hour"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,PG);if(i.isValid)return n.text=n.text+":00:00",r=i.plus({hour:1}).toFormat(b7),new O7(n,r)}}nr.LiteralHour=O7;class Kg extends R7{constructor(e,n,r){super(e,n,"date",r)}getExpression(e){const n=this.makeValue(this.literalPart,"date"),r=this.makeLiteral(`${this.literalPart} 00:00:00`,"timestamp");return{...n,morphic:{timestamp:r},evalSpace:"literal"}}getNext(){const e=this.makeValue(this.nextLit,"date"),n=this.makeLiteral(`${this.nextLit} 00:00:00`,"timestamp");return{...e,morphic:{timestamp:n}}}}class D7 extends Kg{constructor(e,n){super(e,"day",n),this.elementType="literal:day"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,qs);if(i.isValid)return r=i.plus({day:1}).toFormat(qs),new D7(n,r)}}nr.LiteralDay=D7;class w7 extends Kg{constructor(e,n){super(e,"week",n),this.elementType="literal:week"}static parse(e){const n=Of(e,!1);let r=n.text;const i=n.text.slice(0,10),s=S0.DateTime.fromFormat(i,qs);if(s.isValid&&s.weekday===7){const u=s.plus({days:7});return n.text=s.toFormat(qs),r=u.toFormat(qs),new w7(n,r)}}}nr.LiteralWeek=w7;class N7 extends Kg{constructor(e,n){super(e,"month",n),this.elementType="literal:month"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,MG);if(i.isValid){const s=i.plus({months:1});return n.text=i.toFormat(qs),r=s.toFormat(qs),new N7(n,r)}}}nr.LiteralMonth=N7;class F7 extends Kg{constructor(e,n){super(e,"quarter",n),this.elementType="literal:quarter"}static parse(e){const n=Of(e,!1);let r=n.text;const i=n.text.match(/(^\d{4})-[qQ](\d)$/);if(i){const s=Number.parseInt(i[2])-1;let o=S0.DateTime.fromFormat(i[1],"yyyy");s>0&&(o=o.plus({quarters:s}));const u=o.plus({quarter:1});return n.text=o.toFormat(qs),r=u.toFormat(qs),new F7(n,r)}}}nr.LiteralQuarter=F7;class L7 extends Kg{constructor(e,n){super(e,"year",n),this.elementType="literal:year"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,kG);if(i.isValid){const s=i.plus({year:1});return n.text=i.toFormat(qs),r=s.toFormat(qs),new L7(n,r)}}}nr.LiteralYear=L7;var tS={};Object.defineProperty(tS,"__esModule",{value:!0}),tS.PartialCompare=void 0;const qG=ct;class _be extends qG.ExpressionDef{constructor(e,n){super({right:n}),this.op=e,this.right=n,this.elementType="<=> a"}granular(){return this.right.granular()}apply(e,n,r){return this.right.apply(e,this.op,r)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("partial-as-value","Partial comparison does not have a value")}atNodeType(){return qG.ATNodeType.Partial}}tS.PartialCompare=_be;var _h={},Sbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Cbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),bbe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Sbe(e,t,n);return Cbe(e,t),e};Object.defineProperty(_h,"__esModule",{value:!0}),_h.PickWhen=_h.Pick=void 0;const Sh=bbe(Wt),HG=Pt,Tbe=ct,Rbe=Ye;function nS(t,e){return t===void 0||t.type==="null"||t.type==="error"?e:t}class Obe extends Tbe.ExpressionDef{constructor(e,n){super({choices:e}),this.choices=e,this.elsePick=n,this.elementType="pick",this.has({elsePick:n})}requestExpression(e){if(this.elsePick!==void 0){for(const n of this.choices){if(n.pick===void 0)return;const r=n.when.requestExpression(e);if(r===void 0||r.type!=="boolean")return}return this.getExpression(e)}}apply(e,n,r){var i;const s={node:"case",kids:{caseWhen:[],caseThen:[]}};let o;const u=[];for(const d of this.choices){const h=d.when.apply(e,"=",r),p=d.pick?d.pick.getExpression(e):r.getExpression(e);if(u.push(h,p),o&&!Sh.typeEq(o,p,!0))return this.loggedErrorExpr("pick-type-does-not-match",{pickType:p.type,returnType:o.type});o=nS(o,p),s.kids.caseWhen.push(h.value),s.kids.caseThen.push(p.value)}const a=(i=this.elsePick)===null||i===void 0?void 0:i.getExpression(e),l=r.getExpression(e);u.push(l),a&&u.push(a);const c=a??l,f=nS(o,c);return Sh.typeEq(f,c,!0)?(s.kids.caseElse=c.value,(0,HG.computedExprValue)({dataType:f,value:s,from:u})):this.elsePick?this.loggedErrorExpr("pick-else-type-does-not-match",{elseType:c.type,returnType:f.type}):this.loggedErrorExpr("pick-default-type-does-not-match",{defaultType:c.type,returnType:f.type})}getExpression(e){const n={node:"case",kids:{caseWhen:[],caseThen:[]}};if(this.elsePick===void 0)return this.loggedErrorExpr("pick-missing-else","pick incomplete, missing 'else'");const r=[],i=[];for(const a of this.choices){if(a.pick===void 0)return this.loggedErrorExpr("pick-missing-value","pick with no value can only be used with apply");a.when.requestExpression(e)===void 0&&this.loggedErrorExpr("pick-illegal-partial","pick with partial when can only be used with apply");const c=a.pick.getExpression(e),f=a.when.getExpression(e);r.push({pick:c,when:f}),i.push(c,f)}let s;for(const a of r){if(!Sh.typeEq(a.when,Sh.boolT))return this.loggedErrorExpr("pick-when-must-be-boolean",{whenType:a.when.type});if(s&&!Sh.typeEq(s,a.pick,!0))return this.loggedErrorExpr("pick-type-does-not-match",{pickType:a.pick.type,returnType:s.type});s=nS(s,a.pick),n.kids.caseWhen.push(a.when.value),n.kids.caseThen.push(a.pick.value)}const o=this.elsePick.getExpression(e);i.push(o);const u=nS(s,o);return Sh.typeEq(u,o,!0)?(n.kids.caseElse=o.value,(0,HG.computedExprValue)({dataType:u,value:n,from:i})):this.elsePick.loggedErrorExpr("pick-else-type-does-not-match",{elseType:o.type,returnType:u.type})}}_h.Pick=Obe;class Dbe extends Rbe.MalloyElement{constructor(e,n){super({when:n}),this.pick=e,this.when=n,this.elementType="caseWhen",this.has({pick:e})}}_h.PickWhen=Dbe;var Ch={},wbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Nbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Fbe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&wbe(e,t,n);return Nbe(e,t),e};Object.defineProperty(Ch,"__esModule",{value:!0}),Ch.CaseWhen=Ch.Case=void 0;const Lbe=Pt,Ibe=ct,Bbe=Ye,bh=Fbe(Wt);function zG(t,e){return t===void 0||t.type==="null"||t.type==="error"?e:t}class $be extends Ibe.ExpressionDef{constructor(e,n,r){super({choices:n}),this.value=e,this.choices=n,this.elseValue=r,this.elementType="case",this.has({elseValue:r,value:e})}getExpression(e){const n={node:"case",kids:{caseWhen:[],caseThen:[]}},r=[];let i;if(this.value){const u=this.value.getExpression(e);r.push(u),n.kids.caseValue=u.value,i=u}const s=[];for(const u of this.choices){const a=u.when.getExpression(e),l=u.then.getExpression(e);s.push({when:a,then:l}),r.push(a,l)}let o;for(const u of s){if(i!==void 0){if(!bh.typeEq(u.when,i))return this.loggedErrorExpr("case-when-type-does-not-match",{whenType:u.when.type,valueType:i.type})}else if(!bh.typeEq(u.when,bh.boolT))return this.loggedErrorExpr("case-when-must-be-boolean",{whenType:u.when.type});if(o&&!bh.typeEq(o,u.then,!0))return this.loggedErrorExpr("case-then-type-does-not-match",{thenType:u.then.type,returnType:o.type});o=zG(o,u.then),n.kids.caseWhen.push(u.when.value),n.kids.caseThen.push(u.then.value)}if(this.elseValue){const u=this.elseValue.getExpression(e);if(o&&!bh.typeEq(o,u,!0))return this.loggedErrorExpr("case-else-type-does-not-match",{elseType:u.type,returnType:o.type});o=zG(o,u),r.push(u),n.kids.caseElse=u.value}return(0,Lbe.computedExprValue)({value:n,dataType:o?bh.atomicDef(o):{type:"null"},from:r})}}Ch.Case=$be;class kbe extends Bbe.MalloyElement{constructor(e,n){super({when:e,then:n}),this.when=e,this.then=n,this.elementType="caseWhen"}}Ch.CaseWhen=kbe;var rS={},Df={},Mbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Pbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ube=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Mbe(e,t,n);return Pbe(e,t),e};Object.defineProperty(Df,"__esModule",{value:!0}),Df.RecordLiteral=Df.RecordElement=void 0;const QG=ts,jbe=Pt,qbe=ct,Hbe=Ye,zbe=Ube(Wt);class Qbe extends Hbe.MalloyElement{constructor(e){if(super(),this.elementType="record element","value"in e)this.value=e.value,this.has({value:e.value}),e.key&&(this.key=e.key);else{this.has({path:e.path}),this.value=e.path;const n=e.path.fieldReference.path;this.key=n[n.length-1]}}}Df.RecordElement=Qbe;class Gbe extends qbe.ExpressionDef{constructor(e){super(),this.pairs=e,this.elementType="record literal",this.has({pairs:e})}getExpression(e){return this.getRecord(e,[])}getRecord(e,n){var r;const i={node:"recordLiteral",kids:{},typeDef:{type:"record",fields:[]}},s=[];let o=0;for(const u of this.pairs){const a=(r=u.key)!==null&&r!==void 0?r:n[o];if(o+=1,a===void 0){u.logError("record-literal-needs-keys","Anonymous record element not legal here");continue}const l=u.value.getExpression(e);QG.TD.isAtomic(l)?(s.push(l),i.kids[a]=l.value,i.typeDef.fields.push((0,QG.mkFieldDef)(zbe.atomicDef(l),a))):u.value.logError("illegal-record-property-type",`Record property '${u.key} is type '${l.type}', which is not a legal property value type`)}return(0,jbe.computedExprValue)({value:i,dataType:i.typeDef,from:s})}getNextElement(e,n){const r=n.value;return r.node==="recordLiteral"?this.getRecord(e,Object.keys(r.kids)):this.getRecord(e,[])}}Df.RecordLiteral=Gbe;var Wbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Vbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ybe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Wbe(e,t,n);return Vbe(e,t),e};Object.defineProperty(rS,"__esModule",{value:!0}),rS.ArrayLiteral=void 0;const Kbe=Pt,Jbe=ct,GG=Ybe(Wt),Xbe=Df;class Zbe extends Jbe.ExpressionDef{constructor(e){super(),this.elements=e,this.elementType="array literal",this.has({elements:e})}getExpression(e){const n=[],r=[];let i;if(this.elements.length>0)for(const a of this.elements){const l=i&&a instanceof Xbe.RecordLiteral?a.getNextElement(e,i):a.getExpression(e);if(r.push(l),l.type!=="error"){if(i){if(l.type!=="null"&&!GG.typeEq(i,l)){a.logError("array-values-incompatible","All array elements must be same type");continue}}else l.type!=="null"&&(i=l);n.push(l.value)}}const s=GG.atomicDef(i||{type:"number"}),o=s.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:s.fields}:{type:"array",elementTypeDef:s},u={node:"arrayLiteral",kids:{values:n},typeDef:o};return(0,Kbe.computedExprValue)({dataType:o,value:u,from:r})}}rS.ArrayLiteral=Zbe;var iS={};Object.defineProperty(iS,"__esModule",{value:!0}),iS.Timeframe=void 0;const eTe=Ke,tTe=Ye;class nTe extends tTe.MalloyElement{constructor(e){super(),this.elementType="timeframe";let n=e.toLowerCase();n.endsWith("s")&&(n=n.slice(0,-1)),this.text=(0,eTe.isTimestampUnit)(n)?n:"second"}}iS.Timeframe=nTe;var C0={};Object.defineProperty(C0,"__esModule",{value:!0}),C0.ImportStatement=C0.ImportSelect=C0.ImportSourceName=void 0;const I7=Ye;class rTe extends I7.MalloyElement{constructor(e){super(),this.text=e,this.elementType="importSourceName"}}C0.ImportSourceName=rTe;class iTe extends I7.MalloyElement{constructor(e,n){super(),this.text=e,this.from=n,this.elementType="importName",n&&this.has({from:n})}}C0.ImportSelect=iTe;class sTe extends I7.ListOf{constructor(e,n){super([]),this.url=e,this.elementType="import statement";try{this.fullURL=decodeURI(new URL(e,n).toString())}catch{this.logError("invalid-import-url","Invalid URL in import statement")}}needs(){const e=this.translator();if(e&&this.fullURL&&e.root.importZone.getEntry(this.fullURL).status==="present"){const r=e.childRequest(this.fullURL);if(r)return r}}execute(e){const n=this.translator();if(!n)this.logError("no-translator-for-import","Cannot import without translation context");else if(this.fullURL){const r=n.root.pretranslatedModels.get(this.fullURL),i=n.root.importZone.getEntry(this.fullURL);if(r||i.status==="present"){const s=n.getChildExports(this.fullURL);if(this.notEmpty())for(const o of this.list){const u=o.from||o;if(e.getEntry(o.text))o.logError("name-conflict-on-selective-import",`Cannot redefine '${o.text}'`);else if(s[u.text]){const a={...s[u.text]};o.from&&(a.as=o.text),e.setEntry(o.text,{entry:a,exported:!1})}else u.logError("selective-import-not-found",`Cannot find '${u.text}', not imported`)}else for(const[o,u]of Object.entries(n.getChildExports(this.fullURL)))e.getEntry(o)?this.logError("name-conflict-on-indiscriminate-import",`Cannot redefine '${o}'`):e.setEntry(o,{entry:u,exported:!1})}else i.status==="error"?this.logError("failed-import",`import failed: '${i.message}'`):this.logError("failed-import",`import failed with status: '${i.status}'`)}}}C0.ImportStatement=sTe;var Jg={};Object.defineProperty(Jg,"__esModule",{value:!0}),Jg.ExtendBlock=void 0;const oTe=Ye,uTe=wn;class aTe extends oTe.ListOf{constructor(){super(...arguments),this.elementType="extendBlock",this.forceQueryClass=void 0,this.queryRefinementStage=uTe.LegalRefinementStage.Single}queryExecute(e){for(const n of this.list)for(const r of n.list)e.inputFS.extendSource(r)}}Jg.ExtendBlock=aTe;var sS={};Object.defineProperty(sS,"__esModule",{value:!0}),sS.Argument=void 0;const lTe=Ye;class cTe extends lTe.MalloyElement{constructor(e){super({...e}),this.elementType="Argument",this.id=e.id,this.value=e.value}}sS.Argument=cTe;var oS={};Object.defineProperty(oS,"__esModule",{value:!0}),oS.HasParameter=void 0;const WG=Ke,fTe=Ye;class xTe extends fTe.MalloyElement{constructor(e){super(),this.elementType="hasParameter",this.name=e.name,e.type&&(0,WG.isCastType)(e.type)&&(this.type=e.type),e.default&&(this.default=e.default,this.has({default:this.default}))}parameter(){var e;if(this.default!==void 0){const n=this.default.constantValue();return this.type&&this.type!==n.type&&n.type!=="null"&&n.type!=="error"&&this.default.logError("parameter-default-does-not-match-declared-type",`Default value for parameter does not match declared type \`${this.type}\``),n.type==="null"?this.type?{type:this.type,value:n.value,name:this.name}:(this.default.logError("parameter-null-default-without-declared-type","Default value cannot have type `null` unless parameter type is also specified"),{value:n.value,name:this.name,type:"error"}):!(0,WG.isCastType)(n.type)&&n.type!=="error"?(this.default.logError("parameter-illegal-default-type",`Default value cannot have type \`${n.type}\``),{value:n.value,name:this.name,type:"error"}):{value:n.value,name:this.name,type:n.type}}return this.type===void 0&&this.logError("parameter-missing-default-or-type","Parameter must have default value or declared type"),{value:null,name:this.name,type:(e=this.type)!==null&&e!==void 0?e:"error"}}}oS.HasParameter=xTe;var uS={};Object.defineProperty(uS,"__esModule",{value:!0}),uS.AnonymousQuery=void 0;const dTe=Ye,hTe=_r;class pTe extends dTe.MalloyElement{constructor(e){super(),this.queryExpr=e,this.elementType="anonymousQuery",this.isNoteableObj=!0,this.extendNote=hTe.extendNoteMethod,this.has({queryExpr:e})}execute(e){const n=this.queryExpr.getQuery();if(!n){this.queryExpr.sqLog("non-query-used-as-query","Cannot run this object as a query");return}const r={...n.query()},i=this.note||{};r.annotation&&(i.inherits=r.annotation),(i.notes||i.blockNotes||i.inherits)&&(r.annotation=i),e.queryList.push(r)}}uS.AnonymousQuery=pTe;var b0={};Object.defineProperty(b0,"__esModule",{value:!0}),b0.View=void 0;const gTe=Ye;let mTe=class extends gTe.MalloyElement{pipeline(e,n){return this.pipelineComp(e,n).pipeline}};b0.View=mTe;var aS={};Object.defineProperty(aS,"__esModule",{value:!0}),aS.ViewArrow=void 0;const yTe=Cr,ETe=b0;class ATe extends ETe.View{constructor(e,n){super({base:e,operation:n}),this.base=e,this.operation=n,this.elementType="viewArrow"}pipelineComp(e){const n=this.base.pipelineComp(e),r=new yTe.StaticSourceSpace(n.outputStruct),i=this.operation.pipelineComp(r);return{pipeline:[...n.pipeline,...i.pipeline],outputStruct:i.outputStruct}}refine(e,n,r){return this.logError("refinement-with-multistage-view","A multi-segment view cannot be used as a refinement"),[]}getImplicitName(){return this.operation.getImplicitName()}}aS.ViewArrow=ATe;var lS={},Xg={};Object.defineProperty(Xg,"__esModule",{value:!0}),Xg.refine=void 0;const B7=ts,vTe=at,$7=l0;function _Te(t,e,n){var r,i;if(e.length!==1)return t.logError("refinement-with-multistage-view","Named refinements of multi-stage views are not supported"),e;const s={...e[0]},o=n;if((0,B7.isRawSegment)(s))t.logError("refinement-of-raw-query","Cannot refine raw query, must add an explicit query stage");else if(s.type==="partial"&&o.type!=="index"&&o.type!=="raw"?s.type=o.type:o.type!==s.type&&t.logError("mismatched-view-types-for-refinement",`cannot refine ${s.type} view with ${o.type} view`),o.type!=="index"&&s.type!=="index"&&o.type!=="raw"&&(o.orderBy!==void 0&&!o.defaultOrderBy&&(s.orderBy===void 0||s.defaultOrderBy?s.orderBy=o.orderBy:t.logError("ordering-overridden-in-refinement","refinement cannot override existing ordering")),o.limit!==void 0&&(s.limit===void 0?s.limit=o.limit:t.logError("limit-overridden-in-refinement","refinement cannot override existing limit"))),s.filterList=s.filterList!==void 0||o.filterList!==void 0?[...(r=s.filterList)!==null&&r!==void 0?r:[],...(i=o.filterList)!==null&&i!==void 0?i:[]]:void 0,(0,B7.isQuerySegment)(o)&&(0,B7.isQuerySegment)(s)){const u=[],a=[],l=new Map(s.queryFields.map(c=>[(0,$7.nameFromDef)(c),c]));for(const c of o.queryFields)l.has((0,$7.nameFromDef)(c))?u.push(c):a.push(c);s.queryFields=[...s.queryFields,...a],u.length>0&&t.logError("name-conflict-in-refinement",`overlapping fields in refinement: ${u.map($7.nameFromDef)}`),s.compositeFieldUsage=(0,vTe.mergeCompositeFieldUsage)(s.compositeFieldUsage,o.compositeFieldUsage)}else o.type==="index"&&s.type==="index"&&(s.indexFields=[...o.indexFields,...s.indexFields]);return[s]}Xg.refine=_Te,Object.defineProperty(lS,"__esModule",{value:!0}),lS.ViewRefine=void 0;const STe=Ur,CTe=hs,bTe=Xg,TTe=b0;class RTe extends TTe.View{constructor(e,n){super({base:e,refinement:n}),this.base=e,this.refinement=n,this.elementType="refine"}pipelineComp(e,n){const r=this.base.pipelineComp(e),i=this.refinement.refine(e,r.pipeline,n);return{pipeline:i,annotation:r.annotation,outputStruct:i.length>0?(0,CTe.getFinalStruct)(this.refinement,e.structDef(),i):STe.ErrorFactory.structDef}}refine(e,n,r){const i=this.pipeline(e,r);return i.length!==1?(this.refinement.logError("refinement-with-multistage-view","refinement must have exactly one stage"),n):(0,bTe.refine)(this,n,i[0])}getImplicitName(){return this.base.getImplicitName()}}lS.ViewRefine=RTe;var cS={};Object.defineProperty(cS,"__esModule",{value:!0}),cS.ReferenceView=void 0;const k7=Ke,VG=Ur,OTe=hs,DTe=Sr,wTe=Xg,NTe=b0;class FTe extends NTe.View{constructor(e){super({reference:e}),this.reference=e,this.elementType="reference-view"}pipelineComp(e,n){return this._pipelineComp(e)}_pipelineComp(e,{forRefinement:n}={forRefinement:!1}){const r=this.reference.getField(e),i=function(){return{inputStruct:VG.ErrorFactory.structDef,outputStruct:VG.ErrorFactory.structDef,pipeline:[],error:!0}};if(!r.found)return this.reference.logError(r.error.code,r.error.message),i();if(!(r.found instanceof DTe.SpaceField))throw new Error("Expected space field");const s=r.found.fieldDef();if(s===void 0)throw new Error("Expected field to have definition");if((0,k7.isAtomic)(s)){const o={type:"reduce",queryFields:[this.reference.refToField],compositeFieldUsage:s.compositeFieldUsage},u=this.reference.nameString,a={...(0,k7.sourceBase)(e.structDef()),type:"query_result",name:u,fields:[s]};return{pipeline:[o],name:u,outputStruct:a}}else return(0,k7.isTurtle)(s)?this.reference.list.length>1?(n?this.logError("refinement-with-joined-view","Cannot use view from join as refinement"):this.logError("nest-of-joined-view","Cannot use view from join"),i()):{pipeline:[...s.pipeline],name:s.name,annotation:s.annotation,outputStruct:(0,OTe.getFinalStruct)(this.reference,e.structDef(),s.pipeline)}:(n?this.reference.logError("refinement-with-source",`named refinement \`${this.reference.refString}\` must be a view, found a ${s.type}`):this.reference.logError("nest-of-source","This operation is not supported"),i())}getRefinementSegment(e){const{pipeline:n,error:r}=this._pipelineComp(e,{forRefinement:!0});if(!r){if(n.length!==1){this.reference.logError("refinement-with-multistage-view",`named refinement \`${this.reference.refString}\` must have exactly one stage`);return}return n[0]}}refine(e,n,r){const i=this.getRefinementSegment(e);return i?(0,wTe.refine)(this,n,i):n}getImplicitName(){return this.reference.nameString}}cS.ReferenceView=FTe;var fS={},Zg={},xS={},em={};Object.defineProperty(em,"__esModule",{value:!0}),em.Index=void 0;const LTe=Ye,ITe=wn;let BTe=class extends LTe.MalloyElement{constructor(e){super({fields:e}),this.fields=e,this.elementType="index",this.forceQueryClass=ITe.QueryClass.Index,this.queryRefinementStage=void 0}useWeight(e){this.has({weightBy:e}),this.weightBy=e}};em.Index=BTe;var tm={};Object.defineProperty(tm,"__esModule",{value:!0}),tm.SampleProperty=void 0;const $Te=Ye,YG=wn;class kTe extends $Te.MalloyElement{constructor(e){super(),this.sample=e,this.elementType="sampleProperty",this.queryRefinementStage=YG.LegalRefinementStage.Tail,this.forceQueryClass=YG.QueryClass.Index}sampling(){return this.sample}}tm.SampleProperty=kTe;var dS={};Object.defineProperty(dS,"__esModule",{value:!0}),dS.IndexFieldSpace=void 0;const KG=at,JG=Ke,M7=pt,MTe=Sr,PTe=No,UTe=Ig,jTe=Cr;class qTe extends PTe.QueryOperationSpace{constructor(){super(...arguments),this.segmentType="index"}pushFields(...e){for(const n of e)n instanceof M7.FieldReference?super.pushFields(n):n instanceof M7.WildcardFieldReference?this.addWild(n):n.logError("invalid-field-in-index-query","Internal error, not expected in index query")}getPipeSegment(e){if(e)return this.logError("refinement-of-index-segment","index query operations cannot be refined"),{type:"index",indexFields:[]};let n=(0,KG.emptyCompositeFieldUsage)(),r=(0,KG.emptyNarrowedCompositeFieldResolution)();const i=[],s=this.inputSpace().structDef();for(const[o,u]of this.entries())if(u instanceof MTe.SpaceField){let a,l;const c=this.expandedWild[o];if(c)i.push({type:"fieldref",path:c.path}),a=c.entry.typeDesc().compositeFieldUsage;else if(u instanceof UTe.ReferenceField){const d=u.fieldRef,h=d.getField(this.exprSpace);h.error?d.logError(h.error.code,h.error.message):(i.push(d.refToField),a=h.found.typeDesc().compositeFieldUsage,l=d)}const f=this.applyNextCompositeFieldUsage(s,n,r,a,l);n=f.compositeFieldUsage,r=f.narrowedCompositeFieldResolution}return this._compositeFieldUsage=n,{type:"index",indexFields:i}}addRefineFromFields(e){}addWild(e){var n;let r=this.exprSpace;const i=[];if(e.joinPath)for(const u of e.joinPath.list){const a=u.refString;i.push(a);const l=r.entry(a);if(l)if(l instanceof jTe.StructSpaceField)r=l.fieldSpace;else{u.logError("invalid-wildcard-source",`Field '${a}' does not contain rows and cannot be expanded with '*'`);return}else{u.logError("wildcard-source-not-found",`No such field as '${a}'`);return}}const s=this.dialectObj(),o=[];for(const[u,a]of r.entries()){if(e.except.has(u)||a.refType==="parameter")continue;const l=M7.IndexFieldReference.indexOutputName([...i,u]);if(this.entry(l)){const c=(n=this.expandedWild[l].path)===null||n===void 0?void 0:n.join(".");e.logError("name-conflict-in-wildcard-expansion",`Cannot expand '${u}' in '${e.refString}' because a field with that name already exists${c?` (conflicts with ${c})`:""}`)}else{const c=a.typeDesc();JG.TD.isLeafAtomic(c)&&(0,JG.expressionIsScalar)(c.expressionType)&&(s===void 0||!s.ignoreInProject(u))&&(o.push({name:l,entry:a}),this.expandedWild[l]={path:i.concat(u),entry:a})}}for(const u of o.sort((a,l)=>a.name.localeCompare(l.name)))this.setEntry(u.name,u.entry)}}dS.IndexFieldSpace=qTe,Object.defineProperty(xS,"__esModule",{value:!0}),xS.IndexBuilder=void 0;const P7=Ke,HTe=Ur,zTe=Ou,QTe=em,GTe=A0,WTe=tm,VTe=dS,U7=at;class YTe{constructor(e,n,r,i){this.filters=[],this.alwaysJoins=[],this.type="index",this.resultFS=new VTe.IndexFieldSpace(e,n,r,i),this.inputFS=this.resultFS.inputSpace()}execute(e){e instanceof zTe.Filter?e.queryExecute(this):e instanceof GTe.Limit?(this.limit&&this.limit.logError("index-limit-already-specified","Ignored, too many limit: statements"),this.limit=e):e instanceof QTe.Index?(this.resultFS.pushFields(...e.fields.list),e.weightBy&&(this.indexOn&&this.indexOn.logError("index-by-already-specified","Ignoring previous BY"),this.indexOn=e.weightBy)):e instanceof WTe.SampleProperty?this.sample=e.sampling():e.logError("illegal-operation-for-index","Not legal in an index query operation")}get compositeFieldUsage(){return this.resultFS.compositeFieldUsage}finalize(e){var n;if(e&&!(0,P7.isIndexSegment)(e)&&!(0,P7.isPartialSegment)(e))return this.resultFS.logError("refinement-of-index-segment",`Can't refine index with ${e.type}`),HTe.ErrorFactory.indexSegment;const r=this.resultFS.getPipeSegment(e),i=(e==null?void 0:e.filterList)||[];this.filters.length>0&&!i?r.filterList=this.filters:i&&(r.filterList=[...i,...this.filters]),e!=null&&e.limit&&(r.limit=e.limit),this.limit&&(r.limit=this.limit.limit),this.indexOn&&(r.weightMeasure=this.indexOn.refString),e&&(0,P7.isIndexSegment)(e)&&(e!=null&&e.sample)&&(r.sample=e.sample),this.sample&&(r.sample=this.sample),this.alwaysJoins.length>0&&(r.alwaysJoins=[...this.alwaysJoins]);const s=e&&e.type==="index"&&(n=e.compositeFieldUsage)!==null&&n!==void 0?n:(0,U7.emptyCompositeFieldUsage)();return r.compositeFieldUsage=(0,U7.mergeCompositeFieldUsage)(s,this.compositeFieldUsage),r}}xS.IndexBuilder=YTe;var hS={},nm={};Object.defineProperty(nm,"__esModule",{value:!0}),nm.GroupBy=void 0;const KTe=xs,XG=wn;class JTe extends KTe.DefinitionList{constructor(){super(...arguments),this.elementType="groupBy",this.queryRefinementStage=XG.LegalRefinementStage.Single,this.forceQueryClass=XG.QueryClass.Grouping}}nm.GroupBy=JTe;var pS={};Object.defineProperty(pS,"__esModule",{value:!0}),pS.ProjectFieldSpace=void 0;const gS=Ke,XTe=No;class ZTe extends XTe.QuerySpace{constructor(){super(...arguments),this.segmentType="project"}canContain(e){return e===void 0||!gS.TD.isAtomic(e)||(0,gS.expressionIsAggregate)(e.expressionType)?!1:(0,gS.expressionInvolvesAggregate)(e.expressionType)&&(0,gS.expressionIsAnalytic)(e.expressionType)?(this.logError("aggregate-analytic-in-select","Cannot add aggregate analyics to select"),!1):!0}}pS.ProjectFieldSpace=ZTe;var T0={},wf={};Object.defineProperty(wf,"__esModule",{value:!0}),wf.Ordering=wf.OrderBy=void 0;const eRe=Ke,ZG=v0,eW=Ye,tRe=wn;class nRe extends eW.MalloyElement{constructor(e,n){super(),this.field=e,this.dir=n,this.elementType="orderBy",e instanceof ZG.FieldName&&this.has({field:e})}get modelField(){return typeof this.field=="number"?this.field:this.field.refString}getOrderBy(e){var n;if(this.field instanceof ZG.FieldName&&e.isQueryFieldSpace()){const i=e.outputSpace(),s=this.field.getField(i);s.error&&this.field.logError(s.error.code,s.error.message),(!s.found||!s.isOutputField)&&this.logError("order-by-not-found-in-output",`Unknown field ${this.field.refString} in output space`),(0,eRe.expressionIsAnalytic)((n=s.found)===null||n===void 0?void 0:n.typeDesc().expressionType)&&this.logError("order-by-analytic",`Illegal order by of analytic field ${this.field.refString}`)}const r={field:this.modelField};return this.dir&&(r.dir=this.dir),r}}wf.OrderBy=nRe;class rRe extends eW.ListOf{constructor(e){super(e),this.elementType="ordering",this.queryRefinementStage=tRe.LegalRefinementStage.Tail,this.forceQueryClass=void 0}getOrderBy(e){return this.list.map(n=>n.getOrderBy(e))}}wf.Ordering=rRe,Object.defineProperty(T0,"__esModule",{value:!0}),T0.ReduceBuilder=T0.QuerySegmentBuilder=void 0;const Fo=Ke,iRe=Ur,sRe=v0,oRe=A0,uRe=wf,aRe=No,lRe=xs,j7=at;function tW(t){return t.type==="fieldref"?t.path[t.path.length-1]:t.name}class nW{constructor(){this.alwaysJoins=[],this.filters=[]}execute(e){if(e.queryExecute){e.queryExecute(this);return}e instanceof lRe.DefinitionList?this.resultFS.pushFields(...e.list):e instanceof oRe.Limit?this.limit?e.logError("limit-already-specified","Query operation already limited"):this.limit=e.limit:e instanceof uRe.Ordering&&(this.order?e.logError("ordering-already-specified","Query operation already sorted"):this.order=e)}get compositeFieldUsage(){return this.resultFS.compositeFieldUsage}refineFrom(e,n){var r;e&&e.type!=="index"&&e.type!=="raw"&&(!this.limit&&e.orderBy&&!e.defaultOrderBy&&(n.orderBy=e.orderBy),!this.limit&&e.limit&&(n.limit=e.limit)),this.order&&(n.orderBy=this.order.getOrderBy(this.inputFS),delete n.defaultOrderBy),this.limit&&(n.limit=this.limit);const i=(e==null?void 0:e.filterList)||[];this.filters.length>0&&!i?n.filterList=this.filters:i&&(n.filterList=[...i,...this.filters]),this.alwaysJoins.length>0&&(n.alwaysJoins=[...this.alwaysJoins]);const s=e&&(0,Fo.isQuerySegment)(e)&&(r=e.compositeFieldUsage)!==null&&r!==void 0?r:(0,j7.emptyCompositeFieldUsage)();n.compositeFieldUsage=(0,j7.mergeCompositeFieldUsage)(s,this.compositeFieldUsage)}}T0.QuerySegmentBuilder=nW;class cRe extends nW{constructor(e,n,r,i){super(),this.type="grouping",this.resultFS=new aRe.ReduceFieldSpace(e,n,r,i),this.inputFS=this.resultFS.inputSpace()}finalize(e){let n;if(e)if((0,Fo.isReduceSegment)(e)||(0,Fo.isPartialSegment)(e))n=e;else return this.resultFS.logError("incompatible-segment-for-reduce-refinement",`Can't refine reduce with ${e.type}`),iRe.ErrorFactory.reduceSegment;const r=this.resultFS.getQuerySegment(n);if(this.refineFrom(n,r),r.orderBy){for(const i of r.orderBy)if(typeof i.field=="number"){const s=r.queryFields[i.field-1];i.field=tW(s)}}if(r.orderBy===void 0||r.defaultOrderBy){let i;for(const s of r.queryFields){let o=!1,u=!1,a;const l=tW(s);if(s.type==="fieldref"){const c=s.path.map(d=>new sRe.FieldName(d)),f=this.inputFS.lookup(c).found;if(f){const d=f.typeDesc();a=d.type,o=(0,Fo.expressionIsAggregate)(d.expressionType),u=(0,Fo.expressionIsAnalytic)(d.expressionType)}else continue}else a=s.type,o=(0,Fo.hasExpression)(s)&&(0,Fo.expressionIsAggregate)(s.expressionType),u=(0,Fo.hasExpression)(s)&&(0,Fo.expressionIsAnalytic)(s.expressionType);if((0,Fo.isTemporalType)(a)||o){r.defaultOrderBy=!0,r.orderBy=[{field:l,dir:"desc"}],i=void 0;break}(0,Fo.canOrderBy)(a)&&!u&&!i&&(i=l)}i&&(r.defaultOrderBy=!0,r.orderBy=[{field:i,dir:"asc"}])}return r}}T0.ReduceBuilder=cRe,Object.defineProperty(hS,"__esModule",{value:!0}),hS.ProjectBuilder=void 0;const rW=Ke,fRe=Ur,xRe=nm,dRe=pS,hRe=T0;class pRe extends hRe.QuerySegmentBuilder{constructor(e,n,r,i){super(),this.type="project",this.resultFS=new dRe.ProjectFieldSpace(e,n,r,i),this.inputFS=this.resultFS.inputSpace()}execute(e){e.elementType==="having"||e instanceof xRe.GroupBy?e.logError("illegal-operation-in-select-segment","Illegal statement in a select query operation"):super.execute(e)}finalize(e){let n;if(e)if((0,rW.isProjectSegment)(e)||(0,rW.isPartialSegment)(e))n=e;else return this.resultFS.logError("incompatible-segment-for-select-refinement",`Can't refine select with ${e.type}`),fRe.ErrorFactory.projectSegment;const r=this.resultFS.getQuerySegment(n);return this.refineFrom(n,r),r}}hS.ProjectBuilder=pRe;var mS={};Object.defineProperty(mS,"__esModule",{value:!0}),mS.PartialBuilder=void 0;const gRe=ts,mRe=T0;class yRe extends mRe.ReduceBuilder{finalize(e){const n=super.finalize(e);if((0,gRe.isQuerySegment)(n))return{...n,type:"partial"};throw new Error(`Partial Builder cannot finalize from ${n.type}`)}}mS.PartialBuilder=yRe,Object.defineProperty(Zg,"__esModule",{value:!0}),Zg.QOpDesc=void 0;const ERe=xS,ARe=hS,vRe=T0,_Re=Ye,SRe=hs,CRe=Cr,Nf=wn,bRe=mS;class TRe extends _Re.ListOf{constructor(){super(...arguments),this.elementType="queryOperation"}computeType(){var e;let n,r=!1;this.refineThis&&(this.refineThis.type==="reduce"?n=Nf.QueryClass.Grouping:this.refineThis.type==="project"?n=Nf.QueryClass.Project:this.refineThis.type==="index"&&(n=Nf.QueryClass.Index));for(const i of this.list)i.forceQueryClass&&(n?n!==i.forceQueryClass&&i.logError(`illegal-${n}-operation`,`Not legal in ${n} query`):n=i.forceQueryClass),r||(r=(e=i.needsExplicitQueryClass)!==null&&e!==void 0?e:!1);return n===void 0&&r&&(this.logError("ambiguous-view-type",{}),n=Nf.QueryClass.Project),this.opClass=n,n}refineFrom(e){this.refineThis=e}getBuilder(e,n,r){switch(this.computeType()){case Nf.QueryClass.Grouping:return new vRe.ReduceBuilder(e,this.refineThis,n,r);case Nf.QueryClass.Project:return new ARe.ProjectBuilder(e,this.refineThis,n,r);case Nf.QueryClass.Index:return new ERe.IndexBuilder(e,this.refineThis,n,r);case void 0:return new bRe.PartialBuilder(e,this.refineThis,n,r)}}getOp(e,n){const r=this.getBuilder(e,n,this);for(const s of this.list)r.execute(s);const i=r.finalize(this.refineThis);return{segment:i,outputSpace:()=>new CRe.StaticSourceSpace((0,SRe.opOutputStruct)(this,e.structDef(),i))}}}Zg.QOpDesc=TRe,Object.defineProperty(fS,"__esModule",{value:!0}),fS.QOpDescView=void 0;const RRe=Ke,ORe=Cr,iW=Zg,DRe=hs,q7=wn,wRe=b0;class NRe extends wRe.View{constructor(e){super({operation:e}),this.operation=e,this.elementType="qopdesc-view"}pipelineComp(e,n){const r=this.operation.getOp(e,n);return{pipeline:[r.segment],outputStruct:r.outputSpace().structDef()}}getOp(e,n,r,i){return(0,RRe.isRawSegment)(i)?(this.logError("refinement-of-raw-query","A raw query cannot be refined"),i):(r.refineFrom(i),r.getOp(e,n).segment)}refine(e,n,r){const i=[...n];if(i.length===0)return i;if(i.length===1)return this.operation.refineFrom(i[0]),[this.getOp(e,r,this.operation,i[0])];const s=new iW.QOpDesc([]),o=new iW.QOpDesc([]);for(const u of this.operation.list)switch(u.queryRefinementStage){case q7.LegalRefinementStage.Head:s.push(u);break;case q7.LegalRefinementStage.Single:u.logError("illegal-multistage-refinement-operation","Illegal in refinement of a query with more than one stage");break;case q7.LegalRefinementStage.Tail:o.push(u);break;default:u.logError("illegal-refinement-operation","Illegal query refinement")}if(s.notEmpty()&&(this.has({headRefinements:s}),i[0]=this.getOp(e,void 0,s,i[0])),o.notEmpty()){const u=i.length-1;this.has({tailRefinements:o});const a=(0,DRe.getFinalStruct)(this,e.structDef(),i.slice(-1));i[u]=this.getOp(new ORe.StaticSourceSpace(a),void 0,o,i[u])}return i}getImplicitName(){}}fS.QOpDescView=NRe;var yn={},FRe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),LRe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),IRe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&FRe(e,t,n);return LRe(e,t),e};Object.defineProperty(yn,"__esModule",{value:!0}),yn.FieldDefinitionValue=yn.DefSpace=yn.DimensionFieldDeclaration=yn.MeasureFieldDeclaration=yn.DeclareFieldDeclaration=yn.ProjectFieldDeclaration=yn.GroupByFieldDeclaration=yn.AggregateFieldDeclaration=yn.CalculateFieldDeclaration=yn.AtomicFieldDeclaration=void 0;const H7=Ke,sW=IRe(Wt),BRe=ph,$Re=Ye,Ff=jn,kRe=_r,MRe=Sr;class R0 extends $Re.MalloyElement{constructor(e,n,r){super({expr:e}),this.expr=e,this.defineName=n,this.exprSrc=r,this.isNoteableObj=!0,this.extendNote=kRe.extendNoteMethod}getName(){return this.defineName}fieldDef(e,n){return this.queryFieldDef(new z7(e,this),n)}executesInOutputSpace(){return!1}queryFieldDef(e,n){let r;function i(){if(e.isQueryFieldSpace())return e.outputSpace();throw new Error("must be in a query -- weird internal error")}try{const o=this.executesInOutputSpace()?i():e;r=this.expr.getExpression(o)}catch(o){return this.logError("failed-field-definition",`Cannot define '${n}', ${o.message}`),{name:n,type:"error"}}if(r.type==="null"&&(this.expr.logWarning("null-typed-field-definition",'null value defaults to type number, use "null::TYPE" to specify correct type'),r={type:"number",value:r.value,expressionType:r.expressionType,evalSpace:r.evalSpace,compositeFieldUsage:r.compositeFieldUsage}),(0,H7.isAtomicFieldType)(r.type)&&r.type!=="error"){this.typecheckExprValue(r);const o=(0,H7.mkFieldDef)(sW.atomicDef(r),n);return(o.type==="date"||o.type==="timestamp")&&(0,BRe.isGranularResult)(r)&&(o.timeframe=r.timeframe),o.location=this.location,o.e=r.value,o.compositeFieldUsage=r.compositeFieldUsage,r.expressionType&&(o.expressionType=r.expressionType),this.exprSrc&&(o.code=this.exprSrc),this.note&&(o.annotation=this.note),o}if(!(e instanceof z7&&e.foundCircle)&&r.type!=="error"){const o=sW.inspect(r);this.logError("invalid-type-for-field-definition",`Cannot define '${n}', unexpected type: ${o}`)}return{name:n,type:"error"}}makeEntry(e){e.newEntry(this.defineName,this,new oW(e,this))}}yn.AtomicFieldDeclaration=R0;class PRe extends R0{constructor(){super(...arguments),this.elementType="calculateFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckCalculate)(e,this)}executesInOutputSpace(){return!0}}yn.CalculateFieldDeclaration=PRe;class URe extends R0{constructor(){super(...arguments),this.elementType="aggregateFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckAggregate)(e,this)}}yn.AggregateFieldDeclaration=URe;class jRe extends R0{constructor(){super(...arguments),this.elementType="groupByFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckGroupBy)(e,this)}}yn.GroupByFieldDeclaration=jRe;class qRe extends R0{constructor(){super(...arguments),this.elementType="projectFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckProject)(e,this)}}yn.ProjectFieldDeclaration=qRe;class HRe extends R0{constructor(){super(...arguments),this.elementType="declareFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckDeclare)(e,this)}}yn.DeclareFieldDeclaration=HRe;class zRe extends R0{constructor(){super(...arguments),this.elementType="measureFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckMeasure)(e,this)}}yn.MeasureFieldDeclaration=zRe;class QRe extends R0{constructor(){super(...arguments),this.elementType="dimensionFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckDimension)(e,this)}}yn.DimensionFieldDeclaration=QRe;class z7{constructor(e,n){this.realFS=e,this.circular=n,this.type="fieldSpace",this.foundCircle=!1}structDef(){return this.realFS.structDef()}emptyStructDef(){return this.realFS.emptyStructDef()}entry(e){return this.realFS.entry(e)}lookup(e){return e[0]&&e[0].refString===this.circular.defineName?(this.foundCircle=!0,{error:{message:`Circular reference to '${this.circular.defineName}' in definition`,code:"circular-reference-in-field-definition"},found:void 0}):this.realFS.lookup(e)}entries(){return this.realFS.entries()}dialectName(){return this.realFS.dialectName()}dialectObj(){return this.realFS.dialectObj()}isQueryFieldSpace(){return this.realFS.isQueryFieldSpace()}outputSpace(){if(this.realFS.isQueryFieldSpace())return this.realFS.outputSpace();throw new Error("Not a query field space")}inputSpace(){if(this.realFS.isQueryFieldSpace())return this.realFS.inputSpace();throw new Error("Not a query field space")}isProtectedAccessSpace(){return!0}}yn.DefSpace=z7;class oW extends MRe.SpaceField{constructor(e,n){super(),this.space=e,this.exprDef=n,this.fieldName=n.defineName}get name(){return this.fieldName}fieldDef(){var e;const n=(e=this.defInSource)!==null&&e!==void 0?e:this.exprDef.fieldDef(this.space,this.name);return this.defInSource=n,n}getQueryFieldDef(e){if(!this.defInQuery){const n=this.exprDef.queryFieldDef(e,this.name);this.defInQuery=n}return this.defInQuery}typeDesc(){const e=this.defInQuery||this.fieldDef();if((0,H7.isAtomic)(e))return this.fieldTypeFromFieldDef(e);throw new Error(`Can't get typeDesc for ${e.type}`)}entryType(){return(this.defInQuery||this.fieldDef()).type}}yn.FieldDefinitionValue=oW;var yS={};Object.defineProperty(yS,"__esModule",{value:!0}),yS.Aggregate=void 0;const GRe=xs,uW=wn;let WRe=class extends GRe.DefinitionList{constructor(){super(...arguments),this.elementType="aggregateList",this.queryRefinementStage=uW.LegalRefinementStage.Single,this.forceQueryClass=uW.QueryClass.Grouping}};yS.Aggregate=WRe;var ES={};Object.defineProperty(ES,"__esModule",{value:!0}),ES.Calculate=void 0;const VRe=xs,YRe=wn;class KRe extends VRe.DefinitionList{constructor(){super(...arguments),this.elementType="calculate",this.forceQueryClass=void 0,this.needsExplicitQueryClass=!0,this.queryRefinementStage=YRe.LegalRefinementStage.Single}}ES.Calculate=KRe;var rm={};Object.defineProperty(rm,"__esModule",{value:!0}),rm.Dimensions=void 0;const JRe=c0;class XRe extends JRe.DeclareFields{constructor(){super(...arguments),this.elementType="dimensionList"}}rm.Dimensions=XRe;var im={};Object.defineProperty(im,"__esModule",{value:!0}),im.Measures=void 0;const ZRe=c0;class e6e extends ZRe.DeclareFields{constructor(){super(...arguments),this.elementType="measureList"}}im.Measures=e6e;var AS={};Object.defineProperty(AS,"__esModule",{value:!0}),AS.Nests=void 0;const t6e=xs,aW=wn;class n6e extends t6e.DefinitionList{constructor(e){super(e),this.elementType="nestedQueries",this.queryRefinementStage=aW.LegalRefinementStage.Single,this.forceQueryClass=aW.QueryClass.Grouping}}AS.Nests=n6e;var vS={};Object.defineProperty(vS,"__esModule",{value:!0}),vS.ProjectStatement=void 0;const r6e=xs,lW=wn;class i6e extends r6e.DefinitionList{constructor(){super(...arguments),this.elementType="projectStatement",this.forceQueryClass=lW.QueryClass.Project,this.queryRefinementStage=lW.LegalRefinementStage.Single}queryExecute(e){e.type==="project"&&e.resultFS.pushFields(...this.list)}}vS.ProjectStatement=i6e;var O0={},Qa={};Object.defineProperty(Qa,"__esModule",{value:!0}),Qa.findReferences=Qa.deprecatedParseTableURI=Qa.constructTableKey=void 0;const s6e=Ql,Q7=fn;function G7(t){const e=(0,Q7.getStringIfShort)(t);if(e)return e;const n=[],r=t.string().sqlString();if(r){for(const i of(0,Q7.getStringParts)(r))typeof i=="string"&&n.push(i);return n.join("")}return""}class o6e{constructor(e,n){this.trans=e,this.tokens=n,this.needTables={},this.needImports={}}registerTableReference(e,n,r){const i=cW(e,n);this.needTables[i]||(this.needTables[i]={connectionName:e,tablePath:n,firstReference:r})}enterTableMethod(e){const n=(0,Q7.getId)(e.connectionId()),r=G7(e.tablePath()),i=this.trans.rangeFromContext(e);this.registerTableReference(n,r,i)}enterTableFunction(e){const n=G7(e.tableURI()),{connectionName:r,tablePath:i}=fW(n),s=this.trans.rangeFromContext(e);this.registerTableReference(r,i,s)}enterImportURL(e){const n=G7(e);this.needImports[n]||(this.needImports[n]=this.trans.rangeFromContext(e))}}function cW(t,e){return t===void 0?e:`${t}:${e}`}Qa.constructTableKey=cW;function fW(t){const e=t.match(/^([^:]*):(.*)$/);if(e){const[,n,r]=e;return{connectionName:n,tablePath:r}}else return{tablePath:t}}Qa.deprecatedParseTableURI=fW;function u6e(t,e,n){const r=new o6e(t,e),i=r;return s6e.ParseTreeWalker.DEFAULT.walk(i,n),{tables:r.needTables,urls:r.needImports}}Qa.findReferences=u6e,Object.defineProperty(O0,"__esModule",{value:!0}),O0.TableFunctionSource=O0.TableMethodSource=O0.TableSource=void 0;const xW=Qa,a6e=Ms,dW=Ur;class W7 extends a6e.Source{getSourceDef(){var e,n,r;const i=this.getTableInfo();if(i===void 0)return dW.ErrorFactory.structDef;const{tablePath:s,connectionName:o}=i,u=(0,xW.constructTableKey)(o,s),a=(e=this.translator())===null||e===void 0?void 0:e.root.schemaZone.getEntry(u);let l=`Schema read failure for table '${s}' for connection '${o}'`;if(a){if(a.status==="present"){(n=this.document())===null||n===void 0||n.checkExperimentalDialect(this,a.value.dialect),a.value.location=this.location,a.value.fields.forEach(f=>{f.location=this.location});const c={...a.value,fields:a.value.fields.map(f=>({...f,location:this.location})),location:this.location};return(r=this.document())===null||r===void 0||r.rememberToAddModelAnnotations(c),c}a.status==="error"&&(l=a.message)}return this.logError("failed-to-fetch-table-schema",l),dW.ErrorFactory.structDef}}O0.TableSource=W7;class l6e extends W7{constructor(e,n){super(),this.connectionName=e,this.tablePath=n,this.elementType="tableMethodSource",this.has({connectionName:e})}getTableInfo(){var e;const n=this.modelEntry(this.connectionName),r=this.connectionName.refString;if(n===void 0)(e=this.namespace())===null||e===void 0||e.setEntry(r,{entry:{type:"connection",name:r},exported:!0},!0);else if(n.entry.type!=="connection"){this.connectionName.logError("invalid-connection-for-table-source",`${this.connectionName.refString} is not a connection`);return}return{tablePath:this.tablePath,connectionName:this.connectionName.refString}}}O0.TableMethodSource=l6e;class c6e extends W7{constructor(e){super(),this.tableURI=e,this.elementType="tableFunctionSource"}getTableInfo(){return(0,xW.deprecatedParseTableURI)(this.tableURI)}}O0.TableFunctionSource=c6e;var _S={};Object.defineProperty(_S,"__esModule",{value:!0}),_S.SQLString=void 0;const f6e=Ye,hW=Do;class x6e extends f6e.MalloyElement{constructor(){super(...arguments),this.elementType="sqlString",this.elements=[],this.containsQueries=!1}complete(){this.has({queries:this.elements.filter(d6e)})}push(e){typeof e=="string"?e.length>0&&this.elements.push(e):e instanceof hW.SourceQueryElement?(this.elements.push(e),this.containsQueries=!0,e.parent=this):e.logError("invalid-sql-source-interpolation","This element is not legal inside an SQL string")}sqlPhrases(){const e=[];for(const n of this.elements)if(typeof n=="string")e.push({sql:n});else{const r=n.getQuery();r?e.push(r.query()):n.sqLog("failed-to-expand-sql-source","Cannot expand into a query")}return e}}_S.SQLString=x6e;function d6e(t){return t instanceof hW.SourceQueryElement}var SS={};Object.defineProperty(SS,"__esModule",{value:!0}),SS.SourceDesc=void 0;const h6e=Ye;class p6e extends h6e.ListOf{constructor(){super(...arguments),this.elementType="sourceDescription"}}SS.SourceDesc=p6e;var CS={};Object.defineProperty(CS,"__esModule",{value:!0}),CS.isSourceProperty=void 0;const g6e=Ou,m6e=c0,y6e=eh,E6e=p0,A6e=th,v6e=nh,_6e=rh,S6e=h0,C6e=Fi;function b6e(t){return t instanceof g6e.Filter||t instanceof C6e.JoinStatement||t instanceof m6e.DeclareFields||t instanceof y6e.FieldListEdit||t instanceof E6e.Renames||t instanceof A6e.PrimaryKey||t instanceof S6e.ObjectAnnotation||t instanceof v6e.Views||t instanceof _6e.TimezoneStatement}CS.isSourceProperty=b6e;var bS={};Object.defineProperty(bS,"__esModule",{value:!0}),bS.isFieldCollectionMember=void 0;const T6e=yn,pW=pt;function R6e(t){return t instanceof pW.FieldReference||t instanceof pW.WildcardFieldReference||t instanceof T6e.AtomicFieldDeclaration}bS.isFieldCollectionMember=R6e;var TS={};Object.defineProperty(TS,"__esModule",{value:!0}),TS.isQueryElement=void 0;const O6e=xh,D6e=dh,w6e=jg,N6e=qg;function F6e(t){return t instanceof O6e.QueryArrow||t instanceof D6e.QueryRefine||t instanceof w6e.QueryReference||t instanceof N6e.QueryRaw}TS.isQueryElement=F6e;var gW={};Object.defineProperty(gW,"__esModule",{value:!0});var RS={};Object.defineProperty(RS,"__esModule",{value:!0}),RS.isQueryProperty=void 0;function L6e(t){return"queryRefinementStage"in t&&"forceQueryClass"in t}RS.isQueryProperty=L6e;var OS={};Object.defineProperty(OS,"__esModule",{value:!0}),OS.isQueryExtendProperty=void 0;const I6e=rm,B6e=Fi,$6e=im;function k6e(t){return t instanceof I6e.Dimensions||t instanceof $6e.Measures||t instanceof B6e.JoinStatement}OS.isQueryExtendProperty=k6e;var DS={};Object.defineProperty(DS,"__esModule",{value:!0}),DS.isFieldPropStatement=void 0;const M6e=E0,P6e=Ou,U6e=A0,j6e=Ah;function q6e(t){return t instanceof P6e.Filter||t instanceof U6e.Limit||t instanceof j6e.PartitionBy||t instanceof M6e.FunctionOrdering}DS.isFieldPropStatement=q6e,function(t){var e=T&&T.__createBinding||(Object.create?function(r,i,s,o){o===void 0&&(o=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(r,o,u)}:function(r,i,s,o){o===void 0&&(o=s),r[o]=i[s]}),n=T&&T.__exportStar||function(r,i){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,r,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(dg,t),n(Yd,t),n(Kd,t),n(Ms,t),n(mg,t),n(Do,t),n(l_,t),n(c_,t),n(d_,t),n($g,t),n(g_,t),n(m_,t),n(Oo,t),n(eh,t),n(th,t),n(p0,t),n(nh,t),n(rh,t),n(E_,t),n(mh,t),n(v_,t),n(E0,t),n(__,t),n(Ha,t),n(S_,t),n(Eh,t),n(C_,t),n(b_,t),n(T_,t),n(qa,t),n(R_,t),n(O_,t),n(w_,t),n(Wg,t),n(Qg,t),n(Tf,t),n(F_,t),n(L_,t),n(B_,t),n(k_,t),n(M_,t),n(P_,t),n(U_,t),n(_0,t),n(q_,t),n(H_,t),n(z_,t),n(Q_,t),n(G_,t),n(W_,t),n(Y_,t),n(X_,t),n(nr,t),n(tS,t),n(Ah,t),n(_h,t),n(Ch,t),n(rS,t),n(Df,t),n(y0,t),n(iS,t),n(Vg,t),n(C0,t),n(Jg,t),n(sS,t),n(oS,t),n(uS,t),n(dh,t),n(xh,t),n(b0,t),n(aS,t),n(lS,t),n(cS,t),n(fS,t),n(yn,t),n(pt,t),n(yS,t),n(ES,t),n(c0,t),n(rm,t),n(Jg,t),n(Ou,t),n(nm,t),n(em,t),n(Fi,t),n(hg,t),n(A0,t),n(im,t),n(dg,t),n(AS,t),n(wf,t),n(vS,t),n(Zg,t),n(tm,t),n(hh,t),n(bf,t),n(Hg,t),n(O0,t),n(_S,t),n(h0,t),n(wo,t),n(SS,t),n(CS,t),n(ct,t),n(bS,t),n(v0,t),n(Ye,t),n(TS,t),n(gW,t),n(RS,t),n(OS,t),n(DS,t)}(Hv);var wS={},Th={};Object.defineProperty(Th,"__esModule",{value:!0}),Th.ConstantExpression=Th.ConstantFieldSpace=void 0;const H6e=ct;class mW{constructor(){this.type="fieldSpace"}structDef(){throw new Error("ConstantFieldSpace cannot generate a structDef")}emptyStructDef(){throw new Error("ConstantFieldSpace cannot generate a structDef")}lookup(e){return{error:{message:"Only constants allowed in parameter default values",code:"illegal-reference-in-parameter-default"},found:void 0}}entries(){return[]}entry(){}dialectName(){return"~constant-space-unknown-dialect~"}dialectObj(){}isQueryFieldSpace(){return!1}isProtectedAccessSpace(){return!1}}Th.ConstantFieldSpace=mW;class z6e extends H6e.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="constantExpression"}getExpression(e){return this.constantValue()}get constantFs(){return this.cfs||(this.cfs=new mW),this.cfs}constantValue(){return this.expr.getExpression(this.constantFs)}apply(e,n,r){return this.expr.apply(e,n,r)}requestExpression(e){return this.expr.requestExpression(e)}}Th.ConstantExpression=z6e;var Q6e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),G6e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),W6e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Q6e(e,t,n);return G6e(e,t),e};Object.defineProperty(wS,"__esModule",{value:!0}),wS.MalloyToAST=void 0;const yW=eg,V6e=pp,te=W6e(Hv),V7=pg,EW=Jn,Y6e=Hv,kn=fn,Y7=Ke,K6e=fo,J6e=Th,X6e=bu;class AW extends te.SourceQueryElement{constructor(){super(...arguments),this.elementType="parseErrorSourceQuery"}}class K7 extends te.MalloyElement{constructor(e){super(),this.elementType="ignoredByParser",this.malloySrc=e}}const Z6e=["##! m4warnings=error"];class eOe extends V6e.AbstractParseTreeVisitor{constructor(e,n,r){super(),this.parseInfo=e,this.msgLog=n,this.compilerFlags=r;for(const i of Z6e){const s=K6e.Tag.fromTagline(i,this.compilerFlags);this.compilerFlags=s.tag}}internalError(e,n){return this.contextError(e,"internal-translator-error",{message:n}),new Error(`Internal Translator Error: ${n}`)}astError(e,n,r,i){this.msgLog.log((0,V7.makeLogMessage)(n,r,{at:e.location,...i}))}getLocation(e){return{url:this.parseInfo.sourceURL,range:this.parseInfo.rangeFromContext(e)}}getSourceString(e){return this.parseInfo.sourceStream.getText(new EW.Interval(e.start.startIndex,e.stop?e.stop.stopIndex:e.start.startIndex))}contextError(e,n,r,i){this.msgLog.log((0,V7.makeLogMessage)(n,r,{at:this.getLocation(e),...i}))}warnWithReplacement(e,n,r,i){this.msgLog.log((0,V7.makeLogMessage)(e,n,{at:{url:this.parseInfo.sourceURL,range:r},severity:"warn",replacement:i}))}inExperiment(e,n){const r=this.compilerFlags.tag("experimental");return r&&(r.bare()||r.has(e))?!0:(this.contextError(n,"experiment-not-enabled",{experimentId:e}),!1)}m4Severity(){const e=this.compilerFlags.tag("m4warnings");return e?e.text()==="warn"?"warn":"error":!1}m4advisory(e,n,r){const i=this.m4Severity();i&&this.contextError(e,n,r,{severity:i})}only(e,n,r){const i=[];for(const s of e){const o=n(s);o?i.push(o):s instanceof K7||this.astError(s,"unexpected-statement-in-translation",`Parser enountered unexpected statement type '${s.elementType}' when it needed '${r}'`)}return i}getNumber(e){return Number.parseInt(e.text)}getFieldName(e){return this.astAt(new te.FieldName((0,kn.getId)(e)),e.id())}getModelEntryName(e){return this.astAt(new te.ModelEntryReference((0,kn.getId)(e)),e.id())}defaultResult(){return new te.Unimplemented}astAt(e,n){return e.location={url:this.parseInfo.sourceURL,range:this.parseInfo.rangeFromContext(n)},e}getSourceCode(e){const n=e.start.startIndex,r=e.stop||e.start,i=new EW.Interval(n,r.stopIndex);return this.parseInfo.sourceStream.getText(i)}getFilterElement(e){const n=this.getFieldExpr(e),r=new te.FilterElement(n,this.getSourceCode(e));return this.astAt(r,e)}getFieldDefs(e,n){return e.map(r=>this.getFieldDef(r,n))}getFieldExpr(e){const n=this.visit(e);if(n instanceof te.ExpressionDef)return this.astAt(n,e);throw this.internalError(e,`expression node unknown type '${n.elementType}'`)}getPlainStringFrom(e){const[n,r]=(0,kn.getPlainString)(e);for(const i of r)i instanceof yW.ParserRuleContext&&this.contextError(i,"illegal-query-interpolation-outside-sql-block","%{ query } illegal in this string");return n||""}makeSqlString(e,n){for(const r of e.sqlInterpolation())r.CLOSE_CODE()&&this.m4advisory(r,"percent-terminated-query-interpolation","Use %{ ... } instead of %{ ... }%");for(const r of(0,kn.getStringParts)(e))r instanceof yW.ParserRuleContext?n.push(this.visit(r)):n.push(r);n.complete(),this.astAt(n,e)}parseTime(e,n){let r=n(e.text);return r||(this.contextError(e,"failed-to-parse-time-literal","Time data parse error"),r=new te.LiteralTimestamp({text:e.text})),this.astAt(r,e)}getNotes(e){return e.ANNOTATION().map(n=>({text:n.text,at:this.getLocation(e)}))}getIsNotes(e){return this.getNotes(e._beforeIs).concat(this.getNotes(e._afterIs))}visitMalloyDocument(e){const n=this.only(e.malloyStatement().map(r=>this.visit(r)),r=>te.isDocStatementOrDocStatementList(r)&&r,"statement");return new te.Document(n)}visitDefineSourceStatement(e){const r=e.sourcePropertyList().sourceDefinition().map(o=>this.visitSourceDefinition(o)),i=this.getNotes(e.tags()),s=new te.DefineSourceList(r);return s.extendNote({blockNotes:i}),s}getSourceParameter(e){const n=e.fieldExpr(),r=n?this.astAt(new J6e.ConstantExpression(this.getFieldExpr(n)),n):void 0,i=e.malloyType(),s=i?this.getMalloyType(i):void 0;return this.astAt(new te.HasParameter({name:(0,kn.getId)(e.parameterNameDef()),type:s,default:r}),e)}getSourceParameters(e){return e===void 0?[]:(this.inExperiment("parameters",e),e.sourceParameter().map(n=>this.getSourceParameter(n)))}visitSourceDefinition(e){const n=this.visit(e.sqExplore()),r=this.getSourceParameters(e.sourceParameters()),i=new te.DefineSource((0,kn.getId)(e.sourceNameDef()),n instanceof te.SourceQueryElement?n:void 0,!0,r),s=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));return i.extendNote({notes:s}),this.astAt(i,e)}getSourceExtensions(e){return this.astAt(this.visitExploreProperties(e),e)}visitExploreProperties(e){const n=this.only(e.exploreStatement().map(i=>this.visit(i)),i=>te.isSourceProperty(i)&&i,"source property");return new te.SourceDesc(n)}visitTableFunction(e){const n=this.getPlainStringFrom(e.tableURI()),r=this.astAt(new te.TableFunctionSource(n),e);return this.m4advisory(e,"table-function","`table('connection_name:table_path')` is deprecated; use `connection_name.table('table_path')`"),r}visitTableMethod(e){const n=e.connectionId(),r=this.astAt(this.getModelEntryName(n),n),i=this.getPlainStringFrom(e.tablePath());return this.astAt(new te.TableMethodSource(r,i),e)}visitSqlSource(e){const n=e.connectionId(),r=this.astAt(this.getModelEntryName(n),n),i=new te.SQLString,s=e.sqlString();s&&this.makeSqlString(s,i);const o=e.shortString();o&&i.push((0,kn.getShortString)(o));const u=new te.SQLSource(r,i);return this.astAt(u,e)}visitDefJoinMany(e){const n=this.getAccessLabel(e.accessLabel()),r=[];for(const s of e.joinList().joinDef()){const o=this.visit(s);o instanceof te.Join&&(r.push(o),o instanceof te.ExpressionJoin?(o.joinType="many",o.joinOn===void 0&&this.contextError(e,"missing-on-in-join-many","join_many: requires ON expression")):o instanceof te.KeyJoin&&this.contextError(e,"foreign-key-in-join-many","Foreign key join not legal in join_many:"))}const i=new te.JoinStatement(r,n);return i.extendNote({blockNotes:this.getNotes(e.tags())}),i}visitDefJoinOne(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getJoinList(e.joinList()),i=[];for(const o of r)o instanceof te.Join&&(i.push(o),o instanceof te.ExpressionJoin&&(o.joinType="one"));const s=new te.JoinStatement(i,n);return s.extendNote({blockNotes:this.getNotes(e.tags())}),s}visitDefJoinCross(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getJoinList(e.joinList()),i=[];for(const o of r)o instanceof te.Join&&(i.push(o),o instanceof te.ExpressionJoin?o.joinType="cross":o.logError("foreign-key-in-join-cross","Foreign key join not legal in join_cross:"));const s=new te.JoinStatement(i,n);return s.extendNote({blockNotes:this.getNotes(e.tags())}),s}getJoinList(e){return this.only(e.joinDef().map(n=>this.visit(n)),n=>n instanceof te.Join&&n,"join")}getJoinFrom(e){const n=e.isExplore(),r=this.getModelEntryName(e.joinNameDef());if(n){const s=this.getSqExpr(n.sqExpr()),o=this.getNotes(n._before_is).concat(this.getNotes(n._after_is));return{joinFrom:s,notes:o,joinAs:r}}const i=e.sourceArguments();return i?{joinFrom:this.astAt(new te.SQReference(r,this.getSQArguments(i)),e),notes:[],joinAs:r}:{joinAs:r,joinFrom:new te.SQReference(r),notes:[]}}visitQueryJoinStatement(e){return this.astAt(this.visit(e.joinStatement()),e)}visitJoinOn(e){var n;const{joinAs:r,joinFrom:i,notes:s}=this.getJoinFrom(e.joinFrom()),o=new te.ExpressionJoin(r,i),u=e.joinExpression(),a=((n=e.matrixOperation())===null||n===void 0?void 0:n.text.toLocaleLowerCase())||"left";return(0,Y7.isMatrixOperation)(a)?o.matrixOperation=a:this.contextError(e,"unknown-matrix-operation","Internal Error: Unknown matrixOperation"),u&&(o.joinOn=this.getFieldExpr(u)),o.extendNote({notes:this.getNotes(e).concat(s)}),this.astAt(o,e)}visitJoinWith(e){const{joinAs:n,joinFrom:r,notes:i}=this.getJoinFrom(e.joinFrom()),s=this.getFieldExpr(e.fieldExpr()),o=new te.KeyJoin(n,r,s);return o.extendNote({notes:this.getNotes(e).concat(i)}),this.astAt(o,e)}getFieldDef(e,n){const r=e.fieldExpr(),i=(0,kn.getId)(e.fieldNameDef()),s=this.getFieldExpr(r),o=new n(s,i,this.getSourceCode(r)),u=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));return o.extendNote({notes:u}),this.astAt(o,e)}visitDefDimensions(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getFieldDefs(e.defList().fieldDef(),te.DimensionFieldDeclaration),i=new te.Dimensions(r,n);return i.extendNote({blockNotes:this.getNotes(e.tags())}),this.astAt(i,e)}getAccessLabel(e){if(e!==void 0){if(e.INTERNAL_KW())return"internal";if(e.PRIVATE_KW())return"private";if(e.PUBLIC_KW())return"public";throw this.internalError(e,`Unknown access modifier label ${e.text}`)}}getAccessLabelProp(e){if(e!==void 0){if(e.INTERNAL())return"internal";if(e.PRIVATE())return"private";if(e.PUBLIC())return"public";throw this.internalError(e,`Unknown access modifier label ${e.text}`)}}visitDefMeasures(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getFieldDefs(e.defList().fieldDef(),te.MeasureFieldDeclaration),i=new te.Measures(r,n);return i.extendNote({blockNotes:this.getNotes(e.tags())}),this.astAt(i,e)}visitQueryExtend(e){const n=[],r=e.queryExtendStatementList().queryExtendStatement().map(s=>this.visit(s));for(const s of r)if(te.isQueryExtendProperty(s))n.push(s);else throw this.internalError(e,`Query extend matched, but ${s.elementType} found`);const i=new te.ExtendBlock(n);return this.astAt(i,e)}visitDeclareStatement(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getFieldDefs(e.defList().fieldDef(),te.DeclareFieldDeclaration),i=new te.DeclareFields(r,n),s=this.astAt(i,e);return this.m4advisory(e,"declare","`declare:` is deprecated; use `dimension:` or `measure:` inside a source or `extend:` block"),s}visitExploreRenameDef(e){const n=e.fieldName(0),r=e.fieldName(1),i=new te.RenameField((0,kn.getId)(n),this.getFieldName(r));return this.astAt(i,e)}visitDefExploreRename(e){const n=this.getAccessLabel(e.accessLabel()),i=e.renameList().exploreRenameDef().map(o=>this.visitExploreRenameDef(o)),s=new te.Renames(i,n);return this.astAt(s,e)}visitFilterClauseList(e){return new te.Filter(e.fieldExpr().map(n=>this.getFilterElement(n)))}visitWhereStatement(e){const n=this.visitFilterClauseList(e.filterClauseList());return n.having=!1,this.astAt(n,e)}visitHavingStatement(e){const n=this.visitFilterClauseList(e.filterClauseList());return n.having=!0,this.astAt(n,e)}visitDefExploreQuery(e){const n=this.getAccessLabel(e.accessLabel()),r=e.subQueryDefList().exploreQueryDef().map(o=>this.visitExploreQueryDef(o)),i=new te.Views(r,n),s=this.getNotes(e.tags());return i.extendNote({blockNotes:s}),e.QUERY()&&this.m4advisory(e,"query-in-source","Use view: inside of a source instead of query:"),i}visitDefExplorePrimaryKey(e){const n=new te.PrimaryKey(this.getFieldName(e.fieldName()));return this.astAt(n,e)}getFieldNameList(e,n){const r=e.fieldName().map(i=>this.astAt(new n([this.getFieldName(i)]),i));return new te.FieldReferences(r)}visitDefExploreEditField(e){const n=e.ACCEPT()?"accept":"except";return new te.FieldListEdit(n,this.getFieldNameList(e.fieldNameList(),te.AcceptExceptFieldReference))}visitSQInclude(e){const n=this.getSqExpr(e.sqExpr()),r=e.includeBlock(),i=r?this.getIncludeItems(r):void 0,s=new te.SQExtend(n,new te.SourceDesc([]),i);return this.astAt(s,e)}visitDefExploreTimezone(e){return this.visitTimezoneStatement(e.timezoneStatement())}visitTimezoneStatement(e){const n=this.getPlainStringFrom(e),r=this.astAt(new te.TimezoneStatement(n),e.string());return r.isValid||this.astError(r,"invalid-timezone",{timezone:r.tz}),this.astAt(r,e)}visitQueryProperties(e){const n=this.only(e.queryStatement().map(r=>this.astAt(this.visit(r),r)),r=>te.isQueryProperty(r)&&r,"query statement");return new te.QOpDesc(n)}getFieldPath(e,n){const r=e.fieldName().map(i=>this.getFieldName(i));return this.astAt(new n(r),e)}getQueryFieldDef(e,n){const r=this.getFieldDef(e,n);return this.astAt(r,e)}getQueryFieldEntry(e,n,r){const i=e.taggedRef();if(i)return this.getTaggedRef(i,n,r);const s=e.fieldDef();if(s)return this.getQueryFieldDef(s,n);throw new Error("Expected query field entry to be a field reference or definition")}getQueryItems(e,n,r){return this.only(e.queryFieldEntry().map(i=>this.getQueryFieldEntry(i,n,r)),i=>i instanceof te.FieldReference||i instanceof te.AtomicFieldDeclaration?i:!1,"view field")}visitAggregateStatement(e){const n=new te.Aggregate(this.getQueryItems(e.queryFieldList(),te.AggregateFieldDeclaration,te.AggregateFieldReference));return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitGroupByStatement(e){const n=new te.GroupBy(this.getQueryItems(e.queryFieldList(),te.GroupByFieldDeclaration,te.GroupByFieldReference));return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitCalculateStatement(e){const n=new te.Calculate(this.getQueryItems(e.queryFieldList(),te.CalculateFieldDeclaration,te.CalculateFieldReference));return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}getTaggedRef(e,n,r){const i=e.refExpr();if(i){const o=this.getFieldPath(e.fieldPath(),te.ExpressionFieldReference);let u;const a=i.timeframe();a&&(u=new te.ExprGranularTime(new te.ExprIdReference(o),this.visitTimeframe(a).text,!0));const l=i.aggregate();if(l){const f=l.text.toLowerCase();if(f==="sum")u=new te.ExprSum(void 0,o);else return this.contextError(l,"invalid-reference-only-aggregation",`\`${f}\` is not legal in a reference-only aggregation`),o}const c=new n(u,o.outputName);return c.extendNote({notes:this.getNotes(e.tags())}),c}const s=this.getFieldPath(e.fieldPath(),r);return s.extendNote({notes:this.getNotes(e.tags())}),s}getFieldCollectionMember(e,n,r){const i=e.fieldDef();if(i)return this.getFieldDef(i,n);const s=e.taggedRef();if(s)return this.getTaggedRef(s,n,r);const o=e.collectionWildCard();if(o)return this.visitCollectionWildCard(o);throw this.internalError(e,"Unexpected element in fieldCollectionMember")}visitFieldCollection(e){const n=e.collectionMember().map(r=>this.getFieldCollectionMember(r,te.ProjectFieldDeclaration,te.ProjectFieldReference));return this.astAt(new te.ProjectStatement(n),e)}visitProjectStatement(e){e.PROJECT()&&this.m4advisory(e,"project","project: keyword is deprecated, use select:");const n=this.visitFieldCollection(e.fieldCollection());return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitCollectionWildCard(e){var n;const r=e.fieldPath(),i=r?this.getFieldPath(r,te.ProjectFieldReference):void 0,s=this.astAt(new te.WildcardFieldReference(i),e),o=((n=e.starQualified())===null||n===void 0?void 0:n.fieldNameList())||[];for(const u of o)for(const a of u.fieldName())s.except.add((0,kn.getId)(a));return s}visitIndexFields(e){const n=e.indexElement().map(r=>{const i=r.fieldPath();if(!i)return this.astAt(new te.WildcardFieldReference(void 0),e);const s=this.getFieldPath(i,te.IndexFieldReference);return r.STAR()?this.astAt(new te.WildcardFieldReference(s),e):this.astAt(s,e)});return new te.FieldReferences(n)}visitIndexStatement(e){const n=this.visitIndexFields(e.indexFields()),r=new te.Index(n),i=e.fieldName();return i&&r.useWeight(this.getFieldName(i)),this.astAt(r,e)}visitFieldPropertyLimitStatement(e){return this.inExperiment("aggregate_limit",e),this.visitLimitStatement(e.limitStatement())}visitLimitStatement(e){return new te.Limit(this.getNumber(e.INTEGER_LITERAL()))}visitAggregateOrderBySpec(e){const n=e.ASC()?"asc":e.DESC()?"desc":void 0,r=e.fieldExpr(),i=r?this.getFieldExpr(r):void 0;return this.astAt(new te.FunctionOrderBy(i,n),e)}visitAggregateOrderByStatement(e){return this.visitAggregateOrdering(e.aggregateOrdering())}visitAggregateOrdering(e){const n=e.aggregateOrderBySpec().map(r=>this.visitAggregateOrderBySpec(r));return this.astAt(new te.FunctionOrdering(n),e)}visitOrderBySpec(e){const n=e.ASC()?"asc":e.DESC()?"desc":void 0,r=e.INTEGER_LITERAL();if(r)return new te.OrderBy(this.getNumber(r),n);const i=e.fieldName();if(i)return new te.OrderBy(this.getFieldName(i),n);throw this.internalError(e,"can't parse order_by specification")}visitOrdering(e){const n=e.orderBySpec().map(r=>this.visitOrderBySpec(r));return this.astAt(new te.Ordering(n),e)}visitTopStatement(e){const n=this.getNumber(e.INTEGER_LITERAL());return this.astAt(new te.Limit(n),e)}visitTopLevelQueryDefs(e){const n=e.topLevelQueryDef().map(s=>this.visitTopLevelQueryDef(s)),r=this.getNotes(e.tags()),i=new te.DefineQueryList(n);return i.extendNote({blockNotes:r}),i}visitTopLevelQueryDef(e){const n=(0,kn.getId)(e.queryName()),r=this.visit(e.sqExpr()),i=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));if(r instanceof te.SourceQueryElement){const s=new te.DefineQuery(n,r);return s.extendNote({notes:i}),this.astAt(s,e)}throw this.internalError(e,`Expected query definition, got a '${r.elementType}'`)}visitAnonymousQuery(e){const n=e.topLevelAnonQueryDef(),r=this.getSqExpr(n.sqExpr()),i=this.astAt(new te.AnonymousQuery(r),n),s=this.getNotes(e.topLevelAnonQueryDef().tags()),o=this.getNotes(e.tags());return i.extendNote({notes:s,blockNotes:o}),this.m4advisory(n,"anonymous-query","Anonymous `query:` statements are deprecated, use `run:` instead"),this.astAt(i,e)}visitRunStatement(e){const n=e.topLevelAnonQueryDef(),r=this.getSqExpr(n.sqExpr()),i=this.astAt(new te.AnonymousQuery(r),n),s=this.getNotes(e.topLevelAnonQueryDef().tags()),o=this.getNotes(e.tags());return i.extendNote({notes:s,blockNotes:o}),this.astAt(i,e)}visitNestStatement(e){const n=this.visitNestedQueryList(e.nestedQueryList());return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitNestedQueryList(e){return new te.Nests(this.only(e.nestEntry().map(n=>this.visit(n)),n=>n instanceof te.NestFieldDeclaration&&n,"query"))}visitNestDef(e){const n=e.queryName();let r;const i=this.getVExpr(e.vExpr());if(n)r=(0,kn.getId)(n);else{const u=i.getImplicitName();u===void 0&&this.contextError(e,"anonymous-nest","`nest:` view requires a name (add `nest_name is ...`)"),r=u??"__unnamed__"}const s=new te.NestFieldDeclaration(r,i),o=e.isDefine();return s.extendNote({notes:this.getNotes(e.tags()).concat(o?this.getIsNotes(o):[])}),this.astAt(s,e)}visitExploreQueryDef(e){const n=(0,kn.getId)(e.exploreQueryNameDef()),r=new te.ViewFieldDeclaration(n,this.getVExpr(e.vExpr())),i=this.getNotes(e).concat(this.getIsNotes(e.isDefine()));return r.extendNote({notes:i}),this.astAt(r,e)}visitExprNot(e){return new te.ExprNot(this.getFieldExpr(e.fieldExpr()))}visitExprBool(e){return new te.Boolean(e.TRUE()?"true":"false")}allFieldExpressions(e){return e.map(n=>this.getFieldExpr(n))}visitExprLogicalOr(e){const n=this.getFieldExpr(e.fieldExpr(0)),r=this.getFieldExpr(e.fieldExpr(1));return new te.ExprLogicalOp(n,"or",r)}visitExprLogicalAnd(e){const n=this.getFieldExpr(e.fieldExpr(0)),r=this.getFieldExpr(e.fieldExpr(1));return new te.ExprLogicalOp(n,"and",r)}visitExprOrTree(e){const n=this.getFieldExpr(e.fieldExpr()),r=this.getFieldExpr(e.partialAllowedFieldExpr());return this.astAt(new te.ExprAlternationTree(n,"|",r),e)}visitExprAndTree(e){const n=this.getFieldExpr(e.fieldExpr()),r=this.getFieldExpr(e.partialAllowedFieldExpr());return this.astAt(new te.ExprAlternationTree(n,"&",r),e)}visitExprCoalesce(e){const n=this.getFieldExpr(e.fieldExpr()[0]),r=this.getFieldExpr(e.fieldExpr()[1]);return this.astAt(new te.ExprCoalesce(n,r),e)}visitPartialCompare(e){const n=e.compareOp().text;if(te.isComparison(n))return this.astAt(new te.PartialCompare(n,this.getFieldExpr(e.fieldExpr())),e);throw this.internalError(e,`partial comparison '${n}' not recognized`)}visitPartialTest(e){const n=e.partialCompare();return n?this.visitPartialCompare(n):this.astAt(new te.PartialIsNull(e.NOT()?"!=":"="),e)}visitPartialAllowedFieldExpr(e){const n=e.fieldExpr();if(n)return this.getFieldExpr(n);const r=e.partialTest();if(r)return this.visitPartialTest(r);throw this.internalError(e,"impossible partial")}visitExprString(e){const n=this.getPlainStringFrom(e);return new te.ExprString(n)}visitExprRegex(e){const n=e.HACKY_REGEX().text;return new te.ExprRegEx(n.slice(2,-1))}visitExprNow(e){return new te.ExprNow}visitExprNumber(e){return new te.ExprNumber(e.text)}visitExprFieldPath(e){const n=new te.ExprIdReference(this.getFieldPath(e.fieldPath(),te.ExpressionFieldReference));return this.astAt(n,e)}visitExprNULL(e){return new te.ExprNULL}visitExprExpr(e){return new te.ExprParens(this.getFieldExpr(e.fieldExpr()))}visitExprMinus(e){return new te.ExprMinus(this.getFieldExpr(e.fieldExpr()))}visitExprAddSub(e){const n=this.getFieldExpr(e.fieldExpr(0)),r=this.getFieldExpr(e.fieldExpr(1)),i=e.PLUS()?"+":"-";return new te.ExprAddSub(n,i,r)}visitExprMulDiv(e){const n=e.STAR()?"*":e.SLASH()?"/":"%";return new te.ExprMulDiv(this.getFieldExpr(e.fieldExpr(0)),n,this.getFieldExpr(e.fieldExpr(1)))}visitExprCompare(e){const n=e.compareOp().text,r=this.getFieldExpr(e.fieldExpr(0)),i=this.getFieldExpr(e.fieldExpr(1));if(te.isEquality(n)){const s=this.parseInfo.rangeFromContext(e);return i instanceof te.ExprNULL&&(n==="="?this.warnWithReplacement("sql-is-null","Use 'is null' to check for NULL instead of '= null'",s,`${this.getSourceCode(e.fieldExpr(0))} is null`):n==="!="&&this.warnWithReplacement("sql-is-not-null","Use 'is not null' to check for NULL instead of '!= null'",s,`${this.getSourceCode(e.fieldExpr(0))} is not null`)),this.astAt(new te.ExprEquality(r,n,i),e)}else if(te.isComparison(n))return this.astAt(new te.ExprCompare(r,n,i),e);throw this.internalError(e,`untranslatable comparison operator '${n}'`)}visitExprUngroup(e){const n=e.fieldName().map(i=>this.getFieldName(i)),r=e.ungroup().text.toLowerCase();return this.astAt(new te.ExprUngroup(r==="all"?r:"exclude",this.getFieldExpr(e.fieldExpr()),n),e)}symmetricAggregateUsageError(e){return`Symmetric aggregate function \`${e}\` must be written as \`${e}(expression)\` or \`path.to.field.${e}()\``}asymmetricAggregateUsageError(e){return`Asymmetric aggregate function \`${e}\` must be written as \`path.to.field.${e}()\`, \`path.to.join.${e}(expression)\`, or \`${e}(expression)\``}visitExprAggregate(e){const n=e.fieldPath(),r=this.getFieldPath(n,te.ExpressionFieldReference),i=n&&r?this.astAt(r,n):void 0,s=e.aggregate().text.toLowerCase(),o=e.fieldExpr();if(e.aggregate().COUNT())return o&&this.contextError(o,"count-expression-with-locality","Expression illegal inside path.count()"),new te.ExprCount(i);const u=o?this.getFieldExpr(o):void 0;if(s==="min"||s==="max")if(u)this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(s));else{const a=this.astAt(new te.ExprIdReference(r),n);return s==="min"?new te.ExprMin(a):new te.ExprMax(a)}else{if(s==="avg")return new te.ExprAvg(u,i);if(s==="sum")return new te.ExprSum(u,i);this.contextError(e,"aggregate-parse-error",`Cannot parse aggregate function ${s}`)}return new te.ExprNULL}visitExprPathlessAggregate(e){const n=e.fieldExpr(),r=n?this.getFieldExpr(n):void 0,i=void 0,s=e.aggregate().text.toLowerCase();if(e.STAR()&&this.m4advisory(e,"wildcard-in-aggregate",`* illegal inside ${s}()`),s==="count")return this.astAt(r?new te.ExprCountDistinct(r):new te.ExprCount,e);if(s==="min"){if(r)return new te.ExprMin(r);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(s))}else if(s==="max"){if(r)return new te.ExprMax(r);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(s))}else{if(r===void 0)return this.contextError(e,"invalid-asymmetric-aggregate",this.asymmetricAggregateUsageError(s)),new te.ExprNULL;const o=e.SOURCE_KW()!==void 0;if(s==="avg")return new te.ExprAvg(r,i,o);if(s==="sum")return new te.ExprSum(r,i,o)}return new te.ExprNULL}visitExprApply(e){return new te.Apply(this.getFieldExpr(e.fieldExpr()),this.getFieldExpr(e.partialAllowedFieldExpr()))}visitExprRange(e){return new te.Range(this.getFieldExpr(e.fieldExpr(0)),this.getFieldExpr(e.fieldExpr(1)))}visitExprCast(e){const n=this.getMalloyOrSQLType(e.malloyOrSQLType());return new te.ExprCast(this.getFieldExpr(e.fieldExpr()),n)}getMalloyType(e){const n=e.text;if((0,Y7.isCastType)(n))return n;throw this.internalError(e,`unknown type '${n}'`)}getMalloyOrSQLType(e){const n=e.malloyType();if(n)return this.getMalloyType(n);const r=e.string();if(r)return{raw:this.getPlainStringFrom({string:()=>r})};throw this.internalError(e,"Expected Malloy or SQL type to either be a Malloy type or a string")}visitExprSafeCast(e){const n=this.getMalloyOrSQLType(e.malloyOrSQLType());return new te.ExprCast(this.getFieldExpr(e.fieldExpr()),n,!0)}visitExprTimeTrunc(e){return new te.ExprGranularTime(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text,!0)}visitTimeframe(e){return new te.Timeframe(e.text)}visitExprForRange(e){const n=this.getFieldExpr(e._startAt),r=this.getFieldExpr(e._duration),i=this.visitTimeframe(e.timeframe());return new te.ForRange(n,r,i)}visitExprAggFunc(e){const n=e.argumentList(),r=n?this.allFieldExpressions(n.fieldExpr()):[],i=(0,kn.getId)(e),s=e.fieldPath(),o=s?this.getFieldPath(s,te.ExpressionFieldReference):void 0,u=s&&o?this.astAt(o,s):void 0;return te.ExprTimeExtract.extractor(i)?this.astAt(new te.ExprTimeExtract(i,r),e):this.astAt(new te.ExprFunc(i,r,!1,void 0,u),e)}visitExprFunc(e){var n,r;const i=e.argumentList(),s=i?this.allFieldExpressions(i.fieldExpr()):[],o=e.EXCLAM()!==void 0,u=(n=e.malloyType())===null||n===void 0?void 0:n.text;let a;u&&((0,Y7.isCastType)(u)?a=u:(this.contextError(e,"unexpected-malloy-type",`'#' assertion for unknown type '${u}'`),a=void 0));let l=(0,kn.getOptionalId)(e)||((r=e.timeframe())===null||r===void 0?void 0:r.text);return l===void 0&&(this.contextError(e,"failed-to-parse-function-name","Function name error"),l="FUNCTION_NAME_ERROR"),te.ExprTimeExtract.extractor(l)?this.astAt(new te.ExprTimeExtract(l,s),e):this.astAt(new te.ExprFunc(l,s,o,a),e)}visitExprDuration(e){return new te.ExprDuration(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text)}visitCaseStatement(e){const n=e._valueExpr,r=n?this.getFieldExpr(n):void 0,i=e.caseWhen(),s=i.map(a=>new te.CaseWhen(this.getFieldExpr(a._condition),this.getFieldExpr(a._result))),o=e._caseElse,u=o?this.getFieldExpr(o):void 0;return this.warnWithReplacement("sql-case","Use a `pick` statement instead of `case`",this.parseInfo.rangeFromContext(e),`${[...n?[`${this.getSourceCode(n)} ?`]:[],...i.map(a=>`pick ${this.getSourceCode(a._result)} when ${this.getSourceCode(a._condition)}`),o?`else ${o.text}`:"else null"].join(" ")}`),new te.Case(r,s,u)}visitPickStatement(e){const n=e.pick().map(r=>{let i;return r._pickValue&&(i=this.getFieldExpr(r._pickValue)),new te.PickWhen(i,this.getFieldExpr(r._pickWhen))});return e.ELSE()?new te.Pick(n,this.getFieldExpr(e._pickElse)):new te.Pick(n)}visitExprFieldProps(e){const n=this.only(e.fieldProperties().fieldPropertyStatement().map(r=>this.visit(r)),r=>te.isFieldPropStatement(r)&&r,"field property statement");return new te.ExprProps(this.getFieldExpr(e.fieldExpr()),n)}visitPartitionByStatement(e){return this.astAt(new te.PartitionBy(e.id().map(n=>this.astAt(new te.PartitionByFieldReference([this.astAt(new te.FieldName((0,kn.idToStr)(n)),n)]),n))),e)}visitLiteralTimestamp(e){return this.parseTime(e,te.LiteralTimestamp.parse)}visitLiteralHour(e){return this.parseTime(e,te.LiteralHour.parse)}visitLiteralDay(e){return this.parseTime(e,te.LiteralDay.parse)}visitLiteralWeek(e){return this.parseTime(e,te.LiteralWeek.parse)}visitLiteralMonth(e){return this.parseTime(e,te.LiteralMonth.parse)}visitLiteralQuarter(e){return this.parseTime(e,te.LiteralQuarter.parse)}visitLiteralYear(e){return this.parseTime(e,te.LiteralYear.parse)}visitImportStatement(e){const n=this.getPlainStringFrom(e.importURL()),r=this.astAt(new te.ImportStatement(n,this.parseInfo.importBaseURL),e),i=e.importSelect();if(i)for(const s of i.importItem()){const o=s.id(),u=o[1]?this.astAt(new te.ImportSourceName((0,kn.idToStr)(o[1])),o[1]):void 0;r.push(this.astAt(new te.ImportSelect((0,kn.idToStr)(o[0]),u),o[0]))}return r}visitDebugExpr(e){return this.getFieldExpr(e.fieldExpr())}visitSampleStatement(e){const n=e.sampleSpec().INTEGER_LITERAL();if(n)return new te.SampleProperty({rows:this.getNumber(n)});const r=e.sampleSpec().PERCENT_LITERAL();if(r)return new te.SampleProperty({percent:this.getNumber(r)});const i=e.sampleSpec().TRUE()!==void 0;return new te.SampleProperty({enable:i})}visitDocAnnotations(e){const n=e.DOC_ANNOTATION().map(i=>({text:i.text,at:this.getLocation(e)})),r=new te.ModelAnnotation(n);return this.compilerFlags=r.getCompilerFlags(this.compilerFlags,this.msgLog),r}visitIgnoredObjectAnnotations(e){return this.contextError(e,"orphaned-object-annotation","Object annotation not connected to any object"),new K7(e.text)}visitIgnoredModelAnnotations(e){return this.contextError(e,"misplaced-model-annotation","Model annotations not allowed at this scope"),new K7(e.text)}visitDefExploreAnnotation(e){const n=this.getNotes(e);return new te.ObjectAnnotation(n)}getSQArgument(e){const n=e.argumentId(),r=n?this.astAt(new te.PartitionByFieldReference([this.astAt(new te.FieldName((0,kn.idToStr)(n.id())),n)]),n):void 0;return this.astAt(new te.Argument({id:r,value:this.getFieldExpr(e.fieldExpr())}),e)}getSQArguments(e){if(e!==void 0)return this.inExperiment("parameters",e),e.sourceArgument().map(n=>this.getSQArgument(n))}visitSQID(e){const n=this.getModelEntryName(e),r=this.getSQArguments(e.sourceArguments());return this.astAt(new te.SQReference(n,r),e.id())}getSqExpr(e){const n=this.visit(e);return n instanceof te.SourceQueryElement?n:(this.contextError(e,"unexpected-non-source-query-expression-node",`Expected a source/query expression, not '${n.elementType}'`),new AW)}visitSQExtendedSource(e){const n=this.getSqExpr(e.sqExpr()),r=e.includeBlock(),i=r?this.getIncludeItems(r):void 0,s=new te.SQExtend(n,this.getSourceExtensions(e.exploreProperties()),i);return this.astAt(s,e)}getIncludeItems(e){return this.inExperiment("access_modifiers",e),e.includeItem().map(n=>this.getIncludeItem(n)).filter(X6e.isNotUndefined)}getIncludeItem(e){var n;const r=e.tags(),i=r?this.getNotes(r):[],s=e.includeExceptList();if(s){r&&i.length>0&&this.contextError(r,"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const o=this.getExcludeList(s);return this.astAt(new te.IncludeExceptItem(o),e)}else{const o=e.includeList();if(o===void 0){this.contextError((n=e.orphanedAnnotation())!==null&&n!==void 0?n:e,"orphaned-object-annotation","This tag is not attached to anything",{severity:"warn"});return}const u=this.getAccessLabelProp(e.accessLabelProp()),a=this.getIncludeList(o),l=this.astAt(new te.IncludeAccessItem(u,a),e);return l.extendNote({blockNotes:i}),l}}getIncludeList(e){const n=e.includeField();if(n===void 0)throw this.internalError(e,"Expected a field name list");return n.map(r=>this.getIncludeListItem(r))}getExcludeList(e){return e.includeExceptListItem().map(n=>{n.tags().ANNOTATION().length>0&&this.contextError(n.tags(),"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const r=n.fieldName();if(r)return this.astAt(new te.AccessModifierFieldReference([this.astAt(new te.FieldName(n.text),n)]),r);const i=n.collectionWildCard();if(i)return this.astAt(this.visitCollectionWildCard(i),i);throw this.internalError(n,"Expected a field name or wildcard")})}getIncludeListItem(e){const n=e.collectionWildCard(),r=n?this.visitCollectionWildCard(n):void 0,i=e._as?e._as.text:void 0,s=e.tags(),o=s?this.getNotes(s):[],u=e.isDefine(),a=u?this.getIsNotes(u):[],l=[...o,...a],c=e._name?this.astAt(new te.AccessModifierFieldReference([this.astAt(this.getFieldName(e._name),e._name)]),e._name):void 0,f=c??r;if(f===void 0)throw this.internalError(e,"Expected a field name or wildcard");const d=this.astAt(new te.IncludeListItem(f,i),e);return d.extendNote({notes:l}),d}visitSQParens(e){const n=this.getSqExpr(e.sqExpr());return this.astAt(n,e)}visitSQCompose(e){const n=e.sqExpr().map(r=>this.getSqExpr(r));return this.inExperiment("composite_sources",e),this.astAt(new te.SQCompose(n),e)}visitSQArrow(e){const n=this.getSqExpr(e.sqExpr()),r=e.segExpr(),i=new te.SQArrow(n,this.getVExpr(r));return this.astAt(i,e)}getVExpr(e){const n=this.visit(e);if(n instanceof te.View)return n;throw this.internalError(e,`Expected view, got a '${n.elementType}'`)}visitSegField(e){return new te.ReferenceView(this.getFieldPath(e.fieldPath(),te.ViewOrScalarFieldReference))}visitSegOps(e){return new te.QOpDescView(this.visitQueryProperties(e.queryProperties()))}visitSegParen(e){return this.visit(e.vExpr())}visitVSeg(e){return this.visit(e.segExpr())}visitSegRefine(e){return new te.ViewRefine(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitVArrow(e){return new te.ViewArrow(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitSQRefinedQuery(e){const n=this.getSqExpr(e.sqExpr()),r=e.segExpr(),i=new te.SQRefine(n,this.getVExpr(r));return this.astAt(i,e)}visitSQTable(e){const n=this.visit(e.exploreTable());if(n instanceof Y6e.TableSource){const r=new te.SQSource(n);return this.astAt(r,e)}return new AW}visitSQSQL(e){const n=new te.SQSource(this.visitSqlSource(e.sqlSource()));return this.astAt(n,e)}visitExperimentalStatementForTesting(e){return this.inExperiment("compilerTestExperimentParse",e),this.astAt(new te.ExperimentalExperiment("compilerTestExperimentTranslate"),e)}visitRecordRef(e){const n=new te.ExprIdReference(this.getFieldPath(e.fieldPath(),te.ExpressionFieldReference));return this.astAt(new te.RecordElement({path:n}),e)}visitRecordExpr(e){const n=this.getFieldExpr(e.fieldExpr()),r=e.recordKey(),i=r?{key:(0,kn.getId)(r),value:n}:{value:n};return this.astAt(new te.RecordElement(i),e)}visitExprLiteralRecord(e){const n=this.only(e.recordElement().map(r=>this.astAt(this.visit(r),r)),r=>r instanceof te.RecordElement&&r,"a legal record property description");return new te.RecordLiteral(n)}visitExprArrayLiteral(e){const n=e.fieldExpr().map(i=>this.getFieldExpr(i)),r=new te.ArrayLiteral(n);return this.astAt(r,e)}visitExprWarnLike(e){let n="~";const r=e.fieldExpr(0),i=e.fieldExpr(1),s=this.parseInfo.rangeFromContext(e);return e.NOT()?(n="!~",this.warnWithReplacement("sql-not-like","Use Malloy operator '!~' instead of 'NOT LIKE'",s,`${this.getSourceCode(r)} !~ ${this.getSourceCode(i)}`)):this.warnWithReplacement("sql-like","Use Malloy operator '~' instead of 'LIKE'",s,`${this.getSourceCode(r)} ~ ${this.getSourceCode(i)}`),this.astAt(new te.ExprCompare(this.getFieldExpr(r),n,this.getFieldExpr(i)),e)}visitExprNullCheck(e){const n=e.fieldExpr();return this.astAt(new te.ExprIsNull(this.getFieldExpr(n),e.NOT()?"!=":"="),e)}visitExprWarnIn(e){const n=this.getFieldExpr(e.fieldExpr()),r=!!e.NOT(),i=e.fieldExprList().fieldExpr(),s=this.astAt(new te.ExprLegacyIn(n,r,i.map(o=>this.getFieldExpr(o))),e);return this.warnWithReplacement("sql-in",`Use = (a|b|c) instead of${r?" NOT":""} IN (a,b,c)`,this.parseInfo.rangeFromContext(e),`${this.getSourceCode(e.fieldExpr())} ${r?"!=":"="} (${i.map(o=>this.getSourceCode(o)).join(" | ")})`),s}}wS.MalloyToAST=eOe;var NS={};Object.defineProperty(NS,"__esModule",{value:!0}),NS.Zone=void 0;class tOe{constructor(){this.location={},this.zone=new Map}get(e){const n=this.zone.get(e);if((n==null?void 0:n.status)==="present")return n.value}getEntry(e){const n=this.zone.get(e);return n?n.firstReference||!this.location[e]?n:{...n,firstReference:this.location[e]}:{status:"error",message:"import reference failure"}}define(e,n){this.zone.set(e,{status:"present",value:n})}reference(e,n){const r=this.zone.get(e);(r==null?void 0:r.status)===void 0&&(this.zone.set(e,{status:"reference",firstReference:n}),this.location[e]=n)}getUndefined(){const e=[];for(const[n,r]of this.zone)r.status==="reference"&&e.push(n);return e.length>0?e:void 0}updateFrom(e,n){if(e)for(const[r,i]of Object.entries(e))i!==void 0&&this.define(r,i);if(n)for(const[r,i]of Object.entries(n))this.zone.set(r,{status:"error",message:i})}}NS.Zone=tOe;var FS={};Object.defineProperty(FS,"__esModule",{value:!0}),FS.walkForDocumentSymbols=void 0;const nOe=Ql,rOe=fn;class iOe{constructor(e,n,r,i){this.translator=e,this.tokens=n,this.scopes=r,this.symbols=i}popScope(){return this.scopes.pop()}peekScope(){return this.scopes[this.scopes.length-1]}enterTopLevelQueryDefs(e){const n=this.translator.rangeFromContext(e);e.topLevelQueryDef().length===1&&(this.blockRange=n)}enterTopLevelQueryDef(e){this.symbols.push({range:this.translator.rangeFromContext(e),name:e.queryName().text,type:"query",children:[],lensRange:this.blockRange}),this.blockRange=void 0}enterRunStatement(e){this.symbols.push({range:this.translator.rangeFromContext(e.topLevelAnonQueryDef()),name:"unnamed_query",type:"unnamed_query",children:[],lensRange:this.translator.rangeFromContext(e)})}enterAnonymousQuery(e){this.symbols.push({range:this.translator.rangeFromContext(e.topLevelAnonQueryDef().sqExpr()),name:"unnamed_query",type:"unnamed_query",children:[],lensRange:this.translator.rangeFromContext(e)})}enterDefineSourceStatement(e){const n=this.translator.rangeFromContext(e);e.sourcePropertyList().sourceDefinition().length===1&&(this.blockRange=n)}enterSourceDefinition(e){const n=this.translator.rangeFromContext(e);this.scopes.push({range:n,name:e.sourceNameDef().id().text,type:"explore",children:[],lensRange:this.blockRange}),this.blockRange=void 0}exitSourceDefinition(e){const n=this.popScope();n&&this.symbols.push(n)}enterDefExploreQuery(e){const n=this.translator.rangeFromContext(e);e.subQueryDefList().exploreQueryDef().length===1&&(this.blockRange=n)}enterExploreQueryDef(e){const n={range:this.translator.rangeFromContext(e),name:e.exploreQueryNameDef().id().text,type:"query",children:[],lensRange:this.blockRange},r=this.peekScope();r&&r.children.push(n),this.scopes.push(n),this.blockRange=void 0}exitExploreQueryDef(e){this.popScope()}getNestDefName(e){const n=e.queryName();if(n)return n.id().text;let r,i=!1;const s={enterVArrow(u){u.vExpr().enterRule(s)},enterVSeg(u){u.segExpr().enterRule(o)}},o={enterSegField(u){const a=u.fieldPath().fieldName();i||(r??(r=a[a.length-1].id().text))},enterSegParen(u){u.vExpr().enterRule(s)},enterSegRefine(u){u._lhs.enterRule(o)},enterSegOps(){r=void 0,i=!0}};return e.vExpr().enterRule(s),r}handleNestEntry(e){const n=this.getNestDefName(e);if(n===void 0)return;const r={range:this.translator.rangeFromContext(e),name:n,type:"query",children:[]},i=this.peekScope();return i&&i.children.push(r),r}enterNestDef(e){const n=this.handleNestEntry(e);n&&this.scopes.push(n)}exitNestDef(e){this.popScope()}enterFieldDef(e){const n={range:this.translator.rangeFromContext(e),name:e.fieldNameDef().id().text,type:"field",children:[]},r=this.peekScope();r&&r.children.push(n)}enterQueryFieldEntry(e){var n;const r=(n=e.taggedRef())===null||n===void 0?void 0:n.fieldPath();if(r===void 0)return;const i={range:this.translator.rangeFromContext(e),name:r.text,type:"field",children:[]},s=this.peekScope();s&&s.children.push(i)}enterExploreRenameDef(e){const n={range:this.translator.rangeFromContext(e),name:e.fieldName()[0].text,type:"field",children:[]},r=this.peekScope();r&&r.children.push(n)}enterJoinWith(e){this.handleJoinDef(e)}enterJoinOn(e){this.handleJoinDef(e)}handleJoinDef(e){const n={range:this.translator.rangeFromContext(e),name:e.joinFrom().joinNameDef().id().text,type:"join",children:[]},r=this.peekScope();r&&r.children.push(n)}enterImportStatement(e){const n=(0,rOe.getStringIfShort)(e.importURL());n&&this.scopes.push({range:this.translator.rangeFromContext(e),name:n,type:"import",children:[]})}exitImportStatement(){const e=this.popScope();e&&this.symbols.push(e)}enterImportSelect(e){const n=this.peekScope();if(n)for(const r of e.importItem()){const i={range:this.translator.rangeFromContext(e),name:r.text,type:"import_item",children:[]};n.children.push(i)}}}function sOe(t,e,n){const r=new iOe(t,e,[],[]),i=r;return nOe.ParseTreeWalker.DEFAULT.walk(i,n),r.symbols}FS.walkForDocumentSymbols=sOe;var LS={};Object.defineProperty(LS,"__esModule",{value:!0}),LS.walkForDocumentCompletions=void 0;const oOe=Ql,uOe=["dimension","measure","join_one","join_many","join_cross","where","primary_key","rename","accept","except","query","declare"],aOe=["group_by","project","index","aggregate","top","limit","order_by","where","having","nest","declare"],lOe=["source","explore","query","sql"];class cOe{constructor(e,n,r){this.tokens=e,this.completions=n,this.position=r}rangeOf(e){const n=e.stop||e.start;return{start:{line:e.start.line-1,character:e.start.charPositionInLine},end:{line:n.line-1,character:n.stopIndex-(n.startIndex-n.charPositionInLine)+1}}}inRange(e){const{start:n,end:r}=e,i=this.position.line>n.line||this.position.line===n.line&&this.position.character>=n.character,s=this.position.line<r.line||this.position.line===r.line&&this.position.character<=r.character;return i&&s}enterExploreProperties(e){if(this.inRange(this.rangeOf(e))){let n=!1;for(const r of e.exploreStatement())this.inRange(this.rangeOf(r))&&(n=!0);if(!n)for(const r of uOe)this.completions.push({type:"explore_property",text:`${r}: `})}}enterQueryProperties(e){if(this.inRange(this.rangeOf(e))){let n=!1;for(const r of e.queryStatement())this.inRange(this.rangeOf(r))&&(n=!0);if(!n)for(const r of aOe)this.completions.push({type:"query_property",text:`${r}: `})}}enterMalloyDocument(e){if(this.inRange(this.rangeOf(e))){let n=!1;for(const r of e.malloyStatement())this.inRange(this.rangeOf(r))&&(n=!0);if(!n)for(const r of lOe)this.completions.push({type:"model_property",text:`${r}: `})}}}function fOe(t,e,n){const r=new cOe(t,[],n),i=r;return oOe.ParseTreeWalker.DEFAULT.walk(i,e),r.completions}LS.walkForDocumentCompletions=fOe;var IS={};Object.defineProperty(IS,"__esModule",{value:!0}),IS.walkForDocumentHelpContext=void 0;const xOe=LR;class dOe extends xOe.AbstractParseTreeVisitor{constructor(e){super(),this.position=e,this.type=""}rangeOf(e){const n=e.stop||e.start;return{start:{line:e.start.line-1,character:e.start.charPositionInLine},end:{line:n.line-1,character:n.stopIndex-(n.startIndex-n.charPositionInLine)+1}}}inRange(e){return e.start.line<=this.position.line&&e.end.line>=this.position.line&&(this.position.line!==e.start.line||this.position.character>=e.start.character)&&(this.position.line!==e.end.line||this.position.character<=e.end.character)}defaultResult(){}visitChildren(e){let n=this.defaultResult();if(this.inRange(this.rangeOf(e))){n={type:this.type,token:e.start.text};const r=e.childCount;for(let i=0;i<r;i++){const o=e.getChild(i).accept(this);o&&(n=this.aggregateResult(n,o))}}return n}visitMalloyDocument(e){return this.inRange(this.rangeOf(e))?(this.type="model_property",this.visitChildren(e)):this.defaultResult()}visitExploreProperties(e){return this.inRange(this.rangeOf(e))?(this.type="explore_property",this.visitChildren(e)):this.defaultResult()}visitQueryProperties(e){return this.inRange(this.rangeOf(e))?(this.type="query_property",this.visitChildren(e)):this.defaultResult()}aggregateResult(e,n){return n}}function hOe(t,e){return new dOe(e).visit(t)}IS.walkForDocumentHelpContext=hOe;var BS={};Object.defineProperty(BS,"__esModule",{value:!0}),BS.ReferenceList=void 0;const pOe=bu;class gOe{constructor(e){this.sourceURL=e,this.references=[]}findIndexBefore(e){let n=0,r=this.references.length;for(;n<r;){const i=Math.floor((n+r)/2),s=this.references[i].location.range.end;s.line<e.line||s.line===e.line&&s.character<e.character?n=i+1:r=i}return n}add(e){if(e.location.url!==this.sourceURL)return;const n=this.findIndexBefore(e.location.range.end);n<this.references.length&&this.isPositionEqual(e,this.references[n])||this.references.splice(n,0,e)}isPositionEqual(e,n){const r=e.location.range,i=n.location.range;return r.start.line===i.start.line&&r.start.character===i.start.character&&r.end.line===i.end.line&&r.end.character===i.end.character}find(e){const n=this.findIndexBefore(e);if(n===this.references.length)return;const r=this.references[n];if((0,pOe.locationContainsPosition)(r.location,e))return r}}BS.ReferenceList=gOe;var $S={};Object.defineProperty($S,"__esModule",{value:!0}),$S.isNeedResponse=void 0;function mOe(t){return!!t&&(t.tables||t.urls||t.compileSQL)!==void 0}$S.isNeedResponse=mOe;var kS={};Object.defineProperty(kS,"__esModule",{value:!0}),kS.walkForModelAnnotation=void 0;const yOe=Ql;class EOe{constructor(e,n,r){this.translator=e,this.tokens=n,this.parseInfo=r,this.notes=[]}getLocation(e){return{url:this.parseInfo.sourceURL,range:this.parseInfo.rangeFromContext(e)}}enterDocAnnotations(e){const n=e.DOC_ANNOTATION().map(r=>({text:r.text,at:this.getLocation(e)}));this.notes.push(...n)}get annotation(){return{notes:this.notes}}}function AOe(t,e,n){const r=new EOe(t,e,n),i=r;return yOe.ParseTreeWalker.DEFAULT.walk(i,n.root),r.annotation}kS.walkForModelAnnotation=AOe;var MS={};Object.defineProperty(MS,"__esModule",{value:!0}),MS.walkForTablePath=void 0;const vW=fn,vOe=Ql;class _Oe{constructor(e,n){this.translator=e,this.tokens=n,this.pathInfos=[]}enterTableMethod(e){const n=(0,vW.getId)(e.connectionId()),[r,i]=(0,vW.getPlainString)(e.tablePath(),!0);r!==void 0&&this.pathInfos.push({connectionId:n,tablePath:r,range:this.translator.rangeFromContext(e)})}}function SOe(t,e,n){const r=new _Oe(t,e),i=r;return vOe.ParseTreeWalker.DEFAULT.walk(i,n.root),r.pathInfos}MS.walkForTablePath=SOe;var PS={},sm={};Object.defineProperty(sm,"__esModule",{value:!0}),sm.checkCustomErrorMessage=void 0;const COe=(t,e,n)=>{const r=t.getRuleInvocationStack()[0],i=t.currentToken;for(const s of n){const o=!s.currentToken||i.type===s.currentToken,u=!s.offendingSymbol||(e==null?void 0:e.type)===s.offendingSymbol,a=!s.ruleContextOptions||s.ruleContextOptions.includes(r);if(o&&u&&a){if(s.precedingTokenOptions&&!s.precedingTokenOptions.some(f=>_W(t,f,"lookback"))||s.lookAheadOptions&&!s.lookAheadOptions.some(f=>_W(t,f,"lookahead")))continue;return s.errorMessage.replace("${currentToken}",(e==null?void 0:e.text)||i.text||"")}}return""};sm.checkCustomErrorMessage=COe;const _W=(t,e,n)=>{try{for(let r=0;r<e.length;r++){const i=n==="lookahead"?r+2:-1*(r+1),s=t.inputStream.LA(i);if(e[r]>=-1&&s!==e[r]||e[r]<-1&&s===-1*e[r])return!1}return!0}catch{return!1}};Object.defineProperty(PS,"__esModule",{value:!0}),PS.MalloyErrorStrategy=void 0;const bOe=eg,SW=L,TOe=sm,ROe=[{errorMessage:"Missing '{' after 'extend'",currentToken:SW.MalloyParser.EXTEND,ruleContextOptions:["sqExpr"],lookAheadOptions:[[-SW.MalloyParser.OCURLY]]}];class OOe extends bOe.DefaultErrorStrategy{sync(e){const n=(0,TOe.checkCustomErrorMessage)(e,void 0,ROe);if(n){e.notifyErrorListeners(n,e.currentToken,void 0);return}super.sync(e)}}PS.MalloyErrorStrategy=OOe;var CW={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MalloyParserErrorListener=t.commonErrorCases=void 0;const e=L,n=sm,r=pg;t.commonErrorCases=[{errorMessage:"'view:' must be followed by '<identifier> is {'",ruleContextOptions:["exploreQueryDef"],offendingSymbol:e.MalloyParser.OCURLY,precedingTokenOptions:[[e.MalloyParser.VIEW],[e.MalloyParser.COLON]]},{errorMessage:"Missing '}' at '${currentToken}'",ruleContextOptions:["vExpr"],offendingSymbol:e.MalloyParser.VIEW,currentToken:e.MalloyParser.OCURLY},{errorMessage:"Missing '}' at '${currentToken}'",ruleContextOptions:["exploreProperties","queryProperties","exploreStatement"],lookAheadOptions:[[e.MalloyParser.EOF],[e.MalloyParser.RUN],[e.MalloyParser.SOURCE]]}];class i{constructor(o,u){this.translator=o,this.messages=u}logError(o,u,a){return this.messages.log((0,r.makeLogMessage)(o,u,{severity:"error",...a})),o}syntaxError(o,u,a,l,c,f){const d={line:a-1,character:l},h=u?this.translator.rangeFromToken(u):{start:d,end:d},p=(0,n.checkCustomErrorMessage)(o,u,t.commonErrorCases);p&&(c=p),this.logError("syntax-error",{message:c},{at:{url:this.translator.sourceURL,range:h}})}}t.MalloyParserErrorListener=i})(CW);var DOe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),wOe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),NOe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&DOe(e,t,n);return wOe(e,t),e};Object.defineProperty(o0,"__esModule",{value:!0}),o0.MalloyTranslator=o0.MalloyChildTranslator=o0.MalloyTranslation=void 0;const bW=eg,FOe=Ke,LOe=ZA,IOe=L,TW=NOe(Hv),BOe=wS,RW=pg,$Oe=Qa,J7=NS,kOe=FS,MOe=LS,POe=IS,UOe=BS,US=$S,jOe=bu,OW=fo,qOe=kS,HOe=MS,zOe=PS,QOe=CW;class GOe extends LOe.MalloyLexer{popMode(){return this._modeStack.isEmpty?this._mode:super.popMode()}}class WOe{step(e){if(this.response)return this.response;if(!e.urlIsFullPath)return e.fatalResponse();const n=e.root.importZone.getEntry(e.sourceURL);if(n.status!=="present"){if(n.status==="error"){const s=n.firstReference||e.defaultLocation();return e.root.logError("import-error",{message:n.message,url:e.sourceURL},{at:s}),this.response=e.fatalResponse(),this.response}return{urls:[e.sourceURL]}}const r=n.value===""?`
1262
+ `)),p_.ErrorFactory.structDef}else if(i.status==="present"){const s=this.select.location,o={...i.value,fields:i.value.fields.map(l=>({...l,location:s})),location:this.location},u=this.document(),a=u==null?void 0:u.currentModelAnnotation();return a&&(o.modelAnnotation=a),o}else return this.logError("non-top-level-sql-source","`connection_name.sql(...)` can currently only be used in top level source/query definitions"),p_.ErrorFactory.structDef}}Hg.SQLSource=bSe,Object.defineProperty(d_,"__esModule",{value:!0}),d_.SQSource=void 0;const TSe=Do,RSe=qg,OSe=Hg;class DSe extends TSe.SourceQueryElement{constructor(e){super({theSource:e}),this.theSource=e,this.elementType="sq-source"}isSource(){return!0}getSource(){return this.theSource}getQuery(){if(this.theSource instanceof OSe.SQLSource){const e=new RSe.QueryRaw(this.theSource);return this.has({rawQuery:e}),e}else this.sqLog("invalid-source-as-query","This source cannot be used as a query")}}d_.SQSource=DSe;var g_={};Object.defineProperty(g_,"__esModule",{value:!0}),g_.SQExtend=void 0;const wSe=mg,NSe=Do;class FSe extends NSe.SourceQueryElement{constructor(e,n,r){super({sqSrc:e,extend:n}),this.sqSrc=e,this.extend=n,this.includeList=r,this.elementType="sq-extend"}getSource(){if(this.asSource)return this.asSource;const e=this.sqSrc.getSource();if(e)return this.asSource=new wSe.RefinedSource(e,this.extend,this.includeList),this.has({asSource:this.asSource}),this.asSource;this.sqLog("failed-to-compute-source-to-extend","Could not compute source to extend")}isSource(){return!0}}g_.SQExtend=FSe;var m_={},y_={};Object.defineProperty(y_,"__esModule",{value:!0}),y_.CompositeSource=void 0;const LSe=Ke,ISe=Ms;class BSe extends ISe.Source{constructor(e){super({sources:e}),this.sources=e,this.elementType="compositeSource"}getSourceDef(e){return this.withParameters(e,[])}withParameters(e,n){const r=this.sources.map(l=>l.withParameters(e,n)),i=r[0].connection,s=r[0].dialect,o="composite_source",u=[],a=new Map;return this.sources.forEach((l,c)=>{var f;const d=r[c];d.connection!==i&&l.logError("composite-source-connection-mismatch",`All sources in a composite source must share the same connection; connection \`${d.connection}\` differs from previous connection \`${i}\``);for(const h of d.fields){if(!(0,LSe.isAtomic)(h)){l.logWarning("composite-source-atomic-fields-only",`Only atomic fields are supported in composite sources; field \`${h.name}\` is not atomic and will be ignored`);continue}if(h.accessModifier==="private")continue;const p=(f=h.as)!==null&&f!==void 0?f:h.name,m=a.get(p);if(m===void 0){const g={...h,name:p,as:void 0,e:{node:"compositeField"},compositeFieldUsage:{fields:[p],joinedUsage:{}},code:this.code,location:this.codeLocation};a.set(p,g),u.push(g)}else h.accessModifier==="internal"&&(m.accessModifier="internal")}}),{type:"composite",sources:r,connection:i,fields:u,dialect:s,name:o,parameters:r[0].parameters}}}y_.CompositeSource=BSe,Object.defineProperty(m_,"__esModule",{value:!0}),m_.SQCompose=void 0;const $Se=y_,kSe=Do;class MSe extends kSe.SourceQueryElement{constructor(e){super({sources:e}),this.sources=e,this.elementType="sq-compose"}getSource(){if(this.asSource)return this.asSource;const e=this.sources.map(n=>n.getSource());if(e.length===0){this.sqLog("empty-composite-source","Composite source must have at least one input source");return}else e.length===1&&this.sqLog("unnecessary-composite-source","A composite source with one input is equivalent to that input",{severity:"warn"});if(PSe(e))return this.asSource=new $Se.CompositeSource(e),this.has({asSource:this.asSource}),this.asSource;this.sqLog("invalid-composite-source-input","All composite source inputs must be valid sources")}isSource(){return!0}}m_.SQCompose=MSe;function PSe(t){return t.every(e=>e!==void 0)}var E_={},qa={},zg={},USe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),jSe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),qSe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&USe(e,t,n);return jSe(e,t),e};Object.defineProperty(zg,"__esModule",{value:!0}),zg.BinaryBoolean=void 0;const HSe=fs,zSe=qSe(Wt),QSe=wo,GSe=Pt,WSe=ct;class VSe extends WSe.ExpressionDef{constructor(e,n,r){super({left:e,right:r}),this.left=e,this.op=n,this.right=r,this.elementType="abstract boolean binary",this.legalChildTypes=[zSe.boolT]}getExpression(e){const n=this.left.getExpression(e),r=this.right.getExpression(e);return this.typeCheck(this.left,n)&&this.typeCheck(this.right,r)?(0,GSe.computedExprValue)({dataType:{type:"boolean"},value:{node:(0,QSe.getExprNode)(this.op),kids:{left:n.value,right:r.value}},from:[n,r]}):(0,HSe.errorFor)("logical-op expected boolean")}}zg.BinaryBoolean=VSe;var YSe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),KSe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),JSe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&YSe(e,t,n);return KSe(e,t),e};Object.defineProperty(qa,"__esModule",{value:!0}),qa.ExprLegacyIn=qa.ExprEquality=qa.ExprCompare=void 0;const tn=JSe(Wt),XSe=Pt,ZSe=ct,eCe=zg,tCe={"~":[tn.stringT],"!~":[tn.stringT],"<":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],"<=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],"=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],"!=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],">=":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT],">":[tn.numberT,tn.stringT,tn.dateT,tn.timestampT]};class xG extends eCe.BinaryBoolean{constructor(e,n,r){super(e,n,r),this.elementType="a<=>b",this.legalChildTypes=tCe[n]}getExpression(e){return this.right.apply(e,this.op,this.left)}}qa.ExprCompare=xG;class nCe extends xG{constructor(e,n,r){super(e,n,r),this.elementType="a~=b"}getExpression(e){return this.right.apply(e,this.op,this.left,!0)}apply(e,n,r){return super.apply(e,n,r,!0)}}qa.ExprEquality=nCe;class rCe extends ZSe.ExpressionDef{constructor(e,n,r){super(),this.expr=e,this.notIn=n,this.choices=r,this.elementType="in",this.has({expr:e,choices:r})}getExpression(e){const n=this.expr.getExpression(e),r=this.choices.map(i=>i.getExpression(e));return(0,XSe.computedExprValue)({dataType:{type:"boolean"},value:{node:"in",not:this.notIn,kids:{e:n.value,oneOf:r.map(i=>i.value)}},from:[n,...r]})}}qa.ExprLegacyIn=rCe;var Qg={},gh={};Object.defineProperty(gh,"__esModule",{value:!0}),gh.ExprTime=void 0;const iCe=Ke,sCe=Pt,oCe=ct;class x7 extends oCe.ExpressionDef{constructor(e,n,r){super(),this.elementType="timestampOrDate",this.elementType=e,this.translationValue=(0,sCe.computedExprValue)({dataType:{type:e},value:n,from:r??[]})}getExpression(e){return this.translationValue}static fromValue(e,n){let r=n.value;if(e!==n.type){const i={node:"cast",safe:!1,dstType:{type:e},e:n.value};(0,iCe.isTemporalType)(n.type)&&(i.srcType={type:n.type}),r=i}return new x7(e,r,[n])}}gh.ExprTime=x7;var y0={};Object.defineProperty(y0,"__esModule",{value:!0}),y0.Range=void 0;const uCe=fs,aCe=Pt,lCe=ct;class cCe extends lCe.ExpressionDef{constructor(e,n){super({first:e,last:n}),this.first=e,this.last=n,this.elementType="range"}apply(e,n,r){switch(n){case"=":case"!=":{const i=n==="="?">=":"<",s=n==="="?"and":"or",o=n==="="?"<":">=",u=this.first.apply(e,i,r),a=this.last.apply(e,o,r);return(0,aCe.computedExprValue)({dataType:{type:"boolean"},value:{node:s,kids:{left:u.value,right:a.value}},from:[u,a]})}case">":return this.last.apply(e,">=",r);case">=":return this.first.apply(e,">=",r);case"<":return this.first.apply(e,"<",r);case"<=":return this.last.apply(e,"<",r)}throw new Error("mysterious error in range computation")}requestExpression(e){}getExpression(e){return this.logError("range-as-value","A Range is not a value"),(0,uCe.errorFor)("a range is not a value")}}y0.Range=cCe;var fCe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),xCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dCe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&fCe(e,t,n);return xCe(e,t),e};Object.defineProperty(Qg,"__esModule",{value:!0}),Qg.ExprGranularTime=void 0;const d7=Ke,hCe=fs,dG=dCe(Wt),hG=Li,pCe=ct,A_=gh,pG=y0;class gCe extends pCe.ExpressionDef{constructor(e,n,r){super({expr:e}),this.expr=e,this.units=n,this.truncate=r,this.elementType="granularTime",this.legalChildTypes=[dG.timestampT,dG.dateT]}granular(){return!0}getExpression(e){const n=this.units,r=this.expr.getExpression(e);if(d7.TD.isTemporal(r)){const s={...r,timeframe:n};return this.truncate&&(s.value={node:"trunc",e:(0,d7.mkTemporal)(r.value,r.type),units:n}),s}r.type!=="error"&&this.logError("unsupported-type-for-time-truncation",`Cannot do time truncation on type '${r.type}'`);const i={...r};return r.type==="error"&&(i.type=(0,d7.isDateUnit)(n)?"date":"timestamp"),{...i,value:(0,hCe.errorFor)("granularity typecheck").value,evalSpace:"constant"}}toRange(e){const n=this.getExpression(e),r={node:"numberLiteral",literal:"1"};if(n.type==="timestamp"){const u=A_.ExprTime.fromValue("timestamp",n),a=new A_.ExprTime("timestamp",(0,hG.timeOffset)("timestamp",n.value,"+",r,this.units),[n]);return new pG.Range(u,a)}const i=new A_.ExprTime("date",n.value,[n]),s=(0,hG.timeOffset)("date",n.value,"+",r,this.units),o=new A_.ExprTime("date",s,[n]);return new pG.Range(i,o)}}Qg.ExprGranularTime=gCe,Object.defineProperty(E_,"__esModule",{value:!0}),E_.Apply=void 0;const mCe=qa,yCe=ph,gG=Qg;class ECe extends mCe.ExprCompare{constructor(e,n){super(e,"=",n),this.left=e,this.right=n,this.elementType="apply"}getExpression(e){let n=this.right;if(!this.right.granular()){const r=this.right.requestExpression(e);r&&(0,yCe.isGranularResult)(r)&&(n=new gG.ExprGranularTime(this.right,r.timeframe,!1))}return n instanceof gG.ExprGranularTime?n.toRange(e).apply(e,this.op,this.left):super.getExpression(e)}}E_.Apply=ECe;var mh={},ACe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),vCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),_Ce=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&ACe(e,t,n);return vCe(e,t),e};Object.defineProperty(mh,"__esModule",{value:!0}),mh.BinaryNumeric=void 0;const SCe=_Ce(Wt),CCe=ct;class bCe extends CCe.ExpressionDef{constructor(e,n,r){super({left:e,right:r}),this.left=e,this.op=n,this.right=r,this.elementType="numeric binary abstract",this.legalChildTypes=[SCe.numberT]}getExpression(e){return this.right.apply(e,this.op,this.left)}}mh.BinaryNumeric=bCe;var v_={},TCe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),RCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),OCe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&TCe(e,t,n);return RCe(e,t),e};Object.defineProperty(v_,"__esModule",{value:!0}),v_.Boolean=void 0;const DCe=ct,wCe=OCe(Wt);let NCe=class extends DCe.ExpressionDef{constructor(e){super(),this.value=e,this.elementType="boolean literal"}getExpression(){return{...wCe.boolT,value:{node:this.value}}}};v_.Boolean=NCe;var E0={};Object.defineProperty(E0,"__esModule",{value:!0}),E0.FunctionOrdering=E0.FunctionOrderBy=void 0;const h7=Ke,mG=Ye,FCe=Tf;class LCe extends mG.MalloyElement{constructor(e,n){super(),this.field=e,this.dir=n,this.elementType="orderBy",e&&this.has({field:e})}getAnalyticOrderBy(e){if(!this.field)return this.logError("analytic-order-by-missing-field","analytic `order_by` must specify an aggregate expression or output field reference"),{node:"functionOrderBy",e:{node:"error"},dir:this.dir};const n=this.field.getExpression(e);return(0,h7.expressionIsAggregate)(n.expressionType)||((0,h7.expressionIsScalar)(n.expressionType)?(!(this.field instanceof FCe.ExprIdReference)||n.evalSpace==="input")&&this.field.logError("analytic-order-by-not-output","analytic `order_by` must be an aggregate or an output field reference"):this.field.logError("analytic-order-by-not-aggregate-or-output","analytic `order_by` must be scalar or aggregate")),{node:"functionOrderBy",e:n.value,dir:this.dir}}getAggregateOrderBy(e,n){if(this.field){const r=this.field.getExpression(e);return(0,h7.expressionIsScalar)(r.expressionType)||this.field.logError("aggregate-order-by-not-scalar","aggregate `order_by` must be scalar"),n||this.field.logError("aggregate-order-by-expression-not-allowed","`order_by` must be only `asc` or `desc` with no expression"),{node:"functionOrderBy",e:r.value,dir:this.dir}}else return this.dir===void 0?(this.logError("aggregate-order-by-without-field-or-direction","field or order direction must be specified"),{node:"functionDefaultOrderBy",dir:"asc"}):{node:"functionDefaultOrderBy",dir:this.dir}}}E0.FunctionOrderBy=LCe;class ICe extends mG.ListOf{constructor(e){super(e),this.elementType="function-ordering"}getAnalyticOrderBy(e){return this.list.map(n=>n.getAnalyticOrderBy(e))}getAggregateOrderBy(e,n){return this.list.map(r=>r.getAggregateOrderBy(e,n))}}E0.FunctionOrdering=ICe;var __={};Object.defineProperty(__,"__esModule",{value:!0}),__.ExprAddSub=void 0;const BCe=mh;class $Ce extends BCe.BinaryNumeric{constructor(){super(...arguments),this.elementType="+-"}}__.ExprAddSub=$Ce;var Ha={},kCe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),MCe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),PCe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&kCe(e,t,n);return MCe(e,t),e};Object.defineProperty(Ha,"__esModule",{value:!0}),Ha.ExprAggregateFunction=void 0;const Gg=Ke,UCe=Ft,jCe=fs,yG=Cr,EG=PCe(Wt),qCe=pt,HCe=ct,zCe=Sr,QCe=Tf;class GCe extends HCe.ExpressionDef{constructor(e,n,r){super(),this.func=e,this.legalChildTypes=[EG.numberT],this.elementType=e,this.explicitSource=r,n&&(this.expr=n,this.has({expr:n}))}getExpression(e){var n,r,i;const s=e.isQueryFieldSpace()?e.inputSpace():e;let o=this.expr,u=(n=this.expr)===null||n===void 0?void 0:n.getExpression(s),a=(r=this.source)===null||r===void 0?void 0:r.path,l=[];if(this.source){const f=this.source.getField(s);if(f.found){l=f.joinPath;const d=f.found,h=d.typeDesc();if(!(d instanceof yG.StructSpaceField))if((0,Gg.isAtomicFieldType)(h.type)){o=this.source,u={...EG.atomicDef(h),expressionType:h.expressionType,value:h.evalSpace==="output"?{node:"outputField",name:this.source.refString}:{node:"field",path:this.source.path},evalSpace:h.evalSpace,compositeFieldUsage:h.compositeFieldUsage},a=this.source.path.slice(0,-1);const p=this.getJoinUsage(s);(p.length===1||p.length>1&&p.slice(1).every(g=>WCe(g,p[0])))&&(a=p[0].map(g=>g.name),l=p[0])}else return this.loggedErrorExpr("invalid-aggregate-source",`Aggregate source cannot be a ${h.type}`)}else return this.loggedErrorExpr("aggregate-source-not-found",`Reference to undefined value ${this.source.refString}`)}if(u===void 0)return this.loggedErrorExpr("missing-aggregate-expression","Missing expression for aggregate function");if((0,Gg.expressionIsAggregate)(u.expressionType))return this.loggedErrorExpr("aggregate-of-aggregate","Aggregate expression cannot be aggregate");if(!(u.type==="error")){const f=this.getJoinUsage(s),d=this.source!==void 0||this.explicitSource;if(o&&!(!this.source&&f.every(p=>p.length===0))&&!this.isSymmetricFunction()){const p=g7(l,f),m=m7(this.elementType,p),g=d?m==null?void 0:m.message:"Join path is required for this calculation";if(g){const y=VCe(g,f,o,this.elementType),E=(i=m==null?void 0:m.code)!==null&&i!==void 0?i:"bad-join-usage";m?this.logError(E,y):this.logWarning(E,y)}}}if(this.typeCheck(this.expr||this,{...u,expressionType:"scalar"})){const f={node:"aggregate",function:this.func,e:u.value};return a&&a.length>0&&(f.structPath=a),{...this.returns(u),expressionType:"aggregate",value:f,evalSpace:"output"}}return(0,jCe.errorFor)("aggregate type check")}isSymmetricFunction(){return!0}getJoinUsage(e){const n=[];if(this.source&&this.source.getField(e).found){const i={node:"field",path:this.source.path};n.push(...p7(e,i))}if(this.expr){const r=this.expr.getExpression(e).value;n.push(...p7(e,r))}return n}}Ha.ExprAggregateFunction=GCe;function WCe(t,e){let n=t.length;if(n!==e.length)return!1;for(;n>0;)if(n-=1,t[n].name!==e[n].name)return!1;return!0}function p7(t,e){const n=[],r=(i,s)=>{const o=s[0],u=s.slice(1),a=i.entry(o);if(a===void 0)throw new Error(`Invalid field lookup ${o}`);if(a instanceof yG.StructSpaceField&&u.length>0){const l=r(a.fieldSpace,u);return{...l,joinPath:[{...a.joinPathElement,name:o},...l.joinPath]}}else if(a instanceof zCe.SpaceField){if(u.length!==0)throw new Error(`${o} cannot contain a ${u.join(".")}`);const l=a.fieldDef();if(l)return{fs:i,def:l,joinPath:[]};throw new Error("No field def")}else throw new Error("expected a field def or struct")};for(const i of(0,UCe.exprWalk)(e))if(i.node==="field"){const s=r(t,i.path),o=s.def;if((0,Gg.isAtomic)(o)&&!(0,Gg.isJoined)(o))if((0,Gg.hasExpression)(o)){const u=p7(s.fs,o.e);n.push(...u.map(a=>[...s.joinPath,...a]))}else n.push(s.joinPath)}else if(i.node==="source-reference")if(i.path){const s=r(t,i.path);n.push(s.joinPath)}else n.push([]);return n}function g7(t,e){const n=[];for(const r of e){let i=0;for(let a=0;a<t.length&&a<r.length&&t[a].name===r[a].name;a++)i=a+1;const s=t.slice(i),o=r.slice(i),u=[...s.map(a=>({...a,reverse:!0})),...o.map(a=>({...a,reverse:!1}))];n.push(u)}return n}function m7(t,e){for(const n of e)for(const r of n){if(r.joinType==="cross")return{code:"aggregate-traverses-join-cross",message:`Cannot compute \`${t}\` across \`join_cross\` relationship \`${r.name}\``};if(r.joinElementType==="array"&&!r.reverse)return{code:"aggregate-traverses-repeated-relationship",message:`Cannot compute \`${t}\` across repeated relationship \`${r.name}\``};if(r.joinType==="many"&&!r.reverse)return{code:"aggregate-traverses-join-many",message:`Cannot compute \`${t}\` across \`join_many\` relationship \`${r.name}\``}}}function VCe(t,e,n,r){if(e.length===0)return t;let i=e[0];for(const p of e.slice(1))for(let m=0;m<i.length;m++){const g=i[m],y=p[m];if(g.name!==y.name){i=i.slice(0,m);break}}const s=g7(i,e),o=m7(r,s),u=i.slice().reverse().findIndex(p=>p.joinType==="many"||p.joinType==="cross"),a=u===-1?0:i.length-u,l=i.slice(0,a),c=g7(l,e),f=m7(r,c),d=i.length>0?i.map(p=>p.name).join("."):"source",h=l.length>0?l.map(p=>p.name).join("."):"source";if(o)return"Aggregated dimensional expression contains multiple join paths; rewrite, for example `sum(first_join.field + second_join.field)` as `first_join.field.sum() + second_join.field.sum()`";{const p=n instanceof qCe.FieldReference?`${n.refString}.${r}()`:n instanceof QCe.ExprIdReference?`${n.fieldReference.refString}.${r}()`:`${d}.${r}(${n.code})`,m=`${h}.${r}(${n.code})`;let g=`${t}; use \`${p}\``;return f===void 0&&h!==d&&(g+=` or \`${m}\` to get a result weighted with respect to \`${h}\``),g}}var S_={};Object.defineProperty(S_,"__esModule",{value:!0}),S_.ExprAlternationTree=void 0;const AG=Pt,yh=ct,YCe=wo;function y7(t){const e=t.atExpr();switch(e.atNodeType()){case yh.ATNodeType.And:case yh.ATNodeType.Partial:return;case yh.ATNodeType.Or:{if(e instanceof vG){const n=y7(e.left);if(n){const r=y7(e.right);if(r)return[...n,...r]}}return}default:return e.granular()?void 0:[e]}}class vG extends yh.ExpressionDef{constructor(e,n,r){super({left:e,right:r}),this.left=e,this.op=n,this.right=r,this.elementType="alternation",this.elementType=`${n}alternation${n}`}equalityList(){return this.inList===void 0&&(this.inList=y7(this)||[]),this.inList}apply(e,n,r,i){if((0,YCe.isEquality)(n)){const u=this.equalityList();if(u.length>0&&(n==="="||n==="!=")){const a=r.getExpression(e),l=u.map(c=>c.getExpression(e));return(0,AG.computedExprValue)({dataType:{type:"boolean"},value:{node:"in",not:n==="!=",kids:{e:a.value,oneOf:l.map(c=>c.value)}},from:[a,...l]})}u.length===0&&i&&this.logWarning("or-choices-only",`Only | seperated values are legal when used with ${n} operator`)}const s=this.left.apply(e,n,r),o=this.right.apply(e,n,r);return(0,AG.computedExprValue)({dataType:{type:"boolean"},value:{node:this.op==="&"?"and":"or",kids:{left:s.value,right:o.value}},from:[s,o]})}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("alternation-as-value","Alternation tree has no value")}atNodeType(){return this.op==="|"?yh.ATNodeType.Or:yh.ATNodeType.And}}S_.ExprAlternationTree=vG;var Eh={};Object.defineProperty(Eh,"__esModule",{value:!0}),Eh.ExprAsymmetric=void 0;const KCe=Ha;class JCe extends KCe.ExprAggregateFunction{constructor(e,n,r,i){super(e,n,i),this.func=e,this.expr=n,this.source=r,this.has({source:r})}isSymmetricFunction(){return!1}returns(e){return e}defaultFieldName(){if(this.source&&this.expr===void 0){const e=this.source.nameString;switch(this.func){case"sum":return`total_${e}`;case"avg":return`avg_${e}`}}}}Eh.ExprAsymmetric=JCe;var C_={};Object.defineProperty(C_,"__esModule",{value:!0}),C_.ExprAvg=void 0;const XCe=Eh;class ZCe extends XCe.ExprAsymmetric{constructor(e,n,r){super("avg",e,n,r),this.has({source:n})}}C_.ExprAvg=ZCe;var b_={};Object.defineProperty(b_,"__esModule",{value:!0}),b_.ExprCast=void 0;const e5e=Li,t5e=Pt,n5e=ct;class r5e extends n5e.ExpressionDef{constructor(e,n,r=!1){super({expr:e}),this.expr=e,this.castType=n,this.safe=r,this.elementType="cast"}getExpression(e){const n=this.expr.getExpression(e);let r={type:"error"};if(typeof this.castType=="string")r={type:this.castType};else{const i=e.dialectObj();i&&(i.validateTypeName(this.castType.raw)?r=i.sqlTypeToMalloyType(this.castType.raw):this.logError("invalid-sql-native-type",`Cast type \`${this.castType.raw}\` is invalid for ${i.name} dialect`),this.safe&&!i.supportsSafeCast&&this.logError("dialect-cast-unsafe-only",`The SQL dialect '${e.dialectName()}' does not supply a safe cast operator`))}return(0,t5e.computedExprValue)({dataType:r,value:(0,e5e.castTo)(this.castType,n.value,n.type,this.safe),from:[n]})}}b_.ExprCast=r5e;var T_={},i5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),s5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&i5e(e,t,n);return s5e(e,t),e};Object.defineProperty(T_,"__esModule",{value:!0}),T_.ExprCoalesce=void 0;const _G=ts,SG=o5e(Wt),u5e=ct;class a5e extends u5e.ExpressionDef{constructor(e,n){super({expr:e,altExpr:n}),this.expr=e,this.altExpr=n,this.elementType="coalesce expression",this.legalChildTypes=SG.anyAtomicT}getExpression(e){const n=this.expr.getExpression(e),r=this.altExpr.getExpression(e);return n.type==="null"?r:(SG.typeEq(n,r)||this.logError("mismatched-coalesce-types",`Mismatched types for coalesce (${n.type}, ${r.type})`),{...n.type==="error"?r:n,expressionType:(0,_G.maxExpressionType)(n.expressionType,r.expressionType),value:{node:"coalesce",kids:{left:n.value,right:r.value}},evalSpace:(0,_G.mergeEvalSpaces)(n.evalSpace,r.evalSpace)})}}T_.ExprCoalesce=a5e;var R_={};Object.defineProperty(R_,"__esModule",{value:!0}),R_.ExprCount=void 0;const l5e=at,c5e=Ha;class f5e extends c5e.ExprAggregateFunction{constructor(e){super("count"),this.source=e,this.elementType="count",this.has({source:e})}defaultFieldName(){if(this.source)return"count_"+this.source.nameString}returns(e){return{type:"number",numberType:"integer",evalSpace:e.evalSpace,expressionType:"aggregate",value:e.value,compositeFieldUsage:e.compositeFieldUsage}}getExpression(e){const n={node:"aggregate",function:"count",e:{node:""}};return this.source&&(n.structPath=this.source.path),{type:"number",numberType:"integer",expressionType:"aggregate",value:n,evalSpace:"output",compositeFieldUsage:(0,l5e.emptyCompositeFieldUsage)()}}}R_.ExprCount=f5e;var O_={},x5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),d5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),h5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&x5e(e,t,n);return d5e(e,t),e};Object.defineProperty(O_,"__esModule",{value:!0}),O_.ExprCountDistinct=void 0;const D_=h5e(Wt),p5e=Ha;class g5e extends p5e.ExprAggregateFunction{constructor(e){super("distinct",e),this.legalChildTypes=[D_.numberT,D_.stringT,D_.dateT,D_.timestampT]}returns(e){return{type:"number",numberType:"integer",evalSpace:e.evalSpace,expressionType:"aggregate",value:e.value,compositeFieldUsage:e.compositeFieldUsage}}}O_.ExprCountDistinct=g5e;var w_={},A0={};Object.defineProperty(A0,"__esModule",{value:!0}),A0.Limit=void 0;const m5e=Ye,y5e=wn;class E5e extends m5e.MalloyElement{constructor(e){super(),this.limit=e,this.elementType="limit",this.queryRefinementStage=y5e.LegalRefinementStage.Tail,this.forceQueryClass=void 0}}A0.Limit=E5e;var Ah={};Object.defineProperty(Ah,"__esModule",{value:!0}),Ah.PartitionBy=void 0;const A5e=Ye;class v5e extends A5e.ListOf{constructor(e){super(e),this.partitionFields=e,this.elementType="partition_by"}}Ah.PartitionBy=v5e;var Wg={},v0={};Object.defineProperty(v0,"__esModule",{value:!0}),v0.FieldName=void 0;const _5e=Ye;class S5e extends _5e.MalloyElement{constructor(e){super(),this.name=e,this.elementType="fieldName"}get refString(){return this.name}toString(){return this.refString}getField(e){return e.lookup([this])}}v0.FieldName=S5e;var C5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),b5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),T5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&C5e(e,t,n);return b5e(e,t),e};Object.defineProperty(Wg,"__esModule",{value:!0}),Wg.ExprFunc=void 0;const tr=Ke,R5e=fs,O5e=Ef,D5e=Pt,w5e=ct,N5e=v0,CG=Ft,bG=T5e(Wt),F5e=at;class L5e extends w5e.ExpressionDef{constructor(e,n,r,i,s){super({args:n}),this.name=e,this.args=n,this.isRaw=r,this.rawType=i,this.source=s,this.elementType="function call()",this.has({source:s})}canSupportPartitionBy(){return!0}canSupportOrderBy(){return!0}canSupportLimit(){return!0}getExpression(e){return this.getPropsExpression(e)}findFunctionDef(e){var n,r,i;const s=this.name.toLowerCase(),o=e?(r=(n=this.getDialectNamespace(e))===null||n===void 0?void 0:n.getEntry(s))===null||r===void 0?void 0:r.entry:void 0,u=o??((i=this.modelEntry(s))===null||i===void 0?void 0:i.entry);return u===void 0?(this.logError("function-not-found",`Unknown function '${this.name}'. Use '${this.name}!(...)' to call a SQL function directly.`),{found:void 0,error:"unknown function"}):u.type!=="function"?(this.logError("call-of-non-function",`'${this.name}' (with type ${u.type}) is not a function`),{found:void 0,error:"called non function"}):(u.name!==this.name&&this.logWarning("case-insensitive-function",`Case insensitivity for function names is deprecated, use '${u.name}' instead`),{found:u,error:void 0})}getPropsExpression(e,n){var r,i,s,o;const u=this.args.map(F=>F.getExpression(e));if(this.isRaw){const F=[`${this.name}(`];u.forEach((U,J)=>{J!==0&&F.push(","),F.push(U.value)}),F.push(")");const I=(r=u[0])!==null&&r!==void 0?r:{type:"number"},M=this.rawType?{type:this.rawType}:I;return(0,D5e.computedExprValue)({dataType:M,value:(0,CG.composeSQLExpr)(F),from:u})}const a=(i=e.dialectObj())===null||i===void 0?void 0:i.name,{found:l,error:c}=this.findFunctionDef(a);if(l===void 0)return(0,R5e.errorFor)(c);let f,d=(s=this.source)===null||s===void 0?void 0:s.path;if(this.source){const I=this.source.getField(e).found;if(I){const M=I.typeDesc();if((0,tr.isAtomicFieldType)(M.type))f={...bG.atomicDef(M),expressionType:M.expressionType,value:{node:"field",path:this.source.path},evalSpace:M.evalSpace,compositeFieldUsage:M.compositeFieldUsage},d=this.source.path.slice(0,-1);else if(!(I instanceof O5e.StructSpaceFieldBase))return this.loggedErrorExpr("invalid-aggregate-source",`Aggregate source cannot be a ${M.type}`)}else this.loggedErrorExpr("aggregate-source-not-found",`Reference to undefined value ${this.source.refString}`)}const h=[...f?[f]:[],...u],p=I5e(l,h);if(p===void 0)return this.loggedErrorExpr("no-matching-function-overload",`No matching overload for function ${this.name}(${h.map(F=>F.type).join(", ")})`);const{overload:m,expressionTypeErrors:g,evalSpaceErrors:y,nullabilityErrors:E,returnType:A}=p;for(const F of g){const I=F.argIndex-(f?1:0),M=(0,tr.expressionIsScalar)(F.maxExpressionType)?"scalar":"scalar or aggregate";this.args[I].logError("invalid-function-argument-expression-type",`Parameter ${F.argIndex+1} ('${F.param.name}') of ${this.name} must be ${M}, but received ${F.actualExpressionType}`)}for(const F of y){const I=F.argIndex-(f?1:0),M=F.maxEvalSpace==="literal"?"literal":F.maxEvalSpace==="constant"?"literal or constant":"literal, constant or output";this.args[I].logError("invalid-function-argument-evaluation-space",`Parameter ${F.argIndex+1} ('${F.param.name}') of ${this.name} must be ${M}, but received ${F.actualEvalSpace}`)}for(const F of E){const I=F.argIndex-(f?1:0);this.args[I].logError("literal-null-function-argument",`Parameter ${F.argIndex+1} ('${F.param.name}') of ${this.name} must not be a literal null`)}p.returnTypeError&&this.logError(p.returnTypeError.code,p.returnTypeError.parameters);const v=m.returnType,_=(0,tr.maxOfExpressionTypes)([(o=v.expressionType)!==null&&o!==void 0?o:"scalar",...h.map(F=>F.expressionType)]);if(!(0,tr.expressionIsAggregate)(m.returnType.expressionType)&&this.source!==void 0)return this.loggedErrorExpr("non-aggregate-function-with-source",`Cannot call function ${this.name}(${h.map(F=>F.type).join(", ")}) with source`);const S={node:"function_call",overload:m,name:this.name,kids:{args:h.map(F=>F.value)},expressionType:_,structPath:d};let C=S;if(n!=null&&n.orderBys&&n.orderBys.length>0){const F=(0,tr.expressionIsAnalytic)(m.returnType.expressionType);if(F||this.inExperiment("aggregate_order_by",!0)||n.orderBys[0].logError("aggregate-order-by-experiment-not-enabled","Enable experiment `aggregate_order_by` to use `order_by` with an aggregate function"),m.supportsOrderBy||F){const I=m.supportsOrderBy!=="only_default",M=n.orderBys.flatMap(U=>F?U.getAnalyticOrderBy(e):U.getAggregateOrderBy(e,I));S.kids.orderBy=M}else n.orderBys[0].logError("function-does-not-support-order-by",`Function \`${this.name}\` does not support \`order_by\``)}if((n==null?void 0:n.limit)!==void 0&&(m.supportsLimit?S.limit=n.limit.limit:this.logError("function-does-not-support-limit",`Function ${this.name} does not support limit`)),n!=null&&n.partitionBys&&n.partitionBys.length>0){const F=[];for(const I of n.partitionBys)for(const M of I.partitionFields){const U=M.getField(e);U.found===void 0?M.logError("partition-by-not-found",`${M.refString} is not defined`):(0,tr.expressionIsAnalytic)(U.found.typeDesc().expressionType)||(0,tr.expressionIsUngroupedAggregate)(U.found.typeDesc().expressionType)?M.logError("non-scalar-or-aggregate-partition-by","Partition expression must be scalar or aggregate"):F.push(M.nameString)}S.partitionBy=F}if(["sql_number","sql_string","sql_date","sql_timestamp","sql_boolean"].includes(l.name)){if(!this.inExperiment("sql_functions",!0))return this.loggedErrorExpr("sql-functions-experiment-not-enabled",`Cannot use sql_function \`${l.name}\`; use \`sql_functions\` experiment to enable this behavior`);const F=h[0].value;if(F.node!=="stringLiteral")this.logError("invalid-sql-function-argument",`Invalid string literal for \`${l.name}\``);else{const I=F.literal,M=B5e(I),U=M.filter(Q=>Q.type==="interpolation"&&Q.name.includes(".")).map(Q=>Q.type==="interpolation"?`\${${Q.name}}`:`\${${Q.value}}`);if(U.length>0){const Q=U.length===1?`'.' paths are not yet supported in sql interpolations, found ${U.at(0)}`:`'.' paths are not yet supported in sql interpolations, found (${U.join(", ")})`;return this.loggedErrorExpr("unsupported-sql-function-interpolation",Q)}const J=[];for(const Q of M)if(Q.type==="string")J.push(Q.value);else if(Q.name==="TABLE")J.push({node:"source-reference"});else{const ue=new N5e.FieldName(Q.name);this.has({name:ue});const he=e.lookup([ue]);if(he.found===void 0)return this.loggedErrorExpr("sql-function-interpolation-not-found",`Invalid interpolation: ${he.error.message}`);he.found.refType==="parameter"?J.push({node:"parameter",path:[Q.name]}):J.push({node:"field",path:[Q.name]})}C=(0,CG.composeSQLExpr)(J)}}const b=(0,tr.mergeEvalSpaces)(...h.map(F=>F.evalSpace)),w=b==="constant"?"constant":(0,tr.expressionIsScalar)(_)?b:"output";return{...(0,tr.isAtomic)(A)?bG.atomicDef(A):A,expressionType:_,value:C,evalSpace:w,compositeFieldUsage:(0,F5e.mergeCompositeFieldUsage)(...h.map(F=>F.compositeFieldUsage))}}}Wg.ExprFunc=L5e;function I5e(t,e){var n;for(const r of t.overloads){const i=new Map;let s=0,o=!0,u=!1;const a=[],l=[],c=[];for(let h=0;h<e.length;h++){const p=e[h],m=r.params[s];if(m===void 0){o=!1;break}if(!m.allowedTypes.some(y=>{var E;const{dataTypeMatch:A,genericsSet:v}=vh(i,(E=r.genericTypes)!==null&&E!==void 0?E:[],p,y);for(const _ of v)i.set(_.name,_.type);return y.expressionType&&((0,tr.isExpressionTypeLEQ)(p.expressionType,y.expressionType)||a.push({argIndex:h,maxExpressionType:y.expressionType,actualExpressionType:p.expressionType,param:m})),(y.evalSpace==="literal"&&p.evalSpace!=="literal"||y.evalSpace==="constant"&&(p.evalSpace==="input"||p.evalSpace==="output")||(0,tr.expressionIsAnalytic)(r.returnType.expressionType)&&p.evalSpace==="input")&&l.push({argIndex:h,param:m,maxEvalSpace:y.evalSpace,actualEvalSpace:p.evalSpace}),y.evalSpace==="literal"&&p.type==="null"&&c.push({argIndex:h,param:m}),A})){o=!1;break}m.isVariadic?h===e.length-1&&(u=!0):s++}if(!u&&(s!==e.length||s!==r.params.length))continue;const f=N_(r.returnType,i),d=(n=f.returnType)!==null&&n!==void 0?n:{type:"number"};if(o)return{overload:r,expressionTypeErrors:a,evalSpaceErrors:l,nullabilityErrors:c,returnTypeError:f.error,returnType:d}}}function B5e(t){const e=[];let n=t;for(;n.length;){const r=n.indexOf("${");if(r===-1){e.push({type:"string",value:n});break}else{const i=n.slice(r).indexOf("}");if(i===-1){e.push({type:"string",value:n});break}r>0&&e.push({type:"string",value:n.slice(0,r)}),e.push({type:"interpolation",name:n.slice(r+2,i+r)}),n=n.slice(i+r+1)}}return e}function vh(t,e,n,r){var i,s,o,u;if(tr.TD.eq(r,n)||r.type==="any"||r.type!=="generic"&&(n.type==="null"||n.type==="error"))return{dataTypeMatch:!0,genericsSet:[]};if(r.type==="array"&&n.type==="array"){if((0,tr.isScalarArray)(n))return(0,tr.isRepeatedRecordFunctionParam)(r)?{dataTypeMatch:!1,genericsSet:[]}:vh(t,e,n.elementTypeDef,r.elementTypeDef);if((0,tr.isRepeatedRecordFunctionParam)(r)){const a={type:"record",fields:r.fields},l={type:"record",fields:n.fields};return vh(t,e,l,a)}else return{dataTypeMatch:!1,genericsSet:[]}}else if(r.type==="record"&&n.type==="record"){const a=[],l=new Map;for(const c of r.fields)l.set((i=c.as)!==null&&i!==void 0?i:c.name,c);for(const c of n.fields){const f=l.get((s=c.as)!==null&&s!==void 0?s:c.name);if(f===void 0)return{dataTypeMatch:!1,genericsSet:[]};const d=vh(new Map([...t.entries(),...a.map(h=>[h.name,h.type])]),e,c,f);a.push(...d.genericsSet)}return{dataTypeMatch:!0,genericsSet:a}}else if(r.type==="generic"){const a=t.get(r.generic);if(a!==void 0&&a.type!=="null"&&a.type!=="error")return vh(t,e,n,a);const l=(u=(o=e.find(c=>c.name===r.generic))===null||o===void 0?void 0:o.acceptibleTypes)!==null&&u!==void 0?u:[];for(const c of l){const f=vh(t,e,n,c);if(f.dataTypeMatch){if(!(0,tr.isAtomic)(n)&&n.type!=="null")continue;const d={name:r.generic,type:n};return{dataTypeMatch:!0,genericsSet:[...f.genericsSet,d]}}}}return{dataTypeMatch:!1,genericsSet:[]}}function N_(t,e){switch(t.type){case"array":{if("fields"in t){const i=t.fields.map(s=>{const o=N_(s,e);return{...s,...o}});return{error:void 0,returnType:{type:"array",elementTypeDef:t.elementTypeDef,fields:i}}}const n=N_(t.elementTypeDef,e);if(n.error)return n;const r=n.returnType;return r.type==="record"?{error:void 0,returnType:{type:"array",elementTypeDef:{type:"record_element"},fields:r.fields}}:(0,tr.isAtomic)(r)?{error:void 0,returnType:{type:"array",elementTypeDef:r}}:{error:{code:"invalid-resolved-type-for-array",parameters:"Invalid resolved type for array; cannot be non-atomic"},returnType:void 0}}case"record":return{error:void 0,returnType:{type:"record",fields:t.fields.map(r=>{const i=N_(r,e);return{...r,...i}})}};case"generic":{const n=e.get(t.generic);return n===void 0?{error:{code:"generic-not-resolved",parameters:`Generic ${t.generic} in return type could not be resolved`},returnType:void 0}:{error:void 0,returnType:n}}default:return{error:void 0,returnType:t}}}var $5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),k5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),M5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&$5e(e,t,n);return k5e(e,t),e};Object.defineProperty(w_,"__esModule",{value:!0}),w_.ExprProps=void 0;const P5e=Ke,U5e=fs,j5e=M5e(Wt),q5e=E0,H5e=A0,z5e=Ah,Q5e=ct,G5e=Wg,W5e=at;class V5e extends Q5e.ExpressionDef{constructor(e,n){super({expr:e,statements:n}),this.expr=e,this.statements=n,this.elementType="expression with props",this.legalChildTypes=j5e.anyAtomicT}getFilteredExpression(e,n,r){if(r.length>0){if(!this.expr.supportsWhere(n))return this.expr.logError("filter-of-non-aggregate","Filtered expression requires an aggregate computation"),n;const i=[];for(const s of r){const o=s.getFilterList(e);if(o.find(u=>(0,P5e.expressionIsCalculation)(u.expressionType)))return s.logError("aggregate-filter-expression-not-scalar","Cannot filter an expresion with an aggregate or analytical computation"),n;i.push(...o)}return this.typeCheck(this.expr,{...n,expressionType:"scalar"})?{...n,compositeFieldUsage:(0,W5e.mergeCompositeFieldUsage)(n.compositeFieldUsage,...i.map(s=>s.compositeFieldUsage)),value:{node:"filteredExpr",kids:{e:n.value,filterList:i}}}:(this.expr.logError("filter-of-non-aggregate",`Cannot filter '${n.expressionType}' data`),(0,U5e.errorFor)("cannot filter type"))}return n}getExpression(e){const n=[];let r;const i=[],s=[];for(const u of this.statements)u instanceof z5e.PartitionBy?this.expr.canSupportPartitionBy()?n.push(u):u.logError("partition-by-of-non-window-function","`partition_by` is not supported for this kind of expression"):u instanceof H5e.Limit?r?u.logError("expression-limit-already-specified","limit already specified"):this.expr.canSupportLimit()?r=u:u.logError("limit-of-non-aggregate-function","`limit` is not supported for this kind of expression"):u instanceof q5e.FunctionOrdering?this.expr.canSupportOrderBy()?i.push(u):u.logError("order-by-of-non-aggregate-function","`order_by` is not supported for this kind of expression"):s.push(u);const o=this.expr instanceof G5e.ExprFunc?this.expr.getPropsExpression(e,{partitionBys:n,limit:r,orderBys:i}):this.expr.getExpression(e);return this.getFilteredExpression(e,o,s)}}w_.ExprProps=V5e;var F_={},Y5e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),K5e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),J5e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Y5e(e,t,n);return K5e(e,t),e};Object.defineProperty(F_,"__esModule",{value:!0}),F_.ExprLogicalOp=void 0;const X5e=zg,TG=J5e(Wt);class Z5e extends X5e.BinaryBoolean{constructor(){super(...arguments),this.elementType="logical operator",this.legalChildTypes=[TG.boolT,TG.aggregateBoolT]}}F_.ExprLogicalOp=Z5e;var L_={},e4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),t4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&e4e(e,t,n);return t4e(e,t),e};Object.defineProperty(L_,"__esModule",{value:!0}),L_.ExprMax=void 0;const I_=n4e(Wt),r4e=Ha;class i4e extends r4e.ExprAggregateFunction{constructor(e){super("max",e),this.legalChildTypes=[I_.numberT,I_.stringT,I_.dateT,I_.timestampT]}returns(e){return e}}L_.ExprMax=i4e;var B_={},s4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),o4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),u4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&s4e(e,t,n);return o4e(e,t),e};Object.defineProperty(B_,"__esModule",{value:!0}),B_.ExprMin=void 0;const $_=u4e(Wt),a4e=Ha;class l4e extends a4e.ExprAggregateFunction{constructor(e){super("min",e),this.legalChildTypes=[$_.numberT,$_.stringT,$_.dateT,$_.timestampT]}returns(e){return e}}B_.ExprMin=l4e;var k_={},c4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),f4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),x4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&c4e(e,t,n);return f4e(e,t),e};Object.defineProperty(k_,"__esModule",{value:!0}),k_.ExprMinus=void 0;const d4e=fs,RG=x4e(Wt),h4e=ct;class p4e extends h4e.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="unary minus",this.legalChildTypes=[RG.numberT]}getExpression(e){const n=this.expr.getExpression(e);return RG.typeIn(n,this.legalChildTypes)?{...n,type:"number",value:{node:"unary-",e:n.value}}:(0,d4e.errorFor)("negate requires number")}}k_.ExprMinus=p4e;var M_={};Object.defineProperty(M_,"__esModule",{value:!0}),M_.ExprMulDiv=void 0;const g4e=mh;class m4e extends g4e.BinaryNumeric{constructor(){super(...arguments),this.elementType="*/%"}}M_.ExprMulDiv=m4e;var P_={},Vg={};Object.defineProperty(Vg,"__esModule",{value:!0}),Vg.Unary=void 0;const y4e=ct;class E4e extends y4e.ExpressionDef{constructor(e){super({expr:e}),this.expr=e}}Vg.Unary=E4e;var A4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),v4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),_4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&A4e(e,t,n);return v4e(e,t),e};Object.defineProperty(P_,"__esModule",{value:!0}),P_.ExprNot=void 0;const E7=_4e(Wt),S4e=Vg;class C4e extends S4e.Unary{constructor(e){super(e),this.elementType="not",this.legalChildTypes=[E7.boolT,E7.nullT]}getExpression(e){var n;const r=this.expr.getExpression(e);!((n=e.dialectObj())===null||n===void 0)&&n.booleanAsNumbers&&this.legalChildTypes.find(s=>s.type==="number")===void 0&&this.legalChildTypes.push(E7.numberT);const i=this.typeCheck(this.expr,r);return{...r,type:"boolean",value:{node:"not",e:i?r.value:{node:"false"}}}}}P_.ExprNot=C4e;var U_={};Object.defineProperty(U_,"__esModule",{value:!0}),U_.ExprNow=void 0;const b4e=ct,T4e=at;class R4e extends b4e.ExpressionDef{constructor(){super(...arguments),this.elementType="timestamp"}getExpression(e){return{type:"timestamp",expressionType:"scalar",evalSpace:"constant",value:{node:"now"},compositeFieldUsage:(0,T4e.emptyCompositeFieldUsage)()}}}U_.ExprNow=R4e;var _0={};Object.defineProperty(_0,"__esModule",{value:!0}),_0.ExprIsNull=_0.PartialIsNull=_0.ExprNULL=void 0;const O4e=Pt,j_=ct;function A7(t,e,n){const r=n.getExpression(t);return r.type="boolean",r.value={node:e==="="?"is-null":"is-not-null",e:r.value},r}class D4e extends j_.ExpressionDef{constructor(){super(...arguments),this.elementType="NULL"}getExpression(){return(0,O4e.literalExprValue)({dataType:{type:"null"},value:{node:"null"}})}apply(e,n,r){return n==="!="||n==="="?A7(e,n,r):super.apply(e,n,r,!0)}}_0.ExprNULL=D4e;class w4e extends j_.ExpressionDef{constructor(e){super(),this.op=e,this.elementType="<=> NULL"}apply(e,n,r){return A7(e,this.op,r)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("partial-as-value","Partial null check does not have a value")}atNodeType(){return j_.ATNodeType.Partial}}_0.PartialIsNull=w4e;class N4e extends j_.ExpressionDef{constructor(e,n){super(),this.expr=e,this.op=n,this.elementType="is null",this.has({expr:e})}getExpression(e){return A7(e,this.op,this.expr)}}_0.ExprIsNull=N4e;var q_={};Object.defineProperty(q_,"__esModule",{value:!0}),q_.ExprNumber=void 0;const F4e=Pt,L4e=ct;class I4e extends L4e.ExpressionDef{constructor(e){super(),this.n=e,this.elementType="numeric literal"}getExpression(e){return this.constantExpression()}constantExpression(){const e=Number(this.n),n=Number.isNaN(e)?{type:"number"}:{type:"number",numberType:Number.isInteger(e)?"integer":"float"};return(0,F4e.literalExprValue)({dataType:n,value:{node:"numberLiteral",literal:this.n}})}}q_.ExprNumber=I4e;var H_={};Object.defineProperty(H_,"__esModule",{value:!0}),H_.ExprParens=void 0;const v7=ct;class B4e extends v7.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="(expression)"}requestExpression(e){return this.expr.requestExpression(e)}getExpression(e){const n=this.expr.getExpression(e);return{...n,value:{node:"()",e:n.value}}}apply(e,n,r,i){return this.expr.atNodeType()===v7.ATNodeType.Or?this.expr.apply(e,n,r,i):(0,v7.applyBinary)(e,r,n,this)}atNodeType(){return this.expr.atNodeType()}atExpr(){return this.expr}}H_.ExprParens=B4e;var z_={};Object.defineProperty(z_,"__esModule",{value:!0}),z_.ExprRegEx=void 0;const $4e=Pt,k4e=ct;class M4e extends k4e.ExpressionDef{constructor(e){super(),this.regex=e,this.elementType="regular expression literal"}getExpression(){return(0,$4e.literalExprValue)({dataType:{type:"regular expression"},value:{node:"regexpLiteral",literal:this.regex}})}}z_.ExprRegEx=M4e;var Q_={};Object.defineProperty(Q_,"__esModule",{value:!0}),Q_.ExprString=void 0;const P4e=ct,U4e=Pt;class j4e extends P4e.ExpressionDef{constructor(e){super(),this.elementType="string literal",this.value=e}getExpression(e){return(0,U4e.literalExprValue)({dataType:{type:"string"},value:{node:"stringLiteral",literal:this.value}})}}Q_.ExprString=j4e;var G_={};Object.defineProperty(G_,"__esModule",{value:!0}),G_.ExprSum=void 0;const q4e=Eh;class H4e extends q4e.ExprAsymmetric{constructor(e,n,r){super("sum",e,n,r),this.has({source:n})}}G_.ExprSum=H4e;var W_={};Object.defineProperty(W_,"__esModule",{value:!0}),W_.ExprTimeExtract=void 0;const za=Ke,V_=Pt,_7=ct,z4e=y0;class Yg extends _7.ExpressionDef{static extractor(e){const n=Yg.pluralMap[e];if(n)return n;if((0,za.isExtractUnit)(e))return e}constructor(e,n){super({args:n}),this.extractText=e,this.args=n,this.elementType="timeExtract"}getExpression(e){const n=Yg.extractor(this.extractText);if(n){if(this.args.length!==1)return this.loggedErrorExpr("too-many-arguments-for-time-extraction",`Extraction function ${n} requires one argument`);const r=this.args[0];if(r instanceof z4e.Range){let i=r.first.getExpression(e),s=r.last.getExpression(e);if(i.type==="error"||s.type==="error")return(0,V_.computedErrorExprValue)({dataType:{type:"number"},error:"extract from error",from:[i,s]});if(!(0,za.isTemporalType)(i.type))return r.first.loggedErrorExpr("invalid-type-for-time-extraction",`Can't extract ${n} from '${i.type}'`);if(!(0,za.isTemporalType)(s.type))return r.last.loggedErrorExpr("invalid-type-for-time-extraction",`Cannot extract ${n} from '${s.type}'`);let o=i.type;if(!za.TD.eq(i,s)){let u=!0;if(o="timestamp",i.type==="date"){const a=(0,_7.getMorphicValue)(i,"timestamp");a&&(i=a,u=!1)}else{const a=(0,_7.getMorphicValue)(s,"timestamp");a&&(s=a,u=!1)}if(u)return r.first.loggedErrorExpr("invalid-types-for-time-measurement",`Cannot measure from ${i.type} to ${s.type}`)}return["week","month","quarter","year"].includes(n)?this.loggedErrorExpr("invalid-timeframe-for-time-measurement",`Cannot measure interval using '${n}'`):(0,za.isTimestampUnit)(n)?(0,V_.computedExprValue)({dataType:{type:"number",numberType:"integer"},value:{node:"timeDiff",units:n,kids:{left:(0,za.mkTemporal)(i.value,o),right:(0,za.mkTemporal)(s.value,o)}},from:[i,s]}):this.loggedErrorExpr("invalid-time-extraction-unit",`Cannot extract ${n} from a range`)}else{const i=r.getExpression(e);return(0,za.isTemporalType)(i.type)?(0,V_.computedExprValue)({dataType:{type:"number",numberType:"integer"},value:{node:"extract",e:(0,za.mkTemporal)(i.value,i.type),units:n},from:[i]}):(i.type!=="error"&&this.logError("unsupported-type-for-time-extraction",`${this.extractText}() requires time type, not '${i.type}'`),(0,V_.computedErrorExprValue)({dataType:{type:"number",numberType:"integer"},error:`${this.extractText} bad type ${i.type}`,from:[i]}))}}throw this.internalError(`Illegal extraction unit '${this.extractText}'`)}}W_.ExprTimeExtract=Yg,Yg.pluralMap={years:"year",quarters:"quarter",months:"month",weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second"};var Y_={},No={},K_={};Object.defineProperty(K_,"__esModule",{value:!0}),K_.QueryInputSpace=void 0;const Q4e=Fi,G4e=Jd;class W4e extends G4e.RefinedSpace{constructor(e,n,r){super(e),this.queryOutput=n,this._isProtectedAccessSpace=r,this.extendList=[]}extendSource(e){this.pushFields(e),e instanceof Q4e.Join?this.extendList.push(e.name.refString):this.extendList.push(e.defineName)}isQueryFieldSpace(){return!0}outputSpace(){return this.queryOutput}inputSpace(){return this}isProtectedAccessSpace(){return this._isProtectedAccessSpace}}K_.QueryInputSpace=W4e;var V4e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Y4e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),K4e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&V4e(e,t,n);return Y4e(e,t),e};Object.defineProperty(No,"__esModule",{value:!0}),No.ReduceFieldSpace=No.QuerySpace=No.QueryOperationSpace=void 0;const J_=K4e(Ke),S7=l0,OG=v0,DG=Sr,J4e=pt,X4e=Jd,Z4e=Eg,ebe=Cr,tbe=K_,wu=at,nbe=Ef;class wG extends X4e.RefinedSpace{get compositeFieldUsage(){if(this._compositeFieldUsage===void 0)throw new Error("Composite field usage accessed before computed");return this._compositeFieldUsage}constructor(e,n,r,i){super(e.emptyStructDef()),this.queryInputSpace=e,this.nestParent=r,this.astEl=i,this.expandedWild={},this.compositeFieldUsers=[],this._compositeFieldUsage=void 0,this.exprSpace=new tbe.QueryInputSpace(e.structDef(),this,e.isProtectedAccessSpace()),n&&this.addRefineFromFields(n)}logError(e,n,r){return this.astEl&&this.astEl.logError(e,n,r),e}inputSpace(){return this.exprSpace}outputSpace(){return this}addWild(e){var n;let r=this.exprSpace;const i=[];if(e.joinPath)for(const u of e.joinPath.list){const a=u.refString;i.push(a);const l=r.entry(a);if(l)if(l instanceof ebe.StructSpaceField)r=l.fieldSpace;else{u.logError("invalid-wildcard-source",`Field '${a}' does not contain rows and cannot be expanded with '*'`);return}else{u.logError("wildcard-source-not-defined",`No such field as '${a}'`);return}}const s=this.dialectObj(),o=[];for(const[u,a]of r.entries())if(!e.except.has(u)&&a.refType!=="parameter")if(this.entry(u)){const l=(n=this.expandedWild[u])===null||n===void 0?void 0:n.path.join(".");e.logError("name-conflict-in-wildcard-expansion",`Cannot expand '${u}' in '${e.refString}' because a field with that name already exists${l?` (conflicts with ${l})`:""}`)}else{const l=a.typeDesc();J_.TD.isAtomic(l)&&J_.expressionIsScalar(l.expressionType)&&(s===void 0||!s.ignoreInProject(u))&&(o.push({name:u,entry:a}),this.expandedWild[u]={path:i.concat(u),entry:a})}for(const u of o.sort((a,l)=>a.name.localeCompare(l.name)))this.newEntry(u.name,e,u.entry)}addValidatedCompositeFieldUserFromEntry(e,n){n instanceof DG.SpaceField&&this.compositeFieldUsers.push({type:"field",name:e,field:n,logTo:void 0})}getJoinOnCompositeFieldUsage(e){var n;const r=e.map(s=>new OG.FieldName(s));this.astEl.has({reference:r});const i=this.exprSpace.lookup(r);if(i.found&&i.found instanceof nbe.StructSpaceFieldBase)return(0,wu.joinedCompositeFieldUsage)(e.slice(0,-1),(n=i.found.fieldDef().onCompositeFieldUsage)!==null&&n!==void 0?n:(0,wu.emptyCompositeFieldUsage)());throw new Error("Unexpected join lookup was not found or not a struct")}getCompositeFieldUsageIncludingJoinOns(e){let n=e;const r=(0,wu.compositeFieldUsageJoinPaths)(e);for(const i of r)n=(0,wu.mergeCompositeFieldUsage)(this.getJoinOnCompositeFieldUsage(i),n);return n}addCompositeFieldUserFromFilter(e,n){e.compositeFieldUsage!==void 0&&this.compositeFieldUsers.push({type:"filter",filter:e,logTo:n})}newEntry(e,n,r){r instanceof DG.SpaceField&&this.compositeFieldUsers.push({type:"field",name:e,field:r,logTo:n}),super.newEntry(e,n,r)}applyNextCompositeFieldUsage(e,n,r,i,s){if(i){const o=this.getCompositeFieldUsageIncludingJoinOns((0,wu.compositeFieldUsageDifference)(i,n));if(n=(0,wu.mergeCompositeFieldUsage)(n,o),!(0,wu.isEmptyCompositeFieldUsage)(o)){const u=(0,wu.narrowCompositeFieldResolution)(e,n,r);u.error?(s??this).logError("invalid-composite-field-usage",{newUsage:o,allUsage:n}):r=u.narrowedCompositeFieldResolution}}return{compositeFieldUsage:n,narrowedCompositeFieldResolution:r}}}No.QueryOperationSpace=wG;class NG extends wG{addRefineFromFields(e){var n;if(J_.isQuerySegment(e)){if(e!=null&&e.extendSource)for(const r of e.extendSource)this.exprSpace.addFieldDef(r);for(const r of e.queryFields)if(r.type==="fieldref"){const i=this.exprSpace.lookup(r.path.map(s=>new OG.FieldName(s)));if(i.found){const s=r.path[r.path.length-1];this.setEntry(s,i.found),this.addValidatedCompositeFieldUserFromEntry(s,i.found)}}else if(r.type!=="turtle"){const i=new Z4e.ColumnSpaceField(r),s=(n=r.as)!==null&&n!==void 0?n:r.name;this.setEntry(s,i),this.addValidatedCompositeFieldUserFromEntry(s,i)}}}pushFields(...e){for(const n of e)n instanceof J4e.WildcardFieldReference?this.addWild(n):super.pushFields(n)}canContain(e){return!0}queryFieldDefs(){const e=[];let n=(0,wu.emptyCompositeFieldUsage)(),r=(0,wu.emptyNarrowedCompositeFieldResolution)();const i=this.inputSpace().structDef();for(const s of this.compositeFieldUsers){let o;if(s.type==="filter")s.filter.compositeFieldUsage&&(o=s.filter.compositeFieldUsage);else{const{name:a,field:l}=s,c=this.expandedWild[a];if(c)e.push({type:"fieldref",path:c.path}),o=c.entry.typeDesc().compositeFieldUsage;else{const f=l.getQueryFieldDef(this.exprSpace);if(f){const d=l.typeDesc();o=d.compositeFieldUsage,d&&d.type!=="error"&&this.canContain(d)&&!ibe(f)&&e.push(f)}}}const u=this.applyNextCompositeFieldUsage(i,n,r,o,s.logTo);n=u.compositeFieldUsage,r=u.narrowedCompositeFieldResolution}return this._compositeFieldUsage=n,e}getQuerySegment(e){const n=this.getPipeSegment(e);if(J_.isQuerySegment(n))return n;throw new Error("TODO NOT POSSIBLE")}getPipeSegment(e){if(this.segmentType==="index")return this.logError("unexpected-index-segment","internal error generating index segment from non index query"),{type:"reduce",queryFields:[]};const n={type:this.segmentType,queryFields:this.queryFieldDefs()};if(n.queryFields=(0,S7.mergeFields)(e==null?void 0:e.queryFields,n.queryFields),e!=null&&e.extendSource&&(n.extendSource=e.extendSource),this.exprSpace.extendList.length>0){const r=[],i=this.exprSpace.structDef();for(const s of this.exprSpace.extendList){const o=i.fields.find(u=>(0,S7.nameFromDef)(u)===s);o&&r.push(o)}n.extendSource=(0,S7.mergeFields)(n.extendSource,r)}return this.newTimezone&&(n.queryTimezone=this.newTimezone),n}lookup(e){const n=super.lookup(e);return n.found?{...n,isOutputField:!0}:this.exprSpace.lookup(e)}isQueryFieldSpace(){return!0}}No.QuerySpace=NG;class rbe extends NG{constructor(){super(...arguments),this.segmentType="reduce"}}No.ReduceFieldSpace=rbe;function ibe(t){return typeof t!="string"&&t.type==="turtle"&&t.pipeline.length===0}var sbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),obe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ube=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&sbe(e,t,n);return obe(e,t),e};Object.defineProperty(Y_,"__esModule",{value:!0}),Y_.ExprUngroup=void 0;const FG=Ke,abe=No,LG=ube(Wt),lbe=ct;class cbe extends lbe.ExpressionDef{constructor(e,n,r){super({expr:n,fields:r}),this.control=e,this.expr=n,this.fields=r,this.legalChildTypes=LG.anyAtomicT,this.elementType="ungroup"}getExpression(e){const n=this.expr.getExpression(e);if(!(0,FG.expressionIsAggregate)(n.expressionType))return this.expr.loggedErrorExpr("ungroup-of-non-aggregate",`${this.control}() expression must be an aggregate`);if((0,FG.expressionIsUngroupedAggregate)(n.expressionType))return this.expr.loggedErrorExpr("ungroup-of-ungrouped-aggregate",`${this.control}() expression must not already be ungrouped`);const r={node:this.control,e:n.value};if(this.typeCheck(this.expr,{...n,expressionType:"scalar"})){if(e.isQueryFieldSpace()&&this.fields.length>0){const i=[],s=this.control==="exclude";for(const o of this.fields){let u=e.outputSpace(),a=!0;for(;u;){const l=u.lookup([o]);if(l.found&&l.isOutputField)i.push(o.refString),a=!1;else if(u instanceof abe.QuerySpace){u=u.nestParent;continue}break}if(a){const l=s?"exclude()":"all()";o.logError("ungroup-field-not-in-output",`${l} '${o.refString}' is missing from query output`)}}r.fields=i}return{...LG.atomicDef(n),expressionType:"ungrouped_aggregate",value:r,evalSpace:"output",compositeFieldUsage:n.compositeFieldUsage}}return this.loggedErrorExpr("ungroup-with-non-scalar",`${this.control}() incompatible type`)}}Y_.ExprUngroup=cbe;var X_={},fbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),xbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dbe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&fbe(e,t,n);return xbe(e,t),e};Object.defineProperty(X_,"__esModule",{value:!0}),X_.ForRange=void 0;const hbe=fs,IG=dbe(Wt),Z_=Li,pbe=Pt,gbe=ct,eS=gh,BG=y0;class mbe extends gbe.ExpressionDef{constructor(e,n,r){super({from:e,duration:n,timeframe:r}),this.from=e,this.duration=n,this.timeframe=r,this.elementType="forRange",this.legalChildTypes=[IG.timestampT,IG.dateT]}apply(e,n,r){const i=this.from.getExpression(e),s=r.getExpression(e);if(!this.typeCheck(r,s))return(0,hbe.errorFor)("no time for range");const o=this.duration.getExpression(e);if(o.type!=="number")return o.type!=="error"&&this.logError("invalid-duration-quantity",`FOR duration count must be a number, not '${o.type}'`),(0,pbe.computedErrorExprValue)({dataType:{type:"boolean"},error:"for not number",from:[i,s]});const u=this.timeframe.text;let a=(0,Z_.resolution)(u);if(i.type==="timestamp"&&(a="timestamp"),s.type==="date"&&a==="date"){const p=this.from,m=(0,Z_.timeOffset)("date",i.value,"+",o.value,u),g=new eS.ExprTime("date",m);return new BG.Range(p,g).apply(e,n,r)}const l=eS.ExprTime.fromValue("timestamp",s);let c=this.from,f=i.value;if(i.type==="date"){const p=i.morphic&&i.morphic.timestamp;p?f=p:f=(0,Z_.castTo)("timestamp",f,"date"),c=new eS.ExprTime("timestamp",f,[i])}const d=(0,Z_.timeOffset)("timestamp",f,"+",o.value,u),h=new eS.ExprTime("timestamp",d,[i,o]);return new BG.Range(c,h).apply(e,n,l)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("range-as-value","A Range is not a value")}}X_.ForRange=mbe;var nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.LiteralYear=nr.LiteralQuarter=nr.LiteralMonth=nr.LiteralWeek=nr.LiteralDay=nr.LiteralHour=nr.LiteralTimestamp=nr.TimeFormatError=void 0;const S0=ri,ybe=Ke,Ebe=Pt,Abe=y0,$G=gh,C7=ct;class vbe extends Error{}nr.TimeFormatError=vbe;function Of(t,e){const n=t.slice(1);if(e){const r=n.match(/\[[^\]]+]$/);if(r)return{tzSpec:r[0].slice(1,-1),text:n.slice(0,-r[0].length)}}return{text:n}}const kG="yyyy",MG=`${kG}-LL`,qs=`${MG}-dd`,PG=`${qs} HH`,UG=`${PG}:mm`,b7=`${UG}:ss`;class jG extends C7.ExpressionDef{constructor(e,n,r){super(),this.units=n,this.timeType=r,this.literalPart=e.text,e.tzSpec&&(this.timeZone=e.tzSpec)}makeLiteral(e,n){const r={node:"timeLiteral",literal:e,typeDef:{type:n}};return this.timeZone&&(r.timezone=this.timeZone),r}makeValue(e,n){const r=this.makeLiteral(e,n);return(0,Ebe.literalTimeResult)({value:r,dataType:{type:n},timeframe:this.units})}getExpression(e){return this.makeValue(this.literalPart,this.timeType)}getNext(){if(this.nextLit)return this.makeValue(this.nextLit,this.timeType)}granular(){return this.nextLit!==void 0}}class T7 extends jG{constructor(e,n){super(e,n,"timestamp"),this.elementType="literal:timestamp"}static parse(e){let n;const r=Of(e,!0);e=r.text,e[10]==="T"&&(e=e.slice(0,10)+" "+e.slice(11),r.text=e);const i=e.match(/^([^.,]+)[,.](\d+)$/);i&&(e=i[1]);let s=S0.DateTime.fromFormat(e,b7);if(s.isValid)return new T7(r,n);if(s=S0.DateTime.fromFormat(e,UG),s.isValid){r.text=r.text+":00",n="minute";const o=s.plus({minute:1}).toFormat(b7);return new R7(r,n,"timestamp",o)}}}nr.LiteralTimestamp=T7;class R7 extends jG{constructor(e,n,r,i){super(e,n,r),this.nextLit=i,this.elementType="granularTimeLiteral"}apply(e,n,r){let i=this.getExpression(e),s=this.getNext();if(s){const o=r.getExpression(e);if(o.type==="timestamp"){const u=(0,C7.getMorphicValue)(i,"timestamp"),a=(0,C7.getMorphicValue)(s,"timestamp");if(u&&a)i=u,s=a;else return super.apply(e,n,r)}if(s&&(0,ybe.isTemporalType)(o.type)){const u=o.type;return new Abe.Range(new $G.ExprTime(u,i.value),new $G.ExprTime(u,s.value)).apply(e,n,r)}}return super.apply(e,n,r)}}class O7 extends R7{constructor(e,n){super(e,"hour","timestamp",n),this.elementType="literal:hour"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,PG);if(i.isValid)return n.text=n.text+":00:00",r=i.plus({hour:1}).toFormat(b7),new O7(n,r)}}nr.LiteralHour=O7;class Kg extends R7{constructor(e,n,r){super(e,n,"date",r)}getExpression(e){const n=this.makeValue(this.literalPart,"date"),r=this.makeLiteral(`${this.literalPart} 00:00:00`,"timestamp");return{...n,morphic:{timestamp:r},evalSpace:"literal"}}getNext(){const e=this.makeValue(this.nextLit,"date"),n=this.makeLiteral(`${this.nextLit} 00:00:00`,"timestamp");return{...e,morphic:{timestamp:n}}}}class D7 extends Kg{constructor(e,n){super(e,"day",n),this.elementType="literal:day"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,qs);if(i.isValid)return r=i.plus({day:1}).toFormat(qs),new D7(n,r)}}nr.LiteralDay=D7;class w7 extends Kg{constructor(e,n){super(e,"week",n),this.elementType="literal:week"}static parse(e){const n=Of(e,!1);let r=n.text;const i=n.text.slice(0,10),s=S0.DateTime.fromFormat(i,qs);if(s.isValid&&s.weekday===7){const u=s.plus({days:7});return n.text=s.toFormat(qs),r=u.toFormat(qs),new w7(n,r)}}}nr.LiteralWeek=w7;class N7 extends Kg{constructor(e,n){super(e,"month",n),this.elementType="literal:month"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,MG);if(i.isValid){const s=i.plus({months:1});return n.text=i.toFormat(qs),r=s.toFormat(qs),new N7(n,r)}}}nr.LiteralMonth=N7;class F7 extends Kg{constructor(e,n){super(e,"quarter",n),this.elementType="literal:quarter"}static parse(e){const n=Of(e,!1);let r=n.text;const i=n.text.match(/(^\d{4})-[qQ](\d)$/);if(i){const s=Number.parseInt(i[2])-1;let o=S0.DateTime.fromFormat(i[1],"yyyy");s>0&&(o=o.plus({quarters:s}));const u=o.plus({quarter:1});return n.text=o.toFormat(qs),r=u.toFormat(qs),new F7(n,r)}}}nr.LiteralQuarter=F7;class L7 extends Kg{constructor(e,n){super(e,"year",n),this.elementType="literal:year"}static parse(e){const n=Of(e,!1);let r=n.text;const i=S0.DateTime.fromFormat(n.text,kG);if(i.isValid){const s=i.plus({year:1});return n.text=i.toFormat(qs),r=s.toFormat(qs),new L7(n,r)}}}nr.LiteralYear=L7;var tS={};Object.defineProperty(tS,"__esModule",{value:!0}),tS.PartialCompare=void 0;const qG=ct;class _be extends qG.ExpressionDef{constructor(e,n){super({right:n}),this.op=e,this.right=n,this.elementType="<=> a"}granular(){return this.right.granular()}apply(e,n,r){return this.right.apply(e,this.op,r)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("partial-as-value","Partial comparison does not have a value")}atNodeType(){return qG.ATNodeType.Partial}}tS.PartialCompare=_be;var _h={},Sbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Cbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),bbe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Sbe(e,t,n);return Cbe(e,t),e};Object.defineProperty(_h,"__esModule",{value:!0}),_h.PickWhen=_h.Pick=void 0;const Sh=bbe(Wt),HG=Pt,Tbe=ct,Rbe=Ye;function nS(t,e){return t===void 0||t.type==="null"||t.type==="error"?e:t}class Obe extends Tbe.ExpressionDef{constructor(e,n){super({choices:e}),this.choices=e,this.elsePick=n,this.elementType="pick",this.has({elsePick:n})}requestExpression(e){if(this.elsePick!==void 0){for(const n of this.choices){if(n.pick===void 0)return;const r=n.when.requestExpression(e);if(r===void 0||r.type!=="boolean")return}return this.getExpression(e)}}apply(e,n,r){var i;const s={node:"case",kids:{caseWhen:[],caseThen:[]}};let o;const u=[];for(const d of this.choices){const h=d.when.apply(e,"=",r),p=d.pick?d.pick.getExpression(e):r.getExpression(e);if(u.push(h,p),o&&!Sh.typeEq(o,p,!0))return this.loggedErrorExpr("pick-type-does-not-match",{pickType:p.type,returnType:o.type});o=nS(o,p),s.kids.caseWhen.push(h.value),s.kids.caseThen.push(p.value)}const a=(i=this.elsePick)===null||i===void 0?void 0:i.getExpression(e),l=r.getExpression(e);u.push(l),a&&u.push(a);const c=a??l,f=nS(o,c);return Sh.typeEq(f,c,!0)?(s.kids.caseElse=c.value,(0,HG.computedExprValue)({dataType:f,value:s,from:u})):this.elsePick?this.loggedErrorExpr("pick-else-type-does-not-match",{elseType:c.type,returnType:f.type}):this.loggedErrorExpr("pick-default-type-does-not-match",{defaultType:c.type,returnType:f.type})}getExpression(e){const n={node:"case",kids:{caseWhen:[],caseThen:[]}};if(this.elsePick===void 0)return this.loggedErrorExpr("pick-missing-else","pick incomplete, missing 'else'");const r=[],i=[];for(const a of this.choices){if(a.pick===void 0)return this.loggedErrorExpr("pick-missing-value","pick with no value can only be used with apply");a.when.requestExpression(e)===void 0&&this.loggedErrorExpr("pick-illegal-partial","pick with partial when can only be used with apply");const c=a.pick.getExpression(e),f=a.when.getExpression(e);r.push({pick:c,when:f}),i.push(c,f)}let s;for(const a of r){if(!Sh.typeEq(a.when,Sh.boolT))return this.loggedErrorExpr("pick-when-must-be-boolean",{whenType:a.when.type});if(s&&!Sh.typeEq(s,a.pick,!0))return this.loggedErrorExpr("pick-type-does-not-match",{pickType:a.pick.type,returnType:s.type});s=nS(s,a.pick),n.kids.caseWhen.push(a.when.value),n.kids.caseThen.push(a.pick.value)}const o=this.elsePick.getExpression(e);i.push(o);const u=nS(s,o);return Sh.typeEq(u,o,!0)?(n.kids.caseElse=o.value,(0,HG.computedExprValue)({dataType:u,value:n,from:i})):this.elsePick.loggedErrorExpr("pick-else-type-does-not-match",{elseType:o.type,returnType:u.type})}}_h.Pick=Obe;class Dbe extends Rbe.MalloyElement{constructor(e,n){super({when:n}),this.pick=e,this.when=n,this.elementType="caseWhen",this.has({pick:e})}}_h.PickWhen=Dbe;var Ch={},wbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Nbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Fbe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&wbe(e,t,n);return Nbe(e,t),e};Object.defineProperty(Ch,"__esModule",{value:!0}),Ch.CaseWhen=Ch.Case=void 0;const Lbe=Pt,Ibe=ct,Bbe=Ye,bh=Fbe(Wt);function zG(t,e){return t===void 0||t.type==="null"||t.type==="error"?e:t}class $be extends Ibe.ExpressionDef{constructor(e,n,r){super({choices:n}),this.value=e,this.choices=n,this.elseValue=r,this.elementType="case",this.has({elseValue:r,value:e})}getExpression(e){const n={node:"case",kids:{caseWhen:[],caseThen:[]}},r=[];let i;if(this.value){const u=this.value.getExpression(e);r.push(u),n.kids.caseValue=u.value,i=u}const s=[];for(const u of this.choices){const a=u.when.getExpression(e),l=u.then.getExpression(e);s.push({when:a,then:l}),r.push(a,l)}let o;for(const u of s){if(i!==void 0){if(!bh.typeEq(u.when,i))return this.loggedErrorExpr("case-when-type-does-not-match",{whenType:u.when.type,valueType:i.type})}else if(!bh.typeEq(u.when,bh.boolT))return this.loggedErrorExpr("case-when-must-be-boolean",{whenType:u.when.type});if(o&&!bh.typeEq(o,u.then,!0))return this.loggedErrorExpr("case-then-type-does-not-match",{thenType:u.then.type,returnType:o.type});o=zG(o,u.then),n.kids.caseWhen.push(u.when.value),n.kids.caseThen.push(u.then.value)}if(this.elseValue){const u=this.elseValue.getExpression(e);if(o&&!bh.typeEq(o,u,!0))return this.loggedErrorExpr("case-else-type-does-not-match",{elseType:u.type,returnType:o.type});o=zG(o,u),r.push(u),n.kids.caseElse=u.value}return(0,Lbe.computedExprValue)({value:n,dataType:o?bh.atomicDef(o):{type:"null"},from:r})}}Ch.Case=$be;class kbe extends Bbe.MalloyElement{constructor(e,n){super({when:e,then:n}),this.when=e,this.then=n,this.elementType="caseWhen"}}Ch.CaseWhen=kbe;var rS={},Df={},Mbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Pbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ube=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Mbe(e,t,n);return Pbe(e,t),e};Object.defineProperty(Df,"__esModule",{value:!0}),Df.RecordLiteral=Df.RecordElement=void 0;const QG=ts,jbe=Pt,qbe=ct,Hbe=Ye,zbe=Ube(Wt);class Qbe extends Hbe.MalloyElement{constructor(e){if(super(),this.elementType="record element","value"in e)this.value=e.value,this.has({value:e.value}),e.key&&(this.key=e.key);else{this.has({path:e.path}),this.value=e.path;const n=e.path.fieldReference.path;this.key=n[n.length-1]}}}Df.RecordElement=Qbe;class Gbe extends qbe.ExpressionDef{constructor(e){super(),this.pairs=e,this.elementType="record literal",this.has({pairs:e})}getExpression(e){return this.getRecord(e,[])}getRecord(e,n){var r;const i={node:"recordLiteral",kids:{},typeDef:{type:"record",fields:[]}},s=[];let o=0;for(const u of this.pairs){const a=(r=u.key)!==null&&r!==void 0?r:n[o];if(o+=1,a===void 0){u.logError("record-literal-needs-keys","Anonymous record element not legal here");continue}const l=u.value.getExpression(e);QG.TD.isAtomic(l)?(s.push(l),i.kids[a]=l.value,i.typeDef.fields.push((0,QG.mkFieldDef)(zbe.atomicDef(l),a))):u.value.logError("illegal-record-property-type",`Record property '${u.key} is type '${l.type}', which is not a legal property value type`)}return(0,jbe.computedExprValue)({value:i,dataType:i.typeDef,from:s})}getNextElement(e,n){const r=n.value;return r.node==="recordLiteral"?this.getRecord(e,Object.keys(r.kids)):this.getRecord(e,[])}}Df.RecordLiteral=Gbe;var Wbe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),Vbe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ybe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Wbe(e,t,n);return Vbe(e,t),e};Object.defineProperty(rS,"__esModule",{value:!0}),rS.ArrayLiteral=void 0;const Kbe=Pt,Jbe=ct,GG=Ybe(Wt),Xbe=Df;class Zbe extends Jbe.ExpressionDef{constructor(e){super(),this.elements=e,this.elementType="array literal",this.has({elements:e})}getExpression(e){const n=[],r=[];let i;if(this.elements.length>0)for(const a of this.elements){const l=i&&a instanceof Xbe.RecordLiteral?a.getNextElement(e,i):a.getExpression(e);if(r.push(l),l.type!=="error"){if(i){if(l.type!=="null"&&!GG.typeEq(i,l)){a.logError("array-values-incompatible","All array elements must be same type");continue}}else l.type!=="null"&&(i=l);n.push(l.value)}}const s=GG.atomicDef(i||{type:"number"}),o=s.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:s.fields}:{type:"array",elementTypeDef:s},u={node:"arrayLiteral",kids:{values:n},typeDef:o};return(0,Kbe.computedExprValue)({dataType:o,value:u,from:r})}}rS.ArrayLiteral=Zbe;var iS={};Object.defineProperty(iS,"__esModule",{value:!0}),iS.Timeframe=void 0;const eTe=Ke,tTe=Ye;class nTe extends tTe.MalloyElement{constructor(e){super(),this.elementType="timeframe";let n=e.toLowerCase();n.endsWith("s")&&(n=n.slice(0,-1)),this.text=(0,eTe.isTimestampUnit)(n)?n:"second"}}iS.Timeframe=nTe;var C0={};Object.defineProperty(C0,"__esModule",{value:!0}),C0.ImportStatement=C0.ImportSelect=C0.ImportSourceName=void 0;const I7=Ye;class rTe extends I7.MalloyElement{constructor(e){super(),this.text=e,this.elementType="importSourceName"}}C0.ImportSourceName=rTe;class iTe extends I7.MalloyElement{constructor(e,n){super(),this.text=e,this.from=n,this.elementType="importName",n&&this.has({from:n})}}C0.ImportSelect=iTe;class sTe extends I7.ListOf{constructor(e,n){super([]),this.url=e,this.elementType="import statement";try{this.fullURL=decodeURI(new URL(e,n).toString())}catch{this.logError("invalid-import-url","Invalid URL in import statement")}}needs(){const e=this.translator();if(e&&this.fullURL&&e.root.importZone.getEntry(this.fullURL).status==="present"){const r=e.childRequest(this.fullURL);if(r)return r}}execute(e){const n=this.translator();if(!n)this.logError("no-translator-for-import","Cannot import without translation context");else if(this.fullURL){const r=n.root.pretranslatedModels.get(this.fullURL),i=n.root.importZone.getEntry(this.fullURL);if(r||i.status==="present"){const s=n.getChildExports(this.fullURL);if(this.notEmpty())for(const o of this.list){const u=o.from||o;if(e.getEntry(o.text))o.logError("name-conflict-on-selective-import",`Cannot redefine '${o.text}'`);else if(s[u.text]){const a={...s[u.text]};o.from&&(a.as=o.text),e.setEntry(o.text,{entry:a,exported:!1})}else u.logError("selective-import-not-found",`Cannot find '${u.text}', not imported`)}else for(const[o,u]of Object.entries(n.getChildExports(this.fullURL)))e.getEntry(o)?this.logError("name-conflict-on-indiscriminate-import",`Cannot redefine '${o}'`):e.setEntry(o,{entry:u,exported:!1})}else i.status==="error"?this.logError("failed-import",`import failed: '${i.message}'`):this.logError("failed-import",`import failed with status: '${i.status}'`)}}}C0.ImportStatement=sTe;var Jg={};Object.defineProperty(Jg,"__esModule",{value:!0}),Jg.ExtendBlock=void 0;const oTe=Ye,uTe=wn;class aTe extends oTe.ListOf{constructor(){super(...arguments),this.elementType="extendBlock",this.forceQueryClass=void 0,this.queryRefinementStage=uTe.LegalRefinementStage.Single}queryExecute(e){for(const n of this.list)for(const r of n.list)e.inputFS.extendSource(r)}}Jg.ExtendBlock=aTe;var sS={};Object.defineProperty(sS,"__esModule",{value:!0}),sS.Argument=void 0;const lTe=Ye;class cTe extends lTe.MalloyElement{constructor(e){super({...e}),this.elementType="Argument",this.id=e.id,this.value=e.value}}sS.Argument=cTe;var oS={};Object.defineProperty(oS,"__esModule",{value:!0}),oS.HasParameter=void 0;const WG=Ke,fTe=Ye;class xTe extends fTe.MalloyElement{constructor(e){super(),this.elementType="hasParameter",this.name=e.name,e.type&&(0,WG.isCastType)(e.type)&&(this.type=e.type),e.default&&(this.default=e.default,this.has({default:this.default}))}parameter(){var e;if(this.default!==void 0){const n=this.default.constantValue();return this.type&&this.type!==n.type&&n.type!=="null"&&n.type!=="error"&&this.default.logError("parameter-default-does-not-match-declared-type",`Default value for parameter does not match declared type \`${this.type}\``),n.type==="null"?this.type?{type:this.type,value:n.value,name:this.name}:(this.default.logError("parameter-null-default-without-declared-type","Default value cannot have type `null` unless parameter type is also specified"),{value:n.value,name:this.name,type:"error"}):!(0,WG.isCastType)(n.type)&&n.type!=="error"?(this.default.logError("parameter-illegal-default-type",`Default value cannot have type \`${n.type}\``),{value:n.value,name:this.name,type:"error"}):{value:n.value,name:this.name,type:n.type}}return this.type===void 0&&this.logError("parameter-missing-default-or-type","Parameter must have default value or declared type"),{value:null,name:this.name,type:(e=this.type)!==null&&e!==void 0?e:"error"}}}oS.HasParameter=xTe;var uS={};Object.defineProperty(uS,"__esModule",{value:!0}),uS.AnonymousQuery=void 0;const dTe=Ye,hTe=_r;class pTe extends dTe.MalloyElement{constructor(e){super(),this.queryExpr=e,this.elementType="anonymousQuery",this.isNoteableObj=!0,this.extendNote=hTe.extendNoteMethod,this.has({queryExpr:e})}execute(e){const n=this.queryExpr.getQuery();if(!n){this.queryExpr.sqLog("non-query-used-as-query","Cannot run this object as a query");return}const r={...n.query()},i=this.note||{};r.annotation&&(i.inherits=r.annotation),(i.notes||i.blockNotes||i.inherits)&&(r.annotation=i),e.queryList.push(r)}}uS.AnonymousQuery=pTe;var b0={};Object.defineProperty(b0,"__esModule",{value:!0}),b0.View=void 0;const gTe=Ye;let mTe=class extends gTe.MalloyElement{pipeline(e,n){return this.pipelineComp(e,n).pipeline}};b0.View=mTe;var aS={};Object.defineProperty(aS,"__esModule",{value:!0}),aS.ViewArrow=void 0;const yTe=Cr,ETe=b0;class ATe extends ETe.View{constructor(e,n){super({base:e,operation:n}),this.base=e,this.operation=n,this.elementType="viewArrow"}pipelineComp(e){const n=this.base.pipelineComp(e),r=new yTe.StaticSourceSpace(n.outputStruct),i=this.operation.pipelineComp(r);return{pipeline:[...n.pipeline,...i.pipeline],outputStruct:i.outputStruct}}refine(e,n,r){return this.logError("refinement-with-multistage-view","A multi-segment view cannot be used as a refinement"),[]}getImplicitName(){return this.operation.getImplicitName()}}aS.ViewArrow=ATe;var lS={},Xg={};Object.defineProperty(Xg,"__esModule",{value:!0}),Xg.refine=void 0;const B7=ts,vTe=at,$7=l0;function _Te(t,e,n){var r,i;if(e.length!==1)return t.logError("refinement-with-multistage-view","Named refinements of multi-stage views are not supported"),e;const s={...e[0]},o=n;if((0,B7.isRawSegment)(s))t.logError("refinement-of-raw-query","Cannot refine raw query, must add an explicit query stage");else if(s.type==="partial"&&o.type!=="index"&&o.type!=="raw"?s.type=o.type:o.type!==s.type&&t.logError("mismatched-view-types-for-refinement",`cannot refine ${s.type} view with ${o.type} view`),o.type!=="index"&&s.type!=="index"&&o.type!=="raw"&&(o.orderBy!==void 0&&!o.defaultOrderBy&&(s.orderBy===void 0||s.defaultOrderBy?s.orderBy=o.orderBy:t.logError("ordering-overridden-in-refinement","refinement cannot override existing ordering")),o.limit!==void 0&&(s.limit===void 0?s.limit=o.limit:t.logError("limit-overridden-in-refinement","refinement cannot override existing limit"))),s.filterList=s.filterList!==void 0||o.filterList!==void 0?[...(r=s.filterList)!==null&&r!==void 0?r:[],...(i=o.filterList)!==null&&i!==void 0?i:[]]:void 0,(0,B7.isQuerySegment)(o)&&(0,B7.isQuerySegment)(s)){const u=[],a=[],l=new Map(s.queryFields.map(c=>[(0,$7.nameFromDef)(c),c]));for(const c of o.queryFields)l.has((0,$7.nameFromDef)(c))?u.push(c):a.push(c);s.queryFields=[...s.queryFields,...a],u.length>0&&t.logError("name-conflict-in-refinement",`overlapping fields in refinement: ${u.map($7.nameFromDef)}`),s.compositeFieldUsage=(0,vTe.mergeCompositeFieldUsage)(s.compositeFieldUsage,o.compositeFieldUsage)}else o.type==="index"&&s.type==="index"&&(s.indexFields=[...o.indexFields,...s.indexFields]);return[s]}Xg.refine=_Te,Object.defineProperty(lS,"__esModule",{value:!0}),lS.ViewRefine=void 0;const STe=Ur,CTe=hs,bTe=Xg,TTe=b0;class RTe extends TTe.View{constructor(e,n){super({base:e,refinement:n}),this.base=e,this.refinement=n,this.elementType="refine"}pipelineComp(e,n){const r=this.base.pipelineComp(e),i=this.refinement.refine(e,r.pipeline,n);return{pipeline:i,annotation:r.annotation,outputStruct:i.length>0?(0,CTe.getFinalStruct)(this.refinement,e.structDef(),i):STe.ErrorFactory.structDef}}refine(e,n,r){const i=this.pipeline(e,r);return i.length!==1?(this.refinement.logError("refinement-with-multistage-view","refinement must have exactly one stage"),n):(0,bTe.refine)(this,n,i[0])}getImplicitName(){return this.base.getImplicitName()}}lS.ViewRefine=RTe;var cS={};Object.defineProperty(cS,"__esModule",{value:!0}),cS.ReferenceView=void 0;const k7=Ke,VG=Ur,OTe=hs,DTe=Sr,wTe=Xg,NTe=b0;class FTe extends NTe.View{constructor(e){super({reference:e}),this.reference=e,this.elementType="reference-view"}pipelineComp(e,n){return this._pipelineComp(e)}_pipelineComp(e,{forRefinement:n}={forRefinement:!1}){const r=this.reference.getField(e),i=function(){return{inputStruct:VG.ErrorFactory.structDef,outputStruct:VG.ErrorFactory.structDef,pipeline:[],error:!0}};if(!r.found)return this.reference.logError(r.error.code,r.error.message),i();if(!(r.found instanceof DTe.SpaceField))throw new Error("Expected space field");const s=r.found.fieldDef();if(s===void 0)throw new Error("Expected field to have definition");if((0,k7.isAtomic)(s)){const o={type:"reduce",queryFields:[this.reference.refToField],compositeFieldUsage:s.compositeFieldUsage},u=this.reference.nameString,a={...(0,k7.sourceBase)(e.structDef()),type:"query_result",name:u,fields:[s]};return{pipeline:[o],name:u,outputStruct:a}}else return(0,k7.isTurtle)(s)?this.reference.list.length>1?(n?this.logError("refinement-with-joined-view","Cannot use view from join as refinement"):this.logError("nest-of-joined-view","Cannot use view from join"),i()):{pipeline:[...s.pipeline],name:s.name,annotation:s.annotation,outputStruct:(0,OTe.getFinalStruct)(this.reference,e.structDef(),s.pipeline)}:(n?this.reference.logError("refinement-with-source",`named refinement \`${this.reference.refString}\` must be a view, found a ${s.type}`):this.reference.logError("nest-of-source","This operation is not supported"),i())}getRefinementSegment(e){const{pipeline:n,error:r}=this._pipelineComp(e,{forRefinement:!0});if(!r){if(n.length!==1){this.reference.logError("refinement-with-multistage-view",`named refinement \`${this.reference.refString}\` must have exactly one stage`);return}return n[0]}}refine(e,n,r){const i=this.getRefinementSegment(e);return i?(0,wTe.refine)(this,n,i):n}getImplicitName(){return this.reference.nameString}}cS.ReferenceView=FTe;var fS={},Zg={},xS={},em={};Object.defineProperty(em,"__esModule",{value:!0}),em.Index=void 0;const LTe=Ye,ITe=wn;let BTe=class extends LTe.MalloyElement{constructor(e){super({fields:e}),this.fields=e,this.elementType="index",this.forceQueryClass=ITe.QueryClass.Index,this.queryRefinementStage=void 0}useWeight(e){this.has({weightBy:e}),this.weightBy=e}};em.Index=BTe;var tm={};Object.defineProperty(tm,"__esModule",{value:!0}),tm.SampleProperty=void 0;const $Te=Ye,YG=wn;class kTe extends $Te.MalloyElement{constructor(e){super(),this.sample=e,this.elementType="sampleProperty",this.queryRefinementStage=YG.LegalRefinementStage.Tail,this.forceQueryClass=YG.QueryClass.Index}sampling(){return this.sample}}tm.SampleProperty=kTe;var dS={};Object.defineProperty(dS,"__esModule",{value:!0}),dS.IndexFieldSpace=void 0;const KG=at,JG=Ke,M7=pt,MTe=Sr,PTe=No,UTe=Ig,jTe=Cr;class qTe extends PTe.QueryOperationSpace{constructor(){super(...arguments),this.segmentType="index"}pushFields(...e){for(const n of e)n instanceof M7.FieldReference?super.pushFields(n):n instanceof M7.WildcardFieldReference?this.addWild(n):n.logError("invalid-field-in-index-query","Internal error, not expected in index query")}getPipeSegment(e){if(e)return this.logError("refinement-of-index-segment","index query operations cannot be refined"),{type:"index",indexFields:[]};let n=(0,KG.emptyCompositeFieldUsage)(),r=(0,KG.emptyNarrowedCompositeFieldResolution)();const i=[],s=this.inputSpace().structDef();for(const[o,u]of this.entries())if(u instanceof MTe.SpaceField){let a,l;const c=this.expandedWild[o];if(c)i.push({type:"fieldref",path:c.path}),a=c.entry.typeDesc().compositeFieldUsage;else if(u instanceof UTe.ReferenceField){const d=u.fieldRef,h=d.getField(this.exprSpace);h.error?d.logError(h.error.code,h.error.message):(i.push(d.refToField),a=h.found.typeDesc().compositeFieldUsage,l=d)}const f=this.applyNextCompositeFieldUsage(s,n,r,a,l);n=f.compositeFieldUsage,r=f.narrowedCompositeFieldResolution}return this._compositeFieldUsage=n,{type:"index",indexFields:i}}addRefineFromFields(e){}addWild(e){var n;let r=this.exprSpace;const i=[];if(e.joinPath)for(const u of e.joinPath.list){const a=u.refString;i.push(a);const l=r.entry(a);if(l)if(l instanceof jTe.StructSpaceField)r=l.fieldSpace;else{u.logError("invalid-wildcard-source",`Field '${a}' does not contain rows and cannot be expanded with '*'`);return}else{u.logError("wildcard-source-not-found",`No such field as '${a}'`);return}}const s=this.dialectObj(),o=[];for(const[u,a]of r.entries()){if(e.except.has(u)||a.refType==="parameter")continue;const l=M7.IndexFieldReference.indexOutputName([...i,u]);if(this.entry(l)){const c=(n=this.expandedWild[l].path)===null||n===void 0?void 0:n.join(".");e.logError("name-conflict-in-wildcard-expansion",`Cannot expand '${u}' in '${e.refString}' because a field with that name already exists${c?` (conflicts with ${c})`:""}`)}else{const c=a.typeDesc();JG.TD.isLeafAtomic(c)&&(0,JG.expressionIsScalar)(c.expressionType)&&(s===void 0||!s.ignoreInProject(u))&&(o.push({name:l,entry:a}),this.expandedWild[l]={path:i.concat(u),entry:a})}}for(const u of o.sort((a,l)=>a.name.localeCompare(l.name)))this.setEntry(u.name,u.entry)}}dS.IndexFieldSpace=qTe,Object.defineProperty(xS,"__esModule",{value:!0}),xS.IndexBuilder=void 0;const P7=Ke,HTe=Ur,zTe=Ou,QTe=em,GTe=A0,WTe=tm,VTe=dS,U7=at;class YTe{constructor(e,n,r,i){this.filters=[],this.alwaysJoins=[],this.type="index",this.resultFS=new VTe.IndexFieldSpace(e,n,r,i),this.inputFS=this.resultFS.inputSpace()}execute(e){e instanceof zTe.Filter?e.queryExecute(this):e instanceof GTe.Limit?(this.limit&&this.limit.logError("index-limit-already-specified","Ignored, too many limit: statements"),this.limit=e):e instanceof QTe.Index?(this.resultFS.pushFields(...e.fields.list),e.weightBy&&(this.indexOn&&this.indexOn.logError("index-by-already-specified","Ignoring previous BY"),this.indexOn=e.weightBy)):e instanceof WTe.SampleProperty?this.sample=e.sampling():e.logError("illegal-operation-for-index","Not legal in an index query operation")}get compositeFieldUsage(){return this.resultFS.compositeFieldUsage}finalize(e){var n;if(e&&!(0,P7.isIndexSegment)(e)&&!(0,P7.isPartialSegment)(e))return this.resultFS.logError("refinement-of-index-segment",`Can't refine index with ${e.type}`),HTe.ErrorFactory.indexSegment;const r=this.resultFS.getPipeSegment(e),i=(e==null?void 0:e.filterList)||[];this.filters.length>0&&!i?r.filterList=this.filters:i&&(r.filterList=[...i,...this.filters]),e!=null&&e.limit&&(r.limit=e.limit),this.limit&&(r.limit=this.limit.limit),this.indexOn&&(r.weightMeasure=this.indexOn.refString),e&&(0,P7.isIndexSegment)(e)&&(e!=null&&e.sample)&&(r.sample=e.sample),this.sample&&(r.sample=this.sample),this.alwaysJoins.length>0&&(r.alwaysJoins=[...this.alwaysJoins]);const s=e&&e.type==="index"&&(n=e.compositeFieldUsage)!==null&&n!==void 0?n:(0,U7.emptyCompositeFieldUsage)();return r.compositeFieldUsage=(0,U7.mergeCompositeFieldUsage)(s,this.compositeFieldUsage),r}}xS.IndexBuilder=YTe;var hS={},nm={};Object.defineProperty(nm,"__esModule",{value:!0}),nm.GroupBy=void 0;const KTe=xs,XG=wn;class JTe extends KTe.DefinitionList{constructor(){super(...arguments),this.elementType="groupBy",this.queryRefinementStage=XG.LegalRefinementStage.Single,this.forceQueryClass=XG.QueryClass.Grouping}}nm.GroupBy=JTe;var pS={};Object.defineProperty(pS,"__esModule",{value:!0}),pS.ProjectFieldSpace=void 0;const gS=Ke,XTe=No;class ZTe extends XTe.QuerySpace{constructor(){super(...arguments),this.segmentType="project"}canContain(e){return e===void 0||!gS.TD.isAtomic(e)||(0,gS.expressionIsAggregate)(e.expressionType)?!1:(0,gS.expressionInvolvesAggregate)(e.expressionType)&&(0,gS.expressionIsAnalytic)(e.expressionType)?(this.logError("aggregate-analytic-in-select","Cannot add aggregate analyics to select"),!1):!0}}pS.ProjectFieldSpace=ZTe;var T0={},wf={};Object.defineProperty(wf,"__esModule",{value:!0}),wf.Ordering=wf.OrderBy=void 0;const eRe=Ke,ZG=v0,eW=Ye,tRe=wn;class nRe extends eW.MalloyElement{constructor(e,n){super(),this.field=e,this.dir=n,this.elementType="orderBy",e instanceof ZG.FieldName&&this.has({field:e})}get modelField(){return typeof this.field=="number"?this.field:this.field.refString}getOrderBy(e){var n;if(this.field instanceof ZG.FieldName&&e.isQueryFieldSpace()){const i=e.outputSpace(),s=this.field.getField(i);s.error&&this.field.logError(s.error.code,s.error.message),(!s.found||!s.isOutputField)&&this.logError("order-by-not-found-in-output",`Unknown field ${this.field.refString} in output space`),(0,eRe.expressionIsAnalytic)((n=s.found)===null||n===void 0?void 0:n.typeDesc().expressionType)&&this.logError("order-by-analytic",`Illegal order by of analytic field ${this.field.refString}`)}const r={field:this.modelField};return this.dir&&(r.dir=this.dir),r}}wf.OrderBy=nRe;class rRe extends eW.ListOf{constructor(e){super(e),this.elementType="ordering",this.queryRefinementStage=tRe.LegalRefinementStage.Tail,this.forceQueryClass=void 0}getOrderBy(e){return this.list.map(n=>n.getOrderBy(e))}}wf.Ordering=rRe,Object.defineProperty(T0,"__esModule",{value:!0}),T0.ReduceBuilder=T0.QuerySegmentBuilder=void 0;const Fo=Ke,iRe=Ur,sRe=v0,oRe=A0,uRe=wf,aRe=No,lRe=xs,j7=at;function tW(t){return t.type==="fieldref"?t.path[t.path.length-1]:t.name}class nW{constructor(){this.alwaysJoins=[],this.filters=[]}execute(e){if(e.queryExecute){e.queryExecute(this);return}e instanceof lRe.DefinitionList?this.resultFS.pushFields(...e.list):e instanceof oRe.Limit?this.limit?e.logError("limit-already-specified","Query operation already limited"):this.limit=e.limit:e instanceof uRe.Ordering&&(this.order?e.logError("ordering-already-specified","Query operation already sorted"):this.order=e)}get compositeFieldUsage(){return this.resultFS.compositeFieldUsage}refineFrom(e,n){var r;e&&e.type!=="index"&&e.type!=="raw"&&(!this.limit&&e.orderBy&&!e.defaultOrderBy&&(n.orderBy=e.orderBy),!this.limit&&e.limit&&(n.limit=e.limit)),this.order&&(n.orderBy=this.order.getOrderBy(this.inputFS),delete n.defaultOrderBy),this.limit&&(n.limit=this.limit);const i=(e==null?void 0:e.filterList)||[];this.filters.length>0&&!i?n.filterList=this.filters:i&&(n.filterList=[...i,...this.filters]),this.alwaysJoins.length>0&&(n.alwaysJoins=[...this.alwaysJoins]);const s=e&&(0,Fo.isQuerySegment)(e)&&(r=e.compositeFieldUsage)!==null&&r!==void 0?r:(0,j7.emptyCompositeFieldUsage)();n.compositeFieldUsage=(0,j7.mergeCompositeFieldUsage)(s,this.compositeFieldUsage)}}T0.QuerySegmentBuilder=nW;class cRe extends nW{constructor(e,n,r,i){super(),this.type="grouping",this.resultFS=new aRe.ReduceFieldSpace(e,n,r,i),this.inputFS=this.resultFS.inputSpace()}finalize(e){let n;if(e)if((0,Fo.isReduceSegment)(e)||(0,Fo.isPartialSegment)(e))n=e;else return this.resultFS.logError("incompatible-segment-for-reduce-refinement",`Can't refine reduce with ${e.type}`),iRe.ErrorFactory.reduceSegment;const r=this.resultFS.getQuerySegment(n);if(this.refineFrom(n,r),r.orderBy){for(const i of r.orderBy)if(typeof i.field=="number"){const s=r.queryFields[i.field-1];i.field=tW(s)}}if(r.orderBy===void 0||r.defaultOrderBy){let i;for(const s of r.queryFields){let o=!1,u=!1,a;const l=tW(s);if(s.type==="fieldref"){const c=s.path.map(d=>new sRe.FieldName(d)),f=this.inputFS.lookup(c).found;if(f){const d=f.typeDesc();a=d.type,o=(0,Fo.expressionIsAggregate)(d.expressionType),u=(0,Fo.expressionIsAnalytic)(d.expressionType)}else continue}else a=s.type,o=(0,Fo.hasExpression)(s)&&(0,Fo.expressionIsAggregate)(s.expressionType),u=(0,Fo.hasExpression)(s)&&(0,Fo.expressionIsAnalytic)(s.expressionType);if((0,Fo.isTemporalType)(a)||o){r.defaultOrderBy=!0,r.orderBy=[{field:l,dir:"desc"}],i=void 0;break}(0,Fo.canOrderBy)(a)&&!u&&!i&&(i=l)}i&&(r.defaultOrderBy=!0,r.orderBy=[{field:i,dir:"asc"}])}return r}}T0.ReduceBuilder=cRe,Object.defineProperty(hS,"__esModule",{value:!0}),hS.ProjectBuilder=void 0;const rW=Ke,fRe=Ur,xRe=nm,dRe=pS,hRe=T0;class pRe extends hRe.QuerySegmentBuilder{constructor(e,n,r,i){super(),this.type="project",this.resultFS=new dRe.ProjectFieldSpace(e,n,r,i),this.inputFS=this.resultFS.inputSpace()}execute(e){e.elementType==="having"||e instanceof xRe.GroupBy?e.logError("illegal-operation-in-select-segment","Illegal statement in a select query operation"):super.execute(e)}finalize(e){let n;if(e)if((0,rW.isProjectSegment)(e)||(0,rW.isPartialSegment)(e))n=e;else return this.resultFS.logError("incompatible-segment-for-select-refinement",`Can't refine select with ${e.type}`),fRe.ErrorFactory.projectSegment;const r=this.resultFS.getQuerySegment(n);return this.refineFrom(n,r),r}}hS.ProjectBuilder=pRe;var mS={};Object.defineProperty(mS,"__esModule",{value:!0}),mS.PartialBuilder=void 0;const gRe=ts,mRe=T0;class yRe extends mRe.ReduceBuilder{finalize(e){const n=super.finalize(e);if((0,gRe.isQuerySegment)(n))return{...n,type:"partial"};throw new Error(`Partial Builder cannot finalize from ${n.type}`)}}mS.PartialBuilder=yRe,Object.defineProperty(Zg,"__esModule",{value:!0}),Zg.QOpDesc=void 0;const ERe=xS,ARe=hS,vRe=T0,_Re=Ye,SRe=hs,CRe=Cr,Nf=wn,bRe=mS;class TRe extends _Re.ListOf{constructor(){super(...arguments),this.elementType="queryOperation"}computeType(){var e;let n,r=!1;this.refineThis&&(this.refineThis.type==="reduce"?n=Nf.QueryClass.Grouping:this.refineThis.type==="project"?n=Nf.QueryClass.Project:this.refineThis.type==="index"&&(n=Nf.QueryClass.Index));for(const i of this.list)i.forceQueryClass&&(n?n!==i.forceQueryClass&&i.logError(`illegal-${n}-operation`,`Not legal in ${n} query`):n=i.forceQueryClass),r||(r=(e=i.needsExplicitQueryClass)!==null&&e!==void 0?e:!1);return n===void 0&&r&&(this.logError("ambiguous-view-type",{}),n=Nf.QueryClass.Project),this.opClass=n,n}refineFrom(e){this.refineThis=e}getBuilder(e,n,r){switch(this.computeType()){case Nf.QueryClass.Grouping:return new vRe.ReduceBuilder(e,this.refineThis,n,r);case Nf.QueryClass.Project:return new ARe.ProjectBuilder(e,this.refineThis,n,r);case Nf.QueryClass.Index:return new ERe.IndexBuilder(e,this.refineThis,n,r);case void 0:return new bRe.PartialBuilder(e,this.refineThis,n,r)}}getOp(e,n){const r=this.getBuilder(e,n,this);for(const s of this.list)r.execute(s);const i=r.finalize(this.refineThis);return{segment:i,outputSpace:()=>new CRe.StaticSourceSpace((0,SRe.opOutputStruct)(this,e.structDef(),i))}}}Zg.QOpDesc=TRe,Object.defineProperty(fS,"__esModule",{value:!0}),fS.QOpDescView=void 0;const RRe=Ke,ORe=Cr,iW=Zg,DRe=hs,q7=wn,wRe=b0;class NRe extends wRe.View{constructor(e){super({operation:e}),this.operation=e,this.elementType="qopdesc-view"}pipelineComp(e,n){const r=this.operation.getOp(e,n);return{pipeline:[r.segment],outputStruct:r.outputSpace().structDef()}}getOp(e,n,r,i){return(0,RRe.isRawSegment)(i)?(this.logError("refinement-of-raw-query","A raw query cannot be refined"),i):(r.refineFrom(i),r.getOp(e,n).segment)}refine(e,n,r){const i=[...n];if(i.length===0)return i;if(i.length===1)return this.operation.refineFrom(i[0]),[this.getOp(e,r,this.operation,i[0])];const s=new iW.QOpDesc([]),o=new iW.QOpDesc([]);for(const u of this.operation.list)switch(u.queryRefinementStage){case q7.LegalRefinementStage.Head:s.push(u);break;case q7.LegalRefinementStage.Single:u.logError("illegal-multistage-refinement-operation","Illegal in refinement of a query with more than one stage");break;case q7.LegalRefinementStage.Tail:o.push(u);break;default:u.logError("illegal-refinement-operation","Illegal query refinement")}if(s.notEmpty()&&(this.has({headRefinements:s}),i[0]=this.getOp(e,void 0,s,i[0])),o.notEmpty()){const u=i.length-1;this.has({tailRefinements:o});const a=(0,DRe.getFinalStruct)(this,e.structDef(),i.slice(-1));i[u]=this.getOp(new ORe.StaticSourceSpace(a),void 0,o,i[u])}return i}getImplicitName(){}}fS.QOpDescView=NRe;var yn={},FRe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),LRe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),IRe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&FRe(e,t,n);return LRe(e,t),e};Object.defineProperty(yn,"__esModule",{value:!0}),yn.FieldDefinitionValue=yn.DefSpace=yn.DimensionFieldDeclaration=yn.MeasureFieldDeclaration=yn.DeclareFieldDeclaration=yn.ProjectFieldDeclaration=yn.GroupByFieldDeclaration=yn.AggregateFieldDeclaration=yn.CalculateFieldDeclaration=yn.AtomicFieldDeclaration=void 0;const H7=Ke,sW=IRe(Wt),BRe=ph,$Re=Ye,Ff=jn,kRe=_r,MRe=Sr;class R0 extends $Re.MalloyElement{constructor(e,n,r){super({expr:e}),this.expr=e,this.defineName=n,this.exprSrc=r,this.isNoteableObj=!0,this.extendNote=kRe.extendNoteMethod}getName(){return this.defineName}fieldDef(e,n){return this.queryFieldDef(new z7(e,this),n)}executesInOutputSpace(){return!1}queryFieldDef(e,n){let r;function i(){if(e.isQueryFieldSpace())return e.outputSpace();throw new Error("must be in a query -- weird internal error")}try{const o=this.executesInOutputSpace()?i():e;r=this.expr.getExpression(o)}catch(o){return this.logError("failed-field-definition",`Cannot define '${n}', ${o.message}`),{name:n,type:"error"}}if(r.type==="null"&&(this.expr.logWarning("null-typed-field-definition",'null value defaults to type number, use "null::TYPE" to specify correct type'),r={type:"number",value:r.value,expressionType:r.expressionType,evalSpace:r.evalSpace,compositeFieldUsage:r.compositeFieldUsage}),(0,H7.isAtomicFieldType)(r.type)&&r.type!=="error"){this.typecheckExprValue(r);const o=(0,H7.mkFieldDef)(sW.atomicDef(r),n);return(o.type==="date"||o.type==="timestamp")&&(0,BRe.isGranularResult)(r)&&(o.timeframe=r.timeframe),o.location=this.location,o.e=r.value,o.compositeFieldUsage=r.compositeFieldUsage,r.expressionType&&(o.expressionType=r.expressionType),this.exprSrc&&(o.code=this.exprSrc),this.note&&(o.annotation=this.note),o}if(!(e instanceof z7&&e.foundCircle)&&r.type!=="error"){const o=sW.inspect(r);this.logError("invalid-type-for-field-definition",`Cannot define '${n}', unexpected type: ${o}`)}return{name:n,type:"error"}}makeEntry(e){e.newEntry(this.defineName,this,new oW(e,this))}}yn.AtomicFieldDeclaration=R0;class PRe extends R0{constructor(){super(...arguments),this.elementType="calculateFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckCalculate)(e,this)}executesInOutputSpace(){return!0}}yn.CalculateFieldDeclaration=PRe;class URe extends R0{constructor(){super(...arguments),this.elementType="aggregateFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckAggregate)(e,this)}}yn.AggregateFieldDeclaration=URe;class jRe extends R0{constructor(){super(...arguments),this.elementType="groupByFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckGroupBy)(e,this)}}yn.GroupByFieldDeclaration=jRe;class qRe extends R0{constructor(){super(...arguments),this.elementType="projectFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckProject)(e,this)}}yn.ProjectFieldDeclaration=qRe;class HRe extends R0{constructor(){super(...arguments),this.elementType="declareFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckDeclare)(e,this)}}yn.DeclareFieldDeclaration=HRe;class zRe extends R0{constructor(){super(...arguments),this.elementType="measureFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckMeasure)(e,this)}}yn.MeasureFieldDeclaration=zRe;class QRe extends R0{constructor(){super(...arguments),this.elementType="dimensionFieldDeclaration"}typecheckExprValue(e){(0,Ff.typecheckDimension)(e,this)}}yn.DimensionFieldDeclaration=QRe;class z7{constructor(e,n){this.realFS=e,this.circular=n,this.type="fieldSpace",this.foundCircle=!1}structDef(){return this.realFS.structDef()}emptyStructDef(){return this.realFS.emptyStructDef()}entry(e){return this.realFS.entry(e)}lookup(e){return e[0]&&e[0].refString===this.circular.defineName?(this.foundCircle=!0,{error:{message:`Circular reference to '${this.circular.defineName}' in definition`,code:"circular-reference-in-field-definition"},found:void 0}):this.realFS.lookup(e)}entries(){return this.realFS.entries()}dialectName(){return this.realFS.dialectName()}dialectObj(){return this.realFS.dialectObj()}isQueryFieldSpace(){return this.realFS.isQueryFieldSpace()}outputSpace(){if(this.realFS.isQueryFieldSpace())return this.realFS.outputSpace();throw new Error("Not a query field space")}inputSpace(){if(this.realFS.isQueryFieldSpace())return this.realFS.inputSpace();throw new Error("Not a query field space")}isProtectedAccessSpace(){return!0}}yn.DefSpace=z7;class oW extends MRe.SpaceField{constructor(e,n){super(),this.space=e,this.exprDef=n,this.fieldName=n.defineName}get name(){return this.fieldName}fieldDef(){var e;const n=(e=this.defInSource)!==null&&e!==void 0?e:this.exprDef.fieldDef(this.space,this.name);return this.defInSource=n,n}getQueryFieldDef(e){if(!this.defInQuery){const n=this.exprDef.queryFieldDef(e,this.name);this.defInQuery=n}return this.defInQuery}typeDesc(){const e=this.defInQuery||this.fieldDef();if((0,H7.isAtomic)(e))return this.fieldTypeFromFieldDef(e);throw new Error(`Can't get typeDesc for ${e.type}`)}entryType(){return(this.defInQuery||this.fieldDef()).type}}yn.FieldDefinitionValue=oW;var yS={};Object.defineProperty(yS,"__esModule",{value:!0}),yS.Aggregate=void 0;const GRe=xs,uW=wn;let WRe=class extends GRe.DefinitionList{constructor(){super(...arguments),this.elementType="aggregateList",this.queryRefinementStage=uW.LegalRefinementStage.Single,this.forceQueryClass=uW.QueryClass.Grouping}};yS.Aggregate=WRe;var ES={};Object.defineProperty(ES,"__esModule",{value:!0}),ES.Calculate=void 0;const VRe=xs,YRe=wn;class KRe extends VRe.DefinitionList{constructor(){super(...arguments),this.elementType="calculate",this.forceQueryClass=void 0,this.needsExplicitQueryClass=!0,this.queryRefinementStage=YRe.LegalRefinementStage.Single}}ES.Calculate=KRe;var rm={};Object.defineProperty(rm,"__esModule",{value:!0}),rm.Dimensions=void 0;const JRe=c0;class XRe extends JRe.DeclareFields{constructor(){super(...arguments),this.elementType="dimensionList"}}rm.Dimensions=XRe;var im={};Object.defineProperty(im,"__esModule",{value:!0}),im.Measures=void 0;const ZRe=c0;class e6e extends ZRe.DeclareFields{constructor(){super(...arguments),this.elementType="measureList"}}im.Measures=e6e;var AS={};Object.defineProperty(AS,"__esModule",{value:!0}),AS.Nests=void 0;const t6e=xs,aW=wn;class n6e extends t6e.DefinitionList{constructor(e){super(e),this.elementType="nestedQueries",this.queryRefinementStage=aW.LegalRefinementStage.Single,this.forceQueryClass=aW.QueryClass.Grouping}}AS.Nests=n6e;var vS={};Object.defineProperty(vS,"__esModule",{value:!0}),vS.ProjectStatement=void 0;const r6e=xs,lW=wn;class i6e extends r6e.DefinitionList{constructor(){super(...arguments),this.elementType="projectStatement",this.forceQueryClass=lW.QueryClass.Project,this.queryRefinementStage=lW.LegalRefinementStage.Single}queryExecute(e){e.type==="project"&&e.resultFS.pushFields(...this.list)}}vS.ProjectStatement=i6e;var O0={},Qa={};Object.defineProperty(Qa,"__esModule",{value:!0}),Qa.findReferences=Qa.deprecatedParseTableURI=Qa.constructTableKey=void 0;const s6e=Ql,Q7=fn;function G7(t){const e=(0,Q7.getStringIfShort)(t);if(e)return e;const n=[],r=t.string().sqlString();if(r){for(const i of(0,Q7.getStringParts)(r))typeof i=="string"&&n.push(i);return n.join("")}return""}class o6e{constructor(e,n){this.trans=e,this.tokens=n,this.needTables={},this.needImports={}}registerTableReference(e,n,r){const i=cW(e,n);this.needTables[i]||(this.needTables[i]={connectionName:e,tablePath:n,firstReference:r})}enterTableMethod(e){const n=(0,Q7.getId)(e.connectionId()),r=G7(e.tablePath()),i=this.trans.rangeFromContext(e);this.registerTableReference(n,r,i)}enterTableFunction(e){const n=G7(e.tableURI()),{connectionName:r,tablePath:i}=fW(n),s=this.trans.rangeFromContext(e);this.registerTableReference(r,i,s)}enterImportURL(e){const n=G7(e);this.needImports[n]||(this.needImports[n]=this.trans.rangeFromContext(e))}}function cW(t,e){return t===void 0?e:`${t}:${e}`}Qa.constructTableKey=cW;function fW(t){const e=t.match(/^([^:]*):(.*)$/);if(e){const[,n,r]=e;return{connectionName:n,tablePath:r}}else return{tablePath:t}}Qa.deprecatedParseTableURI=fW;function u6e(t,e,n){const r=new o6e(t,e),i=r;return s6e.ParseTreeWalker.DEFAULT.walk(i,n),{tables:r.needTables,urls:r.needImports}}Qa.findReferences=u6e,Object.defineProperty(O0,"__esModule",{value:!0}),O0.TableFunctionSource=O0.TableMethodSource=O0.TableSource=void 0;const xW=Qa,a6e=Ms,dW=Ur;class W7 extends a6e.Source{getSourceDef(){var e,n,r;const i=this.getTableInfo();if(i===void 0)return dW.ErrorFactory.structDef;const{tablePath:s,connectionName:o}=i,u=(0,xW.constructTableKey)(o,s),a=(e=this.translator())===null||e===void 0?void 0:e.root.schemaZone.getEntry(u);let l=`Schema read failure for table '${s}' for connection '${o}'`;if(a){if(a.status==="present"){(n=this.document())===null||n===void 0||n.checkExperimentalDialect(this,a.value.dialect),a.value.location=this.location,a.value.fields.forEach(f=>{f.location=this.location});const c={...a.value,fields:a.value.fields.map(f=>({...f,location:this.location})),location:this.location};return(r=this.document())===null||r===void 0||r.rememberToAddModelAnnotations(c),c}a.status==="error"&&(l=a.message)}return this.logError("failed-to-fetch-table-schema",l),dW.ErrorFactory.structDef}}O0.TableSource=W7;class l6e extends W7{constructor(e,n){super(),this.connectionName=e,this.tablePath=n,this.elementType="tableMethodSource",this.has({connectionName:e})}getTableInfo(){var e;const n=this.modelEntry(this.connectionName),r=this.connectionName.refString;if(n===void 0)(e=this.namespace())===null||e===void 0||e.setEntry(r,{entry:{type:"connection",name:r},exported:!0},!0);else if(n.entry.type!=="connection"){this.connectionName.logError("invalid-connection-for-table-source",`${this.connectionName.refString} is not a connection`);return}return{tablePath:this.tablePath,connectionName:this.connectionName.refString}}}O0.TableMethodSource=l6e;class c6e extends W7{constructor(e){super(),this.tableURI=e,this.elementType="tableFunctionSource"}getTableInfo(){return(0,xW.deprecatedParseTableURI)(this.tableURI)}}O0.TableFunctionSource=c6e;var _S={};Object.defineProperty(_S,"__esModule",{value:!0}),_S.SQLString=void 0;const f6e=Ye,hW=Do;class x6e extends f6e.MalloyElement{constructor(){super(...arguments),this.elementType="sqlString",this.elements=[],this.containsQueries=!1}complete(){this.has({queries:this.elements.filter(d6e)})}push(e){typeof e=="string"?e.length>0&&this.elements.push(e):e instanceof hW.SourceQueryElement?(this.elements.push(e),this.containsQueries=!0,e.parent=this):e.logError("invalid-sql-source-interpolation","This element is not legal inside an SQL string")}sqlPhrases(){const e=[];for(const n of this.elements)if(typeof n=="string")e.push({sql:n});else{const r=n.getQuery();r?e.push(r.query()):n.sqLog("failed-to-expand-sql-source","Cannot expand into a query")}return e}}_S.SQLString=x6e;function d6e(t){return t instanceof hW.SourceQueryElement}var SS={};Object.defineProperty(SS,"__esModule",{value:!0}),SS.SourceDesc=void 0;const h6e=Ye;class p6e extends h6e.ListOf{constructor(){super(...arguments),this.elementType="sourceDescription"}}SS.SourceDesc=p6e;var CS={};Object.defineProperty(CS,"__esModule",{value:!0}),CS.isSourceProperty=void 0;const g6e=Ou,m6e=c0,y6e=eh,E6e=p0,A6e=th,v6e=nh,_6e=rh,S6e=h0,C6e=Fi;function b6e(t){return t instanceof g6e.Filter||t instanceof C6e.JoinStatement||t instanceof m6e.DeclareFields||t instanceof y6e.FieldListEdit||t instanceof E6e.Renames||t instanceof A6e.PrimaryKey||t instanceof S6e.ObjectAnnotation||t instanceof v6e.Views||t instanceof _6e.TimezoneStatement}CS.isSourceProperty=b6e;var bS={};Object.defineProperty(bS,"__esModule",{value:!0}),bS.isFieldCollectionMember=void 0;const T6e=yn,pW=pt;function R6e(t){return t instanceof pW.FieldReference||t instanceof pW.WildcardFieldReference||t instanceof T6e.AtomicFieldDeclaration}bS.isFieldCollectionMember=R6e;var TS={};Object.defineProperty(TS,"__esModule",{value:!0}),TS.isQueryElement=void 0;const O6e=xh,D6e=dh,w6e=jg,N6e=qg;function F6e(t){return t instanceof O6e.QueryArrow||t instanceof D6e.QueryRefine||t instanceof w6e.QueryReference||t instanceof N6e.QueryRaw}TS.isQueryElement=F6e;var gW={};Object.defineProperty(gW,"__esModule",{value:!0});var RS={};Object.defineProperty(RS,"__esModule",{value:!0}),RS.isQueryProperty=void 0;function L6e(t){return"queryRefinementStage"in t&&"forceQueryClass"in t}RS.isQueryProperty=L6e;var OS={};Object.defineProperty(OS,"__esModule",{value:!0}),OS.isQueryExtendProperty=void 0;const I6e=rm,B6e=Fi,$6e=im;function k6e(t){return t instanceof I6e.Dimensions||t instanceof $6e.Measures||t instanceof B6e.JoinStatement}OS.isQueryExtendProperty=k6e;var DS={};Object.defineProperty(DS,"__esModule",{value:!0}),DS.isFieldPropStatement=void 0;const M6e=E0,P6e=Ou,U6e=A0,j6e=Ah;function q6e(t){return t instanceof P6e.Filter||t instanceof U6e.Limit||t instanceof j6e.PartitionBy||t instanceof M6e.FunctionOrdering}DS.isFieldPropStatement=q6e,function(t){var e=T&&T.__createBinding||(Object.create?function(r,i,s,o){o===void 0&&(o=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(r,o,u)}:function(r,i,s,o){o===void 0&&(o=s),r[o]=i[s]}),n=T&&T.__exportStar||function(r,i){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&e(i,r,s)};Object.defineProperty(t,"__esModule",{value:!0}),n(dg,t),n(Yd,t),n(Kd,t),n(Ms,t),n(mg,t),n(Do,t),n(l_,t),n(c_,t),n(d_,t),n($g,t),n(g_,t),n(m_,t),n(Oo,t),n(eh,t),n(th,t),n(p0,t),n(nh,t),n(rh,t),n(E_,t),n(mh,t),n(v_,t),n(E0,t),n(__,t),n(Ha,t),n(S_,t),n(Eh,t),n(C_,t),n(b_,t),n(T_,t),n(qa,t),n(R_,t),n(O_,t),n(w_,t),n(Wg,t),n(Qg,t),n(Tf,t),n(F_,t),n(L_,t),n(B_,t),n(k_,t),n(M_,t),n(P_,t),n(U_,t),n(_0,t),n(q_,t),n(H_,t),n(z_,t),n(Q_,t),n(G_,t),n(W_,t),n(Y_,t),n(X_,t),n(nr,t),n(tS,t),n(Ah,t),n(_h,t),n(Ch,t),n(rS,t),n(Df,t),n(y0,t),n(iS,t),n(Vg,t),n(C0,t),n(Jg,t),n(sS,t),n(oS,t),n(uS,t),n(dh,t),n(xh,t),n(b0,t),n(aS,t),n(lS,t),n(cS,t),n(fS,t),n(yn,t),n(pt,t),n(yS,t),n(ES,t),n(c0,t),n(rm,t),n(Jg,t),n(Ou,t),n(nm,t),n(em,t),n(Fi,t),n(hg,t),n(A0,t),n(im,t),n(dg,t),n(AS,t),n(wf,t),n(vS,t),n(Zg,t),n(tm,t),n(hh,t),n(bf,t),n(Hg,t),n(O0,t),n(_S,t),n(h0,t),n(wo,t),n(SS,t),n(CS,t),n(ct,t),n(bS,t),n(v0,t),n(Ye,t),n(TS,t),n(gW,t),n(RS,t),n(OS,t),n(DS,t)}(Hv);var wS={},Th={};Object.defineProperty(Th,"__esModule",{value:!0}),Th.ConstantExpression=Th.ConstantFieldSpace=void 0;const H6e=ct;class mW{constructor(){this.type="fieldSpace"}structDef(){throw new Error("ConstantFieldSpace cannot generate a structDef")}emptyStructDef(){throw new Error("ConstantFieldSpace cannot generate a structDef")}lookup(e){return{error:{message:"Only constants allowed in parameter default values",code:"illegal-reference-in-parameter-default"},found:void 0}}entries(){return[]}entry(){}dialectName(){return"~constant-space-unknown-dialect~"}dialectObj(){}isQueryFieldSpace(){return!1}isProtectedAccessSpace(){return!1}}Th.ConstantFieldSpace=mW;class z6e extends H6e.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="constantExpression"}getExpression(e){return this.constantValue()}get constantFs(){return this.cfs||(this.cfs=new mW),this.cfs}constantValue(){return this.expr.getExpression(this.constantFs)}apply(e,n,r){return this.expr.apply(e,n,r)}requestExpression(e){return this.expr.requestExpression(e)}}Th.ConstantExpression=z6e;var Q6e=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),G6e=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),W6e=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Q6e(e,t,n);return G6e(e,t),e};Object.defineProperty(wS,"__esModule",{value:!0}),wS.MalloyToAST=void 0;const yW=eg,V6e=pp,te=W6e(Hv),V7=pg,EW=Jn,Y6e=Hv,kn=fn,Y7=Ke,K6e=fo,J6e=Th,X6e=bu;class AW extends te.SourceQueryElement{constructor(){super(...arguments),this.elementType="parseErrorSourceQuery"}}class K7 extends te.MalloyElement{constructor(e){super(),this.elementType="ignoredByParser",this.malloySrc=e}}const Z6e=["##! m4warnings=error"];class eOe extends V6e.AbstractParseTreeVisitor{constructor(e,n,r){super(),this.parseInfo=e,this.msgLog=n,this.compilerFlags=r;for(const i of Z6e){const s=K6e.Tag.fromTagline(i,this.compilerFlags);this.compilerFlags=s.tag}}internalError(e,n){return this.contextError(e,"internal-translator-error",{message:n}),new Error(`Internal Translator Error: ${n}`)}astError(e,n,r,i){this.msgLog.log((0,V7.makeLogMessage)(n,r,{at:e.location,...i}))}getLocation(e){return{url:this.parseInfo.sourceURL,range:this.parseInfo.rangeFromContext(e)}}getSourceString(e){return this.parseInfo.sourceStream.getText(new EW.Interval(e.start.startIndex,e.stop?e.stop.stopIndex:e.start.startIndex))}contextError(e,n,r,i){this.msgLog.log((0,V7.makeLogMessage)(n,r,{at:this.getLocation(e),...i}))}warnWithReplacement(e,n,r,i){this.msgLog.log((0,V7.makeLogMessage)(e,n,{at:{url:this.parseInfo.sourceURL,range:r},severity:"warn",replacement:i}))}inExperiment(e,n){const r=this.compilerFlags.tag("experimental");return r&&(r.bare()||r.has(e))?!0:(this.contextError(n,"experiment-not-enabled",{experimentId:e}),!1)}m4Severity(){const e=this.compilerFlags.tag("m4warnings");return e?e.text()==="warn"?"warn":"error":!1}m4advisory(e,n,r){const i=this.m4Severity();i&&this.contextError(e,n,r,{severity:i})}only(e,n,r){const i=[];for(const s of e){const o=n(s);o?i.push(o):s instanceof K7||this.astError(s,"unexpected-statement-in-translation",`Parser enountered unexpected statement type '${s.elementType}' when it needed '${r}'`)}return i}getNumber(e){return Number.parseInt(e.text)}getFieldName(e){return this.astAt(new te.FieldName((0,kn.getId)(e)),e.id())}getModelEntryName(e){return this.astAt(new te.ModelEntryReference((0,kn.getId)(e)),e.id())}defaultResult(){return new te.Unimplemented}astAt(e,n){return e.location={url:this.parseInfo.sourceURL,range:this.parseInfo.rangeFromContext(n)},e}getSourceCode(e){const n=e.start.startIndex,r=e.stop||e.start,i=new EW.Interval(n,r.stopIndex);return this.parseInfo.sourceStream.getText(i)}getFilterElement(e){const n=this.getFieldExpr(e),r=new te.FilterElement(n,this.getSourceCode(e));return this.astAt(r,e)}getFieldDefs(e,n){return e.map(r=>this.getFieldDef(r,n))}getFieldExpr(e){const n=this.visit(e);if(n instanceof te.ExpressionDef)return this.astAt(n,e);throw this.internalError(e,`expression node unknown type '${n.elementType}'`)}getPlainStringFrom(e){const[n,r]=(0,kn.getPlainString)(e);for(const i of r)i instanceof yW.ParserRuleContext&&this.contextError(i,"illegal-query-interpolation-outside-sql-block","%{ query } illegal in this string");return n||""}makeSqlString(e,n){for(const r of e.sqlInterpolation())r.CLOSE_CODE()&&this.m4advisory(r,"percent-terminated-query-interpolation","Use %{ ... } instead of %{ ... }%");for(const r of(0,kn.getStringParts)(e))r instanceof yW.ParserRuleContext?n.push(this.visit(r)):n.push(r);n.complete(),this.astAt(n,e)}parseTime(e,n){let r=n(e.text);return r||(this.contextError(e,"failed-to-parse-time-literal","Time data parse error"),r=new te.LiteralTimestamp({text:e.text})),this.astAt(r,e)}getNotes(e){return e.ANNOTATION().map(n=>({text:n.text,at:this.getLocation(e)}))}getIsNotes(e){return this.getNotes(e._beforeIs).concat(this.getNotes(e._afterIs))}visitMalloyDocument(e){const n=this.only(e.malloyStatement().map(r=>this.visit(r)),r=>te.isDocStatementOrDocStatementList(r)&&r,"statement");return new te.Document(n)}visitDefineSourceStatement(e){const r=e.sourcePropertyList().sourceDefinition().map(o=>this.visitSourceDefinition(o)),i=this.getNotes(e.tags()),s=new te.DefineSourceList(r);return s.extendNote({blockNotes:i}),s}getSourceParameter(e){const n=e.fieldExpr(),r=n?this.astAt(new J6e.ConstantExpression(this.getFieldExpr(n)),n):void 0,i=e.malloyType(),s=i?this.getMalloyType(i):void 0;return this.astAt(new te.HasParameter({name:(0,kn.getId)(e.parameterNameDef()),type:s,default:r}),e)}getSourceParameters(e){return e===void 0?[]:(this.inExperiment("parameters",e),e.sourceParameter().map(n=>this.getSourceParameter(n)))}visitSourceDefinition(e){const n=this.visit(e.sqExplore()),r=this.getSourceParameters(e.sourceParameters()),i=new te.DefineSource((0,kn.getId)(e.sourceNameDef()),n instanceof te.SourceQueryElement?n:void 0,!0,r),s=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));return i.extendNote({notes:s}),this.astAt(i,e)}getSourceExtensions(e){return this.astAt(this.visitExploreProperties(e),e)}visitExploreProperties(e){const n=this.only(e.exploreStatement().map(i=>this.visit(i)),i=>te.isSourceProperty(i)&&i,"source property");return new te.SourceDesc(n)}visitTableFunction(e){const n=this.getPlainStringFrom(e.tableURI()),r=this.astAt(new te.TableFunctionSource(n),e);return this.m4advisory(e,"table-function","`table('connection_name:table_path')` is deprecated; use `connection_name.table('table_path')`"),r}visitTableMethod(e){const n=e.connectionId(),r=this.astAt(this.getModelEntryName(n),n),i=this.getPlainStringFrom(e.tablePath());return this.astAt(new te.TableMethodSource(r,i),e)}visitSqlSource(e){const n=e.connectionId(),r=this.astAt(this.getModelEntryName(n),n),i=new te.SQLString,s=e.sqlString();s&&this.makeSqlString(s,i);const o=e.shortString();o&&i.push((0,kn.getShortString)(o));const u=new te.SQLSource(r,i);return this.astAt(u,e)}visitDefJoinMany(e){const n=this.getAccessLabel(e.accessLabel()),r=[];for(const s of e.joinList().joinDef()){const o=this.visit(s);o instanceof te.Join&&(r.push(o),o instanceof te.ExpressionJoin?(o.joinType="many",o.joinOn===void 0&&this.contextError(e,"missing-on-in-join-many","join_many: requires ON expression")):o instanceof te.KeyJoin&&this.contextError(e,"foreign-key-in-join-many","Foreign key join not legal in join_many:"))}const i=new te.JoinStatement(r,n);return i.extendNote({blockNotes:this.getNotes(e.tags())}),i}visitDefJoinOne(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getJoinList(e.joinList()),i=[];for(const o of r)o instanceof te.Join&&(i.push(o),o instanceof te.ExpressionJoin&&(o.joinType="one"));const s=new te.JoinStatement(i,n);return s.extendNote({blockNotes:this.getNotes(e.tags())}),s}visitDefJoinCross(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getJoinList(e.joinList()),i=[];for(const o of r)o instanceof te.Join&&(i.push(o),o instanceof te.ExpressionJoin?o.joinType="cross":o.logError("foreign-key-in-join-cross","Foreign key join not legal in join_cross:"));const s=new te.JoinStatement(i,n);return s.extendNote({blockNotes:this.getNotes(e.tags())}),s}getJoinList(e){return this.only(e.joinDef().map(n=>this.visit(n)),n=>n instanceof te.Join&&n,"join")}getJoinFrom(e){const n=e.isExplore(),r=this.getModelEntryName(e.joinNameDef());if(n){const s=this.getSqExpr(n.sqExpr()),o=this.getNotes(n._before_is).concat(this.getNotes(n._after_is));return{joinFrom:s,notes:o,joinAs:r}}const i=e.sourceArguments();return i?{joinFrom:this.astAt(new te.SQReference(r,this.getSQArguments(i)),e),notes:[],joinAs:r}:{joinAs:r,joinFrom:new te.SQReference(r),notes:[]}}visitQueryJoinStatement(e){return this.astAt(this.visit(e.joinStatement()),e)}visitJoinOn(e){var n;const{joinAs:r,joinFrom:i,notes:s}=this.getJoinFrom(e.joinFrom()),o=new te.ExpressionJoin(r,i),u=e.joinExpression(),a=((n=e.matrixOperation())===null||n===void 0?void 0:n.text.toLocaleLowerCase())||"left";return(0,Y7.isMatrixOperation)(a)?o.matrixOperation=a:this.contextError(e,"unknown-matrix-operation","Internal Error: Unknown matrixOperation"),u&&(o.joinOn=this.getFieldExpr(u)),o.extendNote({notes:this.getNotes(e).concat(s)}),this.astAt(o,e)}visitJoinWith(e){const{joinAs:n,joinFrom:r,notes:i}=this.getJoinFrom(e.joinFrom()),s=this.getFieldExpr(e.fieldExpr()),o=new te.KeyJoin(n,r,s);return o.extendNote({notes:this.getNotes(e).concat(i)}),this.astAt(o,e)}getFieldDef(e,n){const r=e.fieldExpr(),i=(0,kn.getId)(e.fieldNameDef()),s=this.getFieldExpr(r),o=new n(s,i,this.getSourceCode(r)),u=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));return o.extendNote({notes:u}),this.astAt(o,e)}visitDefDimensions(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getFieldDefs(e.defList().fieldDef(),te.DimensionFieldDeclaration),i=new te.Dimensions(r,n);return i.extendNote({blockNotes:this.getNotes(e.tags())}),this.astAt(i,e)}getAccessLabel(e){if(e!==void 0){if(e.INTERNAL_KW())return"internal";if(e.PRIVATE_KW())return"private";if(e.PUBLIC_KW())return"public";throw this.internalError(e,`Unknown access modifier label ${e.text}`)}}getAccessLabelProp(e){if(e!==void 0){if(e.INTERNAL())return"internal";if(e.PRIVATE())return"private";if(e.PUBLIC())return"public";throw this.internalError(e,`Unknown access modifier label ${e.text}`)}}visitDefMeasures(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getFieldDefs(e.defList().fieldDef(),te.MeasureFieldDeclaration),i=new te.Measures(r,n);return i.extendNote({blockNotes:this.getNotes(e.tags())}),this.astAt(i,e)}visitQueryExtend(e){const n=[],r=e.queryExtendStatementList().queryExtendStatement().map(s=>this.visit(s));for(const s of r)if(te.isQueryExtendProperty(s))n.push(s);else throw this.internalError(e,`Query extend matched, but ${s.elementType} found`);const i=new te.ExtendBlock(n);return this.astAt(i,e)}visitDeclareStatement(e){const n=this.getAccessLabel(e.accessLabel()),r=this.getFieldDefs(e.defList().fieldDef(),te.DeclareFieldDeclaration),i=new te.DeclareFields(r,n),s=this.astAt(i,e);return this.m4advisory(e,"declare","`declare:` is deprecated; use `dimension:` or `measure:` inside a source or `extend:` block"),s}visitExploreRenameDef(e){const n=e.fieldName(0),r=e.fieldName(1),i=new te.RenameField((0,kn.getId)(n),this.getFieldName(r));return this.astAt(i,e)}visitDefExploreRename(e){const n=this.getAccessLabel(e.accessLabel()),i=e.renameList().exploreRenameDef().map(o=>this.visitExploreRenameDef(o)),s=new te.Renames(i,n);return this.astAt(s,e)}visitFilterClauseList(e){return new te.Filter(e.fieldExpr().map(n=>this.getFilterElement(n)))}visitWhereStatement(e){const n=this.visitFilterClauseList(e.filterClauseList());return n.having=!1,this.astAt(n,e)}visitHavingStatement(e){const n=this.visitFilterClauseList(e.filterClauseList());return n.having=!0,this.astAt(n,e)}visitDefExploreQuery(e){const n=this.getAccessLabel(e.accessLabel()),r=e.subQueryDefList().exploreQueryDef().map(o=>this.visitExploreQueryDef(o)),i=new te.Views(r,n),s=this.getNotes(e.tags());return i.extendNote({blockNotes:s}),e.QUERY()&&this.m4advisory(e,"query-in-source","Use view: inside of a source instead of query:"),i}visitDefExplorePrimaryKey(e){const n=new te.PrimaryKey(this.getFieldName(e.fieldName()));return this.astAt(n,e)}getFieldNameList(e,n){const r=e.fieldName().map(i=>this.astAt(new n([this.getFieldName(i)]),i));return new te.FieldReferences(r)}visitDefExploreEditField(e){const n=e.ACCEPT()?"accept":"except";return new te.FieldListEdit(n,this.getFieldNameList(e.fieldNameList(),te.AcceptExceptFieldReference))}visitSQInclude(e){const n=this.getSqExpr(e.sqExpr()),r=e.includeBlock(),i=r?this.getIncludeItems(r):void 0,s=new te.SQExtend(n,new te.SourceDesc([]),i);return this.astAt(s,e)}visitDefExploreTimezone(e){return this.visitTimezoneStatement(e.timezoneStatement())}visitTimezoneStatement(e){const n=this.getPlainStringFrom(e),r=this.astAt(new te.TimezoneStatement(n),e.string());return r.isValid||this.astError(r,"invalid-timezone",{timezone:r.tz}),this.astAt(r,e)}visitQueryProperties(e){const n=this.only(e.queryStatement().map(r=>this.astAt(this.visit(r),r)),r=>te.isQueryProperty(r)&&r,"query statement");return new te.QOpDesc(n)}getFieldPath(e,n){const r=e.fieldName().map(i=>this.getFieldName(i));return this.astAt(new n(r),e)}getQueryFieldDef(e,n){const r=this.getFieldDef(e,n);return this.astAt(r,e)}getQueryFieldEntry(e,n,r){const i=e.taggedRef();if(i)return this.getTaggedRef(i,n,r);const s=e.fieldDef();if(s)return this.getQueryFieldDef(s,n);throw new Error("Expected query field entry to be a field reference or definition")}getQueryItems(e,n,r){return this.only(e.queryFieldEntry().map(i=>this.getQueryFieldEntry(i,n,r)),i=>i instanceof te.FieldReference||i instanceof te.AtomicFieldDeclaration?i:!1,"view field")}visitAggregateStatement(e){const n=new te.Aggregate(this.getQueryItems(e.queryFieldList(),te.AggregateFieldDeclaration,te.AggregateFieldReference));return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitGroupByStatement(e){const n=new te.GroupBy(this.getQueryItems(e.queryFieldList(),te.GroupByFieldDeclaration,te.GroupByFieldReference));return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitCalculateStatement(e){const n=new te.Calculate(this.getQueryItems(e.queryFieldList(),te.CalculateFieldDeclaration,te.CalculateFieldReference));return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}getTaggedRef(e,n,r){const i=e.refExpr();if(i){const o=this.getFieldPath(e.fieldPath(),te.ExpressionFieldReference);let u;const a=i.timeframe();a&&(u=new te.ExprGranularTime(new te.ExprIdReference(o),this.visitTimeframe(a).text,!0));const l=i.aggregate();if(l){const f=l.text.toLowerCase();if(f==="sum")u=new te.ExprSum(void 0,o);else return this.contextError(l,"invalid-reference-only-aggregation",`\`${f}\` is not legal in a reference-only aggregation`),o}const c=new n(u,o.outputName);return c.extendNote({notes:this.getNotes(e.tags())}),c}const s=this.getFieldPath(e.fieldPath(),r);return s.extendNote({notes:this.getNotes(e.tags())}),s}getFieldCollectionMember(e,n,r){const i=e.fieldDef();if(i)return this.getFieldDef(i,n);const s=e.taggedRef();if(s)return this.getTaggedRef(s,n,r);const o=e.collectionWildCard();if(o)return this.visitCollectionWildCard(o);throw this.internalError(e,"Unexpected element in fieldCollectionMember")}visitFieldCollection(e){const n=e.collectionMember().map(r=>this.getFieldCollectionMember(r,te.ProjectFieldDeclaration,te.ProjectFieldReference));return this.astAt(new te.ProjectStatement(n),e)}visitProjectStatement(e){e.PROJECT()&&this.m4advisory(e,"project","project: keyword is deprecated, use select:");const n=this.visitFieldCollection(e.fieldCollection());return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitCollectionWildCard(e){var n;const r=e.fieldPath(),i=r?this.getFieldPath(r,te.ProjectFieldReference):void 0,s=this.astAt(new te.WildcardFieldReference(i),e),o=((n=e.starQualified())===null||n===void 0?void 0:n.fieldNameList())||[];for(const u of o)for(const a of u.fieldName())s.except.add((0,kn.getId)(a));return s}visitIndexFields(e){const n=e.indexElement().map(r=>{const i=r.fieldPath();if(!i)return this.astAt(new te.WildcardFieldReference(void 0),e);const s=this.getFieldPath(i,te.IndexFieldReference);return r.STAR()?this.astAt(new te.WildcardFieldReference(s),e):this.astAt(s,e)});return new te.FieldReferences(n)}visitIndexStatement(e){const n=this.visitIndexFields(e.indexFields()),r=new te.Index(n),i=e.fieldName();return i&&r.useWeight(this.getFieldName(i)),this.astAt(r,e)}visitFieldPropertyLimitStatement(e){return this.inExperiment("aggregate_limit",e),this.visitLimitStatement(e.limitStatement())}visitLimitStatement(e){return new te.Limit(this.getNumber(e.INTEGER_LITERAL()))}visitAggregateOrderBySpec(e){const n=e.ASC()?"asc":e.DESC()?"desc":void 0,r=e.fieldExpr(),i=r?this.getFieldExpr(r):void 0;return this.astAt(new te.FunctionOrderBy(i,n),e)}visitAggregateOrderByStatement(e){return this.visitAggregateOrdering(e.aggregateOrdering())}visitAggregateOrdering(e){const n=e.aggregateOrderBySpec().map(r=>this.visitAggregateOrderBySpec(r));return this.astAt(new te.FunctionOrdering(n),e)}visitOrderBySpec(e){const n=e.ASC()?"asc":e.DESC()?"desc":void 0,r=e.INTEGER_LITERAL();if(r)return new te.OrderBy(this.getNumber(r),n);const i=e.fieldName();if(i)return new te.OrderBy(this.getFieldName(i),n);throw this.internalError(e,"can't parse order_by specification")}visitOrdering(e){const n=e.orderBySpec().map(r=>this.visitOrderBySpec(r));return this.astAt(new te.Ordering(n),e)}visitTopStatement(e){const n=this.getNumber(e.INTEGER_LITERAL());return this.astAt(new te.Limit(n),e)}visitTopLevelQueryDefs(e){const n=e.topLevelQueryDef().map(s=>this.visitTopLevelQueryDef(s)),r=this.getNotes(e.tags()),i=new te.DefineQueryList(n);return i.extendNote({blockNotes:r}),i}visitTopLevelQueryDef(e){const n=(0,kn.getId)(e.queryName()),r=this.visit(e.sqExpr()),i=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));if(r instanceof te.SourceQueryElement){const s=new te.DefineQuery(n,r);return s.extendNote({notes:i}),this.astAt(s,e)}throw this.internalError(e,`Expected query definition, got a '${r.elementType}'`)}visitAnonymousQuery(e){const n=e.topLevelAnonQueryDef(),r=this.getSqExpr(n.sqExpr()),i=this.astAt(new te.AnonymousQuery(r),n),s=this.getNotes(e.topLevelAnonQueryDef().tags()),o=this.getNotes(e.tags());return i.extendNote({notes:s,blockNotes:o}),this.m4advisory(n,"anonymous-query","Anonymous `query:` statements are deprecated, use `run:` instead"),this.astAt(i,e)}visitRunStatement(e){const n=e.topLevelAnonQueryDef(),r=this.getSqExpr(n.sqExpr()),i=this.astAt(new te.AnonymousQuery(r),n),s=this.getNotes(e.topLevelAnonQueryDef().tags()),o=this.getNotes(e.tags());return i.extendNote({notes:s,blockNotes:o}),this.astAt(i,e)}visitNestStatement(e){const n=this.visitNestedQueryList(e.nestedQueryList());return n.extendNote({blockNotes:this.getNotes(e.tags())}),n}visitNestedQueryList(e){return new te.Nests(this.only(e.nestEntry().map(n=>this.visit(n)),n=>n instanceof te.NestFieldDeclaration&&n,"query"))}visitNestDef(e){const n=e.queryName();let r;const i=this.getVExpr(e.vExpr());if(n)r=(0,kn.getId)(n);else{const u=i.getImplicitName();u===void 0&&this.contextError(e,"anonymous-nest","`nest:` view requires a name (add `nest_name is ...`)"),r=u??"__unnamed__"}const s=new te.NestFieldDeclaration(r,i),o=e.isDefine();return s.extendNote({notes:this.getNotes(e.tags()).concat(o?this.getIsNotes(o):[])}),this.astAt(s,e)}visitExploreQueryDef(e){const n=(0,kn.getId)(e.exploreQueryNameDef()),r=new te.ViewFieldDeclaration(n,this.getVExpr(e.vExpr())),i=this.getNotes(e).concat(this.getIsNotes(e.isDefine()));return r.extendNote({notes:i}),this.astAt(r,e)}visitExprNot(e){return new te.ExprNot(this.getFieldExpr(e.fieldExpr()))}visitExprBool(e){return new te.Boolean(e.TRUE()?"true":"false")}allFieldExpressions(e){return e.map(n=>this.getFieldExpr(n))}visitExprLogicalOr(e){const n=this.getFieldExpr(e.fieldExpr(0)),r=this.getFieldExpr(e.fieldExpr(1));return new te.ExprLogicalOp(n,"or",r)}visitExprLogicalAnd(e){const n=this.getFieldExpr(e.fieldExpr(0)),r=this.getFieldExpr(e.fieldExpr(1));return new te.ExprLogicalOp(n,"and",r)}visitExprOrTree(e){const n=this.getFieldExpr(e.fieldExpr()),r=this.getFieldExpr(e.partialAllowedFieldExpr());return this.astAt(new te.ExprAlternationTree(n,"|",r),e)}visitExprAndTree(e){const n=this.getFieldExpr(e.fieldExpr()),r=this.getFieldExpr(e.partialAllowedFieldExpr());return this.astAt(new te.ExprAlternationTree(n,"&",r),e)}visitExprCoalesce(e){const n=this.getFieldExpr(e.fieldExpr()[0]),r=this.getFieldExpr(e.fieldExpr()[1]);return this.astAt(new te.ExprCoalesce(n,r),e)}visitPartialCompare(e){const n=e.compareOp().text;if(te.isComparison(n))return this.astAt(new te.PartialCompare(n,this.getFieldExpr(e.fieldExpr())),e);throw this.internalError(e,`partial comparison '${n}' not recognized`)}visitPartialTest(e){const n=e.partialCompare();return n?this.visitPartialCompare(n):this.astAt(new te.PartialIsNull(e.NOT()?"!=":"="),e)}visitPartialAllowedFieldExpr(e){const n=e.fieldExpr();if(n)return this.getFieldExpr(n);const r=e.partialTest();if(r)return this.visitPartialTest(r);throw this.internalError(e,"impossible partial")}visitExprString(e){const n=this.getPlainStringFrom(e);return new te.ExprString(n)}visitExprRegex(e){const n=e.HACKY_REGEX().text;return new te.ExprRegEx(n.slice(2,-1))}visitExprNow(e){return new te.ExprNow}visitExprNumber(e){return new te.ExprNumber(e.text)}visitExprFieldPath(e){const n=new te.ExprIdReference(this.getFieldPath(e.fieldPath(),te.ExpressionFieldReference));return this.astAt(n,e)}visitExprNULL(e){return new te.ExprNULL}visitExprExpr(e){return new te.ExprParens(this.getFieldExpr(e.fieldExpr()))}visitExprMinus(e){return new te.ExprMinus(this.getFieldExpr(e.fieldExpr()))}visitExprAddSub(e){const n=this.getFieldExpr(e.fieldExpr(0)),r=this.getFieldExpr(e.fieldExpr(1)),i=e.PLUS()?"+":"-";return new te.ExprAddSub(n,i,r)}visitExprMulDiv(e){const n=e.STAR()?"*":e.SLASH()?"/":"%";return new te.ExprMulDiv(this.getFieldExpr(e.fieldExpr(0)),n,this.getFieldExpr(e.fieldExpr(1)))}visitExprCompare(e){const n=e.compareOp().text,r=this.getFieldExpr(e.fieldExpr(0)),i=this.getFieldExpr(e.fieldExpr(1));if(te.isEquality(n)){const s=this.parseInfo.rangeFromContext(e);return i instanceof te.ExprNULL&&(n==="="?this.warnWithReplacement("sql-is-null","Use 'is null' to check for NULL instead of '= null'",s,`${this.getSourceCode(e.fieldExpr(0))} is null`):n==="!="&&this.warnWithReplacement("sql-is-not-null","Use 'is not null' to check for NULL instead of '!= null'",s,`${this.getSourceCode(e.fieldExpr(0))} is not null`)),this.astAt(new te.ExprEquality(r,n,i),e)}else if(te.isComparison(n))return this.astAt(new te.ExprCompare(r,n,i),e);throw this.internalError(e,`untranslatable comparison operator '${n}'`)}visitExprUngroup(e){const n=e.fieldName().map(i=>this.getFieldName(i)),r=e.ungroup().text.toLowerCase();return this.astAt(new te.ExprUngroup(r==="all"?r:"exclude",this.getFieldExpr(e.fieldExpr()),n),e)}symmetricAggregateUsageError(e){return`Symmetric aggregate function \`${e}\` must be written as \`${e}(expression)\` or \`path.to.field.${e}()\``}asymmetricAggregateUsageError(e){return`Asymmetric aggregate function \`${e}\` must be written as \`path.to.field.${e}()\`, \`path.to.join.${e}(expression)\`, or \`${e}(expression)\``}visitExprAggregate(e){const n=e.fieldPath(),r=this.getFieldPath(n,te.ExpressionFieldReference),i=n&&r?this.astAt(r,n):void 0,s=e.aggregate().text.toLowerCase(),o=e.fieldExpr();if(e.aggregate().COUNT())return o&&this.contextError(o,"count-expression-with-locality","Expression illegal inside path.count()"),new te.ExprCount(i);const u=o?this.getFieldExpr(o):void 0;if(s==="min"||s==="max")if(u)this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(s));else{const a=this.astAt(new te.ExprIdReference(r),n);return s==="min"?new te.ExprMin(a):new te.ExprMax(a)}else{if(s==="avg")return new te.ExprAvg(u,i);if(s==="sum")return new te.ExprSum(u,i);this.contextError(e,"aggregate-parse-error",`Cannot parse aggregate function ${s}`)}return new te.ExprNULL}visitExprPathlessAggregate(e){const n=e.fieldExpr(),r=n?this.getFieldExpr(n):void 0,i=void 0,s=e.aggregate().text.toLowerCase();if(e.STAR()&&this.m4advisory(e,"wildcard-in-aggregate",`* illegal inside ${s}()`),s==="count")return this.astAt(r?new te.ExprCountDistinct(r):new te.ExprCount,e);if(s==="min"){if(r)return new te.ExprMin(r);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(s))}else if(s==="max"){if(r)return new te.ExprMax(r);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(s))}else{if(r===void 0)return this.contextError(e,"invalid-asymmetric-aggregate",this.asymmetricAggregateUsageError(s)),new te.ExprNULL;const o=e.SOURCE_KW()!==void 0;if(s==="avg")return new te.ExprAvg(r,i,o);if(s==="sum")return new te.ExprSum(r,i,o)}return new te.ExprNULL}visitExprApply(e){return new te.Apply(this.getFieldExpr(e.fieldExpr()),this.getFieldExpr(e.partialAllowedFieldExpr()))}visitExprRange(e){return new te.Range(this.getFieldExpr(e.fieldExpr(0)),this.getFieldExpr(e.fieldExpr(1)))}visitExprCast(e){const n=this.getMalloyOrSQLType(e.malloyOrSQLType());return new te.ExprCast(this.getFieldExpr(e.fieldExpr()),n)}getMalloyType(e){const n=e.text;if((0,Y7.isCastType)(n))return n;throw this.internalError(e,`unknown type '${n}'`)}getMalloyOrSQLType(e){const n=e.malloyType();if(n)return this.getMalloyType(n);const r=e.string();if(r)return{raw:this.getPlainStringFrom({string:()=>r})};throw this.internalError(e,"Expected Malloy or SQL type to either be a Malloy type or a string")}visitExprSafeCast(e){const n=this.getMalloyOrSQLType(e.malloyOrSQLType());return new te.ExprCast(this.getFieldExpr(e.fieldExpr()),n,!0)}visitExprTimeTrunc(e){return new te.ExprGranularTime(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text,!0)}visitTimeframe(e){return new te.Timeframe(e.text)}visitExprForRange(e){const n=this.getFieldExpr(e._startAt),r=this.getFieldExpr(e._duration),i=this.visitTimeframe(e.timeframe());return new te.ForRange(n,r,i)}visitExprAggFunc(e){const n=e.argumentList(),r=n?this.allFieldExpressions(n.fieldExpr()):[],i=(0,kn.getId)(e),s=e.fieldPath(),o=s?this.getFieldPath(s,te.ExpressionFieldReference):void 0,u=s&&o?this.astAt(o,s):void 0;return te.ExprTimeExtract.extractor(i)?this.astAt(new te.ExprTimeExtract(i,r),e):this.astAt(new te.ExprFunc(i,r,!1,void 0,u),e)}visitExprFunc(e){var n,r;const i=e.argumentList(),s=i?this.allFieldExpressions(i.fieldExpr()):[],o=e.EXCLAM()!==void 0,u=(n=e.malloyType())===null||n===void 0?void 0:n.text;let a;u&&((0,Y7.isCastType)(u)?a=u:(this.contextError(e,"unexpected-malloy-type",`'#' assertion for unknown type '${u}'`),a=void 0));let l=(0,kn.getOptionalId)(e)||((r=e.timeframe())===null||r===void 0?void 0:r.text);return l===void 0&&(this.contextError(e,"failed-to-parse-function-name","Function name error"),l="FUNCTION_NAME_ERROR"),te.ExprTimeExtract.extractor(l)?this.astAt(new te.ExprTimeExtract(l,s),e):this.astAt(new te.ExprFunc(l,s,o,a),e)}visitExprDuration(e){return new te.ExprDuration(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text)}visitCaseStatement(e){const n=e._valueExpr,r=n?this.getFieldExpr(n):void 0,i=e.caseWhen(),s=i.map(a=>new te.CaseWhen(this.getFieldExpr(a._condition),this.getFieldExpr(a._result))),o=e._caseElse,u=o?this.getFieldExpr(o):void 0;return this.warnWithReplacement("sql-case","Use a `pick` statement instead of `case`",this.parseInfo.rangeFromContext(e),`${[...n?[`${this.getSourceCode(n)} ?`]:[],...i.map(a=>`pick ${this.getSourceCode(a._result)} when ${this.getSourceCode(a._condition)}`),o?`else ${o.text}`:"else null"].join(" ")}`),new te.Case(r,s,u)}visitPickStatement(e){const n=e.pick().map(r=>{let i;return r._pickValue&&(i=this.getFieldExpr(r._pickValue)),new te.PickWhen(i,this.getFieldExpr(r._pickWhen))});return e.ELSE()?new te.Pick(n,this.getFieldExpr(e._pickElse)):new te.Pick(n)}visitExprFieldProps(e){const n=this.only(e.fieldProperties().fieldPropertyStatement().map(r=>this.visit(r)),r=>te.isFieldPropStatement(r)&&r,"field property statement");return new te.ExprProps(this.getFieldExpr(e.fieldExpr()),n)}visitPartitionByStatement(e){return this.astAt(new te.PartitionBy(e.id().map(n=>this.astAt(new te.PartitionByFieldReference([this.astAt(new te.FieldName((0,kn.idToStr)(n)),n)]),n))),e)}visitLiteralTimestamp(e){return this.parseTime(e,te.LiteralTimestamp.parse)}visitLiteralHour(e){return this.parseTime(e,te.LiteralHour.parse)}visitLiteralDay(e){return this.parseTime(e,te.LiteralDay.parse)}visitLiteralWeek(e){return this.parseTime(e,te.LiteralWeek.parse)}visitLiteralMonth(e){return this.parseTime(e,te.LiteralMonth.parse)}visitLiteralQuarter(e){return this.parseTime(e,te.LiteralQuarter.parse)}visitLiteralYear(e){return this.parseTime(e,te.LiteralYear.parse)}visitImportStatement(e){const n=this.getPlainStringFrom(e.importURL()),r=this.astAt(new te.ImportStatement(n,this.parseInfo.importBaseURL),e),i=e.importSelect();if(i)for(const s of i.importItem()){const o=s.id(),u=o[1]?this.astAt(new te.ImportSourceName((0,kn.idToStr)(o[1])),o[1]):void 0;r.push(this.astAt(new te.ImportSelect((0,kn.idToStr)(o[0]),u),o[0]))}return r}visitDebugExpr(e){return this.getFieldExpr(e.fieldExpr())}visitSampleStatement(e){const n=e.sampleSpec().INTEGER_LITERAL();if(n)return new te.SampleProperty({rows:this.getNumber(n)});const r=e.sampleSpec().PERCENT_LITERAL();if(r)return new te.SampleProperty({percent:this.getNumber(r)});const i=e.sampleSpec().TRUE()!==void 0;return new te.SampleProperty({enable:i})}visitDocAnnotations(e){const n=e.DOC_ANNOTATION().map(i=>({text:i.text,at:this.getLocation(e)})),r=new te.ModelAnnotation(n);return this.compilerFlags=r.getCompilerFlags(this.compilerFlags,this.msgLog),r}visitIgnoredObjectAnnotations(e){return this.contextError(e,"orphaned-object-annotation","Object annotation not connected to any object"),new K7(e.text)}visitIgnoredModelAnnotations(e){return this.contextError(e,"misplaced-model-annotation","Model annotations not allowed at this scope"),new K7(e.text)}visitDefExploreAnnotation(e){const n=this.getNotes(e);return new te.ObjectAnnotation(n)}getSQArgument(e){const n=e.argumentId(),r=n?this.astAt(new te.PartitionByFieldReference([this.astAt(new te.FieldName((0,kn.idToStr)(n.id())),n)]),n):void 0;return this.astAt(new te.Argument({id:r,value:this.getFieldExpr(e.fieldExpr())}),e)}getSQArguments(e){if(e!==void 0)return this.inExperiment("parameters",e),e.sourceArgument().map(n=>this.getSQArgument(n))}visitSQID(e){const n=this.getModelEntryName(e),r=this.getSQArguments(e.sourceArguments());return this.astAt(new te.SQReference(n,r),e.id())}getSqExpr(e){const n=this.visit(e);return n instanceof te.SourceQueryElement?n:(this.contextError(e,"unexpected-non-source-query-expression-node",`Expected a source/query expression, not '${n.elementType}'`),new AW)}visitSQExtendedSource(e){const n=this.getSqExpr(e.sqExpr()),r=e.includeBlock(),i=r?this.getIncludeItems(r):void 0,s=new te.SQExtend(n,this.getSourceExtensions(e.exploreProperties()),i);return this.astAt(s,e)}getIncludeItems(e){return this.inExperiment("access_modifiers",e),e.includeItem().map(n=>this.getIncludeItem(n)).filter(X6e.isNotUndefined)}getIncludeItem(e){var n;const r=e.tags(),i=r?this.getNotes(r):[],s=e.includeExceptList();if(s){r&&i.length>0&&this.contextError(r,"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const o=this.getExcludeList(s);return this.astAt(new te.IncludeExceptItem(o),e)}else{const o=e.includeList();if(o===void 0){this.contextError((n=e.orphanedAnnotation())!==null&&n!==void 0?n:e,"orphaned-object-annotation","This tag is not attached to anything",{severity:"warn"});return}const u=this.getAccessLabelProp(e.accessLabelProp()),a=this.getIncludeList(o),l=this.astAt(new te.IncludeAccessItem(u,a),e);return l.extendNote({blockNotes:i}),l}}getIncludeList(e){const n=e.includeField();if(n===void 0)throw this.internalError(e,"Expected a field name list");return n.map(r=>this.getIncludeListItem(r))}getExcludeList(e){return e.includeExceptListItem().map(n=>{n.tags().ANNOTATION().length>0&&this.contextError(n.tags(),"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const r=n.fieldName();if(r)return this.astAt(new te.AccessModifierFieldReference([this.astAt(new te.FieldName(n.text),n)]),r);const i=n.collectionWildCard();if(i)return this.astAt(this.visitCollectionWildCard(i),i);throw this.internalError(n,"Expected a field name or wildcard")})}getIncludeListItem(e){const n=e.collectionWildCard(),r=n?this.visitCollectionWildCard(n):void 0,i=e._as?e._as.text:void 0,s=e.tags(),o=s?this.getNotes(s):[],u=e.isDefine(),a=u?this.getIsNotes(u):[],l=[...o,...a],c=e._name?this.astAt(new te.AccessModifierFieldReference([this.astAt(this.getFieldName(e._name),e._name)]),e._name):void 0,f=c??r;if(f===void 0)throw this.internalError(e,"Expected a field name or wildcard");const d=this.astAt(new te.IncludeListItem(f,i),e);return d.extendNote({notes:l}),d}visitSQParens(e){const n=this.getSqExpr(e.sqExpr());return this.astAt(n,e)}visitSQCompose(e){const n=e.sqExpr().map(r=>this.getSqExpr(r));return this.inExperiment("composite_sources",e),this.astAt(new te.SQCompose(n),e)}visitSQArrow(e){const n=this.getSqExpr(e.sqExpr()),r=e.segExpr(),i=new te.SQArrow(n,this.getVExpr(r));return this.astAt(i,e)}getVExpr(e){const n=this.visit(e);if(n instanceof te.View)return n;throw this.internalError(e,`Expected view, got a '${n.elementType}'`)}visitSegField(e){return new te.ReferenceView(this.getFieldPath(e.fieldPath(),te.ViewOrScalarFieldReference))}visitSegOps(e){return new te.QOpDescView(this.visitQueryProperties(e.queryProperties()))}visitSegParen(e){return this.visit(e.vExpr())}visitVSeg(e){return this.visit(e.segExpr())}visitSegRefine(e){return new te.ViewRefine(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitVArrow(e){return new te.ViewArrow(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitSQRefinedQuery(e){const n=this.getSqExpr(e.sqExpr()),r=e.segExpr(),i=new te.SQRefine(n,this.getVExpr(r));return this.astAt(i,e)}visitSQTable(e){const n=this.visit(e.exploreTable());if(n instanceof Y6e.TableSource){const r=new te.SQSource(n);return this.astAt(r,e)}return new AW}visitSQSQL(e){const n=new te.SQSource(this.visitSqlSource(e.sqlSource()));return this.astAt(n,e)}visitExperimentalStatementForTesting(e){return this.inExperiment("compilerTestExperimentParse",e),this.astAt(new te.ExperimentalExperiment("compilerTestExperimentTranslate"),e)}visitRecordRef(e){const n=new te.ExprIdReference(this.getFieldPath(e.fieldPath(),te.ExpressionFieldReference));return this.astAt(new te.RecordElement({path:n}),e)}visitRecordExpr(e){const n=this.getFieldExpr(e.fieldExpr()),r=e.recordKey(),i=r?{key:(0,kn.getId)(r),value:n}:{value:n};return this.astAt(new te.RecordElement(i),e)}visitExprLiteralRecord(e){const n=this.only(e.recordElement().map(r=>this.astAt(this.visit(r),r)),r=>r instanceof te.RecordElement&&r,"a legal record property description");return new te.RecordLiteral(n)}visitExprArrayLiteral(e){const n=e.fieldExpr().map(i=>this.getFieldExpr(i)),r=new te.ArrayLiteral(n);return this.astAt(r,e)}visitExprWarnLike(e){let n="~";const r=e.fieldExpr(0),i=e.fieldExpr(1),s=this.parseInfo.rangeFromContext(e);return e.NOT()?(n="!~",this.warnWithReplacement("sql-not-like","Use Malloy operator '!~' instead of 'NOT LIKE'",s,`${this.getSourceCode(r)} !~ ${this.getSourceCode(i)}`)):this.warnWithReplacement("sql-like","Use Malloy operator '~' instead of 'LIKE'",s,`${this.getSourceCode(r)} ~ ${this.getSourceCode(i)}`),this.astAt(new te.ExprCompare(this.getFieldExpr(r),n,this.getFieldExpr(i)),e)}visitExprNullCheck(e){const n=e.fieldExpr();return this.astAt(new te.ExprIsNull(this.getFieldExpr(n),e.NOT()?"!=":"="),e)}visitExprWarnIn(e){const n=this.getFieldExpr(e.fieldExpr()),r=!!e.NOT(),i=e.fieldExprList().fieldExpr(),s=this.astAt(new te.ExprLegacyIn(n,r,i.map(o=>this.getFieldExpr(o))),e);return this.warnWithReplacement("sql-in",`Use = (a|b|c) instead of${r?" NOT":""} IN (a,b,c)`,this.parseInfo.rangeFromContext(e),`${this.getSourceCode(e.fieldExpr())} ${r?"!=":"="} (${i.map(o=>this.getSourceCode(o)).join(" | ")})`),s}}wS.MalloyToAST=eOe;var NS={};Object.defineProperty(NS,"__esModule",{value:!0}),NS.Zone=void 0;class tOe{constructor(){this.location={},this.zone=new Map}get(e){const n=this.zone.get(e);if((n==null?void 0:n.status)==="present")return n.value}getEntry(e){const n=this.zone.get(e);return n?n.firstReference||!this.location[e]?n:{...n,firstReference:this.location[e]}:{status:"error",message:"import reference failure"}}define(e,n){this.zone.set(e,{status:"present",value:n})}reference(e,n){const r=this.zone.get(e);(r==null?void 0:r.status)===void 0&&(this.zone.set(e,{status:"reference",firstReference:n}),this.location[e]=n)}getUndefined(){const e=[];for(const[n,r]of this.zone)r.status==="reference"&&e.push(n);return e.length>0?e:void 0}updateFrom(e,n){if(e)for(const[r,i]of Object.entries(e))i!==void 0&&this.define(r,i);if(n)for(const[r,i]of Object.entries(n))this.zone.set(r,{status:"error",message:i})}}NS.Zone=tOe;var FS={};Object.defineProperty(FS,"__esModule",{value:!0}),FS.walkForDocumentSymbols=void 0;const nOe=Ql,rOe=fn;class iOe{constructor(e,n,r,i){this.translator=e,this.tokens=n,this.scopes=r,this.symbols=i}popScope(){return this.scopes.pop()}peekScope(){return this.scopes[this.scopes.length-1]}enterTopLevelQueryDefs(e){const n=this.translator.rangeFromContext(e);e.topLevelQueryDef().length===1&&(this.blockRange=n)}enterTopLevelQueryDef(e){this.symbols.push({range:this.translator.rangeFromContext(e),name:e.queryName().text,type:"query",children:[],lensRange:this.blockRange}),this.blockRange=void 0}enterRunStatement(e){this.symbols.push({range:this.translator.rangeFromContext(e.topLevelAnonQueryDef()),name:"unnamed_query",type:"unnamed_query",children:[],lensRange:this.translator.rangeFromContext(e)})}enterAnonymousQuery(e){this.symbols.push({range:this.translator.rangeFromContext(e.topLevelAnonQueryDef().sqExpr()),name:"unnamed_query",type:"unnamed_query",children:[],lensRange:this.translator.rangeFromContext(e)})}enterDefineSourceStatement(e){const n=this.translator.rangeFromContext(e);e.sourcePropertyList().sourceDefinition().length===1&&(this.blockRange=n)}enterSourceDefinition(e){const n=this.translator.rangeFromContext(e);this.scopes.push({range:n,name:e.sourceNameDef().id().text,type:"explore",children:[],lensRange:this.blockRange}),this.blockRange=void 0}exitSourceDefinition(e){const n=this.popScope();n&&this.symbols.push(n)}enterDefExploreQuery(e){const n=this.translator.rangeFromContext(e);e.subQueryDefList().exploreQueryDef().length===1&&(this.blockRange=n)}enterExploreQueryDef(e){const n={range:this.translator.rangeFromContext(e),name:e.exploreQueryNameDef().id().text,type:"query",children:[],lensRange:this.blockRange},r=this.peekScope();r&&r.children.push(n),this.scopes.push(n),this.blockRange=void 0}exitExploreQueryDef(e){this.popScope()}getNestDefName(e){const n=e.queryName();if(n)return n.id().text;let r,i=!1;const s={enterVArrow(u){u.vExpr().enterRule(s)},enterVSeg(u){u.segExpr().enterRule(o)}},o={enterSegField(u){const a=u.fieldPath().fieldName();i||(r??(r=a[a.length-1].id().text))},enterSegParen(u){u.vExpr().enterRule(s)},enterSegRefine(u){u._lhs.enterRule(o)},enterSegOps(){r=void 0,i=!0}};return e.vExpr().enterRule(s),r}handleNestEntry(e){const n=this.getNestDefName(e);if(n===void 0)return;const r={range:this.translator.rangeFromContext(e),name:n,type:"query",children:[]},i=this.peekScope();return i&&i.children.push(r),r}enterNestDef(e){const n=this.handleNestEntry(e);n&&this.scopes.push(n)}exitNestDef(e){this.popScope()}enterFieldDef(e){const n={range:this.translator.rangeFromContext(e),name:e.fieldNameDef().id().text,type:"field",children:[]},r=this.peekScope();r&&r.children.push(n)}enterQueryFieldEntry(e){var n;const r=(n=e.taggedRef())===null||n===void 0?void 0:n.fieldPath();if(r===void 0)return;const i={range:this.translator.rangeFromContext(e),name:r.text,type:"field",children:[]},s=this.peekScope();s&&s.children.push(i)}enterExploreRenameDef(e){const n={range:this.translator.rangeFromContext(e),name:e.fieldName()[0].text,type:"field",children:[]},r=this.peekScope();r&&r.children.push(n)}enterJoinWith(e){this.handleJoinDef(e)}enterJoinOn(e){this.handleJoinDef(e)}handleJoinDef(e){const n={range:this.translator.rangeFromContext(e),name:e.joinFrom().joinNameDef().id().text,type:"join",children:[]},r=this.peekScope();r&&r.children.push(n)}enterImportStatement(e){const n=(0,rOe.getStringIfShort)(e.importURL());n&&this.scopes.push({range:this.translator.rangeFromContext(e),name:n,type:"import",children:[]})}exitImportStatement(){const e=this.popScope();e&&this.symbols.push(e)}enterImportSelect(e){const n=this.peekScope();if(n)for(const r of e.importItem()){const i={range:this.translator.rangeFromContext(e),name:r.text,type:"import_item",children:[]};n.children.push(i)}}}function sOe(t,e,n){const r=new iOe(t,e,[],[]),i=r;return nOe.ParseTreeWalker.DEFAULT.walk(i,n),r.symbols}FS.walkForDocumentSymbols=sOe;var LS={};Object.defineProperty(LS,"__esModule",{value:!0}),LS.walkForDocumentCompletions=void 0;const oOe=Ql,uOe=["dimension","measure","join_one","join_many","join_cross","where","primary_key","rename","accept","except","query","declare"],aOe=["group_by","project","index","aggregate","top","limit","order_by","where","having","nest","declare"],lOe=["source","explore","query","sql"];class cOe{constructor(e,n,r){this.tokens=e,this.completions=n,this.position=r}rangeOf(e){const n=e.stop||e.start;return{start:{line:e.start.line-1,character:e.start.charPositionInLine},end:{line:n.line-1,character:n.stopIndex-(n.startIndex-n.charPositionInLine)+1}}}inRange(e){const{start:n,end:r}=e,i=this.position.line>n.line||this.position.line===n.line&&this.position.character>=n.character,s=this.position.line<r.line||this.position.line===r.line&&this.position.character<=r.character;return i&&s}enterExploreProperties(e){if(this.inRange(this.rangeOf(e))){let n=!1;for(const r of e.exploreStatement())this.inRange(this.rangeOf(r))&&(n=!0);if(!n)for(const r of uOe)this.completions.push({type:"explore_property",text:`${r}: `})}}enterQueryProperties(e){if(this.inRange(this.rangeOf(e))){let n=!1;for(const r of e.queryStatement())this.inRange(this.rangeOf(r))&&(n=!0);if(!n)for(const r of aOe)this.completions.push({type:"query_property",text:`${r}: `})}}enterMalloyDocument(e){if(this.inRange(this.rangeOf(e))){let n=!1;for(const r of e.malloyStatement())this.inRange(this.rangeOf(r))&&(n=!0);if(!n)for(const r of lOe)this.completions.push({type:"model_property",text:`${r}: `})}}}function fOe(t,e,n){const r=new cOe(t,[],n),i=r;return oOe.ParseTreeWalker.DEFAULT.walk(i,e),r.completions}LS.walkForDocumentCompletions=fOe;var IS={};Object.defineProperty(IS,"__esModule",{value:!0}),IS.walkForDocumentHelpContext=void 0;const xOe=LR;class dOe extends xOe.AbstractParseTreeVisitor{constructor(e){super(),this.position=e,this.type=""}rangeOf(e){const n=e.stop||e.start;return{start:{line:e.start.line-1,character:e.start.charPositionInLine},end:{line:n.line-1,character:n.stopIndex-(n.startIndex-n.charPositionInLine)+1}}}inRange(e){return e.start.line<=this.position.line&&e.end.line>=this.position.line&&(this.position.line!==e.start.line||this.position.character>=e.start.character)&&(this.position.line!==e.end.line||this.position.character<=e.end.character)}defaultResult(){}visitChildren(e){let n=this.defaultResult();if(this.inRange(this.rangeOf(e))){n={type:this.type,token:e.start.text};const r=e.childCount;for(let i=0;i<r;i++){const o=e.getChild(i).accept(this);o&&(n=this.aggregateResult(n,o))}}return n}visitMalloyDocument(e){return this.inRange(this.rangeOf(e))?(this.type="model_property",this.visitChildren(e)):this.defaultResult()}visitExploreProperties(e){return this.inRange(this.rangeOf(e))?(this.type="explore_property",this.visitChildren(e)):this.defaultResult()}visitQueryProperties(e){return this.inRange(this.rangeOf(e))?(this.type="query_property",this.visitChildren(e)):this.defaultResult()}aggregateResult(e,n){return n}}function hOe(t,e){return new dOe(e).visit(t)}IS.walkForDocumentHelpContext=hOe;var BS={};Object.defineProperty(BS,"__esModule",{value:!0}),BS.ReferenceList=void 0;const pOe=bu;class gOe{constructor(e){this.sourceURL=e,this.references=[]}findIndexBefore(e){let n=0,r=this.references.length;for(;n<r;){const i=Math.floor((n+r)/2),s=this.references[i].location.range.end;s.line<e.line||s.line===e.line&&s.character<e.character?n=i+1:r=i}return n}add(e){if(e.location.url!==this.sourceURL)return;const n=this.findIndexBefore(e.location.range.end);n<this.references.length&&this.isPositionEqual(e,this.references[n])||this.references.splice(n,0,e)}isPositionEqual(e,n){const r=e.location.range,i=n.location.range;return r.start.line===i.start.line&&r.start.character===i.start.character&&r.end.line===i.end.line&&r.end.character===i.end.character}find(e){const n=this.findIndexBefore(e);if(n===this.references.length)return;const r=this.references[n];if((0,pOe.locationContainsPosition)(r.location,e))return r}}BS.ReferenceList=gOe;var $S={};Object.defineProperty($S,"__esModule",{value:!0}),$S.isNeedResponse=void 0;function mOe(t){return!!t&&(t.tables||t.urls||t.compileSQL)!==void 0}$S.isNeedResponse=mOe;var kS={};Object.defineProperty(kS,"__esModule",{value:!0}),kS.walkForModelAnnotation=void 0;const yOe=Ql;class EOe{constructor(e,n,r){this.translator=e,this.tokens=n,this.parseInfo=r,this.notes=[]}getLocation(e){return{url:this.parseInfo.sourceURL,range:this.parseInfo.rangeFromContext(e)}}enterDocAnnotations(e){const n=e.DOC_ANNOTATION().map(r=>({text:r.text,at:this.getLocation(e)}));this.notes.push(...n)}get annotation(){return{notes:this.notes}}}function AOe(t,e,n){const r=new EOe(t,e,n),i=r;return yOe.ParseTreeWalker.DEFAULT.walk(i,n.root),r.annotation}kS.walkForModelAnnotation=AOe;var MS={};Object.defineProperty(MS,"__esModule",{value:!0}),MS.walkForTablePath=void 0;const vW=fn,vOe=Ql;class _Oe{constructor(e,n){this.translator=e,this.tokens=n,this.pathInfos=[]}enterTableMethod(e){const n=(0,vW.getId)(e.connectionId()),[r,i]=(0,vW.getPlainString)(e.tablePath(),!0);r!==void 0&&this.pathInfos.push({connectionId:n,tablePath:r,range:this.translator.rangeFromContext(e)})}}function SOe(t,e,n){const r=new _Oe(t,e),i=r;return vOe.ParseTreeWalker.DEFAULT.walk(i,n.root),r.pathInfos}MS.walkForTablePath=SOe;var PS={},sm={};Object.defineProperty(sm,"__esModule",{value:!0}),sm.checkCustomErrorMessage=void 0;const COe=(t,e,n)=>{const r=t.getRuleInvocationStack()[0],i=t.currentToken;for(const s of n){const o=!s.currentToken||i.type===s.currentToken,u=!s.offendingSymbol||(e==null?void 0:e.type)===s.offendingSymbol,a=!s.ruleContextOptions||s.ruleContextOptions.includes(r);if(o&&u&&a){if(s.precedingTokenOptions&&!s.precedingTokenOptions.some(f=>_W(t,f,"lookback",s.lookbackFromOffendingSymbol?e==null?void 0:e.tokenIndex:void 0))||s.lookAheadOptions&&!s.lookAheadOptions.some(f=>_W(t,f,"lookahead",s.lookbackFromOffendingSymbol?e==null?void 0:e.tokenIndex:void 0)))continue;return s.errorMessage.replace("${currentToken}",(e==null?void 0:e.text)||i.text||"")}}return""};sm.checkCustomErrorMessage=COe;const _W=(t,e,n,r)=>{try{for(let i=0;i<e.length;i++){let s;if(typeof r=="number"){const o=n==="lookahead"?i+1:-1*(i+1);s=t.inputStream.get(r+o).type}else{const o=n==="lookahead"?i+2:-1*(i+1);s=t.inputStream.LA(o)}if(e[i]>=-1&&s!==e[i]||e[i]<-1&&s===-1*e[i])return!1}return!0}catch{return!1}};Object.defineProperty(PS,"__esModule",{value:!0}),PS.MalloyErrorStrategy=void 0;const bOe=eg,SW=L,TOe=sm,ROe=[{errorMessage:"Missing '{' after 'extend'",currentToken:SW.MalloyParser.EXTEND,ruleContextOptions:["sqExpr"],lookAheadOptions:[[-SW.MalloyParser.OCURLY]]}];class OOe extends bOe.DefaultErrorStrategy{sync(e){const n=(0,TOe.checkCustomErrorMessage)(e,void 0,ROe);if(n){e.notifyErrorListeners(n,e.currentToken,void 0);return}super.sync(e)}}PS.MalloyErrorStrategy=OOe;var CW={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.MalloyParserErrorListener=t.commonErrorCases=void 0;const e=L,n=sm,r=pg;t.commonErrorCases=[{errorMessage:"'view:' must be followed by '<identifier> is {'",ruleContextOptions:["exploreQueryDef"],offendingSymbol:e.MalloyParser.OCURLY,precedingTokenOptions:[[e.MalloyParser.VIEW],[e.MalloyParser.COLON]]},{errorMessage:"Missing '}' at '${currentToken}'",ruleContextOptions:["vExpr"],offendingSymbol:e.MalloyParser.VIEW,currentToken:e.MalloyParser.OCURLY},{errorMessage:"Missing '}' at '${currentToken}'",ruleContextOptions:["exploreProperties","queryProperties","exploreStatement"],lookAheadOptions:[[e.MalloyParser.EOF],[e.MalloyParser.RUN],[e.MalloyParser.SOURCE]]},{errorMessage:"'aggregate:' entries must include a name (ex: `some_name is count()`)",precedingTokenOptions:[[e.MalloyParser.AGGREGATE]],lookAheadOptions:[[-e.MalloyParser.IS]],lookbackFromOffendingSymbol:!0}];class i{constructor(o,u){this.translator=o,this.messages=u}logError(o,u,a){return this.messages.log((0,r.makeLogMessage)(o,u,{severity:"error",...a})),o}syntaxError(o,u,a,l,c,f){const d={line:a-1,character:l},h=u?this.translator.rangeFromToken(u):{start:d,end:d},p=(0,n.checkCustomErrorMessage)(o,u,t.commonErrorCases);p&&(c=p),this.logError("syntax-error",{message:c},{at:{url:this.translator.sourceURL,range:h}})}}t.MalloyParserErrorListener=i})(CW);var DOe=T&&T.__createBinding||(Object.create?function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]}),wOe=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),NOe=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&DOe(e,t,n);return wOe(e,t),e};Object.defineProperty(o0,"__esModule",{value:!0}),o0.MalloyTranslator=o0.MalloyChildTranslator=o0.MalloyTranslation=void 0;const bW=eg,FOe=Ke,LOe=ZA,IOe=L,TW=NOe(Hv),BOe=wS,RW=pg,$Oe=Qa,J7=NS,kOe=FS,MOe=LS,POe=IS,UOe=BS,US=$S,jOe=bu,OW=fo,qOe=kS,HOe=MS,zOe=PS,QOe=CW;class GOe extends LOe.MalloyLexer{popMode(){return this._modeStack.isEmpty?this._mode:super.popMode()}}class WOe{step(e){if(this.response)return this.response;if(!e.urlIsFullPath)return e.fatalResponse();const n=e.root.importZone.getEntry(e.sourceURL);if(n.status!=="present"){if(n.status==="error"){const s=n.firstReference||e.defaultLocation();return e.root.logError("import-error",{message:n.message,url:e.sourceURL},{at:s}),this.response=e.fatalResponse(),this.response}return{urls:[e.sourceURL]}}const r=n.value===""?`
1263
1263
  `:n.value;this.sourceInfo=this.getSourceInfo(r);let i;try{i=this.runParser(r,e)}catch(s){e.root.logError("parse-exception",{message:s.message}),i=void 0}return e.root.logger.hasErrors()?this.response={parse:i,...e.fatalResponse()}:this.response={parse:i},this.response}getSourceInfo(e){const n=/\r?\n/,r={at:[],lines:[],length:e.length};let i=e,s=0;for(;i!=="";){const o=i.match(n);if(o&&o.index!==void 0){r.lines.push(i.slice(0,o.index));const u=o.index+o[0].length;r.at.push({begin:s,end:s+u}),s+=u,i=i.slice(u)}else{r.lines.push(i),r.at.push({begin:s,end:s+i.length});break}}return r}runParser(e,n){const r=bW.CharStreams.fromString(e),i=new GOe(r),s=new bW.CommonTokenStream(i),o=new IOe.MalloyParser(s);o.removeErrorListeners(),o.addErrorListener(new QOe.MalloyParserErrorListener(n,n.root.logger)),o.errorHandler=new zOe.MalloyErrorStrategy;const u=o[n.grammarRule];if(!u)throw new Error(`No such parse rule as ${n.grammarRule}`);return{root:u.call(o),tokenStream:s,sourceStream:r,sourceURL:n.sourceURL,importBaseURL:n.importBaseURL||n.sourceURL,rangeFromContext:a=>n.rangeFromContext(a),malloyVersion:"4.0.0"}}}class VOe{constructor(e){this.parseStep=e,this.parseReferences=void 0}step(e){var n;const r=this.parseStep.step(e);if(r.parse===void 0)return r;if(!this.parseReferences){this.parseReferences=(0,$Oe.findReferences)(e,r.parse.tokenStream,r.parse.root);for(const u in this.parseReferences.tables)e.root.schemaZone.reference(u,{url:e.sourceURL,range:this.parseReferences.tables[u].firstReference});for(const u in this.parseReferences.urls){const a=this.parseReferences.urls[u];try{const l=decodeURI(new URL(u,e.importBaseURL||e.sourceURL).toString());e.addChild(l),e.imports.push({importURL:l,location:{url:e.sourceURL,range:a}}),e.root.importZone.reference(l,{url:e.sourceURL,range:a})}catch{e.root.logError("invalid-import-url",`Malformed URL '${u}'"`,{at:{url:e.sourceURL,range:a}})}}}if(e.root.logger.hasErrors())return null;let i={};const s=e.root.schemaZone.getUndefined();if(s){const u={};for(const a of s){const l=this.parseReferences.tables[a];u[a]={connectionName:l.connectionName,tablePath:l.tablePath}}i={tables:u}}const o=((n=e.root.importZone.getUndefined())!==null&&n!==void 0?n:[]).filter(u=>e.root.pretranslatedModels.get(u)===void 0);if(o.length>0&&(i={...i,urls:o}),(0,US.isNeedResponse)(i))return i;for(const u of e.childTranslators.values()){if(e.root.pretranslatedModels.get(u.sourceURL))continue;const a=u.importsAndTablesStep.step(u);if((0,US.isNeedResponse)(a))return a}return null}}class YOe{constructor(e){this.importStep=e,this.walked=!1}step(e){if(this.response)return this.response;const n=this.importStep.step(e);if(n)return n;const r=e.parseStep.response;if(e.root.logger.hasErrors())return this.response=e.fatalResponse(),this.response;const i=r==null?void 0:r.parse;if(!i)throw new Error("TRANSLATOR INTERNAL ERROR: Translator parse response had no errors, but also no parser");const s=new BOe.MalloyToAST(i,e.root.logger,e.compilerFlags),o=s.visit(i.root);if(e.compilerFlags=s.compilerFlags,o.elementType==="unimplemented"&&o.logError("untranslated-parse-node","INTERNAL COMPILER ERROR: Untranslated parse node"),!this.walked){for(const u of o.walk())u instanceof TW.Unimplemented&&u.logError("untranslated-parse-node","INTERNAL COMPILER ERROR: Untranslated parse node");this.walked=!0}if(e.root.logger.hasErrors())return this.response=e.fatalResponse(),this.response;for(const u of e.childTranslators.values()){if(e.root.pretranslatedModels.get(u.sourceURL))continue;const a=u.astStep.step(u);if((0,US.isNeedResponse)(a))return a}return o.setTranslator(e),this.response={...e.problemResponse(),ast:o,final:!0},this.response}}class KOe{constructor(e){this.parseStep=e}step(e){if(!this.response){const n=this.parseStep.step(e);if(n.parse){let r;try{r=(0,kOe.walkForDocumentSymbols)(e,n.parse.tokenStream,n.parse.root)}catch{}this.response={symbols:r,final:!0}}else return n}return this.response}}class JOe{constructor(e){this.parseStep=e}step(e,n){const r=this.parseStep.step(e);if(r.parse){let i=[];if(n!==void 0)try{i=(0,MOe.walkForDocumentCompletions)(r.parse.tokenStream,r.parse.root,n)}catch{}return{...r,completions:i}}else return r}}class XOe{constructor(e){this.parseStep=e}step(e,n){const r=this.parseStep.step(e);if(r.parse){let i;if(n!==void 0)try{i=(0,POe.walkForDocumentHelpContext)(r.parse.root,n)}catch{}return{...r,helpContext:i}}else return r}}class ZOe{constructor(e){this.parseStep=e}step(e,n){if(!this.response){const r=this.parseStep.step(e);if(!r.parse||r.final)return r;{const i=(0,qOe.walkForModelAnnotation)(e,r.parse.tokenStream,r.parse);this.response={modelAnnotation:{...i,inherits:n==null?void 0:n.annotation}}}}return this.response}}class eDe{constructor(e){this.parseStep=e}step(e){if(!this.response){const n=this.parseStep.step(e);if(n.parse){const r=(0,HOe.walkForTablePath)(e,n.parse.tokenStream,n.parse);this.response={pathInfo:r}}else return n}return this.response}}class tDe{constructor(e){this.astStep=e,this.importedAnnotations=!1}step(e,n){if(this.response)return this.response;const r=e.root.pretranslatedModels.get(e.sourceURL);if(r!==void 0)return e.modelDef=r,{modelDef:r,final:!0,fromSources:e.getDependencies()};if(n&&!this.importedAnnotations){const s=OW.Tag.annotationToTag(n.annotation,{prefix:/^##! /});e.compilerFlags=s.tag,this.importedAnnotations=!0}const i=this.astStep.step(e);if((0,US.isNeedResponse)(i))return i;if(!i.ast)return this.response=i,this.response;if(e.grammarRule==="malloyDocument")if(i.ast instanceof TW.Document){const s=i.ast;for(s.initModelDef(n);;){const o=s.compile();if(o.needs)return o.needs;e.modelDef=o.modelDef;break}}else e.root.logError("parsed-non-malloy-document",{url:e.sourceURL},{at:e.defaultLocation()});return e.root.logger.hasErrors()?this.response={fromSources:e.getDependencies(),...e.fatalResponse()}:this.response={modelDef:{...e.modelDef,dependencies:e.getDependencyTree()},fromSources:e.getDependencies(),...e.problemResponse(),final:!0},this.response}}class X7{constructor(e,n=null,r="malloyDocument"){this.sourceURL=e,this.importBaseURL=n,this.grammarRule=r,this.sqlSources=[],this.imports=[],this.compilerFlags=new OW.Tag,this._urlIsFullPath=void 0,this.dialectAlreadyChecked={},this.allDialectsEnabled=!1,this.childTranslators=new Map,this.modelDef={name:e,exports:[],contents:{},queryList:[],dependencies:{}},this.parseStep=new WOe,this.modelAnnotationStep=new ZOe(this.parseStep),this.metadataStep=new KOe(this.parseStep),this.completionsStep=new JOe(this.parseStep),this.helpContextStep=new XOe(this.parseStep),this.importsAndTablesStep=new VOe(this.parseStep),this.astStep=new YOe(this.importsAndTablesStep),this.tablePathInfoStep=new eDe(this.parseStep),this.translateStep=new tDe(this.astStep),this.references=new UOe.ReferenceList(e)}get urlIsFullPath(){if(this._urlIsFullPath===void 0)try{const e=new URL(this.sourceURL);this._urlIsFullPath=!0}catch(e){const n=e instanceof Error?e.message:"";this._urlIsFullPath=!1,this.root.logError("failed-to-compute-absolute-import-url",`Could not compute full path URL: ${n}`)}return this._urlIsFullPath}addChild(e){this.childTranslators.get(e)||this.childTranslators.set(e,new DW(e,this.root))}getDependencies(){const e=this.getDependencyTree();return[this.sourceURL,...wW(e)]}getDependencyTree(){const e=this.root.pretranslatedModels.get(this.sourceURL);if(e!==void 0)return e.dependencies;const n={};for(const[r,i]of this.childTranslators)n[r]=i.getDependencyTree();return n}newlyTranslatedDependencies(){if(this.root.pretranslatedModels.get(this.sourceURL)!==void 0)return[];const n=[];for(const[r,i]of this.childTranslators){if(this.root.pretranslatedModels.get(r)!==void 0)continue;const o=i.translate();o.modelDef&&(n.push({url:r,modelDef:o.modelDef}),n.push(...i.newlyTranslatedDependencies()))}return n}addReference(e){this.references.add(e)}referenceAt(e){return this.references.find(e)}fatalResponse(){return{final:!0,...this.problemResponse()}}problemResponse(){return{problems:this.problems()}}problems(){return[...this.root.logger.getLog()]}getLineMap(e){var n,r;if(e===this.sourceURL)return(n=this.parseStep.sourceInfo)===null||n===void 0?void 0:n.lines;const i=this.childTranslators.get(e);if(i)return(r=i.parseStep.sourceInfo)===null||r===void 0?void 0:r.lines}codeAtLocation(e){const n=this.getLineMap(e.url)||[];if(e.range.start.line===e.range.end.line)return n[e.range.start.line].slice(e.range.start.character,e.range.end.character);let r="";r+=n[e.range.start.line].slice(e.range.start.character);for(let i=e.range.start.line+1;i<e.range.end.line;i++)r+=n[i];return r+=n[e.range.end.line].slice(0,e.range.end.character),r}prettyErrors(){let e="",n="";for(const r of this.root.logger.getLog()){let i=r.message,s=this.sourceURL;if(r.at){s=r.at.url;const o=r.at.range.start.line,u=r.at.range.start.character,a=this.getLineMap(r.at.url);if(a){const l=a[o];i=`line ${o+1}: ${r.message}
1264
1264
  | ${l}`,u>0&&(i=i+`
1265
1265
  | ${" ".repeat(u)}^`)}else i=`line ${o+1}: char ${u}: ${r.message}`}n!==s&&(i=`FILE: ${s}