@malloydata/render 0.0.244-dev250317160224 → 0.0.244-dev250318232227
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.
|
@@ -1553,7 +1553,7 @@ ${i} `),s+="]")}return s}*walk(){for(const e of Object.keys(this.children)){con
|
|
|
1553
1553
|
STRUCTDEF: ${(0,a0e.inspect)(o,{breakLength:72,depth:1/0})}`)}catch(o){t.logError("failed-to-compute-output-schema",`INTERNAL ERROR model/Segment.nextStructDef: ${o.message}
|
|
1554
1554
|
QUERY: ${(0,a0e.inspect)(r,{breakLength:72,depth:1/0})}`)}return l0e.ErrorFactory.structDef}Gs.opOutputStruct=c0e;function yst(t,e,r){for(const i of r)e=c0e(t,e,i);return e}Gs.getFinalStruct=yst;function Est(t,e){return t.fields.find(r=>(r.as||r.name)===e)}Gs.getStructFieldDef=Est,Object.defineProperty(B2,"__esModule",{value:!0}),B2.QueryRefine=void 0;const Ast=Gr,_st=Gs,vst=fE;class Cst extends vst.QueryBase{constructor(e,r){super({base:e,refinement:r}),this.base=e,this.refinement=r,this.elementType="query-refine"}queryComp(e){const r=this.base.queryComp(e),i=new Ast.StaticSourceSpace(r.inputStruct),s=this.refinement.refine(i,r.query.pipeline,void 0),o={...r.query,pipeline:s},u=this.resolveCompositeSource(r.inputStruct,o);return{query:{...o,compositeResolvedSourceDef:u},outputStruct:(0,_st.getFinalStruct)(this.refinement,r.inputStruct,s),inputStruct:r.inputStruct}}}B2.QueryRefine=Cst;var xE={},k2={},As={};Object.defineProperty(As,"__esModule",{value:!0}),As.mkTimeResult=As.resolution=As.castTo=As.timeOffset=void 0;const GB=et;function Sst(t,e,r,i,s){return{node:"delta",kids:{base:(0,GB.mkTemporal)(e,t),delta:i},op:r,units:s}}As.timeOffset=Sst;function bst(t,e,r,i=!1){let s;return typeof t!="string"?s={node:"cast",dstSQLType:t.raw,e,safe:i}:s={node:"cast",dstType:{type:t},e,safe:i},(0,GB.isCastType)(r)&&(s.srcType={type:r}),s}As.castTo=bst;function Tst(t){switch(t){case"hour":case"minute":case"second":case"microsecond":case"millisecond":return"timestamp"}return"date"}As.resolution=Tst;function Rst(t,e){if(e){if(t.type==="timestamp")return{...t,timeframe:e};if((0,GB.isDateUnit)(e))return{...t,timeframe:e}}return t}As.mkTimeResult=Rst;var bd={},pt={},zt={};Object.defineProperty(zt,"__esModule",{value:!0}),zt.literalTimeResult=zt.literalExprValue=zt.computedErrorExprValue=zt.computedTimeResult=zt.computedExprValue=void 0;const f0e=Yi,WB=dt;function dE({value:t,dataType:e,from:r}){return{...e,value:t,expressionType:(0,f0e.maxOfExpressionTypes)(r.map(i=>i.expressionType)),evalSpace:(0,f0e.mergeEvalSpaces)(...r.map(i=>i.evalSpace)),compositeFieldUsage:(0,WB.mergeCompositeFieldUsage)(...r.map(i=>i.compositeFieldUsage))}}zt.computedExprValue=dE;function Dst({value:t,dataType:e,from:r,timeframe:i}){const s=dE({value:t,dataType:e,from:r}),o={...e,expressionType:s.expressionType,evalSpace:s.evalSpace,value:s.value,compositeFieldUsage:(0,WB.mergeCompositeFieldUsage)(...r.map(u=>u.compositeFieldUsage))};return i&&(o.timeframe=i),o}zt.computedTimeResult=Dst;function Ost({dataType:t,from:e,error:r}){return dE({dataType:t??{type:"error"},value:{node:"error",message:r},from:e})}zt.computedErrorExprValue=Ost;function wst(t){return dE({...t,from:[]})}zt.literalExprValue=wst;function Fst({value:t,dataType:e,timeframe:r}){const i=dE({value:t,dataType:e,from:[]}),s={...e,expressionType:i.expressionType,evalSpace:i.evalSpace,value:i.value,compositeFieldUsage:(0,WB.emptyCompositeFieldUsage)()};return r&&(s.timeframe=r),s}zt.literalTimeResult=Fst;var M2={};Object.defineProperty(M2,"__esModule",{value:!0}),M2.isGranularResult=void 0;function Nst(t){return t.type==="date"||t.type==="timestamp"?t.timeframe!==void 0:!1}M2.isGranularResult=Nst;var bu={};Object.defineProperty(bu,"__esModule",{value:!0}),bu.isComparison=bu.isEquality=bu.getExprNode=void 0;function Lst(t){switch(t){case"~":return"like";case"!~":return"!like"}return t}bu.getExprNode=Lst;function x0e(t){return t==="="||t==="!="||t==="~"||t==="!~"}bu.isEquality=x0e;function Ist(t){return x0e(t)||t===">="||t==="<="||t===">"||t==="<"}bu.isComparison=Ist;var $st=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Bst=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),kst=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&$st(e,t,r);return Bst(e,t),e};Object.defineProperty(pt,"__esModule",{value:!0}),pt.applyBinary=pt.getMorphicValue=pt.ExprDuration=pt.ExpressionDef=pt.ATNodeType=void 0;const ef=et,Td=kst(nn),VB=Qs,p0=zt,Mst=As,d0e=M2,Pst=Xe,hE=bu;class Ust extends Error{}var YB;(function(t){t[t.And=0]="And",t[t.Or=1]="Or",t[t.Value=2]="Value",t[t.Partial=3]="Partial"})(YB||(pt.ATNodeType=YB={}));class h0e extends Pst.MalloyElement{constructor(){super(...arguments),this.legalChildTypes=Td.anyAtomicT}granular(){return!1}requestExpression(e){return this.getExpression(e)}defaultFieldName(){}typeCheck(e,r){return r.type!=="error"&&!Td.any(r,this.legalChildTypes)?(r.type==="sql native"?e.logError("sql-native-not-allowed-in-expression",{rawType:r.rawType}):e.logError("expression-type-error",`'${this.elementType}' Can't use type ${Td.inspect(r)}`),!1):!0}apply(e,r,i,s=!1){return y0e(e,i,r,this)}canSupportPartitionBy(){return!1}canSupportOrderBy(){return!1}canSupportLimit(){return!1}supportsWhere(e){return(0,ef.expressionIsAggregate)(e.expressionType)}atNodeType(){return YB.Value}atExpr(){return this}}pt.ExpressionDef=h0e;class KB extends h0e{constructor(e,r){super({n:e}),this.n=e,this.timeframe=r,this.elementType="duration",this.legalChildTypes=[Td.timestampT,Td.dateT]}apply(e,r,i){const s=i.getExpression(e);if(this.typeCheck(this,s),(0,ef.isTemporalType)(s.type)&&(r==="+"||r==="-")){const o=this.n.getExpression(e);if(!Td.typeEq(o,Td.numberT))return this.logError("invalid-duration-quantity",`Duration quantity needs number not '${o.type}`),(0,VB.errorFor)("illegal unit expression");let u;return(0,d0e.isGranularResult)(s)&&s.timeframe===this.timeframe&&(u=s.timeframe),s.type==="date"&&!(0,ef.isDateUnit)(this.timeframe)?this.loggedErrorExpr("invalid-timeframe-for-time-offset",`Cannot offset date by ${this.timeframe}`):(0,p0.computedTimeResult)({dataType:{type:s.type},value:(0,Mst.timeOffset)(s.type,s.value,r,o.value,this.timeframe),timeframe:u,from:[s,o]})}return super.apply(e,r,i)}getExpression(e){const r=this.n.getExpression(e);return(0,p0.computedErrorExprValue)({dataType:{type:"duration"},error:"Duration is not a value",from:[r]})}}pt.ExprDuration=KB;function p0e(t,e){return t.type===e?t.value:t.morphic&&t.morphic[e]}function jst(t,e){if(t.type===e)return t;if(t.morphic&&t.morphic[e])return(0,p0.computedExprValue)({dataType:{type:e},value:t.morphic[e],from:[t]})}pt.getMorphicValue=jst;function m0e(t,e,r,i){const s=(0,ef.isTemporalType)(e.type),o=(0,ef.isTemporalType)(i.type),u=(0,hE.getExprNode)(r);if(s&&o)if(e.type!==i.type){const a=p0e(e,"timestamp"),l=p0e(i,"timestamp");if(a&&l)return{node:u,kids:{left:a,right:a}}}else return{node:u,kids:{left:e.value,right:i.value}};if((s||o)&&e.type!=="null"&&i.type!=="null")return t.logError("time-comparison-type-mismatch",`Cannot compare a ${e.type} to a ${i.type}`),{node:"false"}}function qst(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 Hst(t,e,r,i){const s=e.getExpression(t),o=i.getExpression(t),u=(0,hE.getExprNode)(r),a=pE("boolean",s,o);if(a)return a;const l=ef.TD.isSQL(s)?s.rawType||"typeless-left":void 0,c=ef.TD.isSQL(o)?o.rawType||"typeless-right":void 0;if((l||c)&&!(s.type==="null"||o.type==="null"||l===c)){const h=mE(e,s,i,o);if(h)return{...h,type:"boolean"}}let f=m0e(e,s,r,o)||{node:u,kids:{left:s.value,right:o.value}};if(s.type!=="error"&&o.type!=="error"&&(r==="~"||r==="!~")&&(s.type!=="string"||o.type!=="string")){let x=qst(s,o);if(x)r[0]==="!"&&(x={node:"not",e:{...x}});else throw new Ust("Incompatible types for match('~') operator");f=x}return(0,p0.computedExprValue)({dataType:{type:"boolean"},value:f,from:[s,o]})}function Qst(t,e,r,i){const s=e.getExpression(t),o=i.getExpression(t),u=pE("boolean",s,o);if(u)return u;const a=mE(e,s,i,o);if(a)return{...a,type:"boolean"};const l=m0e(e,s,r,o)||{node:(0,hE.getExprNode)(r),kids:{left:s.value,right:o.value}};return(0,p0.computedExprValue)({dataType:{type:"boolean"},value:l,from:[s,o]})}function g0e(t,e,r,i){const s=e.getExpression(t),o=i.getExpression(t),u=pE("number",s,o);if(u)return u;const a=mE(e,s,i,o);if(a)return a;if(s.type!=="number")e.logError("arithmetic-operation-type-mismatch",`The '${r}' operator requires a number, not a '${s.type}'`);else if(o.type!=="number")i.logError("arithmetic-operation-type-mismatch",`The '${r}' operator requires a number, not a '${o.type}'`);else return(0,p0.computedExprValue)({dataType:{type:"number"},value:{node:r,kids:{left:s.value,right:o.value}},from:[s,o]});return(0,VB.errorFor)("numbers required")}function zst(t,e,r,i){const s=e.getExpression(t),o=i.getExpression(t),u=mE(e,s,i,o);if(u)return u;const a=(0,ef.isTemporalType)(s.type),l=pE(a?"error":"number",s,o);if(l)return l;if(a){let c=i;if(o.type!=="duration")if((0,d0e.isGranularResult)(s))c=new KB(i,s.timeframe);else if(s.type==="date")c=new KB(i,"day");else return e.loggedErrorExpr("time-offset-type-mismatch",`Can not offset time by '${o.type}'`);return c.apply(t,r,e)}return g0e(t,e,r,i)}function y0e(t,e,r,i){if((0,hE.isEquality)(r))return Hst(t,e,r,i);if((0,hE.isComparison)(r))return Qst(t,e,r,i);if(r==="+"||r==="-")return zst(t,e,r,i);if(r==="*")return g0e(t,e,r,i);if(r==="/"||r==="%"){const s=e.getExpression(t),o=i.getExpression(t),u=mE(e,s,i,o);if(u)return u;const a=pE("number",s,o);if(a)return a;if(s.type!=="number")e.logError("arithmetic-operation-type-mismatch","Numerator must be a number");else if(o.type!=="number")i.logError("arithmetic-operation-type-mismatch","Denominator must be a number");else{const l={node:r,kids:{left:s.value,right:o.value}};return(0,p0.computedExprValue)({dataType:{type:"number"},value:l,from:[s,o]})}return(0,VB.errorFor)("divide type mismatch")}return e.loggedErrorExpr("unexpected-binary-operator",`Cannot use ${r} operator here`)}pt.applyBinary=y0e;function pE(t,...e){if(e.some(r=>r.type==="error"))return(0,p0.computedExprValue)({dataType:{type:t},value:{node:"error",message:"cascading error"},from:e})}function mE(t,e,r,i){const s=(0,p0.computedExprValue)({dataType:e,value:{node:"error",message:"sql-native unsupported"},from:[e,i]});if(e.type==="sql native")return t.logError("sql-native-not-allowed-in-expression",{rawType:e.rawType}),s.type=i.type,s;if(i.type==="sql native")return r.logError("sql-native-not-allowed-in-expression",{rawType:i.rawType}),s}Object.defineProperty(bd,"__esModule",{value:!0}),bd.ExprIdReference=void 0;const Gst=et,Wst=pt,Vst=dt;class Yst extends Wst.ExpressionDef{constructor(e){super(),this.fieldReference=e,this.elementType="ExpressionIdReference",this.has({fieldPath:e})}get refString(){return this.fieldReference.refString}getExpression(e){const r=this.fieldReference.getField(e),i=this.fieldReference.list.map(s=>s.name).slice(0,-1);if(r.found){const s=r.found.typeDesc(),o=(0,Vst.joinedCompositeFieldUsage)(i,s.compositeFieldUsage);if(r.isOutputField)return{...s,evalSpace:s.evalSpace==="constant"?"constant":"output",value:{node:"outputField",name:this.refString},compositeFieldUsage:o};const u={node:r.found.refType,path:this.fieldReference.path},a=(0,Gst.expressionIsAggregate)(s.expressionType)?"output":s.evalSpace;return{...s,value:u,evalSpace:a,compositeFieldUsage:o}}return this.loggedErrorExpr(r.error.code,r.error.message)}}bd.ExprIdReference=Yst,Object.defineProperty(k2,"__esModule",{value:!0}),k2.NamedSource=void 0;const JB=et,Kst=To,Jst=yi,Xst=As,E0e=Xe,Zst=bd,eot=w2;class tot extends Kst.Source{constructor(e,r,i){super(),this.ref=e,this.sourceArguments=r,this.args=i,this.elementType="namedSource",i&&this.has({args:i}),e instanceof E0e.ModelEntryReference&&this.has({ref:e})}get refName(){return this.ref instanceof E0e.ModelEntryReference?this.ref.name:this.ref}structRef(e){const r=this.modelEntry(this.ref);return r&&!r.exported?{structRef:this.getSourceDef(e)}:{structRef:this.refName,sourceArguments:this.evaluateArgumentsForRef(e)}}refLogError(e,r,i){typeof this.ref=="string"?this.logError(e,r,i):this.ref.logError(e,r,i)}modelStruct(){var e;const r=this.modelEntry(this.ref),i=r==null?void 0:r.entry;if(!i){this.refLogError("source-not-found",`Undefined source '${this.refName}'`);return}if(i.type==="query"){this.logError("invalid-source-from-query",`Cannot construct a source from query '${this.refName}'`);return}else if(i.type==="function"){this.logError("invalid-source-from-function",`Cannot construct a source from a function '${this.refName}'`);return}else if(i.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,i.dialect),(0,JB.isSourceDef)(i))return{...i};this.logError("invalid-source-source","Cannot construct a source from a never type")}evaluateArgumentsForRef(e){const r=this.modelStruct();return r===void 0?{}:this.evaluateArguments(e,r.parameters,[])}evaluateArguments(e,r,i){var s,o;const u={...this.sourceArguments},a=new Set;for(const l of(s=this.args)!==null&&s!==void 0?s:[]){const c=(o=l.id)!==null&&o!==void 0?o:l.value instanceof Zst.ExprIdReference?l.value.fieldReference:void 0;if(c===void 0){l.value.logError("unnamed-source-argument","Parameterized source arguments must be named with `parameter_name is`");continue}const f=c.outputName;if(a.has(f)){l.logError("duplicate-source-argument",`Cannot pass argument for \`${f}\` more than once`);continue}a.add(f);const x=(r??{})[f];if(!x)c.logError("source-parameter-not-found",`\`${this.refName}\` has no declared parameter named \`${c.refString}\``);else{const h=e??new eot.ParameterSpace(i??[]),p=l.value.getExpression(h);let m=p.value;p.type!==x.type&&(0,JB.isCastType)(x.type)&&(m=(0,Xst.castTo)(x.type,p.value,p.type,!0)),u[f]={...x,value:m}}}for(const l in r)l in u||((0,JB.paramHasValue)(r[l])?u[l]={...r[l]}:this.refLogError("missing-source-argument",`Argument not provided for required parameter \`${l}\``));return u}getSourceDef(e){return this.withParameters(e,[])}withParameters(e,r){var i;const s=this.modelStruct();if(!s){const l=Jst.ErrorFactory.structDef,c=`${this.refName}-undefined`;return l.name=l.name+c,l.dialect=l.dialect+c,l}const o={};for(const l of r??[]){const c=l.parameter();o[c.name]=c}const u=this.evaluateArguments(e,s.parameters,r),a={...s,parameters:o,arguments:u};return(i=this.document())===null||i===void 0||i.rememberToAddModelAnnotations(a),a}}k2.NamedSource=tot;var gE={},V4={};Object.defineProperty(V4,"__esModule",{value:!0}),V4.QueryHeadStruct=void 0;const not=et,rot=To,iot=k2;class sot extends rot.Source{constructor(e,r){super(),this.fromRef=e,this.sourceArguments=r,this.elementType="internalOnlyQueryHead"}structRef(){return{structRef:this.fromRef}}getSourceDef(e){if((0,not.refIsStructDef)(this.fromRef))return this.fromRef;const r=new iot.NamedSource(this.fromRef,this.sourceArguments,void 0);return this.has({exploreReference:r}),r.getSourceDef(e)}}V4.QueryHeadStruct=sot,Object.defineProperty(gE,"__esModule",{value:!0}),gE.QueryReference=void 0;const XB=yi,oot=Xe,uot=V4,aot=et,lot=Gs;class cot extends oot.MalloyElement{constructor(e){super(),this.name=e,this.elementType="query-reference"}queryComp(e){const r=this.modelEntry(this.name),i=r==null?void 0:r.entry,s=function(){return{inputStruct:XB.ErrorFactory.structDef,outputStruct:XB.ErrorFactory.structDef,query:XB.ErrorFactory.query}};if(!i)return this.logError("query-reference-not-found",`Reference to undefined query '${this.name.refString}'`),s();if(i.type==="query"){const o=new uot.QueryHeadStruct(i.structRef,i.sourceArguments);this.has({queryHead:o});const u=o.getSourceDef(void 0),a=(0,lot.getFinalStruct)(this,u,i.pipeline);return{query:e||(0,aot.refIsStructDef)(i.structRef)?i:{...i,structRef:u},outputStruct:a,inputStruct:u}}return this.logError("non-query-used-as-query",`Illegal reference to '${this.name}', query expected`),s()}query(){return this.queryComp(!0).query}}gE.QueryReference=cot,Object.defineProperty(xE,"__esModule",{value:!0}),xE.SQReference=void 0;const fot=Su,xot=Sd,dot=k2,A0e=gE,_0e=Yi;class hot extends fot.SourceQueryElement{constructor(e,r){super({ref:e}),this.ref=e,this.args=r,this.elementType="sq-reference",r!==void 0&&this.has({args:r})}getQuery(){const e=this.ref.getNamed();if(e)if(e.type==="query"){const r=new A0e.QueryReference(this.ref);return this.has({query:r}),r}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,_0e.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 r=new A0e.QueryReference(this.ref);this.asSource=new xot.QuerySource(r)}else if((0,_0e.isSourceDef)(e))this.asSource=new dot.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}}xE.SQReference=hot,Object.defineProperty(G4,"__esModule",{value:!0}),G4.SQRefine=void 0;const pot=Su,mot=Sd,got=B2,yot=xE;class Eot extends pot.SourceQueryElement{constructor(e,r){super({toRefine:e,refine:r}),this.toRefine=e,this.refine=r,this.elementType="sq-refine"}getQuery(){if(this.toRefine.isSource()){this.toRefine instanceof yot.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 r=new got.QueryRefine(e,this.refine);return this.has({query:r}),r}}getSource(){const e=this.getQuery();if(e){const r=new mot.QuerySource(e);return this.has({queryAsSource:r}),r}}}G4.SQRefine=Eot;var Y4={},yE={};Object.defineProperty(yE,"__esModule",{value:!0}),yE.QueryRaw=void 0;const Aot=et,_ot=Xe;class vot extends _ot.MalloyElement{constructor(e){super({source:e}),this.source=e,this.elementType="query-raw"}queryComp(e){const r=e?this.source.structRef(void 0):{structRef:this.source.getSourceDef(void 0)},i=(0,Aot.refIsStructDef)(r.structRef)?r.structRef:this.source.getSourceDef(void 0);return{query:{type:"query",...r,pipeline:[{type:"raw",fields:[]}],location:this.location},outputStruct:i,inputStruct:i}}query(){return this.queryComp(!0).query}}yE.QueryRaw=vot;var EE={},m0={};Object.defineProperty(m0,"__esModule",{value:!0}),m0.sqlKey=m0.compileSQLInterpolation=void 0;const Cot=qs,Sot=et,bot=kt;function Tot(t,e,r){let i,s="",o=!1;for(const u of t)if((0,Sot.isSegmentSQL)(u))s+=u.sql,o=u.sql.match(/\(\s*$/)!==null;else{if(!i){if(!r)throw new Error("Internal error: Partial model missing when compiling SQL block");i=new Cot.QueryModel(r)}const a=i.compileQuery(u,{defaultRowLimit:void 0},!1).sql;s+=o?a:`(${a})`,o=!1}return{connection:e,selectStr:s}}m0.compileSQLInterpolation=Tot;function Rot(t,e){return`sql://${t}/${(0,bot.generateHash)(e)}`}m0.sqlKey=Rot,Object.defineProperty(EE,"__esModule",{value:!0}),EE.SQLSource=void 0;const ZB=m0,Dot=To,AE=yi;class Oot extends Dot.Source{constructor(e,r){super({connectionName:e,select:r}),this.connectionName=e,this.select=r,this.elementType="sqlSource",this.connectionNameInvalid=!1}sqlSourceRequest(e){const r=this.select.containsQueries?e.modelDef():void 0;return(0,ZB.compileSQLInterpolation)(this.select.sqlPhrases(),this.connectionName.refString,r)}structRef(){return{structRef:this.getSourceDef()}}validateConnectionName(){var e;const r=this.modelEntry(this.connectionName),i=this.connectionName.refString;if(this.connectionNameInvalid)return!1;if(r===void 0)(e=this.namespace())===null||e===void 0||e.setEntry(i,{entry:{type:"connection",name:i},exported:!0},!0);else if(r.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 r;if(!this.validateConnectionName())return;const i=super.needs(e);if(i)return i;this.requestBlock===void 0&&(this.requestBlock=this.sqlSourceRequest(e));const s=this.requestBlock,o=(r=this.translator())===null||r===void 0?void 0:r.root.sqlQueryZone;if(!o){this.logError("failed-to-fetch-sql-source-schema","Cant't look up schema for sql block");return}const u=(0,ZB.sqlKey)(s.connection,s.selectStr);o.reference(u,this.location);const a=o.getEntry(u);if(a.status==="reference")return{compileSQL:s};a.status==="present"&&e.checkExperimentalDialect(this,a.value.dialect)}getSourceDef(){var e;if(!this.validateConnectionName())return AE.ErrorFactory.structDef;const r=(e=this.translator())===null||e===void 0?void 0:e.root.sqlQueryZone;if(!r)return this.logError("failed-to-fetch-sql-source-schema","Cant't look up schema for sql block"),AE.ErrorFactory.structDef;if(this.requestBlock===void 0)return this.logError("failed-to-fetch-sql-source-schema","Expected to have already compiled the sql block"),AE.ErrorFactory.structDef;const i=this.requestBlock,s=(0,ZB.sqlKey)(i.connection,i.selectStr);r.reference(s,this.location);const o=r.getEntry(s);if(o.status==="error"){const u=o.message.split(/\r?\n/);return this.select.logError("invalid-sql-source","Invalid SQL, "+u.join(`
|
|
1555
1555
|
`)),AE.ErrorFactory.structDef}else if(o.status==="present"){const u=this.select.location,a={...o.value,fields:o.value.fields.map(f=>({...f,location:u})),location:this.location},l=this.document(),c=l==null?void 0:l.currentModelAnnotation();return c&&(a.modelAnnotation=c),a}else return this.logError("non-top-level-sql-source","`connection_name.sql(...)` can currently only be used in top level source/query definitions"),AE.ErrorFactory.structDef}}EE.SQLSource=Oot,Object.defineProperty(Y4,"__esModule",{value:!0}),Y4.SQSource=void 0;const wot=Su,Fot=yE,Not=EE;class Lot extends wot.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 Not.SQLSource){const e=new Fot.QueryRaw(this.theSource);return this.has({rawQuery:e}),e}else this.sqLog("invalid-source-as-query","This source cannot be used as a query")}}Y4.SQSource=Lot;var K4={};Object.defineProperty(K4,"__esModule",{value:!0}),K4.SQExtend=void 0;const Iot=sE,$ot=Su;class Bot extends $ot.SourceQueryElement{constructor(e,r,i){super({sqSrc:e,extend:r}),this.sqSrc=e,this.extend=r,this.includeList=i,this.elementType="sq-extend"}getSource(){if(this.asSource)return this.asSource;const e=this.sqSrc.getSource();if(e)return this.asSource=new Iot.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}}K4.SQExtend=Bot;var J4={},X4={};Object.defineProperty(X4,"__esModule",{value:!0}),X4.CompositeSource=void 0;const kot=et,Mot=To;class Pot extends Mot.Source{constructor(e){super({sources:e}),this.sources=e,this.elementType="compositeSource"}getSourceDef(e){return this.withParameters(e,[])}withParameters(e,r){const i=this.sources.map(c=>c.withParameters(e,r)),s=i[0].connection,o=i[0].dialect,u="composite_source",a=[],l=new Map;return this.sources.forEach((c,f)=>{var x;const h=i[f];h.connection!==s&&c.logError("composite-source-connection-mismatch",`All sources in a composite source must share the same connection; connection \`${h.connection}\` differs from previous connection \`${s}\``);for(const p of h.fields){if(!(0,kot.isAtomic)(p)){c.logWarning("composite-source-atomic-fields-only",`Only atomic fields are supported in composite sources; field \`${p.name}\` is not atomic and will be ignored`);continue}if(p.accessModifier==="private")continue;const m=(x=p.as)!==null&&x!==void 0?x:p.name,y=l.get(m);if(y===void 0){const g={...p,name:m,as:void 0,e:{node:"compositeField"},compositeFieldUsage:{fields:[m],joinedUsage:{}},code:this.code,location:this.codeLocation};l.set(m,g),a.push(g)}else p.accessModifier==="internal"&&(y.accessModifier="internal")}}),{type:"composite",sources:i,connection:s,fields:a,dialect:o,name:u,parameters:i[0].parameters}}}X4.CompositeSource=Pot,Object.defineProperty(J4,"__esModule",{value:!0}),J4.SQCompose=void 0;const Uot=X4,jot=Su;class qot extends jot.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(r=>r.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(Hot(e))return this.asSource=new Uot.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}}J4.SQCompose=qot;function Hot(t){return t.every(e=>e!==void 0)}var Z4={},g0={},_E={},Qot=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),zot=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Got=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Qot(e,t,r);return zot(e,t),e};Object.defineProperty(_E,"__esModule",{value:!0}),_E.BinaryBoolean=void 0;const Wot=Qs,Vot=Got(nn),Yot=bu,Kot=zt,Jot=pt;class Xot extends Jot.ExpressionDef{constructor(e,r,i){super({left:e,right:i}),this.left=e,this.op=r,this.right=i,this.elementType="abstract boolean binary",this.legalChildTypes=[Vot.boolT]}getExpression(e){const r=this.left.getExpression(e),i=this.right.getExpression(e);return this.typeCheck(this.left,r)&&this.typeCheck(this.right,i)?(0,Kot.computedExprValue)({dataType:{type:"boolean"},value:{node:(0,Yot.getExprNode)(this.op),kids:{left:r.value,right:i.value}},from:[r,i]}):(0,Wot.errorFor)("logical-op expected boolean")}}_E.BinaryBoolean=Xot;var Zot=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),eut=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),tut=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Zot(e,t,r);return eut(e,t),e};Object.defineProperty(g0,"__esModule",{value:!0}),g0.ExprLegacyIn=g0.ExprEquality=g0.ExprCompare=void 0;const hn=tut(nn),nut=zt,rut=pt,iut=_E,sut={"~":[hn.stringT],"!~":[hn.stringT],"<":[hn.numberT,hn.stringT,hn.dateT,hn.timestampT],"<=":[hn.numberT,hn.stringT,hn.dateT,hn.timestampT],"=":[hn.numberT,hn.stringT,hn.dateT,hn.timestampT],"!=":[hn.numberT,hn.stringT,hn.dateT,hn.timestampT],">=":[hn.numberT,hn.stringT,hn.dateT,hn.timestampT],">":[hn.numberT,hn.stringT,hn.dateT,hn.timestampT]};class v0e extends iut.BinaryBoolean{constructor(e,r,i){super(e,r,i),this.elementType="a<=>b",this.legalChildTypes=sut[r]}getExpression(e){return this.right.apply(e,this.op,this.left)}}g0.ExprCompare=v0e;class out extends v0e{constructor(e,r,i){super(e,r,i),this.elementType="a~=b"}getExpression(e){return this.right.apply(e,this.op,this.left,!0)}apply(e,r,i){return super.apply(e,r,i,!0)}}g0.ExprEquality=out;class uut extends rut.ExpressionDef{constructor(e,r,i){super(),this.expr=e,this.notIn=r,this.choices=i,this.elementType="in",this.has({expr:e,choices:i})}getExpression(e){const r=this.expr.getExpression(e),i=this.choices.map(s=>s.getExpression(e));return(0,nut.computedExprValue)({dataType:{type:"boolean"},value:{node:"in",not:this.notIn,kids:{e:r.value,oneOf:i.map(s=>s.value)}},from:[r,...i]})}}g0.ExprLegacyIn=uut;var vE={},P2={};Object.defineProperty(P2,"__esModule",{value:!0}),P2.ExprTime=void 0;const aut=et,lut=zt,cut=pt;class ek extends cut.ExpressionDef{constructor(e,r,i){super(),this.elementType="timestampOrDate",this.elementType=e,this.translationValue=(0,lut.computedExprValue)({dataType:{type:e},value:r,from:i??[]})}getExpression(e){return this.translationValue}static fromValue(e,r){let i=r.value;if(e!==r.type){const s={node:"cast",safe:!1,dstType:{type:e},e:r.value};(0,aut.isTemporalType)(r.type)&&(s.srcType={type:r.type}),i=s}return new ek(e,i,[r])}}P2.ExprTime=ek;var tf={};Object.defineProperty(tf,"__esModule",{value:!0}),tf.Range=void 0;const fut=Qs,xut=zt,dut=pt;class hut extends dut.ExpressionDef{constructor(e,r){super({first:e,last:r}),this.first=e,this.last=r,this.elementType="range"}apply(e,r,i){switch(r){case"=":case"!=":{const s=r==="="?">=":"<",o=r==="="?"and":"or",u=r==="="?"<":">=",a=this.first.apply(e,s,i),l=this.last.apply(e,u,i);return(0,xut.computedExprValue)({dataType:{type:"boolean"},value:{node:o,kids:{left:a.value,right:l.value}},from:[a,l]})}case">":return this.last.apply(e,">=",i);case">=":return this.first.apply(e,">=",i);case"<":return this.first.apply(e,"<",i);case"<=":return this.last.apply(e,"<",i)}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,fut.errorFor)("a range is not a value")}}tf.Range=hut;var put=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),mut=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),gut=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&put(e,t,r);return mut(e,t),e};Object.defineProperty(vE,"__esModule",{value:!0}),vE.ExprGranularTime=void 0;const tk=et,yut=Qs,C0e=gut(nn),S0e=As,Eut=pt,eT=P2,b0e=tf;class Aut extends Eut.ExpressionDef{constructor(e,r,i){super({expr:e}),this.expr=e,this.units=r,this.truncate=i,this.elementType="granularTime",this.legalChildTypes=[C0e.timestampT,C0e.dateT]}granular(){return!0}getExpression(e){const r=this.units,i=this.expr.getExpression(e);if(tk.TD.isTemporal(i)){const o={...i,timeframe:r};return this.truncate&&(o.value={node:"trunc",e:(0,tk.mkTemporal)(i.value,i.type),units:r}),o}i.type!=="error"&&this.logError("unsupported-type-for-time-truncation",`Cannot do time truncation on type '${i.type}'`);const s={...i};return i.type==="error"&&(s.type=(0,tk.isDateUnit)(r)?"date":"timestamp"),{...s,value:(0,yut.errorFor)("granularity typecheck").value,evalSpace:"constant"}}toRange(e){const r=this.getExpression(e),i={node:"numberLiteral",literal:"1"};if(r.type==="timestamp"){const a=eT.ExprTime.fromValue("timestamp",r),l=new eT.ExprTime("timestamp",(0,S0e.timeOffset)("timestamp",r.value,"+",i,this.units),[r]);return new b0e.Range(a,l)}const s=new eT.ExprTime("date",r.value,[r]),o=(0,S0e.timeOffset)("date",r.value,"+",i,this.units),u=new eT.ExprTime("date",o,[r]);return new b0e.Range(s,u)}}vE.ExprGranularTime=Aut,Object.defineProperty(Z4,"__esModule",{value:!0}),Z4.Apply=void 0;const _ut=g0,vut=M2,T0e=vE;class Cut extends _ut.ExprCompare{constructor(e,r){super(e,"=",r),this.left=e,this.right=r,this.elementType="apply"}getExpression(e){let r=this.right;if(!this.right.granular()){const i=this.right.requestExpression(e);i&&(0,vut.isGranularResult)(i)&&(r=new T0e.ExprGranularTime(this.right,i.timeframe,!1))}return r instanceof T0e.ExprGranularTime?r.toRange(e).apply(e,this.op,this.left):super.getExpression(e)}}Z4.Apply=Cut;var U2={},Sut=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),but=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Tut=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Sut(e,t,r);return but(e,t),e};Object.defineProperty(U2,"__esModule",{value:!0}),U2.BinaryNumeric=void 0;const Rut=Tut(nn),Dut=pt;class Out extends Dut.ExpressionDef{constructor(e,r,i){super({left:e,right:i}),this.left=e,this.op=r,this.right=i,this.elementType="numeric binary abstract",this.legalChildTypes=[Rut.numberT]}getExpression(e){return this.right.apply(e,this.op,this.left)}}U2.BinaryNumeric=Out;var tT={},wut=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Fut=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Nut=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&wut(e,t,r);return Fut(e,t),e};Object.defineProperty(tT,"__esModule",{value:!0}),tT.Boolean=void 0;const Lut=pt,Iut=Nut(nn);let $ut=class extends Lut.ExpressionDef{constructor(e){super(),this.value=e,this.elementType="boolean literal"}getExpression(){return{...Iut.boolT,value:{node:this.value}}}};tT.Boolean=$ut;var nf={};Object.defineProperty(nf,"__esModule",{value:!0}),nf.FunctionOrdering=nf.FunctionOrderBy=void 0;const nk=et,R0e=Xe,But=bd;class kut extends R0e.MalloyElement{constructor(e,r){super(),this.field=e,this.dir=r,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 r=this.field.getExpression(e);return(0,nk.expressionIsAggregate)(r.expressionType)||((0,nk.expressionIsScalar)(r.expressionType)?(!(this.field instanceof But.ExprIdReference)||r.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:r.value,dir:this.dir}}getAggregateOrderBy(e,r){if(this.field){const i=this.field.getExpression(e);return(0,nk.expressionIsScalar)(i.expressionType)||this.field.logError("aggregate-order-by-not-scalar","aggregate `order_by` must be scalar"),r||this.field.logError("aggregate-order-by-expression-not-allowed","`order_by` must be only `asc` or `desc` with no expression"),{node:"functionOrderBy",e:i.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}}}nf.FunctionOrderBy=kut;class Mut extends R0e.ListOf{constructor(e){super(e),this.elementType="function-ordering"}getAnalyticOrderBy(e){return this.list.map(r=>r.getAnalyticOrderBy(e))}getAggregateOrderBy(e,r){return this.list.map(i=>i.getAggregateOrderBy(e,r))}}nf.FunctionOrdering=Mut;var nT={};Object.defineProperty(nT,"__esModule",{value:!0}),nT.ExprAddSub=void 0;const Put=U2;class Uut extends Put.BinaryNumeric{constructor(){super(...arguments),this.elementType="+-"}}nT.ExprAddSub=Uut;var y0={},jut=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),qut=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Hut=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&jut(e,t,r);return qut(e,t),e};Object.defineProperty(y0,"__esModule",{value:!0}),y0.ExprAggregateFunction=void 0;const CE=et,Qut=kt,zut=Qs,D0e=Gr,O0e=Hut(nn),Gut=_t,Wut=pt,Vut=zr,Yut=bd;class Kut extends Wut.ExpressionDef{constructor(e,r,i){super(),this.func=e,this.legalChildTypes=[O0e.numberT],this.elementType=e,this.explicitSource=i,r&&(this.expr=r,this.has({expr:r}))}getExpression(e){var r,i,s;const o=e.isQueryFieldSpace()?e.inputSpace():e;let u=this.expr,a=(r=this.expr)===null||r===void 0?void 0:r.getExpression(o),l=(i=this.source)===null||i===void 0?void 0:i.path,c=[];if(this.source){const x=this.source.getField(o);if(x.found){c=x.joinPath;const h=x.found,p=h.typeDesc();if(!(h instanceof D0e.StructSpaceField))if((0,CE.isAtomicFieldType)(p.type)){u=this.source,a={...O0e.atomicDef(p),expressionType:p.expressionType,value:p.evalSpace==="output"?{node:"outputField",name:this.source.refString}:{node:"field",path:this.source.path},evalSpace:p.evalSpace,compositeFieldUsage:p.compositeFieldUsage},l=this.source.path.slice(0,-1);const m=this.getJoinUsage(o);(m.length===1||m.length>1&&m.slice(1).every(g=>Jut(g,m[0])))&&(l=m[0].map(g=>g.name),c=m[0])}else return this.loggedErrorExpr("invalid-aggregate-source",`Aggregate source cannot be a ${p.type}`)}else return this.loggedErrorExpr("aggregate-source-not-found",`Reference to undefined value ${this.source.refString}`)}if(a===void 0)return this.loggedErrorExpr("missing-aggregate-expression","Missing expression for aggregate function");if((0,CE.expressionIsAggregate)(a.expressionType))return this.loggedErrorExpr("aggregate-of-aggregate","Aggregate expression cannot be aggregate");if(!(a.type==="error")){const x=this.getJoinUsage(o),h=this.source!==void 0||this.explicitSource;if(u&&!(!this.source&&x.every(m=>m.length===0))&&!this.isSymmetricFunction()){const m=ik(c,x),y=sk(this.elementType,m),g=h?y==null?void 0:y.message:"Join path is required for this calculation";if(g){const E=Xut(g,x,u,this.elementType),A=(s=y==null?void 0:y.code)!==null&&s!==void 0?s:"bad-join-usage";y?this.logError(A,E):this.logWarning(A,E)}}}if(this.typeCheck(this.expr||this,{...a,expressionType:"scalar"})){const x={node:"aggregate",function:this.func,e:a.value};return l&&l.length>0&&(x.structPath=l),{...this.returns(a),expressionType:"aggregate",value:x,evalSpace:"output"}}return(0,zut.errorFor)("aggregate type check")}isSymmetricFunction(){return!0}getJoinUsage(e){const r=[];if(this.source&&this.source.getField(e).found){const s={node:"field",path:this.source.path};r.push(...rk(e,s))}if(this.expr){const i=this.expr.getExpression(e).value;r.push(...rk(e,i))}return r}}y0.ExprAggregateFunction=Kut;function Jut(t,e){let r=t.length;if(r!==e.length)return!1;for(;r>0;)if(r-=1,t[r].name!==e[r].name)return!1;return!0}function rk(t,e){const r=[],i=(s,o)=>{const u=o[0],a=o.slice(1),l=s.entry(u);if(l===void 0)throw new Error(`Invalid field lookup ${u}`);if(l instanceof D0e.StructSpaceField&&a.length>0){const c=i(l.fieldSpace,a);return{...c,joinPath:[{...l.joinPathElement,name:u},...c.joinPath]}}else if(l instanceof Vut.SpaceField){if(a.length!==0)throw new Error(`${u} cannot contain a ${a.join(".")}`);const c=l.fieldDef();if(c)return{fs:s,def:c,joinPath:[]};throw new Error("No field def")}else throw new Error("expected a field def or struct")};for(const s of(0,Qut.exprWalk)(e))if(s.node==="field"){const o=i(t,s.path),u=o.def;if((0,CE.isAtomic)(u)&&!(0,CE.isJoined)(u))if((0,CE.hasExpression)(u)){const a=rk(o.fs,u.e);r.push(...a.map(l=>[...o.joinPath,...l]))}else r.push(o.joinPath)}else if(s.node==="source-reference")if(s.path){const o=i(t,s.path);r.push(o.joinPath)}else r.push([]);return r}function ik(t,e){const r=[];for(const i of e){let s=0;for(let l=0;l<t.length&&l<i.length&&t[l].name===i[l].name;l++)s=l+1;const o=t.slice(s),u=i.slice(s),a=[...o.map(l=>({...l,reverse:!0})),...u.map(l=>({...l,reverse:!1}))];r.push(a)}return r}function sk(t,e){for(const r of e)for(const i of r){if(i.joinType==="cross")return{code:"aggregate-traverses-join-cross",message:`Cannot compute \`${t}\` across \`join_cross\` relationship \`${i.name}\``};if(i.joinElementType==="array"&&!i.reverse)return{code:"aggregate-traverses-repeated-relationship",message:`Cannot compute \`${t}\` across repeated relationship \`${i.name}\``};if(i.joinType==="many"&&!i.reverse)return{code:"aggregate-traverses-join-many",message:`Cannot compute \`${t}\` across \`join_many\` relationship \`${i.name}\``}}}function Xut(t,e,r,i){if(e.length===0)return t;let s=e[0];for(const m of e.slice(1))for(let y=0;y<s.length;y++){const g=s[y],E=m[y];if(g.name!==E.name){s=s.slice(0,y);break}}const o=ik(s,e),u=sk(i,o),a=s.slice().reverse().findIndex(m=>m.joinType==="many"||m.joinType==="cross"),l=a===-1?0:s.length-a,c=s.slice(0,l),f=ik(c,e),x=sk(i,f),h=s.length>0?s.map(m=>m.name).join("."):"source",p=c.length>0?c.map(m=>m.name).join("."):"source";if(u)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 m=r instanceof Gut.FieldReference?`${r.refString}.${i}()`:r instanceof Yut.ExprIdReference?`${r.fieldReference.refString}.${i}()`:`${h}.${i}(${r.code})`,y=`${p}.${i}(${r.code})`;let g=`${t}; use \`${m}\``;return x===void 0&&p!==h&&(g+=` or \`${y}\` to get a result weighted with respect to \`${p}\``),g}}var rT={};Object.defineProperty(rT,"__esModule",{value:!0}),rT.ExprAlternationTree=void 0;const w0e=zt,j2=pt,Zut=bu;function ok(t){const e=t.atExpr();switch(e.atNodeType()){case j2.ATNodeType.And:case j2.ATNodeType.Partial:return;case j2.ATNodeType.Or:{if(e instanceof F0e){const r=ok(e.left);if(r){const i=ok(e.right);if(i)return[...r,...i]}}return}default:return e.granular()?void 0:[e]}}class F0e extends j2.ExpressionDef{constructor(e,r,i){super({left:e,right:i}),this.left=e,this.op=r,this.right=i,this.elementType="alternation",this.elementType=`${r}alternation${r}`}equalityList(){return this.inList===void 0&&(this.inList=ok(this)||[]),this.inList}apply(e,r,i,s){if((0,Zut.isEquality)(r)){const a=this.equalityList();if(a.length>0&&(r==="="||r==="!=")){const l=i.getExpression(e),c=a.map(f=>f.getExpression(e));return(0,w0e.computedExprValue)({dataType:{type:"boolean"},value:{node:"in",not:r==="!=",kids:{e:l.value,oneOf:c.map(f=>f.value)}},from:[l,...c]})}a.length===0&&s&&this.logWarning("or-choices-only",`Only | seperated values are legal when used with ${r} operator`)}const o=this.left.apply(e,r,i),u=this.right.apply(e,r,i);return(0,w0e.computedExprValue)({dataType:{type:"boolean"},value:{node:this.op==="&"?"and":"or",kids:{left:o.value,right:u.value}},from:[o,u]})}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("alternation-as-value","Alternation tree has no value")}atNodeType(){return this.op==="|"?j2.ATNodeType.Or:j2.ATNodeType.And}}rT.ExprAlternationTree=F0e;var q2={};Object.defineProperty(q2,"__esModule",{value:!0}),q2.ExprAsymmetric=void 0;const eat=y0;class tat extends eat.ExprAggregateFunction{constructor(e,r,i,s){super(e,r,s),this.func=e,this.expr=r,this.source=i,this.has({source:i})}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}`}}}}q2.ExprAsymmetric=tat;var iT={};Object.defineProperty(iT,"__esModule",{value:!0}),iT.ExprAvg=void 0;const nat=q2;class rat extends nat.ExprAsymmetric{constructor(e,r,i){super("avg",e,r,i),this.has({source:r})}}iT.ExprAvg=rat;var sT={};Object.defineProperty(sT,"__esModule",{value:!0}),sT.ExprCast=void 0;const iat=As,sat=zt,oat=pt;class uat extends oat.ExpressionDef{constructor(e,r,i=!1){super({expr:e}),this.expr=e,this.castType=r,this.safe=i,this.elementType="cast"}getExpression(e){const r=this.expr.getExpression(e);let i={type:"error"};if(typeof this.castType=="string")i={type:this.castType};else{const s=e.dialectObj();s&&(s.validateTypeName(this.castType.raw)?i=s.sqlTypeToMalloyType(this.castType.raw):this.logError("invalid-sql-native-type",`Cast type \`${this.castType.raw}\` is invalid for ${s.name} dialect`),this.safe&&!s.supportsSafeCast&&this.logError("dialect-cast-unsafe-only",`The SQL dialect '${e.dialectName()}' does not supply a safe cast operator`))}return(0,sat.computedExprValue)({dataType:i,value:(0,iat.castTo)(this.castType,r.value,r.type,this.safe),from:[r]})}}sT.ExprCast=uat;var oT={},aat=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),lat=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),cat=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&aat(e,t,r);return lat(e,t),e};Object.defineProperty(oT,"__esModule",{value:!0}),oT.ExprCoalesce=void 0;const N0e=Yi,L0e=cat(nn),fat=pt;class xat extends fat.ExpressionDef{constructor(e,r){super({expr:e,altExpr:r}),this.expr=e,this.altExpr=r,this.elementType="coalesce expression",this.legalChildTypes=L0e.anyAtomicT}getExpression(e){const r=this.expr.getExpression(e),i=this.altExpr.getExpression(e);return r.type==="null"?i:(L0e.typeEq(r,i)||this.logError("mismatched-coalesce-types",`Mismatched types for coalesce (${r.type}, ${i.type})`),{...r.type==="error"?i:r,expressionType:(0,N0e.maxExpressionType)(r.expressionType,i.expressionType),value:{node:"coalesce",kids:{left:r.value,right:i.value}},evalSpace:(0,N0e.mergeEvalSpaces)(r.evalSpace,i.evalSpace)})}}oT.ExprCoalesce=xat;var uT={};Object.defineProperty(uT,"__esModule",{value:!0}),uT.ExprCount=void 0;const dat=dt,hat=y0;class pat extends hat.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 r={node:"aggregate",function:"count",e:{node:""}};return this.source&&(r.structPath=this.source.path),{type:"number",numberType:"integer",expressionType:"aggregate",value:r,evalSpace:"output",compositeFieldUsage:(0,dat.emptyCompositeFieldUsage)()}}}uT.ExprCount=pat;var aT={},mat=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),gat=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),yat=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&mat(e,t,r);return gat(e,t),e};Object.defineProperty(aT,"__esModule",{value:!0}),aT.ExprCountDistinct=void 0;const lT=yat(nn),Eat=y0;class Aat extends Eat.ExprAggregateFunction{constructor(e){super("distinct",e),this.legalChildTypes=[lT.numberT,lT.stringT,lT.dateT,lT.timestampT]}returns(e){return{type:"number",numberType:"integer",evalSpace:e.evalSpace,expressionType:"aggregate",value:e.value,compositeFieldUsage:e.compositeFieldUsage}}}aT.ExprCountDistinct=Aat;var cT={},rf={};Object.defineProperty(rf,"__esModule",{value:!0}),rf.Limit=void 0;const _at=Xe,vat=Gn;class Cat extends _at.MalloyElement{constructor(e){super(),this.limit=e,this.elementType="limit",this.queryRefinementStage=vat.LegalRefinementStage.Tail,this.forceQueryClass=void 0}}rf.Limit=Cat;var H2={};Object.defineProperty(H2,"__esModule",{value:!0}),H2.PartitionBy=void 0;const Sat=Xe;class bat extends Sat.ListOf{constructor(e){super(e),this.partitionFields=e,this.elementType="partition_by"}}H2.PartitionBy=bat;var SE={},sf={};Object.defineProperty(sf,"__esModule",{value:!0}),sf.FieldName=void 0;const Tat=Xe;class Rat extends Tat.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])}}sf.FieldName=Rat;var Dat=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Oat=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),wat=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Dat(e,t,r);return Oat(e,t),e};Object.defineProperty(SE,"__esModule",{value:!0}),SE.ExprFunc=void 0;const Or=et,Fat=Qs,Nat=Cd,Lat=zt,Iat=pt,$at=sf,I0e=kt,$0e=wat(nn),Bat=dt;class kat extends Iat.ExpressionDef{constructor(e,r,i,s,o){super({args:r}),this.name=e,this.args=r,this.isRaw=i,this.rawType=s,this.source=o,this.elementType="function call()",this.has({source:o})}canSupportPartitionBy(){return!0}canSupportOrderBy(){return!0}canSupportLimit(){return!0}getExpression(e){return this.getPropsExpression(e)}findFunctionDef(e){var r,i,s;const o=this.name.toLowerCase(),u=e?(i=(r=this.getDialectNamespace(e))===null||r===void 0?void 0:r.getEntry(o))===null||i===void 0?void 0:i.entry:void 0,a=u??((s=this.modelEntry(o))===null||s===void 0?void 0:s.entry);return a===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"}):a.type!=="function"?(this.logError("call-of-non-function",`'${this.name}' (with type ${a.type}) is not a function`),{found:void 0,error:"called non function"}):(a.name!==this.name&&this.logWarning("case-insensitive-function",`Case insensitivity for function names is deprecated, use '${a.name}' instead`),{found:a,error:void 0})}getPropsExpression(e,r){var i,s,o,u;const a=this.args.map(B=>B.getExpression(e));if(this.isRaw){const B=[`${this.name}(`];a.forEach((U,V)=>{V!==0&&B.push(","),B.push(U.value)}),B.push(")");const D=(i=a[0])!==null&&i!==void 0?i:{type:"number"},$=this.rawType?{type:this.rawType}:D;return(0,Lat.computedExprValue)({dataType:$,value:(0,I0e.composeSQLExpr)(B),from:a})}const l=(s=e.dialectObj())===null||s===void 0?void 0:s.name,{found:c,error:f}=this.findFunctionDef(l);if(c===void 0)return(0,Fat.errorFor)(f);let x,h=(o=this.source)===null||o===void 0?void 0:o.path;if(this.source){const D=this.source.getField(e).found;if(D){const $=D.typeDesc();if((0,Or.isAtomicFieldType)($.type))x={...$0e.atomicDef($),expressionType:$.expressionType,value:{node:"field",path:this.source.path},evalSpace:$.evalSpace,compositeFieldUsage:$.compositeFieldUsage},h=this.source.path.slice(0,-1);else if(!(D instanceof Nat.StructSpaceFieldBase))return this.loggedErrorExpr("invalid-aggregate-source",`Aggregate source cannot be a ${$.type}`)}else this.loggedErrorExpr("aggregate-source-not-found",`Reference to undefined value ${this.source.refString}`)}const p=[...x?[x]:[],...a],m=Mat(c,p);if(m===void 0)return this.loggedErrorExpr("no-matching-function-overload",`No matching overload for function ${this.name}(${p.map(B=>B.type).join(", ")})`);const{overload:y,expressionTypeErrors:g,evalSpaceErrors:E,nullabilityErrors:A,returnType:_}=m;for(const B of g){const D=B.argIndex-(x?1:0),$=(0,Or.expressionIsScalar)(B.maxExpressionType)?"scalar":"scalar or aggregate";this.args[D].logError("invalid-function-argument-expression-type",`Parameter ${B.argIndex+1} ('${B.param.name}') of ${this.name} must be ${$}, but received ${B.actualExpressionType}`)}for(const B of E){const D=B.argIndex-(x?1:0),$=B.maxEvalSpace==="literal"?"literal":B.maxEvalSpace==="constant"?"literal or constant":"literal, constant or output";this.args[D].logError("invalid-function-argument-evaluation-space",`Parameter ${B.argIndex+1} ('${B.param.name}') of ${this.name} must be ${$}, but received ${B.actualEvalSpace}`)}for(const B of A){const D=B.argIndex-(x?1:0);this.args[D].logError("literal-null-function-argument",`Parameter ${B.argIndex+1} ('${B.param.name}') of ${this.name} must not be a literal null`)}m.returnTypeError&&this.logError(m.returnTypeError.code,m.returnTypeError.parameters);const v=y.returnType,C=(0,Or.maxOfExpressionTypes)([(u=v.expressionType)!==null&&u!==void 0?u:"scalar",...p.map(B=>B.expressionType)]);if(!(0,Or.expressionIsAggregate)(y.returnType.expressionType)&&this.source!==void 0)return this.loggedErrorExpr("non-aggregate-function-with-source",`Cannot call function ${this.name}(${p.map(B=>B.type).join(", ")}) with source`);const S={node:"function_call",overload:y,name:this.name,kids:{args:p.map(B=>B.value)},expressionType:C,structPath:h};let b=S;if(r!=null&&r.orderBys&&r.orderBys.length>0){const B=(0,Or.expressionIsAnalytic)(y.returnType.expressionType);if(B||this.inExperiment("aggregate_order_by",!0)||r.orderBys[0].logError("aggregate-order-by-experiment-not-enabled","Enable experiment `aggregate_order_by` to use `order_by` with an aggregate function"),y.supportsOrderBy||B){const D=y.supportsOrderBy!=="only_default",$=r.orderBys.flatMap(U=>B?U.getAnalyticOrderBy(e):U.getAggregateOrderBy(e,D));S.kids.orderBy=$}else r.orderBys[0].logError("function-does-not-support-order-by",`Function \`${this.name}\` does not support \`order_by\``)}if((r==null?void 0:r.limit)!==void 0&&(y.supportsLimit?S.limit=r.limit.limit:this.logError("function-does-not-support-limit",`Function ${this.name} does not support limit`)),r!=null&&r.partitionBys&&r.partitionBys.length>0){const B=[];for(const D of r.partitionBys)for(const $ of D.partitionFields){const U=$.getField(e);U.found===void 0?$.logError("partition-by-not-found",`${$.refString} is not defined`):(0,Or.expressionIsAnalytic)(U.found.typeDesc().expressionType)||(0,Or.expressionIsUngroupedAggregate)(U.found.typeDesc().expressionType)?$.logError("non-scalar-or-aggregate-partition-by","Partition expression must be scalar or aggregate"):B.push($.nameString)}S.partitionBy=B}if(["sql_number","sql_string","sql_date","sql_timestamp","sql_boolean"].includes(c.name)){if(!this.inExperiment("sql_functions",!0))return this.loggedErrorExpr("sql-functions-experiment-not-enabled",`Cannot use sql_function \`${c.name}\`; use \`sql_functions\` experiment to enable this behavior`);const B=p[0].value;if(B.node!=="stringLiteral")this.logError("invalid-sql-function-argument",`Invalid string literal for \`${c.name}\``);else{const D=B.literal,$=Pat(D),U=$.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 V=[];for(const Q of $)if(Q.type==="string")V.push(Q.value);else if(Q.name==="TABLE")V.push({node:"source-reference"});else{const Z=new $at.FieldName(Q.name);this.has({name:Z});const de=e.lookup([Z]);if(de.found===void 0)return this.loggedErrorExpr("sql-function-interpolation-not-found",`Invalid interpolation: ${de.error.message}`);de.found.refType==="parameter"?V.push({node:"parameter",path:[Q.name]}):V.push({node:"field",path:[Q.name]})}b=(0,I0e.composeSQLExpr)(V)}}const R=(0,Or.mergeEvalSpaces)(...p.map(B=>B.evalSpace)),O=R==="constant"?"constant":(0,Or.expressionIsScalar)(C)?R:"output";return{...(0,Or.isAtomic)(_)?$0e.atomicDef(_):_,expressionType:C,value:b,evalSpace:O,compositeFieldUsage:(0,Bat.mergeCompositeFieldUsage)(...p.map(B=>B.compositeFieldUsage))}}}SE.ExprFunc=kat;function Mat(t,e){var r;for(const i of t.overloads){const s=new Map;let o=0,u=!0,a=!1;const l=[],c=[],f=[];for(let p=0;p<e.length;p++){const m=e[p],y=i.params[o];if(y===void 0){u=!1;break}if(!y.allowedTypes.some(E=>{var A;const{dataTypeMatch:_,genericsSet:v}=Q2(s,(A=i.genericTypes)!==null&&A!==void 0?A:[],m,E);for(const C of v)s.set(C.name,C.type);return E.expressionType&&((0,Or.isExpressionTypeLEQ)(m.expressionType,E.expressionType)||l.push({argIndex:p,maxExpressionType:E.expressionType,actualExpressionType:m.expressionType,param:y})),(E.evalSpace==="literal"&&m.evalSpace!=="literal"||E.evalSpace==="constant"&&(m.evalSpace==="input"||m.evalSpace==="output")||(0,Or.expressionIsAnalytic)(i.returnType.expressionType)&&m.evalSpace==="input")&&c.push({argIndex:p,param:y,maxEvalSpace:E.evalSpace,actualEvalSpace:m.evalSpace}),E.evalSpace==="literal"&&m.type==="null"&&f.push({argIndex:p,param:y}),_})){u=!1;break}y.isVariadic?p===e.length-1&&(a=!0):o++}if(!a&&(o!==e.length||o!==i.params.length))continue;const x=fT(i.returnType,s),h=(r=x.returnType)!==null&&r!==void 0?r:{type:"number"};if(u)return{overload:i,expressionTypeErrors:l,evalSpaceErrors:c,nullabilityErrors:f,returnTypeError:x.error,returnType:h}}}function Pat(t){const e=[];let r=t;for(;r.length;){const i=r.indexOf("${");if(i===-1){e.push({type:"string",value:r});break}else{const s=r.slice(i).indexOf("}");if(s===-1){e.push({type:"string",value:r});break}i>0&&e.push({type:"string",value:r.slice(0,i)}),e.push({type:"interpolation",name:r.slice(i+2,s+i)}),r=r.slice(s+i+1)}}return e}function Q2(t,e,r,i){var s,o,u,a;if(Or.TD.eq(i,r)||i.type==="any"||i.type!=="generic"&&(r.type==="null"||r.type==="error"))return{dataTypeMatch:!0,genericsSet:[]};if(i.type==="array"&&r.type==="array"){if((0,Or.isScalarArray)(r))return(0,Or.isRepeatedRecordFunctionParam)(i)?{dataTypeMatch:!1,genericsSet:[]}:Q2(t,e,r.elementTypeDef,i.elementTypeDef);if((0,Or.isRepeatedRecordFunctionParam)(i)){const l={type:"record",fields:i.fields},c={type:"record",fields:r.fields};return Q2(t,e,c,l)}else return{dataTypeMatch:!1,genericsSet:[]}}else if(i.type==="record"&&r.type==="record"){const l=[],c=new Map;for(const f of i.fields)c.set((s=f.as)!==null&&s!==void 0?s:f.name,f);for(const f of r.fields){const x=c.get((o=f.as)!==null&&o!==void 0?o:f.name);if(x===void 0)return{dataTypeMatch:!1,genericsSet:[]};const h=Q2(new Map([...t.entries(),...l.map(p=>[p.name,p.type])]),e,f,x);l.push(...h.genericsSet)}return{dataTypeMatch:!0,genericsSet:l}}else if(i.type==="generic"){const l=t.get(i.generic);if(l!==void 0&&l.type!=="null"&&l.type!=="error")return Q2(t,e,r,l);const c=(a=(u=e.find(f=>f.name===i.generic))===null||u===void 0?void 0:u.acceptibleTypes)!==null&&a!==void 0?a:[];for(const f of c){const x=Q2(t,e,r,f);if(x.dataTypeMatch){if(!(0,Or.isAtomic)(r)&&r.type!=="null")continue;const h={name:i.generic,type:r};return{dataTypeMatch:!0,genericsSet:[...x.genericsSet,h]}}}}return{dataTypeMatch:!1,genericsSet:[]}}function fT(t,e){switch(t.type){case"array":{if("fields"in t){const s=t.fields.map(o=>{const u=fT(o,e);return{...o,...u}});return{error:void 0,returnType:{type:"array",elementTypeDef:t.elementTypeDef,fields:s}}}const r=fT(t.elementTypeDef,e);if(r.error)return r;const i=r.returnType;return i.type==="record"?{error:void 0,returnType:{type:"array",elementTypeDef:{type:"record_element"},fields:i.fields}}:(0,Or.isAtomic)(i)?{error:void 0,returnType:{type:"array",elementTypeDef:i}}:{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(i=>{const s=fT(i,e);return{...i,...s}})}};case"generic":{const r=e.get(t.generic);return r===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:r}}default:return{error:void 0,returnType:t}}}var Uat=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),jat=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),qat=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Uat(e,t,r);return jat(e,t),e};Object.defineProperty(cT,"__esModule",{value:!0}),cT.ExprProps=void 0;const Hat=et,Qat=Qs,zat=qat(nn),Gat=nf,Wat=rf,Vat=H2,Yat=pt,Kat=SE,Jat=dt;class Xat extends Yat.ExpressionDef{constructor(e,r){super({expr:e,statements:r}),this.expr=e,this.statements=r,this.elementType="expression with props",this.legalChildTypes=zat.anyAtomicT}getFilteredExpression(e,r,i){if(i.length>0){if(!this.expr.supportsWhere(r))return this.expr.logError("filter-of-non-aggregate","Filtered expression requires an aggregate computation"),r;const s=[];for(const o of i){const u=o.getFilterList(e);if(u.find(a=>(0,Hat.expressionIsCalculation)(a.expressionType)))return o.logError("aggregate-filter-expression-not-scalar","Cannot filter an expresion with an aggregate or analytical computation"),r;s.push(...u)}return this.typeCheck(this.expr,{...r,expressionType:"scalar"})?{...r,compositeFieldUsage:(0,Jat.mergeCompositeFieldUsage)(r.compositeFieldUsage,...s.map(o=>o.compositeFieldUsage)),value:{node:"filteredExpr",kids:{e:r.value,filterList:s}}}:(this.expr.logError("filter-of-non-aggregate",`Cannot filter '${r.expressionType}' data`),(0,Qat.errorFor)("cannot filter type"))}return r}getExpression(e){const r=[];let i;const s=[],o=[];for(const a of this.statements)a instanceof Vat.PartitionBy?this.expr.canSupportPartitionBy()?r.push(a):a.logError("partition-by-of-non-window-function","`partition_by` is not supported for this kind of expression"):a instanceof Wat.Limit?i?a.logError("expression-limit-already-specified","limit already specified"):this.expr.canSupportLimit()?i=a:a.logError("limit-of-non-aggregate-function","`limit` is not supported for this kind of expression"):a instanceof Gat.FunctionOrdering?this.expr.canSupportOrderBy()?s.push(a):a.logError("order-by-of-non-aggregate-function","`order_by` is not supported for this kind of expression"):o.push(a);const u=this.expr instanceof Kat.ExprFunc?this.expr.getPropsExpression(e,{partitionBys:r,limit:i,orderBys:s}):this.expr.getExpression(e);return this.getFilteredExpression(e,u,o)}}cT.ExprProps=Xat;var xT={},Zat=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),elt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),tlt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Zat(e,t,r);return elt(e,t),e};Object.defineProperty(xT,"__esModule",{value:!0}),xT.ExprLogicalOp=void 0;const nlt=_E,B0e=tlt(nn);class rlt extends nlt.BinaryBoolean{constructor(){super(...arguments),this.elementType="logical operator",this.legalChildTypes=[B0e.boolT,B0e.aggregateBoolT]}}xT.ExprLogicalOp=rlt;var dT={},ilt=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),slt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),olt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ilt(e,t,r);return slt(e,t),e};Object.defineProperty(dT,"__esModule",{value:!0}),dT.ExprMax=void 0;const hT=olt(nn),ult=y0;class alt extends ult.ExprAggregateFunction{constructor(e){super("max",e),this.legalChildTypes=[hT.numberT,hT.stringT,hT.dateT,hT.timestampT]}returns(e){return e}}dT.ExprMax=alt;var pT={},llt=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),clt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),flt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&llt(e,t,r);return clt(e,t),e};Object.defineProperty(pT,"__esModule",{value:!0}),pT.ExprMin=void 0;const mT=flt(nn),xlt=y0;class dlt extends xlt.ExprAggregateFunction{constructor(e){super("min",e),this.legalChildTypes=[mT.numberT,mT.stringT,mT.dateT,mT.timestampT]}returns(e){return e}}pT.ExprMin=dlt;var gT={},hlt=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),plt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),mlt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&hlt(e,t,r);return plt(e,t),e};Object.defineProperty(gT,"__esModule",{value:!0}),gT.ExprMinus=void 0;const glt=Qs,k0e=mlt(nn),ylt=pt;class Elt extends ylt.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="unary minus",this.legalChildTypes=[k0e.numberT]}getExpression(e){const r=this.expr.getExpression(e);return k0e.typeIn(r,this.legalChildTypes)?{...r,type:"number",value:{node:"unary-",e:r.value}}:(0,glt.errorFor)("negate requires number")}}gT.ExprMinus=Elt;var yT={};Object.defineProperty(yT,"__esModule",{value:!0}),yT.ExprMulDiv=void 0;const Alt=U2;class _lt extends Alt.BinaryNumeric{constructor(){super(...arguments),this.elementType="*/%"}}yT.ExprMulDiv=_lt;var ET={},bE={};Object.defineProperty(bE,"__esModule",{value:!0}),bE.Unary=void 0;const vlt=pt;class Clt extends vlt.ExpressionDef{constructor(e){super({expr:e}),this.expr=e}}bE.Unary=Clt;var Slt=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),blt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Tlt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Slt(e,t,r);return blt(e,t),e};Object.defineProperty(ET,"__esModule",{value:!0}),ET.ExprNot=void 0;const uk=Tlt(nn),Rlt=bE;class Dlt extends Rlt.Unary{constructor(e){super(e),this.elementType="not",this.legalChildTypes=[uk.boolT,uk.nullT]}getExpression(e){var r;const i=this.expr.getExpression(e);!((r=e.dialectObj())===null||r===void 0)&&r.booleanAsNumbers&&this.legalChildTypes.find(o=>o.type==="number")===void 0&&this.legalChildTypes.push(uk.numberT);const s=this.typeCheck(this.expr,i);return{...i,type:"boolean",value:{node:"not",e:s?i.value:{node:"false"}}}}}ET.ExprNot=Dlt;var AT={};Object.defineProperty(AT,"__esModule",{value:!0}),AT.ExprNow=void 0;const Olt=pt,wlt=dt;class Flt extends Olt.ExpressionDef{constructor(){super(...arguments),this.elementType="timestamp"}getExpression(e){return{type:"timestamp",expressionType:"scalar",evalSpace:"constant",value:{node:"now"},compositeFieldUsage:(0,wlt.emptyCompositeFieldUsage)()}}}AT.ExprNow=Flt;var of={};Object.defineProperty(of,"__esModule",{value:!0}),of.ExprIsNull=of.PartialIsNull=of.ExprNULL=void 0;const Nlt=zt,_T=pt;function ak(t,e,r){const i=r.getExpression(t);return i.type="boolean",i.value={node:e==="="?"is-null":"is-not-null",e:i.value},i}class Llt extends _T.ExpressionDef{constructor(){super(...arguments),this.elementType="NULL"}getExpression(){return(0,Nlt.literalExprValue)({dataType:{type:"null"},value:{node:"null"}})}apply(e,r,i){return r==="!="||r==="="?ak(e,r,i):super.apply(e,r,i,!0)}}of.ExprNULL=Llt;class Ilt extends _T.ExpressionDef{constructor(e){super(),this.op=e,this.elementType="<=> NULL"}apply(e,r,i){return ak(e,this.op,i)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("partial-as-value","Partial null check does not have a value")}atNodeType(){return _T.ATNodeType.Partial}}of.PartialIsNull=Ilt;class $lt extends _T.ExpressionDef{constructor(e,r){super(),this.expr=e,this.op=r,this.elementType="is null",this.has({expr:e})}getExpression(e){return ak(e,this.op,this.expr)}}of.ExprIsNull=$lt;var vT={};Object.defineProperty(vT,"__esModule",{value:!0}),vT.ExprNumber=void 0;const Blt=zt,klt=pt;class Mlt extends klt.ExpressionDef{constructor(e){super(),this.n=e,this.elementType="numeric literal"}getExpression(e){return this.constantExpression()}constantExpression(){const e=Number(this.n),r=Number.isNaN(e)?{type:"number"}:{type:"number",numberType:Number.isInteger(e)?"integer":"float"};return(0,Blt.literalExprValue)({dataType:r,value:{node:"numberLiteral",literal:this.n}})}}vT.ExprNumber=Mlt;var CT={};Object.defineProperty(CT,"__esModule",{value:!0}),CT.ExprParens=void 0;const lk=pt;class Plt extends lk.ExpressionDef{constructor(e){super({expr:e}),this.expr=e,this.elementType="(expression)"}requestExpression(e){return this.expr.requestExpression(e)}getExpression(e){const r=this.expr.getExpression(e);return{...r,value:{node:"()",e:r.value}}}apply(e,r,i,s){return this.expr.atNodeType()===lk.ATNodeType.Or?this.expr.apply(e,r,i,s):(0,lk.applyBinary)(e,i,r,this)}atNodeType(){return this.expr.atNodeType()}atExpr(){return this.expr}}CT.ExprParens=Plt;var ST={};Object.defineProperty(ST,"__esModule",{value:!0}),ST.ExprFilterExpression=void 0;const Ult=zt,jlt=pt,bT=dB;class qlt extends jlt.ExpressionDef{constructor(e){super(),this.filterText=e,this.elementType="filter expression literal"}getExpression(){return this.loggedErrorExpr("filter-expression-type","Filter expression illegal here")}apply(e,r,i,s=!1){if(r==="~"||r==="!~"){const o=i.getExpression(e);if(o.type==="error")return o;let u;switch(o.type){case"string":u=bT.StringFilterExpression.parse(this.filterText);break;case"number":u=bT.NumberFilterExpression.parse(this.filterText);break;case"boolean":u=bT.BooleanFilterExpression.parse(this.filterText);break;case"date":case"timestamp":u=bT.TemporalFilterExpression.parse(this.filterText);break;default:return i.loggedErrorExpr("filter-expression-type",`Cannot use filter expressions with type '${o.type}'`)}if(u.log.length>0)for(const l of u.log)return this.loggedErrorExpr("filter-expression-type",`Filter parse error: ${u.log[0].message}`);if(!u.parsed)return this.loggedErrorExpr("filter-expression-type","FJKLD:JDKSL: expression parsed to null");const a={node:"filterMatch",dataType:o.type,filter:u.parsed,e:o.value};return r==="!~"&&(a.notMatch=!0),(0,Ult.computedExprValue)({value:a,dataType:{type:"boolean"},from:[o]})}return this.loggedErrorExpr("filter-expression-type",`Cannot use the '${r}' operator with a filter expression`)}}ST.ExprFilterExpression=qlt;var TT={};Object.defineProperty(TT,"__esModule",{value:!0}),TT.ExprRegEx=void 0;const Hlt=zt,Qlt=pt;class zlt extends Qlt.ExpressionDef{constructor(e){super(),this.regex=e,this.elementType="regular expression literal"}getExpression(){return(0,Hlt.literalExprValue)({dataType:{type:"regular expression"},value:{node:"regexpLiteral",literal:this.regex}})}}TT.ExprRegEx=zlt;var RT={};Object.defineProperty(RT,"__esModule",{value:!0}),RT.ExprString=void 0;const Glt=pt,Wlt=zt;class Vlt extends Glt.ExpressionDef{constructor(e){super(),this.elementType="string literal",this.value=e}getExpression(e){return(0,Wlt.literalExprValue)({dataType:{type:"string"},value:{node:"stringLiteral",literal:this.value}})}}RT.ExprString=Vlt;var DT={};Object.defineProperty(DT,"__esModule",{value:!0}),DT.ExprSum=void 0;const Ylt=q2;class Klt extends Ylt.ExprAsymmetric{constructor(e,r,i){super("sum",e,r,i),this.has({source:r})}}DT.ExprSum=Klt;var OT={};Object.defineProperty(OT,"__esModule",{value:!0}),OT.ExprTimeExtract=void 0;const E0=et,wT=zt,ck=pt,Jlt=tf;class TE extends ck.ExpressionDef{static extractor(e){const r=TE.pluralMap[e];if(r)return r;if((0,E0.isExtractUnit)(e))return e}constructor(e,r){super({args:r}),this.extractText=e,this.args=r,this.elementType="timeExtract"}getExpression(e){const r=TE.extractor(this.extractText);if(r){if(this.args.length!==1)return this.loggedErrorExpr("too-many-arguments-for-time-extraction",`Extraction function ${r} requires one argument`);const i=this.args[0];if(i instanceof Jlt.Range){let s=i.first.getExpression(e),o=i.last.getExpression(e);if(s.type==="error"||o.type==="error")return(0,wT.computedErrorExprValue)({dataType:{type:"number"},error:"extract from error",from:[s,o]});if(!(0,E0.isTemporalType)(s.type))return i.first.loggedErrorExpr("invalid-type-for-time-extraction",`Can't extract ${r} from '${s.type}'`);if(!(0,E0.isTemporalType)(o.type))return i.last.loggedErrorExpr("invalid-type-for-time-extraction",`Cannot extract ${r} from '${o.type}'`);let u=s.type;if(!E0.TD.eq(s,o)){let a=!0;if(u="timestamp",s.type==="date"){const l=(0,ck.getMorphicValue)(s,"timestamp");l&&(s=l,a=!1)}else{const l=(0,ck.getMorphicValue)(o,"timestamp");l&&(o=l,a=!1)}if(a)return i.first.loggedErrorExpr("invalid-types-for-time-measurement",`Cannot measure from ${s.type} to ${o.type}`)}return["week","month","quarter","year"].includes(r)?this.loggedErrorExpr("invalid-timeframe-for-time-measurement",`Cannot measure interval using '${r}'`):(0,E0.isTimestampUnit)(r)?(0,wT.computedExprValue)({dataType:{type:"number",numberType:"integer"},value:{node:"timeDiff",units:r,kids:{left:(0,E0.mkTemporal)(s.value,u),right:(0,E0.mkTemporal)(o.value,u)}},from:[s,o]}):this.loggedErrorExpr("invalid-time-extraction-unit",`Cannot extract ${r} from a range`)}else{const s=i.getExpression(e);return(0,E0.isTemporalType)(s.type)?(0,wT.computedExprValue)({dataType:{type:"number",numberType:"integer"},value:{node:"extract",e:(0,E0.mkTemporal)(s.value,s.type),units:r},from:[s]}):(s.type!=="error"&&this.logError("unsupported-type-for-time-extraction",`${this.extractText}() requires time type, not '${s.type}'`),(0,wT.computedErrorExprValue)({dataType:{type:"number",numberType:"integer"},error:`${this.extractText} bad type ${s.type}`,from:[s]}))}}throw this.internalError(`Illegal extraction unit '${this.extractText}'`)}}OT.ExprTimeExtract=TE,TE.pluralMap={years:"year",quarters:"quarter",months:"month",weeks:"week",days:"day",hours:"hour",minutes:"minute",seconds:"second"};var FT={},Tu={},NT={};Object.defineProperty(NT,"__esModule",{value:!0}),NT.QueryInputSpace=void 0;const Xlt=Es,Zlt=D2;class e0t extends Zlt.RefinedSpace{constructor(e,r,i){super(e),this.queryOutput=r,this._isProtectedAccessSpace=i,this.extendList=[]}extendSource(e){this.pushFields(e),e instanceof Xlt.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}}NT.QueryInputSpace=e0t;var t0t=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),n0t=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),r0t=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&t0t(e,t,r);return n0t(e,t),e};Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.ReduceFieldSpace=Tu.QuerySpace=Tu.QueryOperationSpace=void 0;const LT=r0t(et),fk=Yc,M0e=sf,P0e=zr,i0t=_t,s0t=D2,o0t=uE,u0t=Gr,a0t=NT,Ha=dt,l0t=Cd;class U0e extends s0t.RefinedSpace{get compositeFieldUsage(){if(this._compositeFieldUsage===void 0)throw new Error("Composite field usage accessed before computed");return this._compositeFieldUsage}constructor(e,r,i,s){super(e.emptyStructDef()),this.queryInputSpace=e,this.nestParent=i,this.astEl=s,this.expandedWild={},this.compositeFieldUsers=[],this._compositeFieldUsage=void 0,this.exprSpace=new a0t.QueryInputSpace(e.structDef(),this,e.isProtectedAccessSpace()),r&&this.addRefineFromFields(r)}logError(e,r,i){return this.astEl&&this.astEl.logError(e,r,i),e}inputSpace(){return this.exprSpace}outputSpace(){return this}addWild(e){var r;let i=this.exprSpace;const s=[];if(e.joinPath)for(const a of e.joinPath.list){const l=a.refString;s.push(l);const c=i.entry(l);if(c)if(c instanceof u0t.StructSpaceField)i=c.fieldSpace;else{a.logError("invalid-wildcard-source",`Field '${l}' does not contain rows and cannot be expanded with '*'`);return}else{a.logError("wildcard-source-not-defined",`No such field as '${l}'`);return}}const o=this.dialectObj(),u=[];for(const[a,l]of i.entries())if(!e.except.has(a)&&l.refType!=="parameter")if(this.entry(a)){const c=(r=this.expandedWild[a])===null||r===void 0?void 0:r.path.join(".");e.logError("name-conflict-in-wildcard-expansion",`Cannot expand '${a}' in '${e.refString}' because a field with that name already exists${c?` (conflicts with ${c})`:""}`)}else{const c=l.typeDesc();LT.TD.isAtomic(c)&<.expressionIsScalar(c.expressionType)&&(o===void 0||!o.ignoreInProject(a))&&(u.push({name:a,entry:l}),this.expandedWild[a]={path:s.concat(a),entry:l})}for(const a of u.sort((l,c)=>l.name.localeCompare(c.name)))this.newEntry(a.name,e,a.entry)}addValidatedCompositeFieldUserFromEntry(e,r){r instanceof P0e.SpaceField&&this.compositeFieldUsers.push({type:"field",name:e,field:r,logTo:void 0})}getJoinOnCompositeFieldUsage(e){var r;const i=e.map(o=>new M0e.FieldName(o));this.astEl.has({reference:i});const s=this.exprSpace.lookup(i);if(s.found&&s.found instanceof l0t.StructSpaceFieldBase)return(0,Ha.joinedCompositeFieldUsage)(e.slice(0,-1),(r=s.found.fieldDef().onCompositeFieldUsage)!==null&&r!==void 0?r:(0,Ha.emptyCompositeFieldUsage)());throw new Error("Unexpected join lookup was not found or not a struct")}getCompositeFieldUsageIncludingJoinOns(e){let r=e;const i=(0,Ha.compositeFieldUsageJoinPaths)(e);for(const s of i)r=(0,Ha.mergeCompositeFieldUsage)(this.getJoinOnCompositeFieldUsage(s),r);return r}addCompositeFieldUserFromFilter(e,r){e.compositeFieldUsage!==void 0&&this.compositeFieldUsers.push({type:"filter",filter:e,logTo:r})}newEntry(e,r,i){i instanceof P0e.SpaceField&&this.compositeFieldUsers.push({type:"field",name:e,field:i,logTo:r}),super.newEntry(e,r,i)}applyNextCompositeFieldUsage(e,r,i,s,o){if(s){const u=this.getCompositeFieldUsageIncludingJoinOns((0,Ha.compositeFieldUsageDifference)(s,r));if(r=(0,Ha.mergeCompositeFieldUsage)(r,u),!(0,Ha.isEmptyCompositeFieldUsage)(u)){const a=(0,Ha.narrowCompositeFieldResolution)(e,r,i);a.error?(o??this).logError("invalid-composite-field-usage",{newUsage:u,allUsage:r}):i=a.narrowedCompositeFieldResolution}}return{compositeFieldUsage:r,narrowedCompositeFieldResolution:i}}}Tu.QueryOperationSpace=U0e;class j0e extends U0e{addRefineFromFields(e){var r;if(LT.isQuerySegment(e)){if(e!=null&&e.extendSource)for(const i of e.extendSource)this.exprSpace.addFieldDef(i);for(const i of e.queryFields)if(i.type==="fieldref"){const s=this.exprSpace.lookup(i.path.map(o=>new M0e.FieldName(o)));if(s.found){const o=i.path[i.path.length-1];this.setEntry(o,s.found),this.addValidatedCompositeFieldUserFromEntry(o,s.found)}}else if(i.type!=="turtle"){const s=new o0t.ColumnSpaceField(i),o=(r=i.as)!==null&&r!==void 0?r:i.name;this.setEntry(o,s),this.addValidatedCompositeFieldUserFromEntry(o,s)}}}pushFields(...e){for(const r of e)r instanceof i0t.WildcardFieldReference?this.addWild(r):super.pushFields(r)}canContain(e){return!0}queryFieldDefs(){const e=[];let r=(0,Ha.emptyCompositeFieldUsage)(),i=(0,Ha.emptyNarrowedCompositeFieldResolution)();const s=this.inputSpace().structDef();for(const o of this.compositeFieldUsers){let u;if(o.type==="filter")o.filter.compositeFieldUsage&&(u=o.filter.compositeFieldUsage);else{const{name:l,field:c}=o,f=this.expandedWild[l];if(f)e.push({type:"fieldref",path:f.path}),u=f.entry.typeDesc().compositeFieldUsage;else{const x=c.getQueryFieldDef(this.exprSpace);if(x){const h=c.typeDesc();u=h.compositeFieldUsage,h&&h.type!=="error"&&this.canContain(h)&&!f0t(x)&&e.push(x)}}}const a=this.applyNextCompositeFieldUsage(s,r,i,u,o.logTo);r=a.compositeFieldUsage,i=a.narrowedCompositeFieldResolution}return this._compositeFieldUsage=r,e}getQuerySegment(e){const r=this.getPipeSegment(e);if(LT.isQuerySegment(r))return r;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 r={type:this.segmentType,queryFields:this.queryFieldDefs()};if(r.queryFields=(0,fk.mergeFields)(e==null?void 0:e.queryFields,r.queryFields),e!=null&&e.extendSource&&(r.extendSource=e.extendSource),this.exprSpace.extendList.length>0){const i=[],s=this.exprSpace.structDef();for(const o of this.exprSpace.extendList){const u=s.fields.find(a=>(0,fk.nameFromDef)(a)===o);u&&i.push(u)}r.extendSource=(0,fk.mergeFields)(r.extendSource,i)}return this.newTimezone&&(r.queryTimezone=this.newTimezone),r}lookup(e){const r=super.lookup(e);return r.found?{...r,isOutputField:!0}:this.exprSpace.lookup(e)}isQueryFieldSpace(){return!0}}Tu.QuerySpace=j0e;class c0t extends j0e{constructor(){super(...arguments),this.segmentType="reduce"}}Tu.ReduceFieldSpace=c0t;function f0t(t){return typeof t!="string"&&t.type==="turtle"&&t.pipeline.length===0}var x0t=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),d0t=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),h0t=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&x0t(e,t,r);return d0t(e,t),e};Object.defineProperty(FT,"__esModule",{value:!0}),FT.ExprUngroup=void 0;const q0e=et,p0t=Tu,H0e=h0t(nn),m0t=pt;class g0t extends m0t.ExpressionDef{constructor(e,r,i){super({expr:r,fields:i}),this.control=e,this.expr=r,this.fields=i,this.legalChildTypes=H0e.anyAtomicT,this.elementType="ungroup"}getExpression(e){const r=this.expr.getExpression(e);if(!(0,q0e.expressionIsAggregate)(r.expressionType))return this.expr.loggedErrorExpr("ungroup-of-non-aggregate",`${this.control}() expression must be an aggregate`);if((0,q0e.expressionIsUngroupedAggregate)(r.expressionType))return this.expr.loggedErrorExpr("ungroup-of-ungrouped-aggregate",`${this.control}() expression must not already be ungrouped`);const i={node:this.control,e:r.value};if(this.typeCheck(this.expr,{...r,expressionType:"scalar"})){if(e.isQueryFieldSpace()&&this.fields.length>0){const s=[],o=this.control==="exclude";for(const u of this.fields){let a=e.outputSpace(),l=!0;for(;a;){const c=a.lookup([u]);if(c.found&&c.isOutputField)s.push(u.refString),l=!1;else if(a instanceof p0t.QuerySpace){a=a.nestParent;continue}break}if(l){const c=o?"exclude()":"all()";u.logError("ungroup-field-not-in-output",`${c} '${u.refString}' is missing from query output`)}}i.fields=s}return{...H0e.atomicDef(r),expressionType:"ungrouped_aggregate",value:i,evalSpace:"output",compositeFieldUsage:r.compositeFieldUsage}}return this.loggedErrorExpr("ungroup-with-non-scalar",`${this.control}() incompatible type`)}}FT.ExprUngroup=g0t;var IT={},y0t=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),E0t=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),A0t=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&y0t(e,t,r);return E0t(e,t),e};Object.defineProperty(IT,"__esModule",{value:!0}),IT.ForRange=void 0;const _0t=Qs,Q0e=A0t(nn),$T=As,v0t=zt,C0t=pt,BT=P2,z0e=tf;class S0t extends C0t.ExpressionDef{constructor(e,r,i){super({from:e,duration:r,timeframe:i}),this.from=e,this.duration=r,this.timeframe=i,this.elementType="forRange",this.legalChildTypes=[Q0e.timestampT,Q0e.dateT]}apply(e,r,i){const s=this.from.getExpression(e),o=i.getExpression(e);if(!this.typeCheck(i,o))return(0,_0t.errorFor)("no time for range");const u=this.duration.getExpression(e);if(u.type!=="number")return u.type!=="error"&&this.logError("invalid-duration-quantity",`FOR duration count must be a number, not '${u.type}'`),(0,v0t.computedErrorExprValue)({dataType:{type:"boolean"},error:"for not number",from:[s,o]});const a=this.timeframe.text;let l=(0,$T.resolution)(a);if(s.type==="timestamp"&&(l="timestamp"),o.type==="date"&&l==="date"){const m=this.from,y=(0,$T.timeOffset)("date",s.value,"+",u.value,a),g=new BT.ExprTime("date",y);return new z0e.Range(m,g).apply(e,r,i)}const c=BT.ExprTime.fromValue("timestamp",o);let f=this.from,x=s.value;if(s.type==="date"){const m=s.morphic&&s.morphic.timestamp;m?x=m:x=(0,$T.castTo)("timestamp",x,"date"),f=new BT.ExprTime("timestamp",x,[s])}const h=(0,$T.timeOffset)("timestamp",x,"+",u.value,a),p=new BT.ExprTime("timestamp",h,[s,u]);return new z0e.Range(f,p).apply(e,r,c)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("range-as-value","A Range is not a value")}}IT.ForRange=S0t;var wr={};Object.defineProperty(wr,"__esModule",{value:!0}),wr.LiteralYear=wr.LiteralQuarter=wr.LiteralMonth=wr.LiteralWeek=wr.LiteralDay=wr.LiteralHour=wr.LiteralTimestamp=wr.TimeFormatError=void 0;const uf=fi,b0t=et,T0t=zt,R0t=tf,G0e=P2,xk=pt;class D0t extends Error{}wr.TimeFormatError=D0t;function Rd(t,e){const r=t.slice(1);if(e){const i=r.match(/\[[^\]]+]$/);if(i)return{tzSpec:i[0].slice(1,-1),text:r.slice(0,-i[0].length)}}return{text:r}}const W0e="yyyy",V0e=`${W0e}-LL`,Ro=`${V0e}-dd`,Y0e=`${Ro} HH`,K0e=`${Y0e}:mm`,dk=`${K0e}:ss`;class J0e extends xk.ExpressionDef{constructor(e,r,i){super(),this.units=r,this.timeType=i,this.literalPart=e.text,e.tzSpec&&(this.timeZone=e.tzSpec)}makeLiteral(e,r){const i={node:"timeLiteral",literal:e,typeDef:{type:r}};return this.timeZone&&(i.timezone=this.timeZone),i}makeValue(e,r){const i=this.makeLiteral(e,r);return(0,T0t.literalTimeResult)({value:i,dataType:{type:r},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 hk extends J0e{constructor(e,r){super(e,r,"timestamp"),this.elementType="literal:timestamp"}static parse(e){let r;const i=Rd(e,!0);e=i.text,e[10]==="T"&&(e=e.slice(0,10)+" "+e.slice(11),i.text=e);const s=e.match(/^([^.,]+)[,.](\d+)$/);s&&(e=s[1]);let o=uf.DateTime.fromFormat(e,dk);if(o.isValid)return new hk(i,r);if(o=uf.DateTime.fromFormat(e,K0e),o.isValid){i.text=i.text+":00",r="minute";const u=o.plus({minute:1}).toFormat(dk);return new pk(i,r,"timestamp",u)}}}wr.LiteralTimestamp=hk;class pk extends J0e{constructor(e,r,i,s){super(e,r,i),this.nextLit=s,this.elementType="granularTimeLiteral"}apply(e,r,i){let s=this.getExpression(e),o=this.getNext();if(o){const u=i.getExpression(e);if(u.type==="timestamp"){const a=(0,xk.getMorphicValue)(s,"timestamp"),l=(0,xk.getMorphicValue)(o,"timestamp");if(a&&l)s=a,o=l;else return super.apply(e,r,i)}if(o&&(0,b0t.isTemporalType)(u.type)){const a=u.type;return new R0t.Range(new G0e.ExprTime(a,s.value),new G0e.ExprTime(a,o.value)).apply(e,r,i)}}return super.apply(e,r,i)}}class mk extends pk{constructor(e,r){super(e,"hour","timestamp",r),this.elementType="literal:hour"}static parse(e){const r=Rd(e,!1);let i=r.text;const s=uf.DateTime.fromFormat(r.text,Y0e);if(s.isValid)return r.text=r.text+":00:00",i=s.plus({hour:1}).toFormat(dk),new mk(r,i)}}wr.LiteralHour=mk;class RE extends pk{constructor(e,r,i){super(e,r,"date",i)}getExpression(e){const r=this.makeValue(this.literalPart,"date"),i=this.makeLiteral(`${this.literalPart} 00:00:00`,"timestamp");return{...r,morphic:{timestamp:i},evalSpace:"literal"}}getNext(){const e=this.makeValue(this.nextLit,"date"),r=this.makeLiteral(`${this.nextLit} 00:00:00`,"timestamp");return{...e,morphic:{timestamp:r}}}}class gk extends RE{constructor(e,r){super(e,"day",r),this.elementType="literal:day"}static parse(e){const r=Rd(e,!1);let i=r.text;const s=uf.DateTime.fromFormat(r.text,Ro);if(s.isValid)return i=s.plus({day:1}).toFormat(Ro),new gk(r,i)}}wr.LiteralDay=gk;class yk extends RE{constructor(e,r){super(e,"week",r),this.elementType="literal:week"}static parse(e){const r=Rd(e,!1);let i=r.text;const s=r.text.slice(0,10),o=uf.DateTime.fromFormat(s,Ro);if(o.isValid&&o.weekday===7){const a=o.plus({days:7});return r.text=o.toFormat(Ro),i=a.toFormat(Ro),new yk(r,i)}}}wr.LiteralWeek=yk;class Ek extends RE{constructor(e,r){super(e,"month",r),this.elementType="literal:month"}static parse(e){const r=Rd(e,!1);let i=r.text;const s=uf.DateTime.fromFormat(r.text,V0e);if(s.isValid){const o=s.plus({months:1});return r.text=s.toFormat(Ro),i=o.toFormat(Ro),new Ek(r,i)}}}wr.LiteralMonth=Ek;class Ak extends RE{constructor(e,r){super(e,"quarter",r),this.elementType="literal:quarter"}static parse(e){const r=Rd(e,!1);let i=r.text;const s=r.text.match(/(^\d{4})-[qQ](\d)$/);if(s){const o=Number.parseInt(s[2])-1;let u=uf.DateTime.fromFormat(s[1],"yyyy");o>0&&(u=u.plus({quarters:o}));const a=u.plus({quarter:1});return r.text=u.toFormat(Ro),i=a.toFormat(Ro),new Ak(r,i)}}}wr.LiteralQuarter=Ak;class _k extends RE{constructor(e,r){super(e,"year",r),this.elementType="literal:year"}static parse(e){const r=Rd(e,!1);let i=r.text;const s=uf.DateTime.fromFormat(r.text,W0e);if(s.isValid){const o=s.plus({year:1});return r.text=s.toFormat(Ro),i=o.toFormat(Ro),new _k(r,i)}}}wr.LiteralYear=_k;var kT={};Object.defineProperty(kT,"__esModule",{value:!0}),kT.PartialCompare=void 0;const X0e=pt;class O0t extends X0e.ExpressionDef{constructor(e,r){super({right:r}),this.op=e,this.right=r,this.elementType="<=> a"}granular(){return this.right.granular()}apply(e,r,i){return this.right.apply(e,this.op,i)}requestExpression(e){}getExpression(e){return this.loggedErrorExpr("partial-as-value","Partial comparison does not have a value")}atNodeType(){return X0e.ATNodeType.Partial}}kT.PartialCompare=O0t;var z2={},w0t=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),F0t=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),N0t=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&w0t(e,t,r);return F0t(e,t),e};Object.defineProperty(z2,"__esModule",{value:!0}),z2.PickWhen=z2.Pick=void 0;const G2=N0t(nn),Z0e=zt,L0t=pt,I0t=Xe;function MT(t,e){return t===void 0||t.type==="null"||t.type==="error"?e:t}class $0t extends L0t.ExpressionDef{constructor(e,r){super({choices:e}),this.choices=e,this.elsePick=r,this.elementType="pick",this.has({elsePick:r})}requestExpression(e){if(this.elsePick!==void 0){for(const r of this.choices){if(r.pick===void 0)return;const i=r.when.requestExpression(e);if(i===void 0||i.type!=="boolean")return}return this.getExpression(e)}}apply(e,r,i){var s;const o={node:"case",kids:{caseWhen:[],caseThen:[]}};let u;const a=[];for(const h of this.choices){const p=h.when.apply(e,"=",i),m=h.pick?h.pick.getExpression(e):i.getExpression(e);if(a.push(p,m),u&&!G2.typeEq(u,m,!0))return this.loggedErrorExpr("pick-type-does-not-match",{pickType:m.type,returnType:u.type});u=MT(u,m),o.kids.caseWhen.push(p.value),o.kids.caseThen.push(m.value)}const l=(s=this.elsePick)===null||s===void 0?void 0:s.getExpression(e),c=i.getExpression(e);a.push(c),l&&a.push(l);const f=l??c,x=MT(u,f);return G2.typeEq(x,f,!0)?(o.kids.caseElse=f.value,(0,Z0e.computedExprValue)({dataType:x,value:o,from:a})):this.elsePick?this.loggedErrorExpr("pick-else-type-does-not-match",{elseType:f.type,returnType:x.type}):this.loggedErrorExpr("pick-default-type-does-not-match",{defaultType:f.type,returnType:x.type})}getExpression(e){const r={node:"case",kids:{caseWhen:[],caseThen:[]}};if(this.elsePick===void 0)return this.loggedErrorExpr("pick-missing-else","pick incomplete, missing 'else'");const i=[],s=[];for(const l of this.choices){if(l.pick===void 0)return this.loggedErrorExpr("pick-missing-value","pick with no value can only be used with apply");l.when.requestExpression(e)===void 0&&this.loggedErrorExpr("pick-illegal-partial","pick with partial when can only be used with apply");const f=l.pick.getExpression(e),x=l.when.getExpression(e);i.push({pick:f,when:x}),s.push(f,x)}let o;for(const l of i){if(!G2.typeEq(l.when,G2.boolT))return this.loggedErrorExpr("pick-when-must-be-boolean",{whenType:l.when.type});if(o&&!G2.typeEq(o,l.pick,!0))return this.loggedErrorExpr("pick-type-does-not-match",{pickType:l.pick.type,returnType:o.type});o=MT(o,l.pick),r.kids.caseWhen.push(l.when.value),r.kids.caseThen.push(l.pick.value)}const u=this.elsePick.getExpression(e);s.push(u);const a=MT(o,u);return G2.typeEq(a,u,!0)?(r.kids.caseElse=u.value,(0,Z0e.computedExprValue)({dataType:a,value:r,from:s})):this.elsePick.loggedErrorExpr("pick-else-type-does-not-match",{elseType:u.type,returnType:a.type})}}z2.Pick=$0t;class B0t extends I0t.MalloyElement{constructor(e,r){super({when:r}),this.pick=e,this.when=r,this.elementType="caseWhen",this.has({pick:e})}}z2.PickWhen=B0t;var W2={},k0t=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),M0t=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),P0t=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&k0t(e,t,r);return M0t(e,t),e};Object.defineProperty(W2,"__esModule",{value:!0}),W2.CaseWhen=W2.Case=void 0;const U0t=zt,j0t=pt,q0t=Xe,V2=P0t(nn);function ece(t,e){return t===void 0||t.type==="null"||t.type==="error"?e:t}class H0t extends j0t.ExpressionDef{constructor(e,r,i){super({choices:r}),this.value=e,this.choices=r,this.elseValue=i,this.elementType="case",this.has({elseValue:i,value:e})}getExpression(e){const r={node:"case",kids:{caseWhen:[],caseThen:[]}},i=[];let s;if(this.value){const a=this.value.getExpression(e);i.push(a),r.kids.caseValue=a.value,s=a}const o=[];for(const a of this.choices){const l=a.when.getExpression(e),c=a.then.getExpression(e);o.push({when:l,then:c}),i.push(l,c)}let u;for(const a of o){if(s!==void 0){if(!V2.typeEq(a.when,s))return this.loggedErrorExpr("case-when-type-does-not-match",{whenType:a.when.type,valueType:s.type})}else if(!V2.typeEq(a.when,V2.boolT))return this.loggedErrorExpr("case-when-must-be-boolean",{whenType:a.when.type});if(u&&!V2.typeEq(u,a.then,!0))return this.loggedErrorExpr("case-then-type-does-not-match",{thenType:a.then.type,returnType:u.type});u=ece(u,a.then),r.kids.caseWhen.push(a.when.value),r.kids.caseThen.push(a.then.value)}if(this.elseValue){const a=this.elseValue.getExpression(e);if(u&&!V2.typeEq(u,a,!0))return this.loggedErrorExpr("case-else-type-does-not-match",{elseType:a.type,returnType:u.type});u=ece(u,a),i.push(a),r.kids.caseElse=a.value}return(0,U0t.computedExprValue)({value:r,dataType:u?V2.atomicDef(u):{type:"null"},from:i})}}W2.Case=H0t;class Q0t extends q0t.MalloyElement{constructor(e,r){super({when:e,then:r}),this.when=e,this.then=r,this.elementType="caseWhen"}}W2.CaseWhen=Q0t;var PT={},Dd={},z0t=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),G0t=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),W0t=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&z0t(e,t,r);return G0t(e,t),e};Object.defineProperty(Dd,"__esModule",{value:!0}),Dd.RecordLiteral=Dd.RecordElement=void 0;const tce=Yi,V0t=zt,Y0t=pt,K0t=Xe,J0t=W0t(nn);class X0t extends K0t.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 r=e.path.fieldReference.path;this.key=r[r.length-1]}}}Dd.RecordElement=X0t;class Z0t extends Y0t.ExpressionDef{constructor(e){super(),this.pairs=e,this.elementType="record literal",this.has({pairs:e})}getExpression(e){return this.getRecord(e,[])}getRecord(e,r){var i;const s={node:"recordLiteral",kids:{},typeDef:{type:"record",fields:[]}},o=[];let u=0;for(const a of this.pairs){const l=(i=a.key)!==null&&i!==void 0?i:r[u];if(u+=1,l===void 0){a.logError("record-literal-needs-keys","Anonymous record element not legal here");continue}const c=a.value.getExpression(e);tce.TD.isAtomic(c)?(o.push(c),s.kids[l]=c.value,s.typeDef.fields.push((0,tce.mkFieldDef)(J0t.atomicDef(c),l))):a.value.logError("illegal-record-property-type",`Record property '${a.key} is type '${c.type}', which is not a legal property value type`)}return(0,V0t.computedExprValue)({value:s,dataType:s.typeDef,from:o})}getNextElement(e,r){const i=r.value;return i.node==="recordLiteral"?this.getRecord(e,Object.keys(i.kids)):this.getRecord(e,[])}}Dd.RecordLiteral=Z0t;var ect=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),tct=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),nct=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ect(e,t,r);return tct(e,t),e};Object.defineProperty(PT,"__esModule",{value:!0}),PT.ArrayLiteral=void 0;const rct=zt,ict=pt,nce=nct(nn),sct=Dd;class oct extends ict.ExpressionDef{constructor(e){super(),this.elements=e,this.elementType="array literal",this.has({elements:e})}getExpression(e){const r=[],i=[];let s;if(this.elements.length>0)for(const l of this.elements){const c=s&&l instanceof sct.RecordLiteral?l.getNextElement(e,s):l.getExpression(e);if(i.push(c),c.type!=="error"){if(s){if(c.type!=="null"&&!nce.typeEq(s,c)){l.logError("array-values-incompatible","All array elements must be same type");continue}}else c.type!=="null"&&(s=c);r.push(c.value)}}const o=nce.atomicDef(s||{type:"number"}),u=o.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:o.fields}:{type:"array",elementTypeDef:o},a={node:"arrayLiteral",kids:{values:r},typeDef:u};return(0,rct.computedExprValue)({dataType:u,value:a,from:i})}}PT.ArrayLiteral=oct;var UT={};Object.defineProperty(UT,"__esModule",{value:!0}),UT.Timeframe=void 0;const uct=et,act=Xe;class lct extends act.MalloyElement{constructor(e){super(),this.elementType="timeframe";let r=e.toLowerCase();r.endsWith("s")&&(r=r.slice(0,-1)),this.text=(0,uct.isTimestampUnit)(r)?r:"second"}}UT.Timeframe=lct;var af={};Object.defineProperty(af,"__esModule",{value:!0}),af.ImportStatement=af.ImportSelect=af.ImportSourceName=void 0;const vk=Xe;class cct extends vk.MalloyElement{constructor(e){super(),this.text=e,this.elementType="importSourceName"}}af.ImportSourceName=cct;class fct extends vk.MalloyElement{constructor(e,r){super(),this.text=e,this.from=r,this.elementType="importName",r&&this.has({from:r})}}af.ImportSelect=fct;class xct extends vk.ListOf{constructor(e,r){super([]),this.url=e,this.elementType="import statement";try{this.fullURL=decodeURI(new URL(e,r).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 i=e.childRequest(this.fullURL);if(i)return i}}execute(e){const r=this.translator();if(!r)this.logError("no-translator-for-import","Cannot import without translation context");else if(this.fullURL){const i=r.root.pretranslatedModels.get(this.fullURL),s=r.root.importZone.getEntry(this.fullURL);if(i||s.status==="present"){const o=r.getChildExports(this.fullURL);if(this.notEmpty())for(const u of this.list){const a=u.from||u;if(e.getEntry(u.text))u.logError("name-conflict-on-selective-import",`Cannot redefine '${u.text}'`);else if(o[a.text]){const l={...o[a.text]};u.from&&(l.as=u.text),e.setEntry(u.text,{entry:l,exported:!1})}else a.logError("selective-import-not-found",`Cannot find '${a.text}', not imported`)}else for(const[u,a]of Object.entries(r.getChildExports(this.fullURL)))e.getEntry(u)?this.logError("name-conflict-on-indiscriminate-import",`Cannot redefine '${u}'`):e.setEntry(u,{entry:a,exported:!1})}else s.status==="error"?this.logError("failed-import",`import failed: '${s.message}'`):this.logError("failed-import",`import failed with status: '${s.status}'`)}}}af.ImportStatement=xct;var DE={};Object.defineProperty(DE,"__esModule",{value:!0}),DE.ExtendBlock=void 0;const dct=Xe,hct=Gn;class pct extends dct.ListOf{constructor(){super(...arguments),this.elementType="extendBlock",this.forceQueryClass=void 0,this.queryRefinementStage=hct.LegalRefinementStage.Single}queryExecute(e){for(const r of this.list)for(const i of r.list)e.inputFS.extendSource(i)}}DE.ExtendBlock=pct;var jT={};Object.defineProperty(jT,"__esModule",{value:!0}),jT.Argument=void 0;const mct=Xe;class gct extends mct.MalloyElement{constructor(e){super({...e}),this.elementType="Argument",this.id=e.id,this.value=e.value}}jT.Argument=gct;var qT={};Object.defineProperty(qT,"__esModule",{value:!0}),qT.HasParameter=void 0;const rce=et,yct=Xe;class Ect extends yct.MalloyElement{constructor(e){super(),this.elementType="hasParameter",this.name=e.name,e.type&&(0,rce.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 r=this.default.constantValue();return this.type&&this.type!==r.type&&r.type!=="null"&&r.type!=="error"&&this.default.logError("parameter-default-does-not-match-declared-type",`Default value for parameter does not match declared type \`${this.type}\``),r.type==="null"?this.type?{type:this.type,value:r.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:r.value,name:this.name,type:"error"}):!(0,rce.isCastType)(r.type)&&r.type!=="error"?(this.default.logError("parameter-illegal-default-type",`Default value cannot have type \`${r.type}\``),{value:r.value,name:this.name,type:"error"}):{value:r.value,name:this.name,type:r.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"}}}qT.HasParameter=Ect;var HT={};Object.defineProperty(HT,"__esModule",{value:!0}),HT.AnonymousQuery=void 0;const Act=Xe,_ct=Qr;class vct extends Act.MalloyElement{constructor(e){super(),this.queryExpr=e,this.elementType="anonymousQuery",this.isNoteableObj=!0,this.extendNote=_ct.extendNoteMethod,this.has({queryExpr:e})}execute(e){const r=this.queryExpr.getQuery();if(!r){this.queryExpr.sqLog("non-query-used-as-query","Cannot run this object as a query");return}const i={...r.query()},s=this.note||{};i.annotation&&(s.inherits=i.annotation),(s.notes||s.blockNotes||s.inherits)&&(i.annotation=s),e.queryList.push(i)}}HT.AnonymousQuery=vct;var lf={};Object.defineProperty(lf,"__esModule",{value:!0}),lf.View=void 0;const Cct=Xe;class Sct extends Cct.MalloyElement{pipeline(e,r){return this.pipelineComp(e,r).pipeline}}lf.View=Sct;var QT={};Object.defineProperty(QT,"__esModule",{value:!0}),QT.ViewArrow=void 0;const bct=Gr,Tct=lf;class Rct extends Tct.View{constructor(e,r){super({base:e,operation:r}),this.base=e,this.operation=r,this.elementType="viewArrow"}pipelineComp(e){const r=this.base.pipelineComp(e),i=new bct.StaticSourceSpace(r.outputStruct),s=this.operation.pipelineComp(i);return{pipeline:[...r.pipeline,...s.pipeline],outputStruct:s.outputStruct}}refine(e,r,i){return this.logError("refinement-with-multistage-view","A multi-segment view cannot be used as a refinement"),[]}getImplicitName(){return this.operation.getImplicitName()}}QT.ViewArrow=Rct;var zT={},OE={};Object.defineProperty(OE,"__esModule",{value:!0}),OE.refine=void 0;const Ck=Yi,Dct=dt,Sk=Yc;function Oct(t,e,r){var i,s;if(e.length!==1)return t.logError("refinement-with-multistage-view","Named refinements of multi-stage views are not supported"),e;const o={...e[0]},u=r;if((0,Ck.isRawSegment)(o))t.logError("refinement-of-raw-query","Cannot refine raw query, must add an explicit query stage");else if(o.type==="partial"&&u.type!=="index"&&u.type!=="raw"?o.type=u.type:u.type!==o.type&&t.logError("mismatched-view-types-for-refinement",`cannot refine ${o.type} view with ${u.type} view`),u.type!=="index"&&o.type!=="index"&&u.type!=="raw"&&(u.orderBy!==void 0&&!u.defaultOrderBy&&(o.orderBy===void 0||o.defaultOrderBy?o.orderBy=u.orderBy:t.logError("ordering-overridden-in-refinement","refinement cannot override existing ordering")),u.limit!==void 0&&(o.limit===void 0?o.limit=u.limit:t.logError("limit-overridden-in-refinement","refinement cannot override existing limit"))),o.filterList=o.filterList!==void 0||u.filterList!==void 0?[...(i=o.filterList)!==null&&i!==void 0?i:[],...(s=u.filterList)!==null&&s!==void 0?s:[]]:void 0,(0,Ck.isQuerySegment)(u)&&(0,Ck.isQuerySegment)(o)){const a=[],l=[],c=new Map(o.queryFields.map(f=>[(0,Sk.nameFromDef)(f),f]));for(const f of u.queryFields)c.has((0,Sk.nameFromDef)(f))?a.push(f):l.push(f);o.queryFields=[...o.queryFields,...l],a.length>0&&t.logError("name-conflict-in-refinement",`overlapping fields in refinement: ${a.map(Sk.nameFromDef)}`),o.compositeFieldUsage=(0,Dct.mergeCompositeFieldUsage)(o.compositeFieldUsage,u.compositeFieldUsage)}else u.type==="index"&&o.type==="index"&&(o.indexFields=[...u.indexFields,...o.indexFields]);return[o]}OE.refine=Oct,Object.defineProperty(zT,"__esModule",{value:!0}),zT.ViewRefine=void 0;const wct=yi,Fct=Gs,Nct=OE,Lct=lf;class Ict extends Lct.View{constructor(e,r){super({base:e,refinement:r}),this.base=e,this.refinement=r,this.elementType="refine"}pipelineComp(e,r){const i=this.base.pipelineComp(e),s=this.refinement.refine(e,i.pipeline,r);return{pipeline:s,annotation:i.annotation,outputStruct:s.length>0?(0,Fct.getFinalStruct)(this.refinement,e.structDef(),s):wct.ErrorFactory.structDef}}refine(e,r,i){const s=this.pipeline(e,i);return s.length!==1?(this.refinement.logError("refinement-with-multistage-view","refinement must have exactly one stage"),r):(0,Nct.refine)(this,r,s[0])}getImplicitName(){return this.base.getImplicitName()}}zT.ViewRefine=Ict;var GT={};Object.defineProperty(GT,"__esModule",{value:!0}),GT.ReferenceView=void 0;const bk=et,ice=yi,$ct=Gs,Bct=zr,kct=OE,Mct=lf;class Pct extends Mct.View{constructor(e){super({reference:e}),this.reference=e,this.elementType="reference-view"}pipelineComp(e,r){return this._pipelineComp(e)}_pipelineComp(e,{forRefinement:r}={forRefinement:!1}){const i=this.reference.getField(e),s=function(){return{inputStruct:ice.ErrorFactory.structDef,outputStruct:ice.ErrorFactory.structDef,pipeline:[],error:!0}};if(!i.found)return this.reference.logError(i.error.code,i.error.message),s();if(!(i.found instanceof Bct.SpaceField))throw new Error("Expected space field");const o=i.found.fieldDef();if(o===void 0)throw new Error("Expected field to have definition");if((0,bk.isAtomic)(o)){const u={type:"reduce",queryFields:[this.reference.refToField],compositeFieldUsage:o.compositeFieldUsage},a=this.reference.nameString,l={...(0,bk.sourceBase)(e.structDef()),type:"query_result",name:a,fields:[o]};return{pipeline:[u],name:a,outputStruct:l}}else return(0,bk.isTurtle)(o)?this.reference.list.length>1?(r?this.logError("refinement-with-joined-view","Cannot use view from join as refinement"):this.logError("nest-of-joined-view","Cannot use view from join"),s()):{pipeline:[...o.pipeline],name:o.name,annotation:o.annotation,outputStruct:(0,$ct.getFinalStruct)(this.reference,e.structDef(),o.pipeline)}:(r?this.reference.logError("refinement-with-source",`named refinement \`${this.reference.refString}\` must be a view, found a ${o.type}`):this.reference.logError("nest-of-source","This operation is not supported"),s())}getRefinementSegment(e){const{pipeline:r,error:i}=this._pipelineComp(e,{forRefinement:!0});if(!i){if(r.length!==1){this.reference.logError("refinement-with-multistage-view",`named refinement \`${this.reference.refString}\` must have exactly one stage`);return}return r[0]}}refine(e,r,i){const s=this.getRefinementSegment(e);return s?(0,kct.refine)(this,r,s):r}getImplicitName(){return this.reference.nameString}}GT.ReferenceView=Pct;var WT={},wE={},VT={},FE={};Object.defineProperty(FE,"__esModule",{value:!0}),FE.Index=void 0;const Uct=Xe,jct=Gn;class qct extends Uct.MalloyElement{constructor(e){super({fields:e}),this.fields=e,this.elementType="index",this.forceQueryClass=jct.QueryClass.Index,this.queryRefinementStage=void 0}useWeight(e){this.has({weightBy:e}),this.weightBy=e}}FE.Index=qct;var NE={};Object.defineProperty(NE,"__esModule",{value:!0}),NE.SampleProperty=void 0;const Hct=Xe,sce=Gn;class Qct extends Hct.MalloyElement{constructor(e){super(),this.sample=e,this.elementType="sampleProperty",this.queryRefinementStage=sce.LegalRefinementStage.Tail,this.forceQueryClass=sce.QueryClass.Index}sampling(){return this.sample}}NE.SampleProperty=Qct;var YT={};Object.defineProperty(YT,"__esModule",{value:!0}),YT.IndexFieldSpace=void 0;const oce=dt,uce=et,Tk=_t,zct=zr,Gct=Tu,Wct=cE,Vct=Gr;class Yct extends Gct.QueryOperationSpace{constructor(){super(...arguments),this.segmentType="index"}pushFields(...e){for(const r of e)r instanceof Tk.FieldReference?super.pushFields(r):r instanceof Tk.WildcardFieldReference?this.addWild(r):r.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 r=(0,oce.emptyCompositeFieldUsage)(),i=(0,oce.emptyNarrowedCompositeFieldResolution)();const s=[],o=this.inputSpace().structDef();for(const[u,a]of this.entries())if(a instanceof zct.SpaceField){let l,c;const f=this.expandedWild[u];if(f)s.push({type:"fieldref",path:f.path}),l=f.entry.typeDesc().compositeFieldUsage;else if(a instanceof Wct.ReferenceField){const h=a.fieldRef,p=h.getField(this.exprSpace);p.error?h.logError(p.error.code,p.error.message):(s.push(h.refToField),l=p.found.typeDesc().compositeFieldUsage,c=h)}const x=this.applyNextCompositeFieldUsage(o,r,i,l,c);r=x.compositeFieldUsage,i=x.narrowedCompositeFieldResolution}return this._compositeFieldUsage=r,{type:"index",indexFields:s}}addRefineFromFields(e){}addWild(e){var r;let i=this.exprSpace;const s=[];if(e.joinPath)for(const a of e.joinPath.list){const l=a.refString;s.push(l);const c=i.entry(l);if(c)if(c instanceof Vct.StructSpaceField)i=c.fieldSpace;else{a.logError("invalid-wildcard-source",`Field '${l}' does not contain rows and cannot be expanded with '*'`);return}else{a.logError("wildcard-source-not-found",`No such field as '${l}'`);return}}const o=this.dialectObj(),u=[];for(const[a,l]of i.entries()){if(e.except.has(a)||l.refType==="parameter")continue;const c=Tk.IndexFieldReference.indexOutputName([...s,a]);if(this.entry(c)){const f=(r=this.expandedWild[c].path)===null||r===void 0?void 0:r.join(".");e.logError("name-conflict-in-wildcard-expansion",`Cannot expand '${a}' in '${e.refString}' because a field with that name already exists${f?` (conflicts with ${f})`:""}`)}else{const f=l.typeDesc();uce.TD.isLeafAtomic(f)&&(0,uce.expressionIsScalar)(f.expressionType)&&(o===void 0||!o.ignoreInProject(a))&&(u.push({name:c,entry:l}),this.expandedWild[c]={path:s.concat(a),entry:l})}}for(const a of u.sort((l,c)=>l.name.localeCompare(c.name)))this.setEntry(a.name,a.entry)}}YT.IndexFieldSpace=Yct,Object.defineProperty(VT,"__esModule",{value:!0}),VT.IndexBuilder=void 0;const Rk=et,Kct=yi,Jct=qa,Xct=FE,Zct=rf,eft=NE,tft=YT,Dk=dt;class nft{constructor(e,r,i,s){this.filters=[],this.alwaysJoins=[],this.type="index",this.resultFS=new tft.IndexFieldSpace(e,r,i,s),this.inputFS=this.resultFS.inputSpace()}execute(e){e instanceof Jct.Filter?e.queryExecute(this):e instanceof Zct.Limit?(this.limit&&this.limit.logError("index-limit-already-specified","Ignored, too many limit: statements"),this.limit=e):e instanceof Xct.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 eft.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 r;if(e&&!(0,Rk.isIndexSegment)(e)&&!(0,Rk.isPartialSegment)(e))return this.resultFS.logError("refinement-of-index-segment",`Can't refine index with ${e.type}`),Kct.ErrorFactory.indexSegment;const i=this.resultFS.getPipeSegment(e),s=(e==null?void 0:e.filterList)||[];this.filters.length>0&&!s?i.filterList=this.filters:s&&(i.filterList=[...s,...this.filters]),e!=null&&e.limit&&(i.limit=e.limit),this.limit&&(i.limit=this.limit.limit),this.indexOn&&(i.weightMeasure=this.indexOn.refString),e&&(0,Rk.isIndexSegment)(e)&&(e!=null&&e.sample)&&(i.sample=e.sample),this.sample&&(i.sample=this.sample),this.alwaysJoins.length>0&&(i.alwaysJoins=[...this.alwaysJoins]);const o=e&&e.type==="index"&&(r=e.compositeFieldUsage)!==null&&r!==void 0?r:(0,Dk.emptyCompositeFieldUsage)();return i.compositeFieldUsage=(0,Dk.mergeCompositeFieldUsage)(o,this.compositeFieldUsage),i}}VT.IndexBuilder=nft;var KT={},LE={};Object.defineProperty(LE,"__esModule",{value:!0}),LE.GroupBy=void 0;const rft=zs,ace=Gn;class ift extends rft.DefinitionList{constructor(){super(...arguments),this.elementType="groupBy",this.queryRefinementStage=ace.LegalRefinementStage.Single,this.forceQueryClass=ace.QueryClass.Grouping}}LE.GroupBy=ift;var JT={};Object.defineProperty(JT,"__esModule",{value:!0}),JT.ProjectFieldSpace=void 0;const XT=et,sft=Tu;class oft extends sft.QuerySpace{constructor(){super(...arguments),this.segmentType="project"}canContain(e){return e===void 0||!XT.TD.isAtomic(e)||(0,XT.expressionIsAggregate)(e.expressionType)?!1:(0,XT.expressionInvolvesAggregate)(e.expressionType)&&(0,XT.expressionIsAnalytic)(e.expressionType)?(this.logError("aggregate-analytic-in-select","Cannot add aggregate analyics to select"),!1):!0}}JT.ProjectFieldSpace=oft;var cf={},Od={};Object.defineProperty(Od,"__esModule",{value:!0}),Od.Ordering=Od.OrderBy=void 0;const uft=et,lce=sf,cce=Xe,aft=Gn;class lft extends cce.MalloyElement{constructor(e,r){super(),this.field=e,this.dir=r,this.elementType="orderBy",e instanceof lce.FieldName&&this.has({field:e})}get modelField(){return typeof this.field=="number"?this.field:this.field.refString}getOrderBy(e){var r;if(this.field instanceof lce.FieldName&&e.isQueryFieldSpace()){const s=e.outputSpace(),o=this.field.getField(s);o.error&&this.field.logError(o.error.code,o.error.message),(!o.found||!o.isOutputField)&&this.logError("order-by-not-found-in-output",`Unknown field ${this.field.refString} in output space`),(0,uft.expressionIsAnalytic)((r=o.found)===null||r===void 0?void 0:r.typeDesc().expressionType)&&this.logError("order-by-analytic",`Illegal order by of analytic field ${this.field.refString}`)}const i={field:this.modelField};return this.dir&&(i.dir=this.dir),i}}Od.OrderBy=lft;class cft extends cce.ListOf{constructor(e){super(e),this.elementType="ordering",this.queryRefinementStage=aft.LegalRefinementStage.Tail,this.forceQueryClass=void 0}getOrderBy(e){return this.list.map(r=>r.getOrderBy(e))}}Od.Ordering=cft,Object.defineProperty(cf,"__esModule",{value:!0}),cf.ReduceBuilder=cf.QuerySegmentBuilder=void 0;const Ru=et,fft=yi,xft=sf,dft=rf,hft=Od,pft=Tu,mft=zs,Ok=dt;function fce(t){return t.type==="fieldref"?t.path[t.path.length-1]:t.name}class xce{constructor(){this.alwaysJoins=[],this.filters=[]}execute(e){if(e.queryExecute){e.queryExecute(this);return}e instanceof mft.DefinitionList?this.resultFS.pushFields(...e.list):e instanceof dft.Limit?this.limit?e.logError("limit-already-specified","Query operation already limited"):this.limit=e.limit:e instanceof hft.Ordering&&(this.order?e.logError("ordering-already-specified","Query operation already sorted"):this.order=e)}get compositeFieldUsage(){return this.resultFS.compositeFieldUsage}refineFrom(e,r){var i;e&&e.type!=="index"&&e.type!=="raw"&&(!this.limit&&e.orderBy&&!e.defaultOrderBy&&(r.orderBy=e.orderBy),!this.limit&&e.limit&&(r.limit=e.limit)),this.order&&(r.orderBy=this.order.getOrderBy(this.inputFS),delete r.defaultOrderBy),this.limit&&(r.limit=this.limit);const s=(e==null?void 0:e.filterList)||[];this.filters.length>0&&!s?r.filterList=this.filters:s&&(r.filterList=[...s,...this.filters]),this.alwaysJoins.length>0&&(r.alwaysJoins=[...this.alwaysJoins]);const o=e&&(0,Ru.isQuerySegment)(e)&&(i=e.compositeFieldUsage)!==null&&i!==void 0?i:(0,Ok.emptyCompositeFieldUsage)();r.compositeFieldUsage=(0,Ok.mergeCompositeFieldUsage)(o,this.compositeFieldUsage)}}cf.QuerySegmentBuilder=xce;class gft extends xce{constructor(e,r,i,s){super(),this.type="grouping",this.resultFS=new pft.ReduceFieldSpace(e,r,i,s),this.inputFS=this.resultFS.inputSpace()}finalize(e){let r;if(e)if((0,Ru.isReduceSegment)(e)||(0,Ru.isPartialSegment)(e))r=e;else return this.resultFS.logError("incompatible-segment-for-reduce-refinement",`Can't refine reduce with ${e.type}`),fft.ErrorFactory.reduceSegment;const i=this.resultFS.getQuerySegment(r);if(this.refineFrom(r,i),i.orderBy){for(const s of i.orderBy)if(typeof s.field=="number"){const o=i.queryFields[s.field-1];s.field=fce(o)}}if(i.orderBy===void 0||i.defaultOrderBy){let s;for(const o of i.queryFields){let u=!1,a=!1,l;const c=fce(o);if(o.type==="fieldref"){const f=o.path.map(h=>new xft.FieldName(h)),x=this.inputFS.lookup(f).found;if(x){const h=x.typeDesc();l=h.type,u=(0,Ru.expressionIsAggregate)(h.expressionType),a=(0,Ru.expressionIsAnalytic)(h.expressionType)}else continue}else l=o.type,u=(0,Ru.hasExpression)(o)&&(0,Ru.expressionIsAggregate)(o.expressionType),a=(0,Ru.hasExpression)(o)&&(0,Ru.expressionIsAnalytic)(o.expressionType);if((0,Ru.isTemporalType)(l)||u){i.defaultOrderBy=!0,i.orderBy=[{field:c,dir:"desc"}],s=void 0;break}(0,Ru.canOrderBy)(l)&&!a&&!s&&(s=c)}s&&(i.defaultOrderBy=!0,i.orderBy=[{field:s,dir:"asc"}])}return i}}cf.ReduceBuilder=gft,Object.defineProperty(KT,"__esModule",{value:!0}),KT.ProjectBuilder=void 0;const dce=et,yft=yi,Eft=LE,Aft=JT,_ft=cf;class vft extends _ft.QuerySegmentBuilder{constructor(e,r,i,s){super(),this.type="project",this.resultFS=new Aft.ProjectFieldSpace(e,r,i,s),this.inputFS=this.resultFS.inputSpace()}execute(e){e.elementType==="having"||e instanceof Eft.GroupBy?e.logError("illegal-operation-in-select-segment","Illegal statement in a select query operation"):super.execute(e)}finalize(e){let r;if(e)if((0,dce.isProjectSegment)(e)||(0,dce.isPartialSegment)(e))r=e;else return this.resultFS.logError("incompatible-segment-for-select-refinement",`Can't refine select with ${e.type}`),yft.ErrorFactory.projectSegment;const i=this.resultFS.getQuerySegment(r);return this.refineFrom(r,i),i}}KT.ProjectBuilder=vft;var ZT={};Object.defineProperty(ZT,"__esModule",{value:!0}),ZT.PartialBuilder=void 0;const Cft=Yi,Sft=cf;class bft extends Sft.ReduceBuilder{finalize(e){const r=super.finalize(e);if((0,Cft.isQuerySegment)(r))return{...r,type:"partial"};throw new Error(`Partial Builder cannot finalize from ${r.type}`)}}ZT.PartialBuilder=bft,Object.defineProperty(wE,"__esModule",{value:!0}),wE.QOpDesc=void 0;const Tft=VT,Rft=KT,Dft=cf,Oft=Xe,wft=Gs,Fft=Gr,wd=Gn,Nft=ZT;class Lft extends Oft.ListOf{constructor(){super(...arguments),this.elementType="queryOperation"}computeType(){var e;let r,i=!1;this.refineThis&&(this.refineThis.type==="reduce"?r=wd.QueryClass.Grouping:this.refineThis.type==="project"?r=wd.QueryClass.Project:this.refineThis.type==="index"&&(r=wd.QueryClass.Index));for(const s of this.list)s.forceQueryClass&&(r?r!==s.forceQueryClass&&s.logError(`illegal-${r}-operation`,`Not legal in ${r} query`):r=s.forceQueryClass),i||(i=(e=s.needsExplicitQueryClass)!==null&&e!==void 0?e:!1);return r===void 0&&i&&(this.logError("ambiguous-view-type",{}),r=wd.QueryClass.Project),this.opClass=r,r}refineFrom(e){this.refineThis=e}getBuilder(e,r,i){switch(this.computeType()){case wd.QueryClass.Grouping:return new Dft.ReduceBuilder(e,this.refineThis,r,i);case wd.QueryClass.Project:return new Rft.ProjectBuilder(e,this.refineThis,r,i);case wd.QueryClass.Index:return new Tft.IndexBuilder(e,this.refineThis,r,i);case void 0:return new Nft.PartialBuilder(e,this.refineThis,r,i)}}getOp(e,r){const i=this.getBuilder(e,r,this);for(const o of this.list)i.execute(o);const s=i.finalize(this.refineThis);return{segment:s,outputSpace:()=>new Fft.StaticSourceSpace((0,wft.opOutputStruct)(this,e.structDef(),s))}}}wE.QOpDesc=Lft,Object.defineProperty(WT,"__esModule",{value:!0}),WT.QOpDescView=void 0;const Ift=et,$ft=Gr,hce=wE,Bft=Gs,wk=Gn,kft=lf;class Mft extends kft.View{constructor(e){super({operation:e}),this.operation=e,this.elementType="qopdesc-view"}pipelineComp(e,r){const i=this.operation.getOp(e,r);return{pipeline:[i.segment],outputStruct:i.outputSpace().structDef()}}getOp(e,r,i,s){return(0,Ift.isRawSegment)(s)?(this.logError("refinement-of-raw-query","A raw query cannot be refined"),s):(i.refineFrom(s),i.getOp(e,r).segment)}refine(e,r,i){const s=[...r];if(s.length===0)return s;if(s.length===1)return this.operation.refineFrom(s[0]),[this.getOp(e,i,this.operation,s[0])];const o=new hce.QOpDesc([]),u=new hce.QOpDesc([]);for(const a of this.operation.list)switch(a.queryRefinementStage){case wk.LegalRefinementStage.Head:o.push(a);break;case wk.LegalRefinementStage.Single:a.logError("illegal-multistage-refinement-operation","Illegal in refinement of a query with more than one stage");break;case wk.LegalRefinementStage.Tail:u.push(a);break;default:a.logError("illegal-refinement-operation","Illegal query refinement")}if(o.notEmpty()&&(this.has({headRefinements:o}),s[0]=this.getOp(e,void 0,o,s[0])),u.notEmpty()){const a=s.length-1;this.has({tailRefinements:u});const l=(0,Bft.getFinalStruct)(this,e.structDef(),s.slice(-1));s[a]=this.getOp(new $ft.StaticSourceSpace(l),void 0,u,s[a])}return s}getImplicitName(){}}WT.QOpDescView=Mft;var Fn={},Pft=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Uft=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),jft=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Pft(e,t,r);return Uft(e,t),e};Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.FieldDefinitionValue=Fn.DefSpace=Fn.DimensionFieldDeclaration=Fn.MeasureFieldDeclaration=Fn.DeclareFieldDeclaration=Fn.ProjectFieldDeclaration=Fn.GroupByFieldDeclaration=Fn.AggregateFieldDeclaration=Fn.CalculateFieldDeclaration=Fn.AtomicFieldDeclaration=void 0;const Fk=et,pce=jft(nn),qft=M2,Hft=Xe,Fd=lr,Qft=Qr,zft=zr;class ff extends Hft.MalloyElement{constructor(e,r,i){super({expr:e}),this.expr=e,this.defineName=r,this.exprSrc=i,this.isNoteableObj=!0,this.extendNote=Qft.extendNoteMethod}getName(){return this.defineName}fieldDef(e,r){return this.queryFieldDef(new Nk(e,this),r)}executesInOutputSpace(){return!1}queryFieldDef(e,r){let i;function s(){if(e.isQueryFieldSpace())return e.outputSpace();throw new Error("must be in a query -- weird internal error")}try{const u=this.executesInOutputSpace()?s():e;i=this.expr.getExpression(u)}catch(u){return this.logError("failed-field-definition",`Cannot define '${r}', ${u.message}`),{name:r,type:"error"}}if(i.type==="null"&&(this.expr.logWarning("null-typed-field-definition",'null value defaults to type number, use "null::TYPE" to specify correct type'),i={type:"number",value:i.value,expressionType:i.expressionType,evalSpace:i.evalSpace,compositeFieldUsage:i.compositeFieldUsage}),(0,Fk.isAtomicFieldType)(i.type)&&i.type!=="error"){this.typecheckExprValue(i);const u=(0,Fk.mkFieldDef)(pce.atomicDef(i),r);return(u.type==="date"||u.type==="timestamp")&&(0,qft.isGranularResult)(i)&&(u.timeframe=i.timeframe),u.location=this.location,u.e=i.value,u.compositeFieldUsage=i.compositeFieldUsage,i.expressionType&&(u.expressionType=i.expressionType),this.exprSrc&&(u.code=this.exprSrc),this.note&&(u.annotation=this.note),u}if(!(e instanceof Nk&&e.foundCircle)&&i.type!=="error"){const u=pce.inspect(i);this.logError("invalid-type-for-field-definition",`Cannot define '${r}', unexpected type: ${u}`)}return{name:r,type:"error"}}makeEntry(e){e.newEntry(this.defineName,this,new mce(e,this))}}Fn.AtomicFieldDeclaration=ff;class Gft extends ff{constructor(){super(...arguments),this.elementType="calculateFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckCalculate)(e,this)}executesInOutputSpace(){return!0}}Fn.CalculateFieldDeclaration=Gft;class Wft extends ff{constructor(){super(...arguments),this.elementType="aggregateFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckAggregate)(e,this)}}Fn.AggregateFieldDeclaration=Wft;class Vft extends ff{constructor(){super(...arguments),this.elementType="groupByFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckGroupBy)(e,this)}}Fn.GroupByFieldDeclaration=Vft;class Yft extends ff{constructor(){super(...arguments),this.elementType="projectFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckProject)(e,this)}}Fn.ProjectFieldDeclaration=Yft;class Kft extends ff{constructor(){super(...arguments),this.elementType="declareFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckDeclare)(e,this)}}Fn.DeclareFieldDeclaration=Kft;class Jft extends ff{constructor(){super(...arguments),this.elementType="measureFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckMeasure)(e,this)}}Fn.MeasureFieldDeclaration=Jft;class Xft extends ff{constructor(){super(...arguments),this.elementType="dimensionFieldDeclaration"}typecheckExprValue(e){(0,Fd.typecheckDimension)(e,this)}}Fn.DimensionFieldDeclaration=Xft;class Nk{constructor(e,r){this.realFS=e,this.circular=r,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}}Fn.DefSpace=Nk;class mce extends zft.SpaceField{constructor(e,r){super(),this.space=e,this.exprDef=r,this.fieldName=r.defineName}get name(){return this.fieldName}fieldDef(){var e;const r=(e=this.defInSource)!==null&&e!==void 0?e:this.exprDef.fieldDef(this.space,this.name);return this.defInSource=r,r}getQueryFieldDef(e){if(!this.defInQuery){const r=this.exprDef.queryFieldDef(e,this.name);this.defInQuery=r}return this.defInQuery}typeDesc(){const e=this.defInQuery||this.fieldDef();if((0,Fk.isAtomic)(e))return this.fieldTypeFromFieldDef(e);throw new Error(`Can't get typeDesc for ${e.type}`)}entryType(){return(this.defInQuery||this.fieldDef()).type}}Fn.FieldDefinitionValue=mce;var eR={};Object.defineProperty(eR,"__esModule",{value:!0}),eR.Aggregate=void 0;const Zft=zs,gce=Gn;class ext extends Zft.DefinitionList{constructor(){super(...arguments),this.elementType="aggregateList",this.queryRefinementStage=gce.LegalRefinementStage.Single,this.forceQueryClass=gce.QueryClass.Grouping}}eR.Aggregate=ext;var tR={};Object.defineProperty(tR,"__esModule",{value:!0}),tR.Calculate=void 0;const txt=zs,nxt=Gn;class rxt extends txt.DefinitionList{constructor(){super(...arguments),this.elementType="calculate",this.forceQueryClass=void 0,this.needsExplicitQueryClass=!0,this.queryRefinementStage=nxt.LegalRefinementStage.Single}}tR.Calculate=rxt;var IE={};Object.defineProperty(IE,"__esModule",{value:!0}),IE.Dimensions=void 0;const ixt=Kc;class sxt extends ixt.DeclareFields{constructor(){super(...arguments),this.elementType="dimensionList"}}IE.Dimensions=sxt;var $E={};Object.defineProperty($E,"__esModule",{value:!0}),$E.Measures=void 0;const oxt=Kc;class uxt extends oxt.DeclareFields{constructor(){super(...arguments),this.elementType="measureList"}}$E.Measures=uxt;var nR={};Object.defineProperty(nR,"__esModule",{value:!0}),nR.Nests=void 0;const axt=zs,yce=Gn;class lxt extends axt.DefinitionList{constructor(e){super(e),this.elementType="nestedQueries",this.queryRefinementStage=yce.LegalRefinementStage.Single,this.forceQueryClass=yce.QueryClass.Grouping}}nR.Nests=lxt;var rR={};Object.defineProperty(rR,"__esModule",{value:!0}),rR.ProjectStatement=void 0;const cxt=zs,Ece=Gn;class fxt extends cxt.DefinitionList{constructor(){super(...arguments),this.elementType="projectStatement",this.forceQueryClass=Ece.QueryClass.Project,this.queryRefinementStage=Ece.LegalRefinementStage.Single}queryExecute(e){e.type==="project"&&e.resultFS.pushFields(...this.list)}}rR.ProjectStatement=fxt;var xf={},A0={},Pn={};Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.getPlainString=Pn.unIndent=Pn.getOptionalId=Pn.idToStr=Pn.getId=Pn.getStringParts=Pn.getStringIfShort=Pn.getShortString=void 0;const Ace=Io;function _ce(t){var e,r;const i=((e=t.DQ_STRING())===null||e===void 0?void 0:e.text)||((r=t.SQ_STRING())===null||r===void 0?void 0:r.text);return i?Ace.ParseUtil.parseString(i,i[0]):""}Pn.getShortString=_ce;function vce(t){const e=t.string().shortString();if(e)return _ce(e)}Pn.getStringIfShort=vce;function*Cce(t){var e;if(t){for(const i of t.sqlInterpolation()){const s=i.OPEN_CODE().text;s.length>2&&(yield s.slice(0,s.length-2)),i.sqExpr()&&(yield i.sqExpr())}const r=(e=t.SQL_END())===null||e===void 0?void 0:e.text.slice(0,-3);r&&r.length>0&&(yield r)}}Pn.getStringParts=Cce;function Sce(t){return bce(t.id())}Pn.getId=Sce;function bce(t){const e=t.BQ_STRING();return e?Ace.ParseUtil.parseString(e.text,"`"):t.text}Pn.idToStr=bce;function xxt(t){function e(r){return"id"in r}if(e(t)&&t.id())return Sce(t)}Pn.getOptionalId=xxt;function*Tce(t){for(;t.length>0;){const e=t.match(/^.*?\r?\n/);let r=t;e&&(r=e[0]),yield r,t=t.slice(r.length)}}function dxt(t){let e;for(const r of Tce(t)){const i=r.match(/^( *).*[^\s]/);if(i){const s=i[1].length;(e===void 0||s<e)&&(e=s)}}return e}function Rce(t){let e;for(const r of t)if(typeof r=="string"){const i=dxt(r);i!==void 0&&(e===void 0||i<e)&&(e=i)}if(e)for(let r=0;r<=t.length;r+=1){const i=t[r];if(typeof i=="string"){let s="";for(let o of Tce(i))o[0]===" "&&(o=o.slice(e)),s+=o;t[r]=s}}}Pn.unIndent=Rce;function hxt(t,e=!1){const r=[],i=vce(t);if(i)return[i,r];const s=[],o=t.string().sqlString();if(o){for(const u of Cce(o))if(typeof u=="string")s.push(u);else if(r.push(u),e)return[void 0,r];return Rce(s),[s.join(""),r]}return["",r]}Pn.getPlainString=hxt,Object.defineProperty(A0,"__esModule",{value:!0}),A0.findReferences=A0.deprecatedParseTableURI=A0.constructTableKey=void 0;const pxt=T0,Lk=Pn;function Ik(t){const e=(0,Lk.getStringIfShort)(t);if(e)return e;const r=[],i=t.string().sqlString();if(i){for(const s of(0,Lk.getStringParts)(i))typeof s=="string"&&r.push(s);return r.join("")}return""}class mxt{constructor(e,r){this.trans=e,this.tokens=r,this.needTables={},this.needImports={}}registerTableReference(e,r,i){const s=Dce(e,r);this.needTables[s]||(this.needTables[s]={connectionName:e,tablePath:r,firstReference:i})}enterTableMethod(e){const r=(0,Lk.getId)(e.connectionId()),i=Ik(e.tablePath()),s=this.trans.rangeFromContext(e);this.registerTableReference(r,i,s)}enterTableFunction(e){const r=Ik(e.tableURI()),{connectionName:i,tablePath:s}=Oce(r),o=this.trans.rangeFromContext(e);this.registerTableReference(i,s,o)}enterImportURL(e){const r=Ik(e);this.needImports[r]||(this.needImports[r]=this.trans.rangeFromContext(e))}}function Dce(t,e){return t===void 0?e:`${t}:${e}`}A0.constructTableKey=Dce;function Oce(t){const e=t.match(/^([^:]*):(.*)$/);if(e){const[,r,i]=e;return{connectionName:r,tablePath:i}}else return{tablePath:t}}A0.deprecatedParseTableURI=Oce;function gxt(t,e,r){const i=new mxt(t,e),s=i;return pxt.ParseTreeWalker.DEFAULT.walk(s,r),{tables:i.needTables,urls:i.needImports}}A0.findReferences=gxt,Object.defineProperty(xf,"__esModule",{value:!0}),xf.TableFunctionSource=xf.TableMethodSource=xf.TableSource=void 0;const wce=A0,yxt=To,Fce=yi;class $k extends yxt.Source{getSourceDef(){var e,r,i;const s=this.getTableInfo();if(s===void 0)return Fce.ErrorFactory.structDef;const{tablePath:o,connectionName:u}=s,a=(0,wce.constructTableKey)(u,o),l=(e=this.translator())===null||e===void 0?void 0:e.root.schemaZone.getEntry(a);let c=`Schema read failure for table '${o}' for connection '${u}'`;if(l){if(l.status==="present"){(r=this.document())===null||r===void 0||r.checkExperimentalDialect(this,l.value.dialect),l.value.location=this.location,l.value.fields.forEach(x=>{x.location=this.location});const f={...l.value,fields:l.value.fields.map(x=>({...x,location:this.location})),location:this.location};return(i=this.document())===null||i===void 0||i.rememberToAddModelAnnotations(f),f}l.status==="error"&&(c=l.message)}return this.logError("failed-to-fetch-table-schema",c),Fce.ErrorFactory.structDef}}xf.TableSource=$k;class Ext extends $k{constructor(e,r){super(),this.connectionName=e,this.tablePath=r,this.elementType="tableMethodSource",this.has({connectionName:e})}getTableInfo(){var e;const r=this.modelEntry(this.connectionName),i=this.connectionName.refString;if(r===void 0)(e=this.namespace())===null||e===void 0||e.setEntry(i,{entry:{type:"connection",name:i},exported:!0},!0);else if(r.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}}}xf.TableMethodSource=Ext;class Axt extends $k{constructor(e){super(),this.tableURI=e,this.elementType="tableFunctionSource"}getTableInfo(){return(0,wce.deprecatedParseTableURI)(this.tableURI)}}xf.TableFunctionSource=Axt;var iR={};Object.defineProperty(iR,"__esModule",{value:!0}),iR.SQLString=void 0;const _xt=Xe,Nce=Su;class vxt extends _xt.MalloyElement{constructor(){super(...arguments),this.elementType="sqlString",this.elements=[],this.containsQueries=!1}complete(){this.has({queries:this.elements.filter(Cxt)})}push(e){typeof e=="string"?e.length>0&&this.elements.push(e):e instanceof Nce.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 r of this.elements)if(typeof r=="string")e.push({sql:r});else{const i=r.getQuery();i?e.push(i.query()):r.sqLog("failed-to-expand-sql-source","Cannot expand into a query")}return e}}iR.SQLString=vxt;function Cxt(t){return t instanceof Nce.SourceQueryElement}var sR={};Object.defineProperty(sR,"__esModule",{value:!0}),sR.SourceDesc=void 0;const Sxt=Xe;class bxt extends Sxt.ListOf{constructor(){super(...arguments),this.elementType="sourceDescription"}}sR.SourceDesc=bxt;var oR={};Object.defineProperty(oR,"__esModule",{value:!0}),oR.isSourceProperty=void 0;const Txt=qa,Rxt=Kc,Dxt=F2,Oxt=Xc,wxt=N2,Fxt=L2,Nxt=I2,Lxt=Jc,Ixt=Es;function $xt(t){return t instanceof Txt.Filter||t instanceof Ixt.JoinStatement||t instanceof Rxt.DeclareFields||t instanceof Dxt.FieldListEdit||t instanceof Oxt.Renames||t instanceof wxt.PrimaryKey||t instanceof Lxt.ObjectAnnotation||t instanceof Fxt.Views||t instanceof Nxt.TimezoneStatement}oR.isSourceProperty=$xt;var uR={};Object.defineProperty(uR,"__esModule",{value:!0}),uR.isFieldCollectionMember=void 0;const Bxt=Fn,Lce=_t;function kxt(t){return t instanceof Lce.FieldReference||t instanceof Lce.WildcardFieldReference||t instanceof Bxt.AtomicFieldDeclaration}uR.isFieldCollectionMember=kxt;var aR={};Object.defineProperty(aR,"__esModule",{value:!0}),aR.isQueryElement=void 0;const Mxt=$2,Pxt=B2,Uxt=gE,jxt=yE;function qxt(t){return t instanceof Mxt.QueryArrow||t instanceof Pxt.QueryRefine||t instanceof Uxt.QueryReference||t instanceof jxt.QueryRaw}aR.isQueryElement=qxt;var Ice={};Object.defineProperty(Ice,"__esModule",{value:!0});var lR={};Object.defineProperty(lR,"__esModule",{value:!0}),lR.isQueryProperty=void 0;function Hxt(t){return"queryRefinementStage"in t&&"forceQueryClass"in t}lR.isQueryProperty=Hxt;var cR={};Object.defineProperty(cR,"__esModule",{value:!0}),cR.isQueryExtendProperty=void 0;const Qxt=IE,zxt=Es,Gxt=$E;function Wxt(t){return t instanceof Qxt.Dimensions||t instanceof Gxt.Measures||t instanceof zxt.JoinStatement}cR.isQueryExtendProperty=Wxt;var fR={};Object.defineProperty(fR,"__esModule",{value:!0}),fR.isFieldPropStatement=void 0;const Vxt=nf,Yxt=qa,Kxt=rf,Jxt=H2;function Xxt(t){return t instanceof Yxt.Filter||t instanceof Kxt.Limit||t instanceof Jxt.PartitionBy||t instanceof Vxt.FunctionOrdering}fR.isFieldPropStatement=Xxt,function(t){var e=T&&T.__createBinding||(Object.create?function(i,s,o,u){u===void 0&&(u=o);var a=Object.getOwnPropertyDescriptor(s,o);(!a||("get"in a?!s.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return s[o]}}),Object.defineProperty(i,u,a)}:function(i,s,o,u){u===void 0&&(u=o),i[u]=s[o]}),r=T&&T.__exportStar||function(i,s){for(var o in i)o!=="default"&&!Object.prototype.hasOwnProperty.call(s,o)&&e(s,i,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(nE,t),r(T2,t),r(R2,t),r(To,t),r(sE,t),r(Su,t),r(z4,t),r(G4,t),r(Y4,t),r(xE,t),r(K4,t),r(J4,t),r(Cu,t),r(F2,t),r(N2,t),r(Xc,t),r(L2,t),r(I2,t),r(Z4,t),r(U2,t),r(tT,t),r(nf,t),r(nT,t),r(y0,t),r(rT,t),r(q2,t),r(iT,t),r(sT,t),r(oT,t),r(g0,t),r(uT,t),r(aT,t),r(cT,t),r(SE,t),r(vE,t),r(bd,t),r(xT,t),r(dT,t),r(pT,t),r(gT,t),r(yT,t),r(ET,t),r(AT,t),r(of,t),r(vT,t),r(CT,t),r(ST,t),r(TT,t),r(RT,t),r(DT,t),r(OT,t),r(FT,t),r(IT,t),r(wr,t),r(kT,t),r(H2,t),r(z2,t),r(W2,t),r(PT,t),r(Dd,t),r(tf,t),r(UT,t),r(bE,t),r(af,t),r(DE,t),r(jT,t),r(qT,t),r(HT,t),r(B2,t),r($2,t),r(lf,t),r(QT,t),r(zT,t),r(GT,t),r(WT,t),r(Fn,t),r(_t,t),r(eR,t),r(tR,t),r(Kc,t),r(IE,t),r(DE,t),r(qa,t),r(LE,t),r(FE,t),r(Es,t),r(rE,t),r(rf,t),r($E,t),r(nE,t),r(nR,t),r(Od,t),r(rR,t),r(wE,t),r(NE,t),r(k2,t),r(Sd,t),r(EE,t),r(xf,t),r(iR,t),r(Jc,t),r(bu,t),r(sR,t),r(oR,t),r(pt,t),r(uR,t),r(sf,t),r(Xe,t),r(aR,t),r(Ice,t),r(lR,t),r(cR,t),r(fR,t)}(M4);var xR={},Y2={};Object.defineProperty(Y2,"__esModule",{value:!0}),Y2.ConstantExpression=Y2.ConstantFieldSpace=void 0;const Zxt=pt;class $ce{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}}Y2.ConstantFieldSpace=$ce;class edt extends Zxt.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 $ce),this.cfs}constantValue(){return this.expr.getExpression(this.constantFs)}apply(e,r,i){return this.expr.apply(e,r,i)}requestExpression(e){return this.expr.requestExpression(e)}}Y2.ConstantExpression=edt;var tdt=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),ndt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),rdt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&tdt(e,t,r);return ndt(e,t),e};Object.defineProperty(xR,"__esModule",{value:!0}),xR.MalloyToAST=void 0;const Bce=Zm,idt=jd,ue=rdt(M4),Bk=C2,kce=xr,sdt=M4,Xn=Pn,kk=et,odt=Io,udt=Y2,Mce=Jn;class Pce extends ue.SourceQueryElement{constructor(){super(...arguments),this.elementType="parseErrorSourceQuery"}}class Mk extends ue.MalloyElement{constructor(e){super(),this.elementType="ignoredByParser",this.malloySrc=e}}const adt=["##! m4warnings=error"];class ldt extends idt.AbstractParseTreeVisitor{constructor(e,r,i){super(),this.parseInfo=e,this.msgLog=r,this.compilerFlags=i;for(const s of adt){const o=odt.Tag.fromTagLine(s,0,this.compilerFlags);this.compilerFlags=o.tag}}internalError(e,r){return this.contextError(e,"internal-translator-error",{message:r}),new Error(`Internal Translator Error: ${r}`)}astError(e,r,i,s){this.msgLog.log((0,Bk.makeLogMessage)(r,i,{at:e.location,...s}))}rangeFromContext(e){return(0,Mce.rangeFromContext)(this.parseInfo.sourceInfo,e)}getLocation(e){return{url:this.parseInfo.sourceURL,range:this.rangeFromContext(e)}}getSourceString(e){return this.parseInfo.sourceStream.getText(new kce.Interval(e.start.startIndex,e.stop?e.stop.stopIndex:e.start.startIndex))}contextError(e,r,i,s){this.msgLog.log((0,Bk.makeLogMessage)(r,i,{at:this.getLocation(e),...s}))}warnWithReplacement(e,r,i,s){this.msgLog.log((0,Bk.makeLogMessage)(e,r,{at:{url:this.parseInfo.sourceURL,range:i},severity:"warn",replacement:s}))}inExperiment(e,r){const i=this.compilerFlags.tag("experimental");return i&&(i.bare()||i.has(e))?!0:(this.contextError(r,"experiment-not-enabled",{experimentId:e}),!1)}m4Severity(){const e=this.compilerFlags.tag("m4warnings");return e?e.text()==="warn"?"warn":"error":!1}m4advisory(e,r,i){const s=this.m4Severity();s&&this.contextError(e,r,i,{severity:s})}only(e,r,i){const s=[];for(const o of e){const u=r(o);u?s.push(u):o instanceof Mk||this.astError(o,"unexpected-statement-in-translation",`Parser enountered unexpected statement type '${o.elementType}' when it needed '${i}'`)}return s}getNumber(e){return Number.parseInt(e.text)}getFieldName(e){return this.astAt(new ue.FieldName((0,Xn.getId)(e)),e.id())}getModelEntryName(e){return this.astAt(new ue.ModelEntryReference((0,Xn.getId)(e)),e.id())}defaultResult(){return new ue.Unimplemented}astAt(e,r){return e.location={url:this.parseInfo.sourceURL,range:this.rangeFromContext(r)},e}getSourceCode(e){const r=e.start.startIndex,i=e.stop||e.start,s=new kce.Interval(r,i.stopIndex);return this.parseInfo.sourceStream.getText(s)}getFilterElement(e){const r=this.getFieldExpr(e),i=new ue.FilterElement(r,this.getSourceCode(e));return this.astAt(i,e)}getFieldDefs(e,r){return e.map(i=>this.getFieldDef(i,r))}getFieldExpr(e){const r=this.visit(e);if(r instanceof ue.ExpressionDef)return this.astAt(r,e);throw this.internalError(e,`expression node unknown type '${r.elementType}'`)}getPlainStringFrom(e){const[r,i]=(0,Xn.getPlainString)(e);for(const s of i)s instanceof Bce.ParserRuleContext&&this.contextError(s,"illegal-query-interpolation-outside-sql-block","%{ query } illegal in this string");return r||""}makeSqlString(e,r){for(const i of e.sqlInterpolation())i.CLOSE_CODE()&&this.m4advisory(i,"percent-terminated-query-interpolation","Use %{ ... } instead of %{ ... }%");for(const i of(0,Xn.getStringParts)(e))i instanceof Bce.ParserRuleContext?r.push(this.visit(i)):r.push(i);r.complete(),this.astAt(r,e)}parseTime(e,r){let i=r(e.text);return i||(this.contextError(e,"failed-to-parse-time-literal","Time data parse error"),i=new ue.LiteralTimestamp({text:e.text})),this.astAt(i,e)}getNotes(e){return e.ANNOTATION().map(r=>({text:r.text,at:this.getLocation(e)}))}getIsNotes(e){return this.getNotes(e._beforeIs).concat(this.getNotes(e._afterIs))}visitMalloyDocument(e){const r=this.only(e.malloyStatement().map(i=>this.visit(i)),i=>ue.isDocStatementOrDocStatementList(i)&&i,"statement");return new ue.Document(r)}visitDefineSourceStatement(e){const i=e.sourcePropertyList().sourceDefinition().map(u=>this.visitSourceDefinition(u)),s=this.getNotes(e.tags()),o=new ue.DefineSourceList(i);return o.extendNote({blockNotes:s}),o}getSourceParameter(e){const r=e.fieldExpr(),i=r?this.astAt(new udt.ConstantExpression(this.getFieldExpr(r)),r):void 0,s=e.malloyType(),o=s?this.getMalloyType(s):void 0;return this.astAt(new ue.HasParameter({name:(0,Xn.getId)(e.parameterNameDef()),type:o,default:i}),e)}getSourceParameters(e){return e===void 0?[]:(this.inExperiment("parameters",e),e.sourceParameter().map(r=>this.getSourceParameter(r)))}visitSourceDefinition(e){const r=this.visit(e.sqExplore()),i=this.getSourceParameters(e.sourceParameters()),s=new ue.DefineSource((0,Xn.getId)(e.sourceNameDef()),r instanceof ue.SourceQueryElement?r:void 0,!0,i),o=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));return s.extendNote({notes:o}),this.astAt(s,e)}getSourceExtensions(e){return this.astAt(this.visitExploreProperties(e),e)}visitExploreProperties(e){const r=this.only(e.exploreStatement().map(s=>this.visit(s)),s=>ue.isSourceProperty(s)&&s,"source property");return new ue.SourceDesc(r)}visitTableFunction(e){const r=this.getPlainStringFrom(e.tableURI()),i=this.astAt(new ue.TableFunctionSource(r),e);return this.m4advisory(e,"table-function","`table('connection_name:table_path')` is deprecated; use `connection_name.table('table_path')`"),i}visitTableMethod(e){const r=e.connectionId(),i=this.astAt(this.getModelEntryName(r),r),s=this.getPlainStringFrom(e.tablePath());return this.astAt(new ue.TableMethodSource(i,s),e)}visitSqlSource(e){const r=e.connectionId(),i=this.astAt(this.getModelEntryName(r),r),s=new ue.SQLString,o=e.sqlString();o&&this.makeSqlString(o,s);const u=e.shortString();u&&s.push((0,Xn.getShortString)(u));const a=new ue.SQLSource(i,s);return this.astAt(a,e)}visitDefJoinMany(e){const r=this.getAccessLabel(e.accessLabel()),i=[];for(const o of e.joinList().joinDef()){const u=this.visit(o);u instanceof ue.Join&&(i.push(u),u instanceof ue.ExpressionJoin?(u.joinType="many",u.joinOn===void 0&&this.contextError(e,"missing-on-in-join-many","join_many: requires ON expression")):u instanceof ue.KeyJoin&&this.contextError(e,"foreign-key-in-join-many","Foreign key join not legal in join_many:"))}const s=new ue.JoinStatement(i,r);return s.extendNote({blockNotes:this.getNotes(e.tags())}),s}visitDefJoinOne(e){const r=this.getAccessLabel(e.accessLabel()),i=this.getJoinList(e.joinList()),s=[];for(const u of i)u instanceof ue.Join&&(s.push(u),u instanceof ue.ExpressionJoin&&(u.joinType="one"));const o=new ue.JoinStatement(s,r);return o.extendNote({blockNotes:this.getNotes(e.tags())}),o}visitDefJoinCross(e){const r=this.getAccessLabel(e.accessLabel()),i=this.getJoinList(e.joinList()),s=[];for(const u of i)u instanceof ue.Join&&(s.push(u),u instanceof ue.ExpressionJoin?u.joinType="cross":u.logError("foreign-key-in-join-cross","Foreign key join not legal in join_cross:"));const o=new ue.JoinStatement(s,r);return o.extendNote({blockNotes:this.getNotes(e.tags())}),o}getJoinList(e){return this.only(e.joinDef().map(r=>this.visit(r)),r=>r instanceof ue.Join&&r,"join")}getJoinFrom(e){const r=e.isExplore(),i=this.getModelEntryName(e.joinNameDef());if(r){const o=this.getSqExpr(r.sqExpr()),u=this.getNotes(r._before_is).concat(this.getNotes(r._after_is));return{joinFrom:o,notes:u,joinAs:i}}const s=e.sourceArguments();return s?{joinFrom:this.astAt(new ue.SQReference(i,this.getSQArguments(s)),e),notes:[],joinAs:i}:{joinAs:i,joinFrom:new ue.SQReference(i),notes:[]}}visitQueryJoinStatement(e){return this.astAt(this.visit(e.joinStatement()),e)}visitJoinOn(e){var r;const{joinAs:i,joinFrom:s,notes:o}=this.getJoinFrom(e.joinFrom()),u=new ue.ExpressionJoin(i,s),a=e.joinExpression(),l=((r=e.matrixOperation())===null||r===void 0?void 0:r.text.toLocaleLowerCase())||"left";return(0,kk.isMatrixOperation)(l)?u.matrixOperation=l:this.contextError(e,"unknown-matrix-operation","Internal Error: Unknown matrixOperation"),a&&(u.joinOn=this.getFieldExpr(a)),u.extendNote({notes:this.getNotes(e).concat(o)}),this.astAt(u,e)}visitJoinWith(e){const{joinAs:r,joinFrom:i,notes:s}=this.getJoinFrom(e.joinFrom()),o=this.getFieldExpr(e.fieldExpr()),u=new ue.KeyJoin(r,i,o);return u.extendNote({notes:this.getNotes(e).concat(s)}),this.astAt(u,e)}getFieldDef(e,r){const i=e.fieldExpr(),s=(0,Xn.getId)(e.fieldNameDef()),o=this.getFieldExpr(i),u=new r(o,s,this.getSourceCode(i)),a=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));return u.extendNote({notes:a}),this.astAt(u,e)}visitDefDimensions(e){const r=this.getAccessLabel(e.accessLabel()),i=this.getFieldDefs(e.defList().fieldDef(),ue.DimensionFieldDeclaration),s=new ue.Dimensions(i,r);return s.extendNote({blockNotes:this.getNotes(e.tags())}),this.astAt(s,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 r=this.getAccessLabel(e.accessLabel()),i=this.getFieldDefs(e.defList().fieldDef(),ue.MeasureFieldDeclaration),s=new ue.Measures(i,r);return s.extendNote({blockNotes:this.getNotes(e.tags())}),this.astAt(s,e)}visitQueryExtend(e){const r=[],i=e.queryExtendStatementList().queryExtendStatement().map(o=>this.visit(o));for(const o of i)if(ue.isQueryExtendProperty(o))r.push(o);else throw this.internalError(e,`Query extend matched, but ${o.elementType} found`);const s=new ue.ExtendBlock(r);return this.astAt(s,e)}visitDeclareStatement(e){const r=this.getAccessLabel(e.accessLabel()),i=this.getFieldDefs(e.defList().fieldDef(),ue.DeclareFieldDeclaration),s=new ue.DeclareFields(i,r),o=this.astAt(s,e);return this.m4advisory(e,"declare","`declare:` is deprecated; use `dimension:` or `measure:` inside a source or `extend:` block"),o}visitExploreRenameDef(e){const r=e.fieldName(0),i=e.fieldName(1),s=new ue.RenameField((0,Xn.getId)(r),this.getFieldName(i));return this.astAt(s,e)}visitDefExploreRename(e){const r=this.getAccessLabel(e.accessLabel()),s=e.renameList().exploreRenameDef().map(u=>this.visitExploreRenameDef(u)),o=new ue.Renames(s,r);return this.astAt(o,e)}visitFilterClauseList(e){return new ue.Filter(e.fieldExpr().map(r=>this.getFilterElement(r)))}visitWhereStatement(e){const r=this.visitFilterClauseList(e.filterClauseList());return r.having=!1,this.astAt(r,e)}visitHavingStatement(e){const r=this.visitFilterClauseList(e.filterClauseList());return r.having=!0,this.astAt(r,e)}visitDefExploreQuery(e){const r=this.getAccessLabel(e.accessLabel()),i=e.subQueryDefList().exploreQueryDef().map(u=>this.visitExploreQueryDef(u)),s=new ue.Views(i,r),o=this.getNotes(e.tags());return s.extendNote({blockNotes:o}),e.QUERY()&&this.m4advisory(e,"query-in-source","Use view: inside of a source instead of query:"),s}visitDefExplorePrimaryKey(e){const r=new ue.PrimaryKey(this.getFieldName(e.fieldName()));return this.astAt(r,e)}getFieldNameList(e,r){const i=e.fieldName().map(s=>this.astAt(new r([this.getFieldName(s)]),s));return new ue.FieldReferences(i)}visitDefExploreEditField(e){const r=e.ACCEPT()?"accept":"except";return new ue.FieldListEdit(r,this.getFieldNameList(e.fieldNameList(),ue.AcceptExceptFieldReference))}visitSQInclude(e){const r=this.getSqExpr(e.sqExpr()),i=e.includeBlock(),s=i?this.getIncludeItems(i):void 0,o=new ue.SQExtend(r,new ue.SourceDesc([]),s);return this.astAt(o,e)}visitDefExploreTimezone(e){return this.visitTimezoneStatement(e.timezoneStatement())}visitTimezoneStatement(e){const r=this.getPlainStringFrom(e),i=this.astAt(new ue.TimezoneStatement(r),e.string());return i.isValid||this.astError(i,"invalid-timezone",{timezone:i.tz}),this.astAt(i,e)}visitQueryProperties(e){const r=this.only(e.queryStatement().map(i=>this.astAt(this.visit(i),i)),i=>ue.isQueryProperty(i)&&i,"query statement");return new ue.QOpDesc(r)}getFieldPath(e,r){const i=e.fieldName().map(s=>this.getFieldName(s));return this.astAt(new r(i),e)}getQueryFieldDef(e,r){const i=this.getFieldDef(e,r);return this.astAt(i,e)}getQueryFieldEntry(e,r,i){const s=e.taggedRef();if(s)return this.getTaggedRef(s,r,i);const o=e.fieldDef();if(o)return this.getQueryFieldDef(o,r);throw new Error("Expected query field entry to be a field reference or definition")}getQueryItems(e,r,i){return this.only(e.queryFieldEntry().map(s=>this.getQueryFieldEntry(s,r,i)),s=>s instanceof ue.FieldReference||s instanceof ue.AtomicFieldDeclaration?s:!1,"view field")}visitAggregateStatement(e){const r=new ue.Aggregate(this.getQueryItems(e.queryFieldList(),ue.AggregateFieldDeclaration,ue.AggregateFieldReference));return r.extendNote({blockNotes:this.getNotes(e.tags())}),r}visitGroupByStatement(e){const r=new ue.GroupBy(this.getQueryItems(e.queryFieldList(),ue.GroupByFieldDeclaration,ue.GroupByFieldReference));return r.extendNote({blockNotes:this.getNotes(e.tags())}),r}visitCalculateStatement(e){const r=new ue.Calculate(this.getQueryItems(e.queryFieldList(),ue.CalculateFieldDeclaration,ue.CalculateFieldReference));return r.extendNote({blockNotes:this.getNotes(e.tags())}),r}getTaggedRef(e,r,i){const s=e.refExpr();if(s){const u=this.getFieldPath(e.fieldPath(),ue.ExpressionFieldReference);let a;const l=s.timeframe();l&&(a=new ue.ExprGranularTime(new ue.ExprIdReference(u),this.visitTimeframe(l).text,!0));const c=s.aggregate();if(c){const x=c.text.toLowerCase();if(x==="sum")a=new ue.ExprSum(void 0,u);else return this.contextError(c,"invalid-reference-only-aggregation",`\`${x}\` is not legal in a reference-only aggregation`),u}const f=new r(a,u.outputName);return f.extendNote({notes:this.getNotes(e.tags())}),f}const o=this.getFieldPath(e.fieldPath(),i);return o.extendNote({notes:this.getNotes(e.tags())}),o}getFieldCollectionMember(e,r,i){const s=e.fieldDef();if(s)return this.getFieldDef(s,r);const o=e.taggedRef();if(o)return this.getTaggedRef(o,r,i);const u=e.collectionWildCard();if(u)return this.visitCollectionWildCard(u);throw this.internalError(e,"Unexpected element in fieldCollectionMember")}visitFieldCollection(e){const r=e.collectionMember().map(i=>this.getFieldCollectionMember(i,ue.ProjectFieldDeclaration,ue.ProjectFieldReference));return this.astAt(new ue.ProjectStatement(r),e)}visitProjectStatement(e){e.PROJECT()&&this.m4advisory(e,"project","project: keyword is deprecated, use select:");const r=this.visitFieldCollection(e.fieldCollection());return r.extendNote({blockNotes:this.getNotes(e.tags())}),r}visitCollectionWildCard(e){var r;const i=e.fieldPath(),s=i?this.getFieldPath(i,ue.ProjectFieldReference):void 0,o=this.astAt(new ue.WildcardFieldReference(s),e),u=((r=e.starQualified())===null||r===void 0?void 0:r.fieldNameList())||[];for(const a of u)for(const l of a.fieldName())o.except.add((0,Xn.getId)(l));return o}visitIndexFields(e){const r=e.indexElement().map(i=>{const s=i.fieldPath();if(!s)return this.astAt(new ue.WildcardFieldReference(void 0),e);const o=this.getFieldPath(s,ue.IndexFieldReference);return i.STAR()?this.astAt(new ue.WildcardFieldReference(o),e):this.astAt(o,e)});return new ue.FieldReferences(r)}visitIndexStatement(e){const r=this.visitIndexFields(e.indexFields()),i=new ue.Index(r),s=e.fieldName();return s&&i.useWeight(this.getFieldName(s)),this.astAt(i,e)}visitFieldPropertyLimitStatement(e){return this.inExperiment("aggregate_limit",e),this.visitLimitStatement(e.limitStatement())}visitLimitStatement(e){return new ue.Limit(this.getNumber(e.INTEGER_LITERAL()))}visitAggregateOrderBySpec(e){const r=e.ASC()?"asc":e.DESC()?"desc":void 0,i=e.fieldExpr(),s=i?this.getFieldExpr(i):void 0;return this.astAt(new ue.FunctionOrderBy(s,r),e)}visitAggregateOrderByStatement(e){return this.visitAggregateOrdering(e.aggregateOrdering())}visitAggregateOrdering(e){const r=e.aggregateOrderBySpec().map(i=>this.visitAggregateOrderBySpec(i));return this.astAt(new ue.FunctionOrdering(r),e)}visitOrderBySpec(e){const r=e.ASC()?"asc":e.DESC()?"desc":void 0,i=e.INTEGER_LITERAL();if(i)return new ue.OrderBy(this.getNumber(i),r);const s=e.fieldName();if(s)return new ue.OrderBy(this.getFieldName(s),r);throw this.internalError(e,"can't parse order_by specification")}visitOrdering(e){const r=e.orderBySpec().map(i=>this.visitOrderBySpec(i));return this.astAt(new ue.Ordering(r),e)}visitTopStatement(e){const r=this.getNumber(e.INTEGER_LITERAL());return this.astAt(new ue.Limit(r),e)}visitTopLevelQueryDefs(e){const r=e.topLevelQueryDef().map(o=>this.visitTopLevelQueryDef(o)),i=this.getNotes(e.tags()),s=new ue.DefineQueryList(r);return s.extendNote({blockNotes:i}),s}visitTopLevelQueryDef(e){const r=(0,Xn.getId)(e.queryName()),i=this.visit(e.sqExpr()),s=this.getNotes(e.tags()).concat(this.getIsNotes(e.isDefine()));if(i instanceof ue.SourceQueryElement){const o=new ue.DefineQuery(r,i);return o.extendNote({notes:s}),this.astAt(o,e)}throw this.internalError(e,`Expected query definition, got a '${i.elementType}'`)}visitAnonymousQuery(e){const r=e.topLevelAnonQueryDef(),i=this.getSqExpr(r.sqExpr()),s=this.astAt(new ue.AnonymousQuery(i),r),o=this.getNotes(e.topLevelAnonQueryDef().tags()),u=this.getNotes(e.tags());return s.extendNote({notes:o,blockNotes:u}),this.m4advisory(r,"anonymous-query","Anonymous `query:` statements are deprecated, use `run:` instead"),this.astAt(s,e)}visitRunStatement(e){const r=e.topLevelAnonQueryDef(),i=this.getSqExpr(r.sqExpr()),s=this.astAt(new ue.AnonymousQuery(i),r),o=this.getNotes(e.topLevelAnonQueryDef().tags()),u=this.getNotes(e.tags());return s.extendNote({notes:o,blockNotes:u}),this.astAt(s,e)}visitNestStatement(e){const r=this.visitNestedQueryList(e.nestedQueryList());return r.extendNote({blockNotes:this.getNotes(e.tags())}),r}visitNestedQueryList(e){return new ue.Nests(this.only(e.nestEntry().map(r=>this.visit(r)),r=>r instanceof ue.NestFieldDeclaration&&r,"query"))}visitNestDef(e){const r=e.queryName();let i;const s=this.getVExpr(e.vExpr());if(r)i=(0,Xn.getId)(r);else{const a=s.getImplicitName();a===void 0&&this.contextError(e,"anonymous-nest","`nest:` view requires a name (add `nest_name is ...`)"),i=a??"__unnamed__"}const o=new ue.NestFieldDeclaration(i,s),u=e.isDefine();return o.extendNote({notes:this.getNotes(e.tags()).concat(u?this.getIsNotes(u):[])}),this.astAt(o,e)}visitExploreQueryDef(e){const r=(0,Xn.getId)(e.exploreQueryNameDef()),i=new ue.ViewFieldDeclaration(r,this.getVExpr(e.vExpr())),s=this.getNotes(e).concat(this.getIsNotes(e.isDefine()));return i.extendNote({notes:s}),this.astAt(i,e)}visitExprNot(e){return new ue.ExprNot(this.getFieldExpr(e.fieldExpr()))}visitExprBool(e){return new ue.Boolean(e.TRUE()?"true":"false")}allFieldExpressions(e){return e.map(r=>this.getFieldExpr(r))}visitExprLogicalOr(e){const r=this.getFieldExpr(e.fieldExpr(0)),i=this.getFieldExpr(e.fieldExpr(1));return new ue.ExprLogicalOp(r,"or",i)}visitExprLogicalAnd(e){const r=this.getFieldExpr(e.fieldExpr(0)),i=this.getFieldExpr(e.fieldExpr(1));return new ue.ExprLogicalOp(r,"and",i)}visitExprOrTree(e){const r=this.getFieldExpr(e.fieldExpr()),i=this.getFieldExpr(e.partialAllowedFieldExpr());return this.astAt(new ue.ExprAlternationTree(r,"|",i),e)}visitExprAndTree(e){const r=this.getFieldExpr(e.fieldExpr()),i=this.getFieldExpr(e.partialAllowedFieldExpr());return this.astAt(new ue.ExprAlternationTree(r,"&",i),e)}visitExprCoalesce(e){const r=this.getFieldExpr(e.fieldExpr()[0]),i=this.getFieldExpr(e.fieldExpr()[1]);return this.astAt(new ue.ExprCoalesce(r,i),e)}visitPartialCompare(e){const r=e.compareOp().text;if(ue.isComparison(r))return this.astAt(new ue.PartialCompare(r,this.getFieldExpr(e.fieldExpr())),e);throw this.internalError(e,`partial comparison '${r}' not recognized`)}visitPartialTest(e){const r=e.partialCompare();return r?this.visitPartialCompare(r):this.astAt(new ue.PartialIsNull(e.NOT()?"!=":"="),e)}visitPartialAllowedFieldExpr(e){const r=e.fieldExpr();if(r)return this.getFieldExpr(r);const i=e.partialTest();if(i)return this.visitPartialTest(i);throw this.internalError(e,"impossible partial")}visitExprString(e){const r=this.getPlainStringFrom(e);return new ue.ExprString(r)}visitRawString(e){const r=e.text.slice(1).trimStart();if(r[r.length-1]===`
|
|
1556
|
-
`){const o=r[0]==="'"?'"':"'";this.contextError(e,"literal-string-newline",`Missing ${o}${r[0]}${o} before end-of-line`)}const s=new ue.ExprString(r.slice(1,-1));return this.astAt(s,e)}visitExprRegex(e){const r=e.HACKY_REGEX().text;return new ue.ExprRegEx(r.slice(2,-1))}visitExprNow(e){return new ue.ExprNow}visitExprNumber(e){return new ue.ExprNumber(e.text)}visitExprFieldPath(e){const r=new ue.ExprIdReference(this.getFieldPath(e.fieldPath(),ue.ExpressionFieldReference));return this.astAt(r,e)}visitExprNULL(e){return new ue.ExprNULL}visitExprExpr(e){return new ue.ExprParens(this.getFieldExpr(e.fieldExpr()))}visitExprMinus(e){return new ue.ExprMinus(this.getFieldExpr(e.fieldExpr()))}visitExprAddSub(e){const r=this.getFieldExpr(e.fieldExpr(0)),i=this.getFieldExpr(e.fieldExpr(1)),s=e.PLUS()?"+":"-";return new ue.ExprAddSub(r,s,i)}visitExprMulDiv(e){const r=e.STAR()?"*":e.SLASH()?"/":"%";return new ue.ExprMulDiv(this.getFieldExpr(e.fieldExpr(0)),r,this.getFieldExpr(e.fieldExpr(1)))}visitExprCompare(e){const r=e.compareOp().text,i=this.getFieldExpr(e.fieldExpr(0)),s=this.getFieldExpr(e.fieldExpr(1));if(ue.isEquality(r)){const o=this.rangeFromContext(e);return s instanceof ue.ExprNULL&&(r==="="?this.warnWithReplacement("sql-is-null","Use 'is null' to check for NULL instead of '= null'",o,`${this.getSourceCode(e.fieldExpr(0))} is null`):r==="!="&&this.warnWithReplacement("sql-is-not-null","Use 'is not null' to check for NULL instead of '!= null'",o,`${this.getSourceCode(e.fieldExpr(0))} is not null`)),this.astAt(new ue.ExprEquality(i,r,s),e)}else if(ue.isComparison(r))return this.astAt(new ue.ExprCompare(i,r,s),e);throw this.internalError(e,`untranslatable comparison operator '${r}'`)}visitExprUngroup(e){const r=e.fieldName().map(s=>this.getFieldName(s)),i=e.ungroup().text.toLowerCase();return this.astAt(new ue.ExprUngroup(i==="all"?i:"exclude",this.getFieldExpr(e.fieldExpr()),r),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 r=e.fieldPath(),i=this.getFieldPath(r,ue.ExpressionFieldReference),s=r&&i?this.astAt(i,r):void 0,o=e.aggregate().text.toLowerCase(),u=e.fieldExpr();if(e.aggregate().COUNT())return u&&this.contextError(u,"count-expression-with-locality","Expression illegal inside path.count()"),new ue.ExprCount(s);const a=u?this.getFieldExpr(u):void 0;if(o==="min"||o==="max")if(a)this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(o));else{const l=this.astAt(new ue.ExprIdReference(i),r);return o==="min"?new ue.ExprMin(l):new ue.ExprMax(l)}else{if(o==="avg")return new ue.ExprAvg(a,s);if(o==="sum")return new ue.ExprSum(a,s);this.contextError(e,"aggregate-parse-error",`Cannot parse aggregate function ${o}`)}return new ue.ExprNULL}visitExprPathlessAggregate(e){const r=e.fieldExpr(),i=r?this.getFieldExpr(r):void 0,s=void 0,o=e.aggregate().text.toLowerCase();if(e.STAR()&&this.m4advisory(e,"wildcard-in-aggregate",`* illegal inside ${o}()`),o==="count")return this.astAt(i?new ue.ExprCountDistinct(i):new ue.ExprCount,e);if(o==="min"){if(i)return new ue.ExprMin(i);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(o))}else if(o==="max"){if(i)return new ue.ExprMax(i);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(o))}else{if(i===void 0)return this.contextError(e,"invalid-asymmetric-aggregate",this.asymmetricAggregateUsageError(o)),new ue.ExprNULL;const u=e.SOURCE_KW()!==void 0;if(o==="avg")return new ue.ExprAvg(i,s,u);if(o==="sum")return new ue.ExprSum(i,s,u)}return new ue.ExprNULL}visitExprApply(e){return new ue.Apply(this.getFieldExpr(e.fieldExpr()),this.getFieldExpr(e.partialAllowedFieldExpr()))}visitExprRange(e){return new ue.Range(this.getFieldExpr(e.fieldExpr(0)),this.getFieldExpr(e.fieldExpr(1)))}visitExprCast(e){const r=this.getMalloyOrSQLType(e.malloyOrSQLType());return new ue.ExprCast(this.getFieldExpr(e.fieldExpr()),r)}getMalloyType(e){const r=e.text;if((0,kk.isCastType)(r))return r;throw this.internalError(e,`unknown type '${r}'`)}getMalloyOrSQLType(e){const r=e.malloyType();if(r)return this.getMalloyType(r);const i=e.string();if(i)return{raw:this.getPlainStringFrom({string:()=>i})};throw this.internalError(e,"Expected Malloy or SQL type to either be a Malloy type or a string")}visitExprSafeCast(e){const r=this.getMalloyOrSQLType(e.malloyOrSQLType());return new ue.ExprCast(this.getFieldExpr(e.fieldExpr()),r,!0)}visitExprTimeTrunc(e){return new ue.ExprGranularTime(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text,!0)}visitTimeframe(e){return new ue.Timeframe(e.text)}visitExprForRange(e){const r=this.getFieldExpr(e._startAt),i=this.getFieldExpr(e._duration),s=this.visitTimeframe(e.timeframe());return new ue.ForRange(r,i,s)}visitExprAggFunc(e){const r=e.argumentList(),i=r?this.allFieldExpressions(r.fieldExpr()):[],s=(0,Xn.getId)(e),o=e.fieldPath(),u=o?this.getFieldPath(o,ue.ExpressionFieldReference):void 0,a=o&&u?this.astAt(u,o):void 0;return ue.ExprTimeExtract.extractor(s)?this.astAt(new ue.ExprTimeExtract(s,i),e):this.astAt(new ue.ExprFunc(s,i,!1,void 0,a),e)}visitExprFunc(e){var r,i;const s=e.argumentList(),o=s?this.allFieldExpressions(s.fieldExpr()):[],u=e.EXCLAM()!==void 0,a=(r=e.malloyType())===null||r===void 0?void 0:r.text;let l;a&&((0,kk.isCastType)(a)?l=a:(this.contextError(e,"unexpected-malloy-type",`'#' assertion for unknown type '${a}'`),l=void 0));let c=(0,Xn.getOptionalId)(e)||((i=e.timeframe())===null||i===void 0?void 0:i.text);return c===void 0&&(this.contextError(e,"failed-to-parse-function-name","Function name error"),c="FUNCTION_NAME_ERROR"),ue.ExprTimeExtract.extractor(c)?this.astAt(new ue.ExprTimeExtract(c,o),e):this.astAt(new ue.ExprFunc(c,o,u,l),e)}visitExprDuration(e){return new ue.ExprDuration(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text)}visitCaseStatement(e){const r=e._valueExpr,i=r?this.getFieldExpr(r):void 0,s=e.caseWhen(),o=s.map(l=>new ue.CaseWhen(this.getFieldExpr(l._condition),this.getFieldExpr(l._result))),u=e._caseElse,a=u?this.getFieldExpr(u):void 0;return this.warnWithReplacement("sql-case","Use a `pick` statement instead of `case`",this.rangeFromContext(e),`${[...r?[`${this.getSourceCode(r)} ?`]:[],...s.map(l=>`pick ${this.getSourceCode(l._result)} when ${this.getSourceCode(l._condition)}`),u?`else ${u.text}`:"else null"].join(" ")}`),new ue.Case(i,o,a)}visitPickStatement(e){const r=e.pick().map(i=>{let s;return i._pickValue&&(s=this.getFieldExpr(i._pickValue)),new ue.PickWhen(s,this.getFieldExpr(i._pickWhen))});return e.ELSE()?new ue.Pick(r,this.getFieldExpr(e._pickElse)):new ue.Pick(r)}visitExprFieldProps(e){const r=this.only(e.fieldProperties().fieldPropertyStatement().map(i=>this.visit(i)),i=>ue.isFieldPropStatement(i)&&i,"field property statement");return new ue.ExprProps(this.getFieldExpr(e.fieldExpr()),r)}visitPartitionByStatement(e){return this.astAt(new ue.PartitionBy(e.id().map(r=>this.astAt(new ue.PartitionByFieldReference([this.astAt(new ue.FieldName((0,Xn.idToStr)(r)),r)]),r))),e)}visitLiteralTimestamp(e){return this.parseTime(e,ue.LiteralTimestamp.parse)}visitLiteralHour(e){return this.parseTime(e,ue.LiteralHour.parse)}visitLiteralDay(e){return this.parseTime(e,ue.LiteralDay.parse)}visitLiteralWeek(e){return this.parseTime(e,ue.LiteralWeek.parse)}visitLiteralMonth(e){return this.parseTime(e,ue.LiteralMonth.parse)}visitLiteralQuarter(e){return this.parseTime(e,ue.LiteralQuarter.parse)}visitLiteralYear(e){return this.parseTime(e,ue.LiteralYear.parse)}visitImportStatement(e){const r=this.getPlainStringFrom(e.importURL()),i=this.astAt(new ue.ImportStatement(r,this.parseInfo.importBaseURL),e),s=e.importSelect();if(s)for(const o of s.importItem()){const u=o.id(),a=u[1]?this.astAt(new ue.ImportSourceName((0,Xn.idToStr)(u[1])),u[1]):void 0;i.push(this.astAt(new ue.ImportSelect((0,Xn.idToStr)(u[0]),a),u[0]))}return i}visitDebugExpr(e){return this.getFieldExpr(e.fieldExpr())}visitSampleStatement(e){const r=e.sampleSpec().INTEGER_LITERAL();if(r)return new ue.SampleProperty({rows:this.getNumber(r)});const i=e.sampleSpec().PERCENT_LITERAL();if(i)return new ue.SampleProperty({percent:this.getNumber(i)});const s=e.sampleSpec().TRUE()!==void 0;return new ue.SampleProperty({enable:s})}visitDocAnnotations(e){const r=e.DOC_ANNOTATION().map(s=>({text:s.text,at:this.getLocation(e)})),i=new ue.ModelAnnotation(r);return this.compilerFlags=i.getCompilerFlags(this.compilerFlags,this.msgLog),i}visitIgnoredObjectAnnotations(e){return this.contextError(e,"orphaned-object-annotation","Object annotation not connected to any object"),new Mk(e.text)}visitIgnoredModelAnnotations(e){return this.contextError(e,"misplaced-model-annotation","Model annotations not allowed at this scope"),new Mk(e.text)}visitDefExploreAnnotation(e){const r=this.getNotes(e);return new ue.ObjectAnnotation(r)}getSQArgument(e){const r=e.argumentId(),i=r?this.astAt(new ue.PartitionByFieldReference([this.astAt(new ue.FieldName((0,Xn.idToStr)(r.id())),r)]),r):void 0;return this.astAt(new ue.Argument({id:i,value:this.getFieldExpr(e.fieldExpr())}),e)}getSQArguments(e){if(e!==void 0)return this.inExperiment("parameters",e),e.sourceArgument().map(r=>this.getSQArgument(r))}visitSQID(e){const r=this.getModelEntryName(e),i=this.getSQArguments(e.sourceArguments());return this.astAt(new ue.SQReference(r,i),e.id())}getSqExpr(e){const r=this.visit(e);return r instanceof ue.SourceQueryElement?r:(this.contextError(e,"unexpected-non-source-query-expression-node",`Expected a source/query expression, not '${r.elementType}'`),new Pce)}visitSQExtendedSource(e){const r=this.getSqExpr(e.sqExpr()),i=e.includeBlock(),s=i?this.getIncludeItems(i):void 0,o=new ue.SQExtend(r,this.getSourceExtensions(e.exploreProperties()),s);return this.astAt(o,e)}getIncludeItems(e){return this.inExperiment("access_modifiers",e),e.includeItem().map(r=>this.getIncludeItem(r)).filter(Mce.isNotUndefined)}getIncludeItem(e){var r;const i=e.tags(),s=i?this.getNotes(i):[],o=e.includeExceptList();if(o){i&&s.length>0&&this.contextError(i,"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const u=this.getExcludeList(o);return this.astAt(new ue.IncludeExceptItem(u),e)}else{const u=e.includeList();if(u===void 0){this.contextError((r=e.orphanedAnnotation())!==null&&r!==void 0?r:e,"orphaned-object-annotation","This tag is not attached to anything",{severity:"warn"});return}const a=this.getAccessLabelProp(e.accessLabelProp()),l=this.getIncludeList(u),c=this.astAt(new ue.IncludeAccessItem(a,l),e);return c.extendNote({blockNotes:s}),c}}getIncludeList(e){const r=e.includeField();if(r===void 0)throw this.internalError(e,"Expected a field name list");return r.map(i=>this.getIncludeListItem(i))}getExcludeList(e){return e.includeExceptListItem().map(r=>{r.tags().ANNOTATION().length>0&&this.contextError(r.tags(),"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const i=r.fieldName();if(i)return this.astAt(new ue.AccessModifierFieldReference([this.astAt(new ue.FieldName(r.text),r)]),i);const s=r.collectionWildCard();if(s)return this.astAt(this.visitCollectionWildCard(s),s);throw this.internalError(r,"Expected a field name or wildcard")})}getIncludeListItem(e){const r=e.collectionWildCard(),i=r?this.visitCollectionWildCard(r):void 0,s=e._as?e._as.text:void 0,o=e.tags(),u=o?this.getNotes(o):[],a=e.isDefine(),l=a?this.getIsNotes(a):[],c=[...u,...l],f=e._name?this.astAt(new ue.AccessModifierFieldReference([this.astAt(this.getFieldName(e._name),e._name)]),e._name):void 0,x=f??i;if(x===void 0)throw this.internalError(e,"Expected a field name or wildcard");const h=this.astAt(new ue.IncludeListItem(x,s),e);return h.extendNote({notes:c}),h}visitSQParens(e){const r=this.getSqExpr(e.sqExpr());return this.astAt(r,e)}visitSQCompose(e){const r=e.sqExpr().map(i=>this.getSqExpr(i));return this.inExperiment("composite_sources",e),this.astAt(new ue.SQCompose(r),e)}visitSQArrow(e){const r=this.getSqExpr(e.sqExpr()),i=e.segExpr(),s=new ue.SQArrow(r,this.getVExpr(i));return this.astAt(s,e)}getVExpr(e){const r=this.visit(e);if(r instanceof ue.View)return r;throw this.internalError(e,`Expected view, got a '${r.elementType}'`)}visitSegField(e){return new ue.ReferenceView(this.getFieldPath(e.fieldPath(),ue.ViewOrScalarFieldReference))}visitSegOps(e){return new ue.QOpDescView(this.visitQueryProperties(e.queryProperties()))}visitSegParen(e){return this.visit(e.vExpr())}visitVSeg(e){return this.visit(e.segExpr())}visitSegRefine(e){return new ue.ViewRefine(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitVArrow(e){return new ue.ViewArrow(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitSQRefinedQuery(e){const r=this.getSqExpr(e.sqExpr()),i=e.segExpr(),s=new ue.SQRefine(r,this.getVExpr(i));return this.astAt(s,e)}visitSQTable(e){const r=this.visit(e.exploreTable());if(r instanceof sdt.TableSource){const i=new ue.SQSource(r);return this.astAt(i,e)}return new Pce}visitSQSQL(e){const r=new ue.SQSource(this.visitSqlSource(e.sqlSource()));return this.astAt(r,e)}visitExperimentalStatementForTesting(e){return this.inExperiment("compilerTestExperimentParse",e),this.astAt(new ue.ExperimentalExperiment("compilerTestExperimentTranslate"),e)}visitRecordRef(e){const r=new ue.ExprIdReference(this.getFieldPath(e.fieldPath(),ue.ExpressionFieldReference));return this.astAt(new ue.RecordElement({path:r}),e)}visitRecordExpr(e){const r=this.getFieldExpr(e.fieldExpr()),i=e.recordKey(),s=i?{key:(0,Xn.getId)(i),value:r}:{value:r};return this.astAt(new ue.RecordElement(s),e)}visitExprLiteralRecord(e){const r=this.only(e.recordElement().map(i=>this.astAt(this.visit(i),i)),i=>i instanceof ue.RecordElement&&i,"a legal record property description");return new ue.RecordLiteral(r)}visitExprArrayLiteral(e){const r=e.fieldExpr().map(s=>this.getFieldExpr(s)),i=new ue.ArrayLiteral(r);return this.astAt(i,e)}visitExprWarnLike(e){let r="~";const i=e.fieldExpr(0),s=e.fieldExpr(1),o=this.rangeFromContext(e);return e.NOT()?(r="!~",this.warnWithReplacement("sql-not-like","Use Malloy operator '!~' instead of 'NOT LIKE'",o,`${this.getSourceCode(i)} !~ ${this.getSourceCode(s)}`)):this.warnWithReplacement("sql-like","Use Malloy operator '~' instead of 'LIKE'",o,`${this.getSourceCode(i)} ~ ${this.getSourceCode(s)}`),this.astAt(new ue.ExprCompare(this.getFieldExpr(i),r,this.getFieldExpr(s)),e)}visitExprNullCheck(e){const r=e.fieldExpr();return this.astAt(new ue.ExprIsNull(this.getFieldExpr(r),e.NOT()?"!=":"="),e)}visitExprWarnIn(e){const r=this.getFieldExpr(e.fieldExpr()),i=!!e.NOT(),s=e.fieldExprList().fieldExpr(),o=this.astAt(new ue.ExprLegacyIn(r,i,s.map(u=>this.getFieldExpr(u))),e);return this.warnWithReplacement("sql-in",`Use = (a|b|c) instead of${i?" NOT":""} IN (a,b,c)`,this.rangeFromContext(e),`${this.getSourceCode(e.fieldExpr())} ${i?"!=":"="} (${s.map(u=>this.getSourceCode(u)).join(" | ")})`),o}visitTickFilterString(e){const r=e.text.slice(1).trimStart();if(r[r.length-1]===`
|
|
1556
|
+
`){const o=r[0]==="'"?'"':"'";this.contextError(e,"literal-string-newline",`Missing ${o}${r[0]}${o} before end-of-line`)}const s=new ue.ExprString(r.slice(1,-1));return this.astAt(s,e)}visitExprRegex(e){const r=e.HACKY_REGEX().text;return new ue.ExprRegEx(r.slice(2,-1))}visitExprNow(e){return new ue.ExprNow}visitExprNumber(e){return new ue.ExprNumber(e.text)}visitExprFieldPath(e){const r=new ue.ExprIdReference(this.getFieldPath(e.fieldPath(),ue.ExpressionFieldReference));return this.astAt(r,e)}visitExprNULL(e){return new ue.ExprNULL}visitExprExpr(e){return new ue.ExprParens(this.getFieldExpr(e.fieldExpr()))}visitExprMinus(e){return new ue.ExprMinus(this.getFieldExpr(e.fieldExpr()))}visitExprAddSub(e){const r=this.getFieldExpr(e.fieldExpr(0)),i=this.getFieldExpr(e.fieldExpr(1)),s=e.PLUS()?"+":"-";return new ue.ExprAddSub(r,s,i)}visitExprMulDiv(e){const r=e.STAR()?"*":e.SLASH()?"/":"%";return new ue.ExprMulDiv(this.getFieldExpr(e.fieldExpr(0)),r,this.getFieldExpr(e.fieldExpr(1)))}visitExprCompare(e){const r=e.compareOp().text,i=this.getFieldExpr(e.fieldExpr(0)),s=this.getFieldExpr(e.fieldExpr(1));if(ue.isEquality(r)){const o=this.rangeFromContext(e);return s instanceof ue.ExprNULL&&(r==="="?this.warnWithReplacement("sql-is-null","Use 'is null' to check for NULL instead of '= null'",o,`${this.getSourceCode(e.fieldExpr(0))} is null`):r==="!="&&this.warnWithReplacement("sql-is-not-null","Use 'is not null' to check for NULL instead of '!= null'",o,`${this.getSourceCode(e.fieldExpr(0))} is not null`)),this.astAt(new ue.ExprEquality(i,r,s),e)}else if(ue.isComparison(r))return this.astAt(new ue.ExprCompare(i,r,s),e);throw this.internalError(e,`untranslatable comparison operator '${r}'`)}visitExprUngroup(e){const r=e.fieldName().map(s=>this.getFieldName(s)),i=e.ungroup().text.toLowerCase();return this.astAt(new ue.ExprUngroup(i==="all"?i:"exclude",this.getFieldExpr(e.fieldExpr()),r),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 r=e.fieldPath(),i=this.getFieldPath(r,ue.ExpressionFieldReference),s=r&&i?this.astAt(i,r):void 0,o=e.aggregate().text.toLowerCase(),u=e.fieldExpr();if(e.aggregate().COUNT())return u&&this.contextError(u,"count-expression-with-locality","Expression illegal inside path.count()"),new ue.ExprCount(s);const a=u?this.getFieldExpr(u):void 0;if(o==="min"||o==="max")if(a)this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(o));else{const l=this.astAt(new ue.ExprIdReference(i),r);return o==="min"?new ue.ExprMin(l):new ue.ExprMax(l)}else{if(o==="avg")return new ue.ExprAvg(a,s);if(o==="sum")return new ue.ExprSum(a,s);this.contextError(e,"aggregate-parse-error",`Cannot parse aggregate function ${o}`)}return new ue.ExprNULL}visitExprPathlessAggregate(e){const r=e.fieldExpr(),i=r?this.getFieldExpr(r):void 0,s=void 0,o=e.aggregate().text.toLowerCase();if(e.STAR()&&this.m4advisory(e,"wildcard-in-aggregate",`* illegal inside ${o}()`),o==="count")return this.astAt(i?new ue.ExprCountDistinct(i):new ue.ExprCount,e);if(o==="min"){if(i)return new ue.ExprMin(i);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(o))}else if(o==="max"){if(i)return new ue.ExprMax(i);this.contextError(e,"invalid-symmetric-aggregate",this.symmetricAggregateUsageError(o))}else{if(i===void 0)return this.contextError(e,"invalid-asymmetric-aggregate",this.asymmetricAggregateUsageError(o)),new ue.ExprNULL;const u=e.SOURCE_KW()!==void 0;if(o==="avg")return new ue.ExprAvg(i,s,u);if(o==="sum")return new ue.ExprSum(i,s,u)}return new ue.ExprNULL}visitExprApply(e){return new ue.Apply(this.getFieldExpr(e.fieldExpr()),this.getFieldExpr(e.partialAllowedFieldExpr()))}visitExprRange(e){return new ue.Range(this.getFieldExpr(e.fieldExpr(0)),this.getFieldExpr(e.fieldExpr(1)))}visitExprCast(e){const r=this.getMalloyOrSQLType(e.malloyOrSQLType());return new ue.ExprCast(this.getFieldExpr(e.fieldExpr()),r)}getMalloyType(e){const r=e.text;if((0,kk.isCastType)(r))return r;throw this.internalError(e,`unknown type '${r}'`)}getMalloyOrSQLType(e){const r=e.malloyType();if(r)return this.getMalloyType(r);const i=e.string();if(i)return{raw:this.getPlainStringFrom({string:()=>i})};throw this.internalError(e,"Expected Malloy or SQL type to either be a Malloy type or a string")}visitExprSafeCast(e){const r=this.getMalloyOrSQLType(e.malloyOrSQLType());return new ue.ExprCast(this.getFieldExpr(e.fieldExpr()),r,!0)}visitExprTimeTrunc(e){return new ue.ExprGranularTime(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text,!0)}visitTimeframe(e){return new ue.Timeframe(e.text)}visitExprForRange(e){const r=this.getFieldExpr(e._startAt),i=this.getFieldExpr(e._duration),s=this.visitTimeframe(e.timeframe());return new ue.ForRange(r,i,s)}visitExprAggFunc(e){const r=e.argumentList(),i=r?this.allFieldExpressions(r.fieldExpr()):[],s=(0,Xn.getId)(e),o=e.fieldPath(),u=o?this.getFieldPath(o,ue.ExpressionFieldReference):void 0,a=o&&u?this.astAt(u,o):void 0;return ue.ExprTimeExtract.extractor(s)?this.astAt(new ue.ExprTimeExtract(s,i),e):this.astAt(new ue.ExprFunc(s,i,!1,void 0,a),e)}visitExprFunc(e){var r,i;const s=e.argumentList(),o=s?this.allFieldExpressions(s.fieldExpr()):[],u=e.EXCLAM()!==void 0,a=(r=e.malloyType())===null||r===void 0?void 0:r.text;let l;a&&((0,kk.isCastType)(a)?l=a:(this.contextError(e,"unexpected-malloy-type",`'#' assertion for unknown type '${a}'`),l=void 0));let c=(0,Xn.getOptionalId)(e)||((i=e.timeframe())===null||i===void 0?void 0:i.text);return c===void 0&&(this.contextError(e,"failed-to-parse-function-name","Function name error"),c="FUNCTION_NAME_ERROR"),ue.ExprTimeExtract.extractor(c)?this.astAt(new ue.ExprTimeExtract(c,o),e):this.astAt(new ue.ExprFunc(c,o,u,l),e)}visitExprDuration(e){return new ue.ExprDuration(this.getFieldExpr(e.fieldExpr()),this.visitTimeframe(e.timeframe()).text)}visitCaseStatement(e){const r=e._valueExpr,i=r?this.getFieldExpr(r):void 0,s=e.caseWhen(),o=s.map(l=>new ue.CaseWhen(this.getFieldExpr(l._condition),this.getFieldExpr(l._result))),u=e._caseElse,a=u?this.getFieldExpr(u):void 0;return this.warnWithReplacement("sql-case","Use a `pick` statement instead of `case`",this.rangeFromContext(e),`${[...r?[`${this.getSourceCode(r)} ?`]:[],...s.map(l=>`pick ${this.getSourceCode(l._result)} when ${this.getSourceCode(l._condition)}`),u?`else ${u.text}`:"else null"].join(" ")}`),new ue.Case(i,o,a)}visitPickStatement(e){const r=e.pick().map(i=>{let s;return i._pickValue&&(s=this.getFieldExpr(i._pickValue)),new ue.PickWhen(s,this.getFieldExpr(i._pickWhen))});return e.ELSE()?new ue.Pick(r,this.getFieldExpr(e._pickElse)):new ue.Pick(r)}visitExprFieldProps(e){const r=this.only(e.fieldProperties().fieldPropertyStatement().map(i=>this.visit(i)),i=>ue.isFieldPropStatement(i)&&i,"field property statement");return new ue.ExprProps(this.getFieldExpr(e.fieldExpr()),r)}visitPartitionByStatement(e){return this.astAt(new ue.PartitionBy(e.id().map(r=>this.astAt(new ue.PartitionByFieldReference([this.astAt(new ue.FieldName((0,Xn.idToStr)(r)),r)]),r))),e)}visitLiteralTimestamp(e){return this.parseTime(e,ue.LiteralTimestamp.parse)}visitLiteralHour(e){return this.parseTime(e,ue.LiteralHour.parse)}visitLiteralDay(e){return this.parseTime(e,ue.LiteralDay.parse)}visitLiteralWeek(e){return this.parseTime(e,ue.LiteralWeek.parse)}visitLiteralMonth(e){return this.parseTime(e,ue.LiteralMonth.parse)}visitLiteralQuarter(e){return this.parseTime(e,ue.LiteralQuarter.parse)}visitLiteralYear(e){return this.parseTime(e,ue.LiteralYear.parse)}visitImportStatement(e){const r=this.getPlainStringFrom(e.importURL()),i=this.astAt(new ue.ImportStatement(r,this.parseInfo.importBaseURL),e),s=e.importSelect();if(s)for(const o of s.importItem()){const u=o.id(),a=u[1]?this.astAt(new ue.ImportSourceName((0,Xn.idToStr)(u[1])),u[1]):void 0;i.push(this.astAt(new ue.ImportSelect((0,Xn.idToStr)(u[0]),a),u[0]))}return i}visitDebugExpr(e){return this.getFieldExpr(e.fieldExpr())}visitSampleStatement(e){const r=e.sampleSpec().INTEGER_LITERAL();if(r)return new ue.SampleProperty({rows:this.getNumber(r)});const i=e.sampleSpec().PERCENT_LITERAL();if(i)return new ue.SampleProperty({percent:this.getNumber(i)});const s=e.sampleSpec().TRUE()!==void 0;return new ue.SampleProperty({enable:s})}visitDocAnnotations(e){const r=e.DOC_ANNOTATION().map(s=>({text:s.text,at:this.getLocation(e)})),i=new ue.ModelAnnotation(r);return this.compilerFlags=i.getCompilerFlags(this.compilerFlags,this.msgLog),i}visitIgnoredObjectAnnotations(e){return this.contextError(e,"orphaned-object-annotation","Object annotation not connected to any object"),new Mk(e.text)}visitIgnoredModelAnnotations(e){return this.contextError(e,"misplaced-model-annotation","Model annotations not allowed at this scope"),new Mk(e.text)}visitDefExploreAnnotation(e){const r=this.getNotes(e);return new ue.ObjectAnnotation(r)}getSQArgument(e){const r=e.argumentId(),i=r?this.astAt(new ue.PartitionByFieldReference([this.astAt(new ue.FieldName((0,Xn.idToStr)(r.id())),r)]),r):void 0;return this.astAt(new ue.Argument({id:i,value:this.getFieldExpr(e.fieldExpr())}),e)}getSQArguments(e){if(e!==void 0)return this.inExperiment("parameters",e),e.sourceArgument().map(r=>this.getSQArgument(r))}visitSQID(e){const r=this.getModelEntryName(e),i=this.getSQArguments(e.sourceArguments());return this.astAt(new ue.SQReference(r,i),e.id())}getSqExpr(e){const r=this.visit(e);return r instanceof ue.SourceQueryElement?r:(this.contextError(e,"unexpected-non-source-query-expression-node",`Expected a source/query expression, not '${r.elementType}'`),new Pce)}visitSQExtendedSource(e){const r=this.getSqExpr(e.sqExpr()),i=e.includeBlock(),s=i?this.getIncludeItems(i):void 0,o=new ue.SQExtend(r,this.getSourceExtensions(e.exploreProperties()),s);return this.astAt(o,e)}getIncludeItems(e){return this.inExperiment("access_modifiers",e),e.includeItem().map(r=>this.getIncludeItem(r)).filter(Mce.isNotUndefined)}getIncludeItem(e){var r;const i=e.tags(),s=i?this.getNotes(i):[],o=e.includeExceptList();if(o){i&&s.length>0&&this.contextError(i,"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const u=this.getExcludeList(o);return this.astAt(new ue.IncludeExceptItem(u),e)}else{const u=e.includeList();if(u===void 0){this.contextError((r=e.orphanedAnnotation())!==null&&r!==void 0?r:e,"orphaned-object-annotation","This tag is not attached to anything",{severity:"warn"});return}const a=this.getAccessLabelProp(e.accessLabelProp()),l=this.getIncludeList(u),c=this.astAt(new ue.IncludeAccessItem(a,l),e);return c.extendNote({blockNotes:s}),c}}getIncludeList(e){const r=e.includeField();if(r===void 0)throw this.internalError(e,"Expected a field name list");return r.map(i=>this.getIncludeListItem(i))}getExcludeList(e){return e.includeExceptListItem().map(r=>{r.tags().ANNOTATION().length>0&&this.contextError(r.tags(),"cannot-tag-include-except","Tags on `except:` are ignored",{severity:"warn"});const i=r.fieldName();if(i)return this.astAt(new ue.AccessModifierFieldReference([this.astAt(this.getFieldName(i),r)]),i);const s=r.collectionWildCard();if(s)return this.astAt(this.visitCollectionWildCard(s),s);throw this.internalError(r,"Expected a field name or wildcard")})}getIncludeListItem(e){const r=e.collectionWildCard(),i=r?this.visitCollectionWildCard(r):void 0,s=e._as?e._as.text:void 0,o=e.tags(),u=o?this.getNotes(o):[],a=e.isDefine(),l=a?this.getIsNotes(a):[],c=[...u,...l],f=e._name?this.astAt(new ue.AccessModifierFieldReference([this.astAt(this.getFieldName(e._name),e._name)]),e._name):void 0,x=f??i;if(x===void 0)throw this.internalError(e,"Expected a field name or wildcard");const h=this.astAt(new ue.IncludeListItem(x,s),e);return h.extendNote({notes:c}),h}visitSQParens(e){const r=this.getSqExpr(e.sqExpr());return this.astAt(r,e)}visitSQCompose(e){const r=e.sqExpr().map(i=>this.getSqExpr(i));return this.inExperiment("composite_sources",e),this.astAt(new ue.SQCompose(r),e)}visitSQArrow(e){const r=this.getSqExpr(e.sqExpr()),i=e.segExpr(),s=new ue.SQArrow(r,this.getVExpr(i));return this.astAt(s,e)}getVExpr(e){const r=this.visit(e);if(r instanceof ue.View)return r;throw this.internalError(e,`Expected view, got a '${r.elementType}'`)}visitSegField(e){return new ue.ReferenceView(this.getFieldPath(e.fieldPath(),ue.ViewOrScalarFieldReference))}visitSegOps(e){return new ue.QOpDescView(this.visitQueryProperties(e.queryProperties()))}visitSegParen(e){return this.visit(e.vExpr())}visitVSeg(e){return this.visit(e.segExpr())}visitSegRefine(e){return new ue.ViewRefine(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitVArrow(e){return new ue.ViewArrow(this.getVExpr(e._lhs),this.getVExpr(e._rhs))}visitSQRefinedQuery(e){const r=this.getSqExpr(e.sqExpr()),i=e.segExpr(),s=new ue.SQRefine(r,this.getVExpr(i));return this.astAt(s,e)}visitSQTable(e){const r=this.visit(e.exploreTable());if(r instanceof sdt.TableSource){const i=new ue.SQSource(r);return this.astAt(i,e)}return new Pce}visitSQSQL(e){const r=new ue.SQSource(this.visitSqlSource(e.sqlSource()));return this.astAt(r,e)}visitExperimentalStatementForTesting(e){return this.inExperiment("compilerTestExperimentParse",e),this.astAt(new ue.ExperimentalExperiment("compilerTestExperimentTranslate"),e)}visitRecordRef(e){const r=new ue.ExprIdReference(this.getFieldPath(e.fieldPath(),ue.ExpressionFieldReference));return this.astAt(new ue.RecordElement({path:r}),e)}visitRecordExpr(e){const r=this.getFieldExpr(e.fieldExpr()),i=e.recordKey(),s=i?{key:(0,Xn.getId)(i),value:r}:{value:r};return this.astAt(new ue.RecordElement(s),e)}visitExprLiteralRecord(e){const r=this.only(e.recordElement().map(i=>this.astAt(this.visit(i),i)),i=>i instanceof ue.RecordElement&&i,"a legal record property description");return new ue.RecordLiteral(r)}visitExprArrayLiteral(e){const r=e.fieldExpr().map(s=>this.getFieldExpr(s)),i=new ue.ArrayLiteral(r);return this.astAt(i,e)}visitExprWarnLike(e){let r="~";const i=e.fieldExpr(0),s=e.fieldExpr(1),o=this.rangeFromContext(e);return e.NOT()?(r="!~",this.warnWithReplacement("sql-not-like","Use Malloy operator '!~' instead of 'NOT LIKE'",o,`${this.getSourceCode(i)} !~ ${this.getSourceCode(s)}`)):this.warnWithReplacement("sql-like","Use Malloy operator '~' instead of 'LIKE'",o,`${this.getSourceCode(i)} ~ ${this.getSourceCode(s)}`),this.astAt(new ue.ExprCompare(this.getFieldExpr(i),r,this.getFieldExpr(s)),e)}visitExprNullCheck(e){const r=e.fieldExpr();return this.astAt(new ue.ExprIsNull(this.getFieldExpr(r),e.NOT()?"!=":"="),e)}visitExprWarnIn(e){const r=this.getFieldExpr(e.fieldExpr()),i=!!e.NOT(),s=e.fieldExprList().fieldExpr(),o=this.astAt(new ue.ExprLegacyIn(r,i,s.map(u=>this.getFieldExpr(u))),e);return this.warnWithReplacement("sql-in",`Use = (a|b|c) instead of${i?" NOT":""} IN (a,b,c)`,this.rangeFromContext(e),`${this.getSourceCode(e.fieldExpr())} ${i?"!=":"="} (${s.map(u=>this.getSourceCode(u)).join(" | ")})`),o}visitTickFilterString(e){const r=e.text.slice(1).trimStart();if(r[r.length-1]===`
|
|
1557
1557
|
`){const u=r[0]==="'"?'"':"'";this.contextError(e,"literal-string-newline",`Missing $${u}${r[0]}${u} before end-of-line`)}const s=r.slice(1,-1),o=new ue.ExprFilterExpression(s);return this.astAt(o,e)}visitTripFilterString(e){const i=e.text.slice(1).trimStart().slice(3,-3),s=new ue.ExprFilterExpression(i);return this.astAt(s,e)}}xR.MalloyToAST=ldt;var dR={};Object.defineProperty(dR,"__esModule",{value:!0}),dR.Zone=void 0;class cdt{constructor(){this.location={},this.zone=new Map}get(e){const r=this.zone.get(e);if((r==null?void 0:r.status)==="present")return r.value}getEntry(e){const r=this.zone.get(e);return r?r.firstReference||!this.location[e]?r:{...r,firstReference:this.location[e]}:{status:"error",message:"import reference failure"}}define(e,r){this.zone.set(e,{status:"present",value:r})}reference(e,r){const i=this.zone.get(e);(i==null?void 0:i.status)===void 0&&(this.zone.set(e,{status:"reference",firstReference:r}),this.location[e]=r)}getUndefined(){const e=[];for(const[r,i]of this.zone)i.status==="reference"&&e.push(r);return e.length>0?e:void 0}updateFrom(e,r){if(e)for(const[i,s]of Object.entries(e))s!==void 0&&this.define(i,s);if(r)for(const[i,s]of Object.entries(r))this.zone.set(i,{status:"error",message:s})}}dR.Zone=cdt;var hR={};Object.defineProperty(hR,"__esModule",{value:!0}),hR.walkForDocumentSymbols=void 0;const fdt=T0,xdt=Pn;class ddt{constructor(e,r,i,s){this.translator=e,this.tokens=r,this.scopes=i,this.symbols=s}popScope(){return this.scopes.pop()}peekScope(){return this.scopes[this.scopes.length-1]}enterTopLevelQueryDefs(e){const r=this.translator.rangeFromContext(e);e.topLevelQueryDef().length===1&&(this.blockRange=r)}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 r=this.translator.rangeFromContext(e);e.sourcePropertyList().sourceDefinition().length===1&&(this.blockRange=r)}enterSourceDefinition(e){const r=this.translator.rangeFromContext(e);this.scopes.push({range:r,name:e.sourceNameDef().id().text,type:"explore",children:[],lensRange:this.blockRange}),this.blockRange=void 0}exitSourceDefinition(e){const r=this.popScope();r&&this.symbols.push(r)}enterDefExploreQuery(e){const r=this.translator.rangeFromContext(e);e.subQueryDefList().exploreQueryDef().length===1&&(this.blockRange=r)}enterExploreQueryDef(e){const r={range:this.translator.rangeFromContext(e),name:e.exploreQueryNameDef().id().text,type:"query",children:[],lensRange:this.blockRange},i=this.peekScope();i&&i.children.push(r),this.scopes.push(r),this.blockRange=void 0}exitExploreQueryDef(e){this.popScope()}getNestDefName(e){const r=e.queryName();if(r)return r.id().text;let i,s=!1;const o={enterVArrow(a){a.vExpr().enterRule(o)},enterVSeg(a){a.segExpr().enterRule(u)}},u={enterSegField(a){const l=a.fieldPath().fieldName();s||(i??(i=l[l.length-1].id().text))},enterSegParen(a){a.vExpr().enterRule(o)},enterSegRefine(a){a._lhs.enterRule(u)},enterSegOps(){i=void 0,s=!0}};return e.vExpr().enterRule(o),i}handleNestEntry(e){const r=this.getNestDefName(e);if(r===void 0)return;const i={range:this.translator.rangeFromContext(e),name:r,type:"query",children:[]},s=this.peekScope();return s&&s.children.push(i),i}enterNestDef(e){const r=this.handleNestEntry(e);r&&this.scopes.push(r)}exitNestDef(e){this.popScope()}enterFieldDef(e){const r={range:this.translator.rangeFromContext(e),name:e.fieldNameDef().id().text,type:"field",children:[]},i=this.peekScope();i&&i.children.push(r)}enterQueryFieldEntry(e){var r;const i=(r=e.taggedRef())===null||r===void 0?void 0:r.fieldPath();if(i===void 0)return;const s={range:this.translator.rangeFromContext(e),name:i.text,type:"field",children:[]},o=this.peekScope();o&&o.children.push(s)}enterExploreRenameDef(e){const r={range:this.translator.rangeFromContext(e),name:e.fieldName()[0].text,type:"field",children:[]},i=this.peekScope();i&&i.children.push(r)}enterJoinWith(e){this.handleJoinDef(e)}enterJoinOn(e){this.handleJoinDef(e)}handleJoinDef(e){const r={range:this.translator.rangeFromContext(e),name:e.joinFrom().joinNameDef().id().text,type:"join",children:[]},i=this.peekScope();i&&i.children.push(r)}enterImportStatement(e){const r=(0,xdt.getStringIfShort)(e.importURL());r&&this.scopes.push({range:this.translator.rangeFromContext(e),name:r,type:"import",children:[]})}exitImportStatement(){const e=this.popScope();e&&this.symbols.push(e)}enterImportSelect(e){const r=this.peekScope();if(r)for(const i of e.importItem()){const s={range:this.translator.rangeFromContext(e),name:i.text,type:"import_item",children:[]};r.children.push(s)}}}function hdt(t,e,r){const i=new ddt(t,e,[],[]),s=i;return fdt.ParseTreeWalker.DEFAULT.walk(s,r),i.symbols}hR.walkForDocumentSymbols=hdt;var pR={};Object.defineProperty(pR,"__esModule",{value:!0}),pR.walkForDocumentCompletions=void 0;const pdt=T0,mdt=["dimension","measure","join_one","join_many","join_cross","where","primary_key","rename","accept","except","query","declare"],gdt=["group_by","project","index","aggregate","top","limit","order_by","where","having","nest","declare"],ydt=["source","explore","query","sql"];class Edt{constructor(e,r,i){this.tokens=e,this.completions=r,this.position=i}rangeOf(e){const r=e.stop||e.start;return{start:{line:e.start.line-1,character:e.start.charPositionInLine},end:{line:r.line-1,character:r.stopIndex-(r.startIndex-r.charPositionInLine)+1}}}inRange(e){const{start:r,end:i}=e,s=this.position.line>r.line||this.position.line===r.line&&this.position.character>=r.character,o=this.position.line<i.line||this.position.line===i.line&&this.position.character<=i.character;return s&&o}enterExploreProperties(e){if(this.inRange(this.rangeOf(e))){let r=!1;for(const i of e.exploreStatement())this.inRange(this.rangeOf(i))&&(r=!0);if(!r)for(const i of mdt)this.completions.push({type:"explore_property",text:`${i}: `})}}enterQueryProperties(e){if(this.inRange(this.rangeOf(e))){let r=!1;for(const i of e.queryStatement())this.inRange(this.rangeOf(i))&&(r=!0);if(!r)for(const i of gdt)this.completions.push({type:"query_property",text:`${i}: `})}}enterMalloyDocument(e){if(this.inRange(this.rangeOf(e))){let r=!1;for(const i of e.malloyStatement())this.inRange(this.rangeOf(i))&&(r=!0);if(!r)for(const i of ydt)this.completions.push({type:"model_property",text:`${i}: `})}}}function Adt(t,e,r){const i=new Edt(t,[],r),s=i;return pdt.ParseTreeWalker.DEFAULT.walk(s,e),i.completions}pR.walkForDocumentCompletions=Adt;var mR={};Object.defineProperty(mR,"__esModule",{value:!0}),mR.walkForDocumentHelpContext=void 0;const _dt=nO;class vdt extends _dt.AbstractParseTreeVisitor{constructor(e){super(),this.position=e,this.type=""}rangeOf(e){const r=e.stop||e.start;return{start:{line:e.start.line-1,character:e.start.charPositionInLine},end:{line:r.line-1,character:r.stopIndex-(r.startIndex-r.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 r=this.defaultResult();if(this.inRange(this.rangeOf(e))){r={type:this.type,token:e.start.text};const i=e.childCount;for(let s=0;s<i;s++){const u=e.getChild(s).accept(this);u&&(r=this.aggregateResult(r,u))}}return r}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,r){return r}}function Cdt(t,e){return new vdt(e).visit(t)}mR.walkForDocumentHelpContext=Cdt;var gR={};Object.defineProperty(gR,"__esModule",{value:!0}),gR.ReferenceList=void 0;const Sdt=Jn;class bdt{constructor(e){this.sourceURL=e,this.references=[]}findIndexBefore(e){let r=0,i=this.references.length;for(;r<i;){const s=Math.floor((r+i)/2),o=this.references[s].location.range.end;o.line<e.line||o.line===e.line&&o.character<e.character?r=s+1:i=s}return r}add(e){if(e.location.url!==this.sourceURL)return;const r=this.findIndexBefore(e.location.range.end);r<this.references.length&&this.isPositionEqual(e,this.references[r])||this.references.splice(r,0,e)}isPositionEqual(e,r){const i=e.location.range,s=r.location.range;return i.start.line===s.start.line&&i.start.character===s.start.character&&i.end.line===s.end.line&&i.end.character===s.end.character}find(e){const r=this.findIndexBefore(e);if(r===this.references.length)return;const i=this.references[r];if((0,Sdt.locationContainsPosition)(i.location,e))return i}}gR.ReferenceList=bdt;var yR={};Object.defineProperty(yR,"__esModule",{value:!0}),yR.isNeedResponse=void 0;function Tdt(t){return!!t&&(t.tables||t.urls||t.compileSQL)!==void 0}yR.isNeedResponse=Tdt;var ER={};Object.defineProperty(ER,"__esModule",{value:!0}),ER.walkForModelAnnotation=void 0;const Rdt=T0;class Ddt{constructor(e,r,i){this.translator=e,this.tokens=r,this.parseInfo=i,this.notes=[]}getLocation(e){return{url:this.parseInfo.sourceURL,range:this.translator.rangeFromContext(e)}}enterDocAnnotations(e){const r=e.DOC_ANNOTATION().map(i=>({text:i.text,at:this.getLocation(e)}));this.notes.push(...r)}get annotation(){return{notes:this.notes}}}function Odt(t,e,r){const i=new Ddt(t,e,r),s=i;return Rdt.ParseTreeWalker.DEFAULT.walk(s,r.root),i.annotation}ER.walkForModelAnnotation=Odt;var AR={};Object.defineProperty(AR,"__esModule",{value:!0}),AR.walkForTablePath=void 0;const Uce=Pn,wdt=T0;class Fdt{constructor(e,r){this.translator=e,this.tokens=r,this.pathInfos=[]}enterTableMethod(e){const r=(0,Uce.getId)(e.connectionId()),[i,s]=(0,Uce.getPlainString)(e.tablePath(),!0);i!==void 0&&this.pathInfos.push({connectionId:r,tablePath:i,range:this.translator.rangeFromContext(e)})}}function Ndt(t,e,r){const i=new Fdt(t,e),s=i;return wdt.ParseTreeWalker.DEFAULT.walk(s,r.root),i.pathInfos}AR.walkForTablePath=Ndt;var BE={},_R={},Ldt=T&&T.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,s)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),Idt=T&&T.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),$dt=T&&T.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Ldt(e,t,r);return Idt(e,t),e};Object.defineProperty(_R,"__esModule",{value:!0}),_R.MalloyLexer=void 0;const Bdt=hh(),kdt=fl(),Mdt=B1(),Pdt=Rs,jce=$dt(Sn);class le extends kdt.Lexer{get vocabulary(){return le.VOCABULARY}constructor(e){super(e),this._interp=new Mdt.LexerATNSimulator(le._ATN,this)}get grammarFileName(){return"MalloyLexer.g4"}get ruleNames(){return le.ruleNames}get serializedATN(){return le._serializedATN}get channelNames(){return le.channelNames}get modeNames(){return le.modeNames}static get _ATN(){return le.__ATN||(le.__ATN=new Bdt.ATNDeserializer().deserialize(jce.toCharArray(le._serializedATN))),le.__ATN}}_R.MalloyLexer=le,le.ACCEPT=1,le.AGGREGATE=2,le.CALCULATE=3,le.CALCULATION=4,le.CONNECTION=5,le.DECLARE=6,le.DIMENSION=7,le.EXCEPT=8,le.EXTENDQ=9,le.GROUP_BY=10,le.HAVING=11,le.INDEX=12,le.INTERNAL=13,le.JOIN_CROSS=14,le.JOIN_ONE=15,le.JOIN_MANY=16,le.LIMIT=17,le.MEASURE=18,le.NEST=19,le.ORDER_BY=20,le.PARTITION_BY=21,le.PRIMARY_KEY=22,le.PRIVATE=23,le.PROJECT=24,le.PUBLIC=25,le.QUERY=26,le.RENAME=27,le.RUN=28,le.SAMPLE=29,le.SELECT=30,le.SOURCE=31,le.TOP=32,le.WHERE=33,le.VIEW=34,le.TIMEZONE=35,le.ALL=36,le.AND=37,le.AS=38,le.ASC=39,le.AVG=40,le.BOOLEAN=41,le.BY=42,le.CASE=43,le.CAST=44,le.CONDITION=45,le.COUNT=46,le.COMPOSE=47,le.DATE=48,le.DAY=49,le.DESC=50,le.DISTINCT=51,le.ELSE=52,le.END=53,le.EXCLUDE=54,le.EXTEND=55,le.FALSE=56,le.FULL=57,le.FOR=58,le.FROM=59,le.HAS=60,le.HOUR=61,le.IMPORT=62,le.INCLUDE=63,le.INNER=64,le.IS=65,le.IN=66,le.INTERNAL_KW=67,le.JSON=68,le.LAST=69,le.LEFT=70,le.LIKE=71,le.MAX=72,le.MIN=73,le.MINUTE=74,le.MONTH=75,le.NOT=76,le.NOW=77,le.NULL=78,le.NUMBER=79,le.ON=80,le.OR=81,le.PICK=82,le.PRIVATE_KW=83,le.PUBLIC_KW=84,le.QUARTER=85,le.RIGHT=86,le.SECOND=87,le.STRING=88,le.SOURCE_KW=89,le.SUM=90,le.SQL=91,le.TABLE=92,le.THEN=93,le.THIS=94,le.TIMESTAMP=95,le.TO=96,le.TRUE=97,le.TURTLE=98,le.WEEK=99,le.WHEN=100,le.WITH=101,le.YEAR=102,le.UNGROUPED=103,le.HACKY_REGEX=104,le.RAW_SQ=105,le.RAW_DQ=106,le.SQ3_FILTER=107,le.SQ_FILTER=108,le.DQ3_FILTER=109,le.DQ_FILTER=110,le.BQ3_FILTER=111,le.BQ_FILTER=112,le.SQ_STRING=113,le.DQ_STRING=114,le.BQ_STRING=115,le.DOC_ANNOTATION=116,le.ANNOTATION=117,le.AMPER=118,le.ARROW=119,le.FAT_ARROW=120,le.OPAREN=121,le.CPAREN=122,le.OBRACK=123,le.CBRACK=124,le.OCURLY=125,le.CCURLY=126,le.DOUBLECOLON=127,le.TRIPLECOLON=128,le.EXCLAM=129,le.COLON=130,le.COMMA=131,le.DOT=132,le.LT=133,le.GT=134,le.EQ=135,le.NE=136,le.LTE=137,le.GTE=138,le.PLUS=139,le.MINUS=140,le.STAR=141,le.STARSTAR=142,le.SLASH=143,le.BAR=144,le.SEMI=145,le.NOT_MATCH=146,le.MATCH=147,le.PERCENT=148,le.DOUBLE_QMARK=149,le.QMARK=150,le.LITERAL_TIMESTAMP=151,le.LITERAL_HOUR=152,le.LITERAL_DAY=153,le.LITERAL_QUARTER=154,le.LITERAL_MONTH=155,le.LITERAL_WEEK=156,le.LITERAL_YEAR=157,le.IDENTIFIER=158,le.PERCENT_LITERAL=159,le.NUMERIC_LITERAL=160,le.INTEGER_LITERAL=161,le.BLOCK_COMMENT=162,le.COMMENT_TO_EOL=163,le.WHITE_SPACE=164,le.SQL_BEGIN=165,le.CLOSE_CODE=166,le.UNWATED_CHARS_TRAILING_NUMBERS=167,le.UNEXPECTED_CHAR=168,le.OPEN_CODE=169,le.SQL_END=170,le.SQL_MODE=1,le.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"],le.modeNames=["DEFAULT_MODE","SQL_MODE"],le.ruleNames=["SPACE_CHAR","ACCEPT","AGGREGATE","CALCULATE","CALCULATION","CONNECTION","DECLARE","DIMENSION","EXCEPT","EXTENDQ","GROUP_BY","HAVING","INDEX","INTERNAL","JOIN_CROSS","JOIN_ONE","JOIN_MANY","LIMIT","MEASURE","NEST","ORDER_BY","PARTITION_BY","PRIMARY_KEY","PRIVATE","PROJECT","PUBLIC","QUERY","RENAME","RUN","SAMPLE","SELECT","SOURCE","TOP","WHERE","VIEW","TIMEZONE","ALL","AND","AS","ASC","AVG","BOOLEAN","BY","CASE","CAST","CONDITION","COUNT","COMPOSE","DATE","DAY","DESC","DISTINCT","ELSE","END","EXCLUDE","EXTEND","FALSE","FULL","FOR","FROM","HAS","HOUR","IMPORT","INCLUDE","INNER","IS","IN","INTERNAL_KW","JSON","LAST","LEFT","LIKE","MAX","MIN","MINUTE","MONTH","NOT","NOW","NULL","NUMBER","ON","OR","PICK","PRIVATE_KW","PUBLIC_KW","QUARTER","RIGHT","SECOND","STRING","SOURCE_KW","SUM","SQL","TABLE","THEN","THIS","TIMESTAMP","TO","TRUE","TURTLE","WEEK","WHEN","WITH","YEAR","UNGROUPED","SQ","BQ","DQ","SQ3","DQ3","BQ3","RAW_CHAR","RAW3_CHAR","FILTER","RAWSTR","HACKY_REGEX","RAW_SQ","RAW_DQ","SQ3_FILTER","SQ_FILTER","DQ3_FILTER","DQ_FILTER","BQ3_FILTER","BQ_FILTER","HEX","UNICODE","SAFE_NON_QUOTE","ESCAPED","STR_CHAR","SQ_STRING","DQ_STRING","BQ_STRING","F_TO_EOL","DOC_ANNOTATION","ANNOTATION","AMPER","ARROW","FAT_ARROW","OPAREN","CPAREN","OBRACK","CBRACK","OCURLY","CCURLY","DOUBLECOLON","TRIPLECOLON","EXCLAM","COLON","COMMA","DOT","LT","GT","EQ","NE","LTE","GTE","PLUS","MINUS","STAR","STARSTAR","SLASH","BAR","SEMI","NOT_MATCH","MATCH","PERCENT","DOUBLE_QMARK","QMARK","F_YEAR","F_DD","F_TZ","LITERAL_TIMESTAMP","LITERAL_HOUR","LITERAL_DAY","LITERAL_QUARTER","LITERAL_MONTH","LITERAL_WEEK","LITERAL_YEAR","IDENTIFIER","PERCENT_LITERAL","EXPONENT","NUMERIC_LITERAL","INTEGER_LITERAL","ID_CHAR","DIGIT","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","BLOCK_COMMENT","COMMENT_TO_EOL","WHITE_SPACE","SQL_BEGIN","CLOSE_CODE","UNWATED_CHARS_TRAILING_NUMBERS","UNEXPECTED_CHAR","SQL_CHAR","OPEN_CODE","SQL_END"],le._LITERAL_NAMES=[void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,"'&'","'->'","'=>'","'('","')'","'['","']'","'{'","'}'","'::'","':::'","'!'","':'","','","'.'","'<'","'>'","'='","'!='","'<='","'>='","'+'","'-'","'*'","'**'","'/'","'|'","';'","'!~'","'~'","'%'","'??'","'?'",void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,`'"""'`,"'}%'"],le._SYMBOLIC_NAMES=[void 0,"ACCEPT","AGGREGATE","CALCULATE","CALCULATION","CONNECTION","DECLARE","DIMENSION","EXCEPT","EXTENDQ","GROUP_BY","HAVING","INDEX","INTERNAL","JOIN_CROSS","JOIN_ONE","JOIN_MANY","LIMIT","MEASURE","NEST","ORDER_BY","PARTITION_BY","PRIMARY_KEY","PRIVATE","PROJECT","PUBLIC","QUERY","RENAME","RUN","SAMPLE","SELECT","SOURCE","TOP","WHERE","VIEW","TIMEZONE","ALL","AND","AS","ASC","AVG","BOOLEAN","BY","CASE","CAST","CONDITION","COUNT","COMPOSE","DATE","DAY","DESC","DISTINCT","ELSE","END","EXCLUDE","EXTEND","FALSE","FULL","FOR","FROM","HAS","HOUR","IMPORT","INCLUDE","INNER","IS","IN","INTERNAL_KW","JSON","LAST","LEFT","LIKE","MAX","MIN","MINUTE","MONTH","NOT","NOW","NULL","NUMBER","ON","OR","PICK","PRIVATE_KW","PUBLIC_KW","QUARTER","RIGHT","SECOND","STRING","SOURCE_KW","SUM","SQL","TABLE","THEN","THIS","TIMESTAMP","TO","TRUE","TURTLE","WEEK","WHEN","WITH","YEAR","UNGROUPED","HACKY_REGEX","RAW_SQ","RAW_DQ","SQ3_FILTER","SQ_FILTER","DQ3_FILTER","DQ_FILTER","BQ3_FILTER","BQ_FILTER","SQ_STRING","DQ_STRING","BQ_STRING","DOC_ANNOTATION","ANNOTATION","AMPER","ARROW","FAT_ARROW","OPAREN","CPAREN","OBRACK","CBRACK","OCURLY","CCURLY","DOUBLECOLON","TRIPLECOLON","EXCLAM","COLON","COMMA","DOT","LT","GT","EQ","NE","LTE","GTE","PLUS","MINUS","STAR","STARSTAR","SLASH","BAR","SEMI","NOT_MATCH","MATCH","PERCENT","DOUBLE_QMARK","QMARK","LITERAL_TIMESTAMP","LITERAL_HOUR","LITERAL_DAY","LITERAL_QUARTER","LITERAL_MONTH","LITERAL_WEEK","LITERAL_YEAR","IDENTIFIER","PERCENT_LITERAL","NUMERIC_LITERAL","INTEGER_LITERAL","BLOCK_COMMENT","COMMENT_TO_EOL","WHITE_SPACE","SQL_BEGIN","CLOSE_CODE","UNWATED_CHARS_TRAILING_NUMBERS","UNEXPECTED_CHAR","OPEN_CODE","SQL_END"],le.VOCABULARY=new Pdt.VocabularyImpl(le._LITERAL_NAMES,le._SYMBOLIC_NAMES,[]),le._serializedATNSegments=4,le._serializedATNSegment0=`줝쪺֍꾺体؇쉁¬ވ\b\b \x07 \x07\b \b
|
|
1558
1558
|
|
|
1559
1559
|
\v \v\f \f\r \r \x1B \x1B ! !" "# #$ $% %& &' '( () )* *+ +, ,- -. ./ /0 01 12 23 34 45 56 67 78 89 9: :; ;< <= => >? ?@ @A AB BC CD DE EF FG GH HI IJ JK KL LM MN NO OP PQ QR RS ST TU UV VW WX XY YZ Z[ [\\ \\] ]^ ^_ _\` \`a ab bc cd de ef fg gh hi ij jk kl lm mn no op pq qr rs st tu uv vw wx xy yz z{ {| |} }~ ~
¡ ¡¢ ¢£ £¤ ¤¥ ¥¦ ¦§ §¨ ¨© ©ª ª« «¬ ¬ ® ®¯ ¯° °± ±² ²³ ³´ ´µ µ¶ ¶· ·¸ ¸¹ ¹º º» »¼ ¼½ ½¾ ¾¿ ¿À ÀÁ Á Âà ÃÄ ÄÅ ÅÆ ÆÇ ÇÈ ÈÉ ÉÊ ÊË ËÌ ÌÍ ÍÎ ÎÏ ÏÐ ÐÑ ÑÒ ÒÓ ÓÔ ÔÕ ÕÖ Ö× ×Ø ØÙ ÙÚ ÚÛ ÛÜ ÜÝ Ý\x07dž
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/render",
|
|
3
|
-
"version": "0.0.244-
|
|
3
|
+
"version": "0.0.244-dev250318232227",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/module/index.umd.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"generate-flow": "ts-node ../../scripts/gen-flow.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@malloydata/db-duckdb": "^0.0.244-
|
|
36
|
-
"@malloydata/malloy": "^0.0.244-
|
|
37
|
-
"@malloydata/malloy-interfaces": "^0.0.244-
|
|
38
|
-
"@malloydata/malloy-tag": "^0.0.244-
|
|
35
|
+
"@malloydata/db-duckdb": "^0.0.244-dev250318232227",
|
|
36
|
+
"@malloydata/malloy": "^0.0.244-dev250318232227",
|
|
37
|
+
"@malloydata/malloy-interfaces": "^0.0.244-dev250318232227",
|
|
38
|
+
"@malloydata/malloy-tag": "^0.0.244-dev250318232227",
|
|
39
39
|
"@tanstack/solid-virtual": "^3.10.4",
|
|
40
40
|
"component-register": "^0.8.6",
|
|
41
41
|
"lodash": "^4.17.20",
|