@malloy-publisher/app 0.0.188 → 0.0.189-dev

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.
@@ -1,4 +1,4 @@
1
- import{a2 as I0,a3 as Mp}from"./index-BL2TJgTw.js";function qp(a,d){for(var y=0;y<d.length;y++){const m=d[y];if(typeof m!="string"&&!Array.isArray(m)){for(const h in m)if(h!=="default"&&!(h in a)){const u=Object.getOwnPropertyDescriptor(m,h);u&&Object.defineProperty(a,h,u.get?u:{enumerable:!0,get:()=>m[h]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}var mo={},Cr={},Xe={},Ma;function pe(){if(Ma)return Xe;Ma=1;/*!
1
+ import{a2 as I0,a3 as Mp}from"./index-15BOvhp0.js";function qp(a,d){for(var y=0;y<d.length;y++){const m=d[y];if(typeof m!="string"&&!Array.isArray(m)){for(const h in m)if(h!=="default"&&!(h in a)){const u=Object.getOwnPropertyDescriptor(m,h);u&&Object.defineProperty(a,h,u.get?u:{enumerable:!0,get:()=>m[h]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}var mo={},Cr={},Xe={},Ma;function pe(){if(Ma)return Xe;Ma=1;/*!
2
2
  * Copyright 2016 The ANTLR Project. All rights reserved.
3
3
  * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
4
4
  */Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.SuppressWarnings=Xe.Override=Xe.Nullable=Xe.NotNull=void 0;function a(h,u,r){}Xe.NotNull=a;function d(h,u,r){}Xe.Nullable=d;function y(h,u,r){}Xe.Override=y;function m(h){return(u,r,o)=>{}}return Xe.SuppressWarnings=m,Xe}var Or={},Dr={},qa;function Ve(){if(qa)return Dr;qa=1;/*!
@@ -1,4 +1,4 @@
1
- import{_ as vO,r as D,j as w,$ as gr,R as N4,a0 as F4,a1 as oo}from"./index-BL2TJgTw.js";import{r as I4,a as G2,b as k4,c as M4,d as P4,e as B4,f as $4,g as q4,h as j4,j as W2,k as V2,l as N0,m as Gh,n as U4,o as CO,p as Q4,q as H4,s as G4,t as I3,u as k3,v as M3,w as At}from"./index-BWJkzsfl.js";import{a as w1}from"./index.umd-lY-87l4L.js";var va={},ay={},Hr={},uy={},pC;function st(){return pC||(pC=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=s,e.exprHasKids=a,e.exprHasE=o,e.exprIsLeaf=c,e.isAsymmetricExpr=d,e.mkTemporal=f,e.isRawCast=u,e.isFilterExprType=p,e.isTimeLiteral=h,e.isParameterType=m,e.paramHasValue=x,e.expressionIsScalar=E,e.expressionIsAggregate=v,e.expressionIsUngroupedAggregate=g,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=R,e.isExpressionTypeLEQ=b,e.maxExpressionType=T,e.maxOfExpressionTypes=N,e.hasExpression=k,e.isTemporalType=L,e.isBasicAtomicType=F,e.isAtomicFieldType=M,e.canOrderBy=q,e.fieldIsIntrinsic=B,e.mkFieldDef=P,e.mkArrayDef=Y,e.mkArrayTypeDef=ee,e.isRepeatedRecordFunctionParam=oe,e.isRepeatedRecord=I,e.isRecordOrRepeatedRecord=X,e.isBasicArray=G,e.isMatrixOperation=te,e.isJoinable=V,e.isJoined=se,e.isJoinedSource=Ee,e.isDateUnit=ve,e.isTimestampUnit=le,e.isExtractUnit=ae,e.refIsStructDef=ce,e.segmentHasErrors=ie,e.structHasErrors=xe,e.isReduceSegment=me,e.isPartialSegment=Te,e.isProjectSegment=ye,e.isQuerySegment=be,e.isSamplingRows=pe,e.isSamplingPercent=Pe,e.isSamplingEnable=qe,e.isRawSegment=Ue,e.isIndexSegment=pt,e.bareFieldUsage=gt,e.isSegmentSQL=St,e.isSegmentSource=Ot,e.isSourceRegistryReference=Qt,e.sourceBase=br,e.isSourceDef=rr,e.isPersistableSourceDef=Le,e.isBaseTable=We,e.isLiteral=wt,e.mergeEvalSpaces=He,e.isBasicAtomic=de,e.getIdentifier=he,e.isUserTypeDef=ke,e.isCompoundArrayData=Be,e.isTurtle=Ke,e.isAtomic=ot,e.isValueString=rt,e.isValueNumber=Nt,e.isValueBoolean=Rt,e.isValueTimestamp=Se,e.isValueDate=it,e.mergeUniqueKeyRequirement=Ge;const t=Object.prototype.hasOwnProperty;function r(re,we){return t.call(re,we)?re[we]:void 0}function s(){return Object.create(null)}function a(re){return"kids"in re}function o(re){return"e"in re}function c(re){return!(a(re)||o(re))}function d(re){return re.node==="aggregate"&&["sum","avg","count","distinct"].includes(re.function)}function l(re){return re.node!=="arrayLiteral"&&re.node!=="recordLiteral"}function f(re,we){if(!("typeDef"in re)){const Ye=typeof we=="string"?{type:we}:we;if(l(re))return{...re,typeDef:{...Ye}}}return re}function u(re){return"dstSQLType"in re}function p(re){return["string","number","boolean","date","timestamp","timestamptz"].includes(re)}function h(re){return re.node==="dateLiteral"||re.node==="timestampLiteral"||re.node==="timestamptzLiteral"}function m(re){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(re)}function x(re){return re.value!==null}function E(re){return re===void 0||re==="scalar"}function v(re){return re==="aggregate"||re==="ungrouped_aggregate"}function g(re){return re==="ungrouped_aggregate"}function _(re){return re==="aggregate"||re==="ungrouped_aggregate"||re==="aggregate_analytic"}function S(re){return re==="aggregate"||re==="scalar_analytic"||re==="aggregate_analytic"||re==="ungrouped_aggregate"}function R(re){return re==="aggregate_analytic"||re==="scalar_analytic"}function C(re){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[re]}function b(re,we){return re===we||C(re)<C(we)}function T(re,we){let Ye="scalar";return(re==="aggregate"||we==="aggregate")&&(Ye="aggregate"),(re==="ungrouped_aggregate"||we==="ungrouped_aggregate")&&(Ye="ungrouped_aggregate"),(re==="scalar_analytic"||we==="scalar_analytic")&&(Ye="scalar_analytic"),(re==="aggregate_analytic"||we==="aggregate_analytic")&&(Ye="aggregate_analytic"),(re==="scalar_analytic"&&we==="aggregate"||re==="aggregate"&&we==="scalar_analytic")&&(Ye="aggregate_analytic"),Ye}function N(re){return re.reduce(T,"scalar")}function k(re){return"e"in re&&re.e!==void 0}function L(re){return re==="date"||re==="timestamp"||re==="timestamptz"}function F(re){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(re)}function M(re){return F(re)||re==="record"||re==="array"}function q(re){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(re)}function B(re){return M(re.type)&&!k(re)}function P(re,we){if(G(re))return Y(re.elementTypeDef,we);if(I(re)){const{type:ze,fields:mt,elementTypeDef:vt}=re;return{type:ze,fields:mt,elementTypeDef:vt,join:"many",name:we}}if(re.type==="record"){const{type:ze,fields:mt}=re;return{type:ze,fields:mt,join:"one",name:we}}const Ye={name:we,type:re.type};switch(re.type){case"sql native":return{...Ye,rawType:re.rawType};case"number":{const ze=re.numberType;return ze?{...Ye,numberType:ze}:Ye}case"date":{const ze=re.timeframe;return ze?{name:we,type:"date",timeframe:ze}:Ye}case"timestamp":{const ze={name:we,type:"timestamp"};return re.timeframe&&(ze.timeframe=re.timeframe),ze}case"timestamptz":{const ze={name:we,type:"timestamptz"};return re.timeframe&&(ze.timeframe=re.timeframe),ze}}return Ye}function Y(re,we){if(re.type==="record")return{type:"array",join:"many",name:we,elementTypeDef:{type:"record_element"},fields:re.fields};const Ye=P(re,"value");return{type:"array",join:"many",name:we,elementTypeDef:re,fields:[Ye,{...Ye,name:"each",e:{node:"field",path:["value"]}}]}}function ee(re){return re.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:re.fields}:{type:"array",elementTypeDef:re}}function oe(re){return re.type==="array"&&re.elementTypeDef.type==="record_element"}function I(re){return re.type==="array"&&re.elementTypeDef.type==="record_element"}function X(re){return re.type==="record"||re.type==="array"&&"elementTypeDef"in re&&re.elementTypeDef.type==="record_element"}function G(re){return re.type==="array"&&re.elementTypeDef.type!=="record_element"}function te(re){return["left","right","full","inner"].includes(re)}function V(re){return["composite","table","sql_select","query_source","virtual","array","record"].includes(re.type)}function se(re){return"join"in re}function Ee(re){return rr(re)&&se(re)}function ve(re){return["day","week","month","quarter","year"].includes(re)}function le(re){return ve(re)||["hour","minute","second"].includes(re)}function ae(re){return le(re)||re==="day_of_week"||re==="day_of_year"}var Z;(function(re){re.Date="date",re.Timestamp="timestamp",re.Number="number",re.String="string"})(Z||(e.ValueType=Z={}));function ce(re){return typeof re!="string"}function ie(re){return!!((re.type==="reduce"||re.type==="project"||re.type==="partial")&&(re.extendSource&&re.extendSource.some(we=>we.type==="error")||re.queryFields.some(we=>we.type==="error")))}function xe(re){return re.fields.some(we=>we.type==="error")}function me(re){return re.type==="reduce"}function Te(re){return re.type==="partial"}function ye(re){return re.type==="project"}function be(re){return ye(re)||me(re)}function pe(re){return re.rows!==void 0}function Pe(re){return re.percent!==void 0}function qe(re){return re.enable!==void 0}function Ue(re){return re.type==="raw"}function pt(re){return re.type==="index"}function gt(re){return re.uniqueKeyRequirement===void 0&&re.analyticFunctionUse===void 0}function St(re){return"sql"in re}function Ot(re){return"type"in re&&(re.type==="sql_select"||re.type==="query_source")}function Qt(re){return re.type==="source_registry_reference"}function br(re){return{...re}}function rr(re){return re.type==="table"||re.type==="sql_select"||re.type==="query_source"||re.type==="query_result"||re.type==="finalize"||re.type==="nest_source"||re.type==="virtual"||re.type==="composite"}function Le(re){return re.type==="sql_select"||re.type==="query_source"}function We(re){return Ee(re)?!1:!!rr(re)}function wt(re){return re==="literal"}function He(...re){return re.length<=1&&re.every(we=>we==="literal")?"literal":re.every(we=>we==="constant"||we==="literal")?"constant":re.every(we=>we==="output"||we==="constant"||we==="literal")?"output":"input"}function de(re){return re.type==="string"||L(re.type)||re.type==="number"||re.type==="boolean"||re.type==="json"||re.type==="sql native"||re.type==="error"}function he(re){return re.as!==void 0?re.as:re.name}function ke(re){return re.type==="userType"}function Be(re){return Array.isArray(re)&&(re.length===0||typeof re[0]=="object"&&re[0]!==null&&!Array.isArray(re[0]))}function Ke(re){return re.type==="turtle"}function ot(re){return M(re.type)}function rt(re,we){return we.type==="string"}function Nt(re,we){return we.type==="number"}function Rt(re,we){return we.type==="boolean"}function Se(re,we){return we.type==="timestamp"}function it(re,we){return we.type==="date"}e.TD={isAtomic(re){return re!==void 0&&M(re.type)},isBasicAtomic(re){return re!==void 0&&de({type:re.type})},isString:re=>re?.type==="string",isNumber:re=>re?.type==="number",isBoolean:re=>re?.type==="boolean",isJSON:re=>re?.type==="json",isSQL:re=>re?.type==="sql native",isDate:re=>re?.type==="date",isTimestamp:re=>re?.type==="timestamp",isTimestamptz:re=>re?.type==="timestamptz",isAnyTimestamp(re){return re?.type==="timestamp"||re?.type==="timestamptz"},isTemporal(re){var we;const Ye=(we=re?.type)!==null&&we!==void 0?we:"";return L(Ye)},isError:re=>re?.type==="error",eq(re,we){if(re===void 0||we===void 0)return!1;function Ye(ze,mt){const vt={},Tt=ze.fields||[],at=mt.fields||[];if(Tt.length!==at.length)return!1;for(const Ct of Tt)if(Ct.name)vt[Ct.name]=Ct;else return!1;for(const Ct of at)if(!e.TD.eq(vt[Ct.name],Ct))return!1;return!0}return re.type==="array"&&we.type==="array"?re.elementTypeDef.type!==we.elementTypeDef.type?!1:re.elementTypeDef.type!=="record_element"&&we.elementTypeDef.type!=="record_element"?e.TD.eq(re.elementTypeDef,we.elementTypeDef):e.TD.isAtomic(re)&&e.TD.isAtomic(we)&&Ye(re,we):re.type==="record"&&we.type==="record"?e.TD.isAtomic(re)&&e.TD.isAtomic(we)&&Ye(re,we):re.type==="sql native"&&we.type==="sql native"?re.rawType!==void 0&&re.rawType===we.rawType:re.type===we.type}};function Ge(re,we){return re?we?{isCount:re.isCount||we.isCount}:re:we}})(uy)),uy}var mC;function ho(){if(mC)return Hr;mC=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.arg=t,Hr.spread=r,Hr.sql=s,Hr.constant=a,Hr.output=o,Hr.literal=c,Hr.variadicParam=d,Hr.param=l,Hr.makeParam=f,Hr.maxScalar=u,Hr.maxAggregate=p,Hr.anyExprType=h,Hr.maxUngroupedAggregate=m,Hr.maxAnalytic=x,Hr.minScalar=E,Hr.minAggregate=v,Hr.minAnalytic=g,Hr.overload=_,Hr.expandBlueprintMap=te,Hr.expandOverrideMapFromBase=Ee,Hr.def=le;const e=st();function t(ae){return{node:"function_parameter",name:ae}}function r(ae,Z=void 0,ce=void 0){return{node:"spread",e:ae,prefix:Z,suffix:ce}}function s(ae,...Z){const ce={node:"genericSQLExpr",kids:{args:[]},src:[]},ie=[...Z];let xe="";for(const me of ae){xe+=me;const Te=ie.shift();Te!==void 0&&(typeof Te=="string"?xe+=Te:(ce.src.push(xe),ce.kids.args.push(Te),xe=""))}return xe.length>0&&ce.src.push(xe),ce}function a(ae){return{...ae,evalSpace:"constant"}}function o(ae){return{...ae,evalSpace:"output"}}function c(ae){return{...ae,evalSpace:"literal"}}function d(ae,...Z){return{name:ae,isVariadic:!0,allowedTypes:Z}}function l(ae,...Z){return{name:ae,isVariadic:!1,allowedTypes:Z}}function f(ae,...Z){return{param:l(ae,...Z),arg:t(ae)}}function u(ae){return{...ae,expressionType:"scalar",evalSpace:"input"}}function p(ae){return{...ae,expressionType:"aggregate",evalSpace:"input"}}function h(ae){return{...ae,expressionType:void 0,evalSpace:"input"}}function m(ae){return{...ae,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function x(ae){return{...ae,expressionType:"aggregate_analytic",evalSpace:"input"}}function E(ae){return{...ae,expressionType:"scalar",evalSpace:"input"}}function v(ae){return{...ae,expressionType:"aggregate",evalSpace:"input"}}function g(ae){return{...ae,expressionType:"scalar_analytic",evalSpace:"input"}}function _(ae,Z,ce,ie){return{returnType:ae,params:Z,e:ce,needsWindowOrderBy:ie?.needsWindowOrderBy,between:ie?.between,isSymmetric:ie?.isSymmetric,supportsOrderBy:ie?.supportsOrderBy,defaultOrderByArgIndex:ie?.defaultOrderByArgIndex,supportsLimit:ie?.supportsLimit}}function S(ae,Z=!0,ce=!0){if(!Z&&ae==="any")throw new Error("Return type cannot include any");if(typeof ae=="string")return{type:ae};if("array"in ae){const ie=Z?S(ae.array,!0):S(ae.array,!1);return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}else if("record"in ae){const ie=[];for(const[xe,me]of Object.entries(ae.record)){const Te=Z?S(me,!0):S(me,!1);e.TD.isAtomic(Te)&&ie.push((0,e.mkFieldDef)(Te,xe))}return{type:"record",fields:ie}}else if("generic"in ae){if(!ce)throw new Error("Cannot use generic");return{type:"generic",generic:ae.generic}}else if("sql_native"in ae)return{type:"sql native",rawType:ae.sql_native};throw new Error("Cannot figure out type")}function R(ae){if(ae==="any")throw new Error("Cannot return any type");if(typeof ae=="string")return E({type:ae});if("array"in ae)return h(S(ae,!1));if("record"in ae)return h(S(ae,!1));if("generic"in ae)return E(S(ae,!1));if("literal"in ae)return c(E(S(ae.literal,!1)));if("constant"in ae)return a(E(S(ae.constant,!1)));if("dimension"in ae)return E(S(ae.dimension,!1));if("measure"in ae)return v(S(ae.measure,!1));if("sql_native"in ae)return h({type:"sql native",rawType:ae.sql_native});if("calculation"in ae)return g(S(ae.calculation,!1));throw new Error("Invalid function blueprint")}function C(ae){return typeof ae=="string"||"array"in ae||"record"in ae||"generic"in ae||"literal"in ae||"constant"in ae||"dimension"in ae||"measure"in ae||"calculation"in ae||"sql_native"in ae}function b(ae){return C(ae)?[ae]:Array.isArray(ae)?ae:C(ae.variadic)?[ae.variadic]:ae.variadic}function T(ae){if(typeof ae=="string")return h({type:ae});if("generic"in ae)return h(S(ae));if("literal"in ae)return c(u(S(ae.literal)));if("constant"in ae)return a(u(S(ae.constant)));if("dimension"in ae)return u(S(ae.dimension));if("measure"in ae)return p(S(ae.measure));if("array"in ae)return h(S(ae,!1));if("record"in ae)return h(S(ae,!1));if("sql_native"in ae)return h({type:"sql native",rawType:ae.sql_native});if("calculation"in ae)return x(S(ae.calculation));throw new Error("Invalid function blueprint")}function N(ae){return ae.map(Z=>T(Z))}function k(ae){return typeof ae!="string"&&"variadic"in ae}function L(ae,Z){return{name:ae,allowedTypes:N(b(Z)),isVariadic:k(Z)}}function F(ae){return Object.entries(ae).map(ce=>L(ce[0],ce[1]))}function M(ae){const Z=[],ce=[];let ie=ae;for(;ie.length>0;){const me=ie.indexOf("${");if(me===-1){Z.push(ie);break}const Te=ie.slice(0,me);ie=ie.slice(me);const ye=ie.indexOf("}");if(ye===-1){Z.push(Te+ie);break}const be=ie.slice(2,ye);ie=ie.slice(ye+1);const pe=be.startsWith("..."),Pe=be.endsWith(":"),qe=pe?be.slice(3):Pe?be.slice(0,-1):be,Ue={node:"function_parameter",name:qe};Z.push(Te),pe?ce.push({node:"spread",e:Ue,prefix:"",suffix:""}):Pe&&qe==="order_by"?ce.push({node:"aggregate_order_by"}):Pe&&qe==="limit"?ce.push({node:"aggregate_limit"}):ce.push(Ue)}return{node:"genericSQLExpr",kids:{args:ce},src:Z}}function q(ae,Z){return k(Z)?{node:"spread",e:{node:"function_parameter",name:ae},prefix:"",suffix:""}:{node:"function_parameter",name:ae}}function B(ae,Z){const ce=Object.entries(Z.takes),ie=ce.length>0?ce.length-1:0;return{node:"genericSQLExpr",kids:{args:ce.map(xe=>q(xe[0],xe[1]))},src:[`${ae}(`,...Array(ie).fill(","),")"]}}function P(ae){return"sql"in ae.impl?M(ae.impl.sql):"expr"in ae.impl?ae.impl.expr:B(ae.impl.function,ae)}function Y(ae){return{e:P(ae),between:ae.impl.between,needsWindowOrderBy:ae.impl.needsWindowOrderBy,defaultOrderByArgIndex:ae.impl.defaultOrderByArgIndex}}function ee(ae){if(ae!==void 0)return Object.entries(ae).map(([Z,ce])=>({name:Z,acceptibleTypes:ce.map(ie=>S(ie,!0,!1))}))}function oe(ae){return{returnType:R(ae.returns),params:F(ae.takes),isSymmetric:ae.isSymmetric,supportsOrderBy:ae.supportsOrderBy,supportsLimit:ae.supportsLimit,genericTypes:ee(ae.generic),...Y(ae)}}function I(ae){return"takes"in ae&&"returns"in ae&&"impl"in ae}function X(ae){return"function"in ae||"sql"in ae||"expr"in ae}function G(ae){return I(ae)?[oe(ae)]:Object.values(ae).flatMap(Z=>oe(Z))}function te(ae){const Z={};for(const ce in ae)Z[ce]=G(ae[ce]);return Z}function V(ae,Z){return[oe({...ae,impl:Z})]}function se(ae,Z,ce){if(X(ce)){if(!I(Z))throw new Error(`Malformed function override: ${ae}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(Z)})`);return V(Z,ce)}else{if(I(Z))throw new Error(`Malformed function override: ${ae}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(ce)})`);return Object.entries(ce).flatMap(([ie,xe])=>{const me=Z[ie];if(me===void 0)throw new Error(`Malformed function override: ${ae}. No overload named ${ie}`);return V(me,xe)})}}function Ee(ae,Z){const ce={};for(const ie in Z){if(!(ie in ae))throw new Error(`Malformed function override: ${ie}. No such function in Malloy standard`);ce[ie]=se(ie,ae[ie],Z[ie])}return ce}function*ve(ae){if(typeof ae!="string"){if("generic"in ae)yield ae;else if("record"in ae)for(const Z of Object.values(ae.record))yield*ve(Z);else for(const Z of["array","literal","measure","dimension","measure","constant","cacluation"])if(Z in ae){yield*ve(ae[Z]);return}}}function le(ae,Z,ce,ie={}){let xe=!1;const me={};for(const ye of Object.values(Z))for(const be of ve(ye))me[be.generic]=["any"],xe=!0;xe&&ie.generic===void 0&&(ie.generic=me);const Te={takes:Z,returns:ce,impl:{function:ae.toUpperCase()},...ie};return{[ae]:Te}}return Hr}var ly={},gC;function za(){return gC||(gC=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=e.MAX_DECIMAL38=e.MIN_DECIMAL38=e.MAX_INT128=e.MIN_INT128=e.MAX_INT64=e.MIN_INT64=e.MAX_INT32=e.MIN_INT32=void 0,e.inDays=s,e.qtz=a;const t=st();e.MIN_INT32=-2147483648,e.MAX_INT32=2147483647,e.MIN_INT64=BigInt("-9223372036854775808"),e.MAX_INT64=BigInt("9223372036854775807"),e.MIN_INT128=BigInt("-170141183460469231731687303715884105728"),e.MAX_INT128=BigInt("170141183460469231731687303715884105727"),e.MIN_DECIMAL38=BigInt("-99999999999999999999999999999999999999"),e.MAX_DECIMAL38=BigInt("99999999999999999999999999999999999999");const r=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=r.indexOf("day");function s(c){return r.indexOf(c)>=e.dayIndex}function a(c){const d=c.queryTimezone;if(!(d===void 0||d===c.systemTimezone))return d}class o{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsArraysInData=!0,this.hasTimestamptz=!1,this.readsNestedData=!0,this.orderByClause="ordinal",this.nullMatchesFunctionSignature=!0,this.supportsSelectReplace=!0,this.supportsBigIntPrecision=!0,this.supportsComplexFilteredSources=!0,this.supportsTempTables=!0,this.maxIdentifierLength=128,this.hasModOperator=!0,this.supportsLeftJoinUnnest=!0,this.requiresExplicitUnnestOrdering=!1,this.hasLateralColumnAliasInSelect=!1,this.supportsCountApprox=!1,this.supportsHyperLogLog=!1,this.supportsFullJoin=!0,this.nestedArrays=!0,this.compoundObjectInSchema=!0,this.booleanType="supported",this.likeEscape=!0,this.integerTypeMappings=[{min:BigInt(e.MIN_INT32),max:BigInt(e.MAX_INT32),numberType:"integer"},{min:e.MIN_INT64,max:e.MAX_INT64,numberType:"bigint"}]}sqlLateralJoinBag(d){throw this.cantPartitionWindowFunctionsOnExpressions?new Error(`Dialect '${this.name}' sets cantPartitionWindowFunctionsOnExpressions but does not implement sqlLateralJoinBag`):new Error("Internal error: sqlLateralJoinBag called but cantPartitionWindowFunctionsOnExpressions is false")}literalNumberType(d){if(!/^-?\d+$/.test(d))return{type:"number",numberType:"float"};const f=BigInt(d);for(const u of this.integerTypeMappings)if(f>=u.min&&f<=u.max)return{type:"number",numberType:u.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,l,f,u,p){var h;const m=(h=d?.hasTimestamptz)!==null&&h!==void 0?h:!1;return p==="date"?{node:"dateLiteral",literal:l,typeDef:{type:"date",timeframe:u!==void 0&&(0,t.isDateUnit)(u)?u:void 0}}:f&&m?{node:"timestamptzLiteral",literal:l,typeDef:{type:"timestamptz",timeframe:u},timezone:f}:f?{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u},timezone:f}:{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u}}}sqlTurtleOrderByClause(d){const l=d.map(f=>` ${f.field} ${f.dir.toUpperCase()}`);return" "+this.sqlOrderBy(l,"turtle")}sqlFinalStage(d,l){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(d){return this.castToString(`DATE(${d})`)}sqlLiteralNumber(d){return d}ignoreInProject(d){return!1}needsCivilTimeComputation(d,l,f,u){const p=["day","week","month","quarter","year"],h=l!==void 0&&p.includes(l),m=f!==void 0&&p.includes(f),x=a(u);return{needed:t.TD.isAnyTimestamp(d)&&(h||m)&&x!==void 0,tz:x}}sqlTruncAndOffset(d,l,f,u){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:h,tz:m}=this.needsCivilTimeComputation(d.typeDef,f,u?.unit,l);if(h&&m){const x=this.sqlConvertToCivilTime(d.sql,m,d.typeDef);let E=x.sql;const v=x.typeDef;return f&&(E=this.sqlTruncate(E,f,v,!0,m)),u&&(E=this.sqlOffsetTime(E,u.op,u.magnitude,u.unit,v,!0,m)),this.sqlConvertFromCivilTime(E,m,d.typeDef)}}let p=d.sql;return f&&(p=this.sqlTruncate(p,f,d.typeDef,!1,a(l))),u&&(p=this.sqlOffsetTime(p,u.op,u.magnitude,u.unit,d.typeDef,!1,a(l))),p}exprToSQL(d,l){switch(l.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(l);case"delta":{const f=l.kids.base;return f.node==="trunc"?this.sqlTruncAndOffset(f.e,d,f.units,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units}):this.sqlTruncAndOffset(f,d,void 0,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units})}case"trunc":return this.sqlTruncAndOffset(l.e,d,l.units);case"extract":return this.sqlTimeExtractExpr(d,l);case"cast":return this.sqlCast(d,l);case"regexpMatch":return this.sqlRegexpMatch(l);case"/":return this.divisionIsInteger?`${l.kids.left.sql}*1.0/${l.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${l.kids.left.sql},${l.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(d,l.literal);case"timestampLiteral":return this.sqlTimestampLiteral(d,l.literal,l.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(d,l.literal,l.timezone);case"stringLiteral":return this.sqlLiteralString(l.literal);case"numberLiteral":return this.sqlLiteralNumber(l.literal);case"regexpLiteral":return this.sqlLiteralRegexp(l.literal);case"recordLiteral":return this.sqlLiteralRecord(l);case"arrayLiteral":return this.sqlLiteralArray(l)}}sqlSumDistinct(d,l,f){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,l,f){return"sqlAggDistinct called but not implemented"}sqlSampleTable(d,l){if(l!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return d}sqlOrderBy(d,l){return`ORDER BY ${d.join(",")}`}sqlTzStr(d){return`"${d.queryTimezone}"`}sqlMakeUnnestKey(d,l){return this.concat(d,"'x'",l)}sqlStringAggDistinct(d,l,f){const u="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
1
+ import{_ as vO,r as D,j as w,$ as gr,R as N4,a0 as F4,a1 as oo}from"./index-15BOvhp0.js";import{r as I4,a as G2,b as k4,c as M4,d as P4,e as B4,f as $4,g as q4,h as j4,j as W2,k as V2,l as N0,m as Gh,n as U4,o as CO,p as Q4,q as H4,s as G4,t as I3,u as k3,v as M3,w as At}from"./index-Bb2jqquW.js";import{a as w1}from"./index.umd-DGBekgSu.js";var va={},ay={},Hr={},uy={},pC;function st(){return pC||(pC=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=s,e.exprHasKids=a,e.exprHasE=o,e.exprIsLeaf=c,e.isAsymmetricExpr=d,e.mkTemporal=f,e.isRawCast=u,e.isFilterExprType=p,e.isTimeLiteral=h,e.isParameterType=m,e.paramHasValue=x,e.expressionIsScalar=E,e.expressionIsAggregate=v,e.expressionIsUngroupedAggregate=g,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=R,e.isExpressionTypeLEQ=b,e.maxExpressionType=T,e.maxOfExpressionTypes=N,e.hasExpression=k,e.isTemporalType=L,e.isBasicAtomicType=F,e.isAtomicFieldType=M,e.canOrderBy=q,e.fieldIsIntrinsic=B,e.mkFieldDef=P,e.mkArrayDef=Y,e.mkArrayTypeDef=ee,e.isRepeatedRecordFunctionParam=oe,e.isRepeatedRecord=I,e.isRecordOrRepeatedRecord=X,e.isBasicArray=G,e.isMatrixOperation=te,e.isJoinable=V,e.isJoined=se,e.isJoinedSource=Ee,e.isDateUnit=ve,e.isTimestampUnit=le,e.isExtractUnit=ae,e.refIsStructDef=ce,e.segmentHasErrors=ie,e.structHasErrors=xe,e.isReduceSegment=me,e.isPartialSegment=Te,e.isProjectSegment=ye,e.isQuerySegment=be,e.isSamplingRows=pe,e.isSamplingPercent=Pe,e.isSamplingEnable=qe,e.isRawSegment=Ue,e.isIndexSegment=pt,e.bareFieldUsage=gt,e.isSegmentSQL=St,e.isSegmentSource=Ot,e.isSourceRegistryReference=Qt,e.sourceBase=br,e.isSourceDef=rr,e.isPersistableSourceDef=Le,e.isBaseTable=We,e.isLiteral=wt,e.mergeEvalSpaces=He,e.isBasicAtomic=de,e.getIdentifier=he,e.isUserTypeDef=ke,e.isCompoundArrayData=Be,e.isTurtle=Ke,e.isAtomic=ot,e.isValueString=rt,e.isValueNumber=Nt,e.isValueBoolean=Rt,e.isValueTimestamp=Se,e.isValueDate=it,e.mergeUniqueKeyRequirement=Ge;const t=Object.prototype.hasOwnProperty;function r(re,we){return t.call(re,we)?re[we]:void 0}function s(){return Object.create(null)}function a(re){return"kids"in re}function o(re){return"e"in re}function c(re){return!(a(re)||o(re))}function d(re){return re.node==="aggregate"&&["sum","avg","count","distinct"].includes(re.function)}function l(re){return re.node!=="arrayLiteral"&&re.node!=="recordLiteral"}function f(re,we){if(!("typeDef"in re)){const Ye=typeof we=="string"?{type:we}:we;if(l(re))return{...re,typeDef:{...Ye}}}return re}function u(re){return"dstSQLType"in re}function p(re){return["string","number","boolean","date","timestamp","timestamptz"].includes(re)}function h(re){return re.node==="dateLiteral"||re.node==="timestampLiteral"||re.node==="timestamptzLiteral"}function m(re){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(re)}function x(re){return re.value!==null}function E(re){return re===void 0||re==="scalar"}function v(re){return re==="aggregate"||re==="ungrouped_aggregate"}function g(re){return re==="ungrouped_aggregate"}function _(re){return re==="aggregate"||re==="ungrouped_aggregate"||re==="aggregate_analytic"}function S(re){return re==="aggregate"||re==="scalar_analytic"||re==="aggregate_analytic"||re==="ungrouped_aggregate"}function R(re){return re==="aggregate_analytic"||re==="scalar_analytic"}function C(re){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[re]}function b(re,we){return re===we||C(re)<C(we)}function T(re,we){let Ye="scalar";return(re==="aggregate"||we==="aggregate")&&(Ye="aggregate"),(re==="ungrouped_aggregate"||we==="ungrouped_aggregate")&&(Ye="ungrouped_aggregate"),(re==="scalar_analytic"||we==="scalar_analytic")&&(Ye="scalar_analytic"),(re==="aggregate_analytic"||we==="aggregate_analytic")&&(Ye="aggregate_analytic"),(re==="scalar_analytic"&&we==="aggregate"||re==="aggregate"&&we==="scalar_analytic")&&(Ye="aggregate_analytic"),Ye}function N(re){return re.reduce(T,"scalar")}function k(re){return"e"in re&&re.e!==void 0}function L(re){return re==="date"||re==="timestamp"||re==="timestamptz"}function F(re){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(re)}function M(re){return F(re)||re==="record"||re==="array"}function q(re){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(re)}function B(re){return M(re.type)&&!k(re)}function P(re,we){if(G(re))return Y(re.elementTypeDef,we);if(I(re)){const{type:ze,fields:mt,elementTypeDef:vt}=re;return{type:ze,fields:mt,elementTypeDef:vt,join:"many",name:we}}if(re.type==="record"){const{type:ze,fields:mt}=re;return{type:ze,fields:mt,join:"one",name:we}}const Ye={name:we,type:re.type};switch(re.type){case"sql native":return{...Ye,rawType:re.rawType};case"number":{const ze=re.numberType;return ze?{...Ye,numberType:ze}:Ye}case"date":{const ze=re.timeframe;return ze?{name:we,type:"date",timeframe:ze}:Ye}case"timestamp":{const ze={name:we,type:"timestamp"};return re.timeframe&&(ze.timeframe=re.timeframe),ze}case"timestamptz":{const ze={name:we,type:"timestamptz"};return re.timeframe&&(ze.timeframe=re.timeframe),ze}}return Ye}function Y(re,we){if(re.type==="record")return{type:"array",join:"many",name:we,elementTypeDef:{type:"record_element"},fields:re.fields};const Ye=P(re,"value");return{type:"array",join:"many",name:we,elementTypeDef:re,fields:[Ye,{...Ye,name:"each",e:{node:"field",path:["value"]}}]}}function ee(re){return re.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:re.fields}:{type:"array",elementTypeDef:re}}function oe(re){return re.type==="array"&&re.elementTypeDef.type==="record_element"}function I(re){return re.type==="array"&&re.elementTypeDef.type==="record_element"}function X(re){return re.type==="record"||re.type==="array"&&"elementTypeDef"in re&&re.elementTypeDef.type==="record_element"}function G(re){return re.type==="array"&&re.elementTypeDef.type!=="record_element"}function te(re){return["left","right","full","inner"].includes(re)}function V(re){return["composite","table","sql_select","query_source","virtual","array","record"].includes(re.type)}function se(re){return"join"in re}function Ee(re){return rr(re)&&se(re)}function ve(re){return["day","week","month","quarter","year"].includes(re)}function le(re){return ve(re)||["hour","minute","second"].includes(re)}function ae(re){return le(re)||re==="day_of_week"||re==="day_of_year"}var Z;(function(re){re.Date="date",re.Timestamp="timestamp",re.Number="number",re.String="string"})(Z||(e.ValueType=Z={}));function ce(re){return typeof re!="string"}function ie(re){return!!((re.type==="reduce"||re.type==="project"||re.type==="partial")&&(re.extendSource&&re.extendSource.some(we=>we.type==="error")||re.queryFields.some(we=>we.type==="error")))}function xe(re){return re.fields.some(we=>we.type==="error")}function me(re){return re.type==="reduce"}function Te(re){return re.type==="partial"}function ye(re){return re.type==="project"}function be(re){return ye(re)||me(re)}function pe(re){return re.rows!==void 0}function Pe(re){return re.percent!==void 0}function qe(re){return re.enable!==void 0}function Ue(re){return re.type==="raw"}function pt(re){return re.type==="index"}function gt(re){return re.uniqueKeyRequirement===void 0&&re.analyticFunctionUse===void 0}function St(re){return"sql"in re}function Ot(re){return"type"in re&&(re.type==="sql_select"||re.type==="query_source")}function Qt(re){return re.type==="source_registry_reference"}function br(re){return{...re}}function rr(re){return re.type==="table"||re.type==="sql_select"||re.type==="query_source"||re.type==="query_result"||re.type==="finalize"||re.type==="nest_source"||re.type==="virtual"||re.type==="composite"}function Le(re){return re.type==="sql_select"||re.type==="query_source"}function We(re){return Ee(re)?!1:!!rr(re)}function wt(re){return re==="literal"}function He(...re){return re.length<=1&&re.every(we=>we==="literal")?"literal":re.every(we=>we==="constant"||we==="literal")?"constant":re.every(we=>we==="output"||we==="constant"||we==="literal")?"output":"input"}function de(re){return re.type==="string"||L(re.type)||re.type==="number"||re.type==="boolean"||re.type==="json"||re.type==="sql native"||re.type==="error"}function he(re){return re.as!==void 0?re.as:re.name}function ke(re){return re.type==="userType"}function Be(re){return Array.isArray(re)&&(re.length===0||typeof re[0]=="object"&&re[0]!==null&&!Array.isArray(re[0]))}function Ke(re){return re.type==="turtle"}function ot(re){return M(re.type)}function rt(re,we){return we.type==="string"}function Nt(re,we){return we.type==="number"}function Rt(re,we){return we.type==="boolean"}function Se(re,we){return we.type==="timestamp"}function it(re,we){return we.type==="date"}e.TD={isAtomic(re){return re!==void 0&&M(re.type)},isBasicAtomic(re){return re!==void 0&&de({type:re.type})},isString:re=>re?.type==="string",isNumber:re=>re?.type==="number",isBoolean:re=>re?.type==="boolean",isJSON:re=>re?.type==="json",isSQL:re=>re?.type==="sql native",isDate:re=>re?.type==="date",isTimestamp:re=>re?.type==="timestamp",isTimestamptz:re=>re?.type==="timestamptz",isAnyTimestamp(re){return re?.type==="timestamp"||re?.type==="timestamptz"},isTemporal(re){var we;const Ye=(we=re?.type)!==null&&we!==void 0?we:"";return L(Ye)},isError:re=>re?.type==="error",eq(re,we){if(re===void 0||we===void 0)return!1;function Ye(ze,mt){const vt={},Tt=ze.fields||[],at=mt.fields||[];if(Tt.length!==at.length)return!1;for(const Ct of Tt)if(Ct.name)vt[Ct.name]=Ct;else return!1;for(const Ct of at)if(!e.TD.eq(vt[Ct.name],Ct))return!1;return!0}return re.type==="array"&&we.type==="array"?re.elementTypeDef.type!==we.elementTypeDef.type?!1:re.elementTypeDef.type!=="record_element"&&we.elementTypeDef.type!=="record_element"?e.TD.eq(re.elementTypeDef,we.elementTypeDef):e.TD.isAtomic(re)&&e.TD.isAtomic(we)&&Ye(re,we):re.type==="record"&&we.type==="record"?e.TD.isAtomic(re)&&e.TD.isAtomic(we)&&Ye(re,we):re.type==="sql native"&&we.type==="sql native"?re.rawType!==void 0&&re.rawType===we.rawType:re.type===we.type}};function Ge(re,we){return re?we?{isCount:re.isCount||we.isCount}:re:we}})(uy)),uy}var mC;function ho(){if(mC)return Hr;mC=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.arg=t,Hr.spread=r,Hr.sql=s,Hr.constant=a,Hr.output=o,Hr.literal=c,Hr.variadicParam=d,Hr.param=l,Hr.makeParam=f,Hr.maxScalar=u,Hr.maxAggregate=p,Hr.anyExprType=h,Hr.maxUngroupedAggregate=m,Hr.maxAnalytic=x,Hr.minScalar=E,Hr.minAggregate=v,Hr.minAnalytic=g,Hr.overload=_,Hr.expandBlueprintMap=te,Hr.expandOverrideMapFromBase=Ee,Hr.def=le;const e=st();function t(ae){return{node:"function_parameter",name:ae}}function r(ae,Z=void 0,ce=void 0){return{node:"spread",e:ae,prefix:Z,suffix:ce}}function s(ae,...Z){const ce={node:"genericSQLExpr",kids:{args:[]},src:[]},ie=[...Z];let xe="";for(const me of ae){xe+=me;const Te=ie.shift();Te!==void 0&&(typeof Te=="string"?xe+=Te:(ce.src.push(xe),ce.kids.args.push(Te),xe=""))}return xe.length>0&&ce.src.push(xe),ce}function a(ae){return{...ae,evalSpace:"constant"}}function o(ae){return{...ae,evalSpace:"output"}}function c(ae){return{...ae,evalSpace:"literal"}}function d(ae,...Z){return{name:ae,isVariadic:!0,allowedTypes:Z}}function l(ae,...Z){return{name:ae,isVariadic:!1,allowedTypes:Z}}function f(ae,...Z){return{param:l(ae,...Z),arg:t(ae)}}function u(ae){return{...ae,expressionType:"scalar",evalSpace:"input"}}function p(ae){return{...ae,expressionType:"aggregate",evalSpace:"input"}}function h(ae){return{...ae,expressionType:void 0,evalSpace:"input"}}function m(ae){return{...ae,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function x(ae){return{...ae,expressionType:"aggregate_analytic",evalSpace:"input"}}function E(ae){return{...ae,expressionType:"scalar",evalSpace:"input"}}function v(ae){return{...ae,expressionType:"aggregate",evalSpace:"input"}}function g(ae){return{...ae,expressionType:"scalar_analytic",evalSpace:"input"}}function _(ae,Z,ce,ie){return{returnType:ae,params:Z,e:ce,needsWindowOrderBy:ie?.needsWindowOrderBy,between:ie?.between,isSymmetric:ie?.isSymmetric,supportsOrderBy:ie?.supportsOrderBy,defaultOrderByArgIndex:ie?.defaultOrderByArgIndex,supportsLimit:ie?.supportsLimit}}function S(ae,Z=!0,ce=!0){if(!Z&&ae==="any")throw new Error("Return type cannot include any");if(typeof ae=="string")return{type:ae};if("array"in ae){const ie=Z?S(ae.array,!0):S(ae.array,!1);return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}else if("record"in ae){const ie=[];for(const[xe,me]of Object.entries(ae.record)){const Te=Z?S(me,!0):S(me,!1);e.TD.isAtomic(Te)&&ie.push((0,e.mkFieldDef)(Te,xe))}return{type:"record",fields:ie}}else if("generic"in ae){if(!ce)throw new Error("Cannot use generic");return{type:"generic",generic:ae.generic}}else if("sql_native"in ae)return{type:"sql native",rawType:ae.sql_native};throw new Error("Cannot figure out type")}function R(ae){if(ae==="any")throw new Error("Cannot return any type");if(typeof ae=="string")return E({type:ae});if("array"in ae)return h(S(ae,!1));if("record"in ae)return h(S(ae,!1));if("generic"in ae)return E(S(ae,!1));if("literal"in ae)return c(E(S(ae.literal,!1)));if("constant"in ae)return a(E(S(ae.constant,!1)));if("dimension"in ae)return E(S(ae.dimension,!1));if("measure"in ae)return v(S(ae.measure,!1));if("sql_native"in ae)return h({type:"sql native",rawType:ae.sql_native});if("calculation"in ae)return g(S(ae.calculation,!1));throw new Error("Invalid function blueprint")}function C(ae){return typeof ae=="string"||"array"in ae||"record"in ae||"generic"in ae||"literal"in ae||"constant"in ae||"dimension"in ae||"measure"in ae||"calculation"in ae||"sql_native"in ae}function b(ae){return C(ae)?[ae]:Array.isArray(ae)?ae:C(ae.variadic)?[ae.variadic]:ae.variadic}function T(ae){if(typeof ae=="string")return h({type:ae});if("generic"in ae)return h(S(ae));if("literal"in ae)return c(u(S(ae.literal)));if("constant"in ae)return a(u(S(ae.constant)));if("dimension"in ae)return u(S(ae.dimension));if("measure"in ae)return p(S(ae.measure));if("array"in ae)return h(S(ae,!1));if("record"in ae)return h(S(ae,!1));if("sql_native"in ae)return h({type:"sql native",rawType:ae.sql_native});if("calculation"in ae)return x(S(ae.calculation));throw new Error("Invalid function blueprint")}function N(ae){return ae.map(Z=>T(Z))}function k(ae){return typeof ae!="string"&&"variadic"in ae}function L(ae,Z){return{name:ae,allowedTypes:N(b(Z)),isVariadic:k(Z)}}function F(ae){return Object.entries(ae).map(ce=>L(ce[0],ce[1]))}function M(ae){const Z=[],ce=[];let ie=ae;for(;ie.length>0;){const me=ie.indexOf("${");if(me===-1){Z.push(ie);break}const Te=ie.slice(0,me);ie=ie.slice(me);const ye=ie.indexOf("}");if(ye===-1){Z.push(Te+ie);break}const be=ie.slice(2,ye);ie=ie.slice(ye+1);const pe=be.startsWith("..."),Pe=be.endsWith(":"),qe=pe?be.slice(3):Pe?be.slice(0,-1):be,Ue={node:"function_parameter",name:qe};Z.push(Te),pe?ce.push({node:"spread",e:Ue,prefix:"",suffix:""}):Pe&&qe==="order_by"?ce.push({node:"aggregate_order_by"}):Pe&&qe==="limit"?ce.push({node:"aggregate_limit"}):ce.push(Ue)}return{node:"genericSQLExpr",kids:{args:ce},src:Z}}function q(ae,Z){return k(Z)?{node:"spread",e:{node:"function_parameter",name:ae},prefix:"",suffix:""}:{node:"function_parameter",name:ae}}function B(ae,Z){const ce=Object.entries(Z.takes),ie=ce.length>0?ce.length-1:0;return{node:"genericSQLExpr",kids:{args:ce.map(xe=>q(xe[0],xe[1]))},src:[`${ae}(`,...Array(ie).fill(","),")"]}}function P(ae){return"sql"in ae.impl?M(ae.impl.sql):"expr"in ae.impl?ae.impl.expr:B(ae.impl.function,ae)}function Y(ae){return{e:P(ae),between:ae.impl.between,needsWindowOrderBy:ae.impl.needsWindowOrderBy,defaultOrderByArgIndex:ae.impl.defaultOrderByArgIndex}}function ee(ae){if(ae!==void 0)return Object.entries(ae).map(([Z,ce])=>({name:Z,acceptibleTypes:ce.map(ie=>S(ie,!0,!1))}))}function oe(ae){return{returnType:R(ae.returns),params:F(ae.takes),isSymmetric:ae.isSymmetric,supportsOrderBy:ae.supportsOrderBy,supportsLimit:ae.supportsLimit,genericTypes:ee(ae.generic),...Y(ae)}}function I(ae){return"takes"in ae&&"returns"in ae&&"impl"in ae}function X(ae){return"function"in ae||"sql"in ae||"expr"in ae}function G(ae){return I(ae)?[oe(ae)]:Object.values(ae).flatMap(Z=>oe(Z))}function te(ae){const Z={};for(const ce in ae)Z[ce]=G(ae[ce]);return Z}function V(ae,Z){return[oe({...ae,impl:Z})]}function se(ae,Z,ce){if(X(ce)){if(!I(Z))throw new Error(`Malformed function override: ${ae}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(Z)})`);return V(Z,ce)}else{if(I(Z))throw new Error(`Malformed function override: ${ae}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(ce)})`);return Object.entries(ce).flatMap(([ie,xe])=>{const me=Z[ie];if(me===void 0)throw new Error(`Malformed function override: ${ae}. No overload named ${ie}`);return V(me,xe)})}}function Ee(ae,Z){const ce={};for(const ie in Z){if(!(ie in ae))throw new Error(`Malformed function override: ${ie}. No such function in Malloy standard`);ce[ie]=se(ie,ae[ie],Z[ie])}return ce}function*ve(ae){if(typeof ae!="string"){if("generic"in ae)yield ae;else if("record"in ae)for(const Z of Object.values(ae.record))yield*ve(Z);else for(const Z of["array","literal","measure","dimension","measure","constant","cacluation"])if(Z in ae){yield*ve(ae[Z]);return}}}function le(ae,Z,ce,ie={}){let xe=!1;const me={};for(const ye of Object.values(Z))for(const be of ve(ye))me[be.generic]=["any"],xe=!0;xe&&ie.generic===void 0&&(ie.generic=me);const Te={takes:Z,returns:ce,impl:{function:ae.toUpperCase()},...ie};return{[ae]:Te}}return Hr}var ly={},gC;function za(){return gC||(gC=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=e.MAX_DECIMAL38=e.MIN_DECIMAL38=e.MAX_INT128=e.MIN_INT128=e.MAX_INT64=e.MIN_INT64=e.MAX_INT32=e.MIN_INT32=void 0,e.inDays=s,e.qtz=a;const t=st();e.MIN_INT32=-2147483648,e.MAX_INT32=2147483647,e.MIN_INT64=BigInt("-9223372036854775808"),e.MAX_INT64=BigInt("9223372036854775807"),e.MIN_INT128=BigInt("-170141183460469231731687303715884105728"),e.MAX_INT128=BigInt("170141183460469231731687303715884105727"),e.MIN_DECIMAL38=BigInt("-99999999999999999999999999999999999999"),e.MAX_DECIMAL38=BigInt("99999999999999999999999999999999999999");const r=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=r.indexOf("day");function s(c){return r.indexOf(c)>=e.dayIndex}function a(c){const d=c.queryTimezone;if(!(d===void 0||d===c.systemTimezone))return d}class o{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsArraysInData=!0,this.hasTimestamptz=!1,this.readsNestedData=!0,this.orderByClause="ordinal",this.nullMatchesFunctionSignature=!0,this.supportsSelectReplace=!0,this.supportsBigIntPrecision=!0,this.supportsComplexFilteredSources=!0,this.supportsTempTables=!0,this.maxIdentifierLength=128,this.hasModOperator=!0,this.supportsLeftJoinUnnest=!0,this.requiresExplicitUnnestOrdering=!1,this.hasLateralColumnAliasInSelect=!1,this.supportsCountApprox=!1,this.supportsHyperLogLog=!1,this.supportsFullJoin=!0,this.nestedArrays=!0,this.compoundObjectInSchema=!0,this.booleanType="supported",this.likeEscape=!0,this.integerTypeMappings=[{min:BigInt(e.MIN_INT32),max:BigInt(e.MAX_INT32),numberType:"integer"},{min:e.MIN_INT64,max:e.MAX_INT64,numberType:"bigint"}]}sqlLateralJoinBag(d){throw this.cantPartitionWindowFunctionsOnExpressions?new Error(`Dialect '${this.name}' sets cantPartitionWindowFunctionsOnExpressions but does not implement sqlLateralJoinBag`):new Error("Internal error: sqlLateralJoinBag called but cantPartitionWindowFunctionsOnExpressions is false")}literalNumberType(d){if(!/^-?\d+$/.test(d))return{type:"number",numberType:"float"};const f=BigInt(d);for(const u of this.integerTypeMappings)if(f>=u.min&&f<=u.max)return{type:"number",numberType:u.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,l,f,u,p){var h;const m=(h=d?.hasTimestamptz)!==null&&h!==void 0?h:!1;return p==="date"?{node:"dateLiteral",literal:l,typeDef:{type:"date",timeframe:u!==void 0&&(0,t.isDateUnit)(u)?u:void 0}}:f&&m?{node:"timestamptzLiteral",literal:l,typeDef:{type:"timestamptz",timeframe:u},timezone:f}:f?{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u},timezone:f}:{node:"timestampLiteral",literal:l,typeDef:{type:"timestamp",timeframe:u}}}sqlTurtleOrderByClause(d){const l=d.map(f=>` ${f.field} ${f.dir.toUpperCase()}`);return" "+this.sqlOrderBy(l,"turtle")}sqlFinalStage(d,l){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(d){return this.castToString(`DATE(${d})`)}sqlLiteralNumber(d){return d}ignoreInProject(d){return!1}needsCivilTimeComputation(d,l,f,u){const p=["day","week","month","quarter","year"],h=l!==void 0&&p.includes(l),m=f!==void 0&&p.includes(f),x=a(u);return{needed:t.TD.isAnyTimestamp(d)&&(h||m)&&x!==void 0,tz:x}}sqlTruncAndOffset(d,l,f,u){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:h,tz:m}=this.needsCivilTimeComputation(d.typeDef,f,u?.unit,l);if(h&&m){const x=this.sqlConvertToCivilTime(d.sql,m,d.typeDef);let E=x.sql;const v=x.typeDef;return f&&(E=this.sqlTruncate(E,f,v,!0,m)),u&&(E=this.sqlOffsetTime(E,u.op,u.magnitude,u.unit,v,!0,m)),this.sqlConvertFromCivilTime(E,m,d.typeDef)}}let p=d.sql;return f&&(p=this.sqlTruncate(p,f,d.typeDef,!1,a(l))),u&&(p=this.sqlOffsetTime(p,u.op,u.magnitude,u.unit,d.typeDef,!1,a(l))),p}exprToSQL(d,l){switch(l.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(l);case"delta":{const f=l.kids.base;return f.node==="trunc"?this.sqlTruncAndOffset(f.e,d,f.units,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units}):this.sqlTruncAndOffset(f,d,void 0,{op:l.op,magnitude:l.kids.delta.sql,unit:l.units})}case"trunc":return this.sqlTruncAndOffset(l.e,d,l.units);case"extract":return this.sqlTimeExtractExpr(d,l);case"cast":return this.sqlCast(d,l);case"regexpMatch":return this.sqlRegexpMatch(l);case"/":return this.divisionIsInteger?`${l.kids.left.sql}*1.0/${l.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${l.kids.left.sql},${l.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(d,l.literal);case"timestampLiteral":return this.sqlTimestampLiteral(d,l.literal,l.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(d,l.literal,l.timezone);case"stringLiteral":return this.sqlLiteralString(l.literal);case"numberLiteral":return this.sqlLiteralNumber(l.literal);case"regexpLiteral":return this.sqlLiteralRegexp(l.literal);case"recordLiteral":return this.sqlLiteralRecord(l);case"arrayLiteral":return this.sqlLiteralArray(l)}}sqlSumDistinct(d,l,f){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,l,f){return"sqlAggDistinct called but not implemented"}sqlSampleTable(d,l){if(l!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return d}sqlOrderBy(d,l){return`ORDER BY ${d.join(",")}`}sqlTzStr(d){return`"${d.queryTimezone}"`}sqlMakeUnnestKey(d,l){return this.concat(d,"'x'",l)}sqlStringAggDistinct(d,l,f){const u="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
2
2
  STRING_AGG(DISTINCT ${`concat('${u}', ${d}, '${p}', ${l})`}${f.length>0?","+f:""}),
3
3
  '${u}.*?${p}',
4
4
  ''