@malloy-publisher/server 0.0.223 → 0.0.225

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.
Files changed (43) hide show
  1. package/dist/app/api-doc.yaml +75 -0
  2. package/dist/app/assets/{EnvironmentPage-3wCdljov.js → EnvironmentPage-DYTeXDll.js} +1 -1
  3. package/dist/app/assets/{HomePage-K0GHwqq2.js → HomePage-pDK2BPJY.js} +1 -1
  4. package/dist/app/assets/{LightMode-CwU3kN4I.js → LightMode-C2bwGPY1.js} +1 -1
  5. package/dist/app/assets/{MainPage-CTncHE5T.js → MainPage-WtBulMH_.js} +2 -2
  6. package/dist/app/assets/{MaterializationsPage-DziAOD6-.js → MaterializationsPage-hMgOtflG.js} +1 -1
  7. package/dist/app/assets/{ModelPage-XrS2jXEc.js → ModelPage-B2N5kYII.js} +1 -1
  8. package/dist/app/assets/{PackagePage-BkwgFxG8.js → PackagePage-CEN90nQG.js} +1 -1
  9. package/dist/app/assets/{RouteError-9cIQga6p.js → RouteError-BG2c5Zf0.js} +1 -1
  10. package/dist/app/assets/{ThemeEditorPage-DWiCRfEe.js → ThemeEditorPage-DNfeUwEZ.js} +1 -1
  11. package/dist/app/assets/{WorkbookPage-Ce7FM_Po.js → WorkbookPage-NKI1BhFS.js} +1 -1
  12. package/dist/app/assets/{core-D9Hl0IDY.es-CrO01m4X.js → core-C6anj5c0.es-DDLHqpzt.js} +1 -1
  13. package/dist/app/assets/{index-D2sm5RBA.js → index-C6gZ6sSY.js} +5 -5
  14. package/dist/app/assets/{index-CtQm7kvp.js → index-CzNqKMVl.js} +1 -1
  15. package/dist/app/assets/{index-wJU_kzl2.js → index-DMQtnaf4.js} +2 -2
  16. package/dist/app/assets/{index-Dz8hgkmy.js → index-JXgvyZna.js} +1 -1
  17. package/dist/app/assets/{index-8E2uLeV9.js → index-OEjKNSYb.js} +2 -2
  18. package/dist/app/index.html +1 -1
  19. package/dist/server.mjs +411 -26
  20. package/dist/sshcrypto-8m50vnmb.node +0 -0
  21. package/package.json +12 -12
  22. package/src/controller/materialization.controller.spec.ts +72 -0
  23. package/src/controller/materialization.controller.ts +75 -11
  24. package/src/mcp/skills/skills_bundle.json +1 -1
  25. package/src/service/build_plan.spec.ts +119 -0
  26. package/src/service/build_plan.ts +143 -0
  27. package/src/service/environment.ts +3 -3
  28. package/src/service/freshness.spec.ts +183 -0
  29. package/src/service/freshness.ts +112 -0
  30. package/src/service/manifest_loader.spec.ts +33 -0
  31. package/src/service/manifest_loader.ts +17 -8
  32. package/src/service/materialization_cron_gate.spec.ts +61 -17
  33. package/src/service/materialization_service.spec.ts +42 -0
  34. package/src/service/materialization_service.ts +46 -3
  35. package/src/service/materialization_test_fixtures.ts +47 -14
  36. package/src/service/model.ts +54 -4
  37. package/src/service/package.ts +173 -35
  38. package/src/storage/DatabaseInterface.ts +24 -0
  39. package/tests/fixtures/persist-multi-level/data/orders.csv +5 -0
  40. package/tests/fixtures/persist-multi-level/multi_level.malloy +18 -0
  41. package/tests/fixtures/persist-multi-level/publisher.json +5 -0
  42. package/tests/integration/materialization/freshness_gate.integration.spec.ts +292 -0
  43. package/tests/integration/materialization/reference_manifest.integration.spec.ts +251 -0
@@ -1 +1 @@
1
- import{aI as a}from"./index-D2sm5RBA.js";import{r as f}from"./index-w_0OQJgZ.js";function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(e,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var s=f();const p=a(s),l=c({__proto__:null,default:p},[s]);export{s as d,l as i};
1
+ import{aI as a}from"./index-C6gZ6sSY.js";import{r as f}from"./index-w_0OQJgZ.js";function c(t,n){for(var o=0;o<n.length;o++){const e=n[o];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(e,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var s=f();const p=a(s),l=c({__proto__:null,default:p},[s]);export{s as d,l as i};
@@ -1,4 +1,4 @@
1
- import{aF as KF,r as L,j as O,ae as Ht,R as JF,aG as XF,aH as is}from"./index-D2sm5RBA.js";import{r as Zd,a as dA,d as ft}from"./index-Dz8hgkmy.js";import{r as za}from"./index-w_0OQJgZ.js";import{d as CU}from"./index-CtQm7kvp.js";import{MalloyRenderer as ZF,isCoreVizPluginInstance as AU}from"./index-8E2uLeV9.js";var vo={},K3={},xr={},J3={},mR;function Ge(){return mR||(mR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=i,e.exprHasKids=o,e.exprHasE=s,e.exprIsLeaf=a,e.isAsymmetricExpr=l,e.mkTemporal=d,e.isRawCast=c,e.isFilterExprType=h,e.isTimeLiteral=f,e.isParameterType=p,e.paramHasValue=x,e.activeName=m,e.expressionIsScalar=g,e.expressionIsAggregate=E,e.expressionIsUngroupedAggregate=v,e.expressionInvolvesAggregate=S,e.expressionIsCalculation=C,e.expressionIsAnalytic=T,e.isExpressionTypeLEQ=_,e.maxExpressionType=R,e.maxOfExpressionTypes=D,e.hasExpression=w,e.isTemporalType=N,e.isBasicAtomicType=I,e.isAtomicFieldType=k,e.canOrderBy=$,e.fieldIsIntrinsic=J,e.mkFieldDef=re,e.mkArrayDef=ie,e.mkArrayTypeDef=oe,e.isRepeatedRecordFunctionParam=U,e.isRepeatedRecord=ee,e.isRecordOrRepeatedRecord=K,e.isBasicArray=te,e.isMatrixOperation=q,e.isJoinable=H,e.isJoined=Q,e.isJoinedSource=M,e.isDateUnit=j,e.isTimestampUnit=P,e.isExtractUnit=V,e.refIsStructDef=ae,e.segmentHasErrors=ce,e.structHasErrors=le,e.isReduceSegment=se,e.isPartialSegment=fe,e.isProjectSegment=pe,e.isQuerySegment=ye,e.isSamplingRows=Ce,e.isSamplingPercent=me,e.isSamplingEnable=_e,e.isRawSegment=we,e.isIndexSegment=Ke,e.bareFieldUsage=rt,e.fieldUsageFrom=ge,e.givenUsageFrom=Ee,e.mkRefSummary=Pe,e.mapFieldUsage=ke,e.setFieldUsage=Me,e.isSegmentSQL=Xe,e.isSegmentSource=at,e.isSourceRegistryReference=Qe,e.sourceBase=Et,e.isSourceDef=mt,e.isPersistableSourceDef=Te,e.isBaseTable=ze,e.isLiteral=st,e.mergeEvalSpaces=de,e.isBasicAtomic=he,e.isUserTypeDef=ve,e.isCompoundArrayData=be,e.isTurtle=Be,e.isAtomic=Ie,e.isValueString=We,e.isValueNumber=nt,e.isValueBoolean=gt,e.isValueTimestamp=yt,e.isValueDate=ut,e.mergeUniqueKeyRequirement=et;const t=Object.prototype.hasOwnProperty;function r(ne,Ae){return t.call(ne,Ae)?ne[Ae]:void 0}function i(){return Object.create(null)}function o(ne){return"kids"in ne}function s(ne){return"e"in ne}function a(ne){return!(o(ne)||s(ne))}function l(ne){return ne.node==="aggregate"&&["sum","avg","count","distinct"].includes(ne.function)}function u(ne){return ne.node!=="arrayLiteral"&&ne.node!=="recordLiteral"}function d(ne,Ae){if(!("typeDef"in ne)){const Ne=typeof Ae=="string"?{type:Ae}:Ae;if(u(ne))return{...ne,typeDef:{...Ne}}}return ne}function c(ne){return"dstSQLType"in ne}function h(ne){return["string","number","boolean","date","timestamp","timestamptz"].includes(ne)}function f(ne){return ne.node==="dateLiteral"||ne.node==="timestampLiteral"||ne.node==="timestamptzLiteral"}function p(ne){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ne)}function x(ne){return ne.value!==null}function m(ne){var Ae;return(Ae=ne.as)!==null&&Ae!==void 0?Ae:ne.name}function g(ne){return ne===void 0||ne==="scalar"}function E(ne){return ne==="aggregate"||ne==="ungrouped_aggregate"}function v(ne){return ne==="ungrouped_aggregate"}function S(ne){return ne==="aggregate"||ne==="ungrouped_aggregate"||ne==="aggregate_analytic"}function C(ne){return ne==="aggregate"||ne==="scalar_analytic"||ne==="aggregate_analytic"||ne==="ungrouped_aggregate"}function T(ne){return ne==="aggregate_analytic"||ne==="scalar_analytic"}function b(ne){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ne]}function _(ne,Ae){return ne===Ae||b(ne)<b(Ae)}function R(ne,Ae){let Ne="scalar";return(ne==="aggregate"||Ae==="aggregate")&&(Ne="aggregate"),(ne==="ungrouped_aggregate"||Ae==="ungrouped_aggregate")&&(Ne="ungrouped_aggregate"),(ne==="scalar_analytic"||Ae==="scalar_analytic")&&(Ne="scalar_analytic"),(ne==="aggregate_analytic"||Ae==="aggregate_analytic")&&(Ne="aggregate_analytic"),(ne==="scalar_analytic"&&Ae==="aggregate"||ne==="aggregate"&&Ae==="scalar_analytic")&&(Ne="aggregate_analytic"),Ne}function D(ne){return ne.reduce(R,"scalar")}function w(ne){return"e"in ne&&ne.e!==void 0}function N(ne){return ne==="date"||ne==="timestamp"||ne==="timestamptz"}function I(ne){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ne)}function k(ne){return I(ne)||ne==="record"||ne==="array"}function $(ne){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ne)}function J(ne){return k(ne.type)&&!w(ne)}function re(ne,Ae){if(te(ne))return ie(ne.elementTypeDef,Ae);if(ee(ne)){const{type:je,fields:it,elementTypeDef:dt}=ne;return{type:je,fields:it,elementTypeDef:dt,join:"many",name:Ae}}if(ne.type==="record"){const{type:je,fields:it}=ne;return{type:je,fields:it,join:"one",name:Ae}}const Ne={name:Ae,type:ne.type};switch(ne.type){case"sql native":return{...Ne,rawType:ne.rawType};case"number":{const je=ne.numberType;return je?{...Ne,numberType:je}:Ne}case"date":{const je=ne.timeframe;return je?{name:Ae,type:"date",timeframe:je}:Ne}case"timestamp":{const je={name:Ae,type:"timestamp"};return ne.timeframe&&(je.timeframe=ne.timeframe),je}case"timestamptz":{const je={name:Ae,type:"timestamptz"};return ne.timeframe&&(je.timeframe=ne.timeframe),je}}return Ne}function ie(ne,Ae){if(ne.type==="record")return{type:"array",join:"many",name:Ae,elementTypeDef:{type:"record_element"},fields:ne.fields};const Ne=re(ne,"value");return{type:"array",join:"many",name:Ae,elementTypeDef:ne,fields:[Ne,{...Ne,name:"each",e:{node:"field",path:["value"]}}]}}function oe(ne){return ne.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ne.fields}:{type:"array",elementTypeDef:ne}}function U(ne){return ne.type==="array"&&ne.elementTypeDef.type==="record_element"}function ee(ne){return ne.type==="array"&&ne.elementTypeDef.type==="record_element"}function K(ne){return ne.type==="record"||ne.type==="array"&&"elementTypeDef"in ne&&ne.elementTypeDef.type==="record_element"}function te(ne){return ne.type==="array"&&ne.elementTypeDef.type!=="record_element"}function q(ne){return["left","right","full","inner"].includes(ne)}function H(ne){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ne.type)}function Q(ne){return"join"in ne}function M(ne){return mt(ne)&&Q(ne)}function j(ne){return["day","week","month","quarter","year"].includes(ne)}function P(ne){return j(ne)||["hour","minute","second"].includes(ne)}function V(ne){return P(ne)||ne==="day_of_week"||ne==="day_of_year"}var Z;(function(ne){ne.Date="date",ne.Timestamp="timestamp",ne.Number="number",ne.String="string"})(Z||(e.ValueType=Z={}));function ae(ne){return typeof ne!="string"}function ce(ne){return!!((ne.type==="reduce"||ne.type==="project"||ne.type==="partial")&&(ne.extendSource&&ne.extendSource.some(Ae=>Ae.type==="error")||ne.queryFields.some(Ae=>Ae.type==="error")))}function le(ne){return ne.fields.some(Ae=>Ae.type==="error")}function se(ne){return ne.type==="reduce"}function fe(ne){return ne.type==="partial"}function pe(ne){return ne.type==="project"}function ye(ne){return pe(ne)||se(ne)}function Ce(ne){return ne.rows!==void 0}function me(ne){return ne.percent!==void 0}function _e(ne){return ne.enable!==void 0}function we(ne){return ne.type==="raw"}function Ke(ne){return ne.type==="index"}function rt(ne){return ne.uniqueKeyRequirement===void 0&&ne.analyticFunctionUse===void 0}function ge(ne){var Ae;return(Ae=ne?.fieldUsage)!==null&&Ae!==void 0?Ae:[]}function Ee(ne){var Ae;return(Ae=ne?.givenUsage)!==null&&Ae!==void 0?Ae:[]}function Pe({fieldUsage:ne,givenUsage:Ae}){if(!(ne===void 0&&Ae===void 0))return{fieldUsage:ne??[],...Ae&&{givenUsage:Ae}}}function ke(ne,Ae){return ne&&{...ne,fieldUsage:ne.fieldUsage.map(Ae)}}function Me(ne,Ae){ne.refSummary?ne.refSummary.fieldUsage=Ae:ne.refSummary={fieldUsage:Ae}}function Xe(ne){return"sql"in ne}function at(ne){return"type"in ne&&(ne.type==="sql_select"||ne.type==="query_source")}function Qe(ne){return ne.type==="source_registry_reference"}function Et(ne){return{...ne}}function mt(ne){return ne.type==="table"||ne.type==="sql_select"||ne.type==="query_source"||ne.type==="query_result"||ne.type==="finalize"||ne.type==="nest_source"||ne.type==="virtual"||ne.type==="composite"}function Te(ne){return ne.type==="sql_select"||ne.type==="query_source"}function ze(ne){return M(ne)?!1:!!mt(ne)}function st(ne){return ne==="literal"}function de(...ne){return ne.length<=1&&ne.every(Ae=>Ae==="literal")?"literal":ne.every(Ae=>Ae==="constant"||Ae==="literal")?"constant":ne.every(Ae=>Ae==="output"||Ae==="constant"||Ae==="literal")?"output":"input"}function he(ne){return ne.type==="string"||N(ne.type)||ne.type==="number"||ne.type==="boolean"||ne.type==="json"||ne.type==="sql native"||ne.type==="error"}function ve(ne){return ne.type==="userType"}function be(ne){return Array.isArray(ne)&&(ne.length===0||typeof ne[0]=="object"&&ne[0]!==null&&!Array.isArray(ne[0]))}function Be(ne){return ne.type==="turtle"}function Ie(ne){return k(ne.type)}function We(ne,Ae){return Ae.type==="string"}function nt(ne,Ae){return Ae.type==="number"}function gt(ne,Ae){return Ae.type==="boolean"}function yt(ne,Ae){return Ae.type==="timestamp"}function ut(ne,Ae){return Ae.type==="date"}e.TD={isAtomic(ne){return ne!==void 0&&k(ne.type)},isBasicAtomic(ne){return ne!==void 0&&he({type:ne.type})},isString:ne=>ne?.type==="string",isNumber:ne=>ne?.type==="number",isBoolean:ne=>ne?.type==="boolean",isJSON:ne=>ne?.type==="json",isSQL:ne=>ne?.type==="sql native",isDate:ne=>ne?.type==="date",isTimestamp:ne=>ne?.type==="timestamp",isTimestamptz:ne=>ne?.type==="timestamptz",isAnyTimestamp(ne){return ne?.type==="timestamp"||ne?.type==="timestamptz"},isTemporal(ne){var Ae;const Ne=(Ae=ne?.type)!==null&&Ae!==void 0?Ae:"";return N(Ne)},isError:ne=>ne?.type==="error",atomicDef(ne){if(!e.TD.isAtomic(ne))return{type:"error"};switch(ne.type){case"array":return ee(ne)?{type:"array",elementTypeDef:ne.elementTypeDef,fields:ne.fields}:{type:"array",elementTypeDef:ne.elementTypeDef};case"record":return{type:"record",fields:ne.fields};case"number":return ne.numberType?{type:"number",numberType:ne.numberType}:{type:"number"};case"sql native":return ne.rawType?{type:"sql native",rawType:ne.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ne.timeframe?{type:ne.type,timeframe:ne.timeframe}:{type:ne.type};default:return{type:ne.type}}},eq(ne,Ae){if(ne===void 0||Ae===void 0)return!1;function Ne(je,it){const dt={},lt=je.fields||[],xt=it.fields||[];if(lt.length!==xt.length)return!1;for(const It of lt)if(It.name)dt[It.name]=It;else return!1;for(const It of xt)if(!e.TD.eq(dt[It.name],It))return!1;return!0}return ne.type==="array"&&Ae.type==="array"?ne.elementTypeDef.type!==Ae.elementTypeDef.type?!1:ne.elementTypeDef.type!=="record_element"&&Ae.elementTypeDef.type!=="record_element"?e.TD.eq(ne.elementTypeDef,Ae.elementTypeDef):e.TD.isAtomic(ne)&&e.TD.isAtomic(Ae)&&Ne(ne,Ae):ne.type==="record"&&Ae.type==="record"?e.TD.isAtomic(ne)&&e.TD.isAtomic(Ae)&&Ne(ne,Ae):ne.type==="sql native"&&Ae.type==="sql native"?ne.rawType!==void 0&&ne.rawType===Ae.rawType:ne.type===Ae.type}};function et(ne,Ae){return ne?Ae?{isCount:ne.isCount||Ae.isCount}:ne:Ae}})(J3)),J3}var gR;function ds(){if(gR)return xr;gR=1,Object.defineProperty(xr,"__esModule",{value:!0}),xr.arg=t,xr.spread=r,xr.sql=i,xr.constant=o,xr.output=s,xr.literal=a,xr.variadicParam=l,xr.param=u,xr.makeParam=d,xr.maxScalar=c,xr.maxAggregate=h,xr.anyExprType=f,xr.maxUngroupedAggregate=p,xr.maxAnalytic=x,xr.minScalar=m,xr.minAggregate=g,xr.minAnalytic=E,xr.overload=v,xr.expandBlueprintMap=te,xr.expandOverrideMapFromBase=Q,xr.def=j;const e=Ge();function t(P){return{node:"function_parameter",name:P}}function r(P,V=void 0,Z=void 0){return{node:"spread",e:P,prefix:V,suffix:Z}}function i(P,...V){const Z={node:"genericSQLExpr",kids:{args:[]},src:[]},ae=[...V];let ce="";for(const le of P){ce+=le;const se=ae.shift();se!==void 0&&(typeof se=="string"?ce+=se:(Z.src.push(ce),Z.kids.args.push(se),ce=""))}return ce.length>0&&Z.src.push(ce),Z}function o(P){return{...P,evalSpace:"constant"}}function s(P){return{...P,evalSpace:"output"}}function a(P){return{...P,evalSpace:"literal"}}function l(P,...V){return{name:P,isVariadic:!0,allowedTypes:V}}function u(P,...V){return{name:P,isVariadic:!1,allowedTypes:V}}function d(P,...V){return{param:u(P,...V),arg:t(P)}}function c(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function h(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function f(P){return{...P,expressionType:void 0,evalSpace:"input"}}function p(P){return{...P,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function x(P){return{...P,expressionType:"aggregate_analytic",evalSpace:"input"}}function m(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function g(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function E(P){return{...P,expressionType:"scalar_analytic",evalSpace:"input"}}function v(P,V,Z,ae){return{returnType:P,params:V,e:Z,needsWindowOrderBy:ae?.needsWindowOrderBy,between:ae?.between,isSymmetric:ae?.isSymmetric,supportsOrderBy:ae?.supportsOrderBy,defaultOrderByArgIndex:ae?.defaultOrderByArgIndex,supportsLimit:ae?.supportsLimit}}function S(P,V=!0,Z=!0){if(!V&&P==="any")throw new Error("Return type cannot include any");if(typeof P=="string")return{type:P};if("array"in P){const ae=V?S(P.array,!0):S(P.array,!1);return ae.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ae.fields}:{type:"array",elementTypeDef:ae}}else if("record"in P){const ae=[];for(const[ce,le]of Object.entries(P.record)){const se=V?S(le,!0):S(le,!1);e.TD.isAtomic(se)&&ae.push((0,e.mkFieldDef)(se,ce))}return{type:"record",fields:ae}}else if("generic"in P){if(!Z)throw new Error("Cannot use generic");return{type:"generic",generic:P.generic}}else if("sql_native"in P)return{type:"sql native",rawType:P.sql_native};throw new Error("Cannot figure out type")}function C(P){if(P==="any")throw new Error("Cannot return any type");if(typeof P=="string")return m({type:P});if("array"in P)return f(S(P,!1));if("record"in P)return f(S(P,!1));if("generic"in P)return m(S(P,!1));if("literal"in P)return a(m(S(P.literal,!1)));if("constant"in P)return o(m(S(P.constant,!1)));if("dimension"in P)return m(S(P.dimension,!1));if("measure"in P)return g(S(P.measure,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return E(S(P.calculation,!1));throw new Error("Invalid function blueprint")}function T(P){return typeof P=="string"||"array"in P||"record"in P||"generic"in P||"literal"in P||"constant"in P||"dimension"in P||"measure"in P||"calculation"in P||"sql_native"in P}function b(P){return T(P)?[P]:Array.isArray(P)?P:T(P.variadic)?[P.variadic]:P.variadic}function _(P){if(typeof P=="string")return f({type:P});if("generic"in P)return f(S(P));if("literal"in P)return a(c(S(P.literal)));if("constant"in P)return o(c(S(P.constant)));if("dimension"in P)return c(S(P.dimension));if("measure"in P)return h(S(P.measure));if("array"in P)return f(S(P,!1));if("record"in P)return f(S(P,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return x(S(P.calculation));throw new Error("Invalid function blueprint")}function R(P){return P.map(V=>_(V))}function D(P){return typeof P!="string"&&"variadic"in P}function w(P,V){return{name:P,allowedTypes:R(b(V)),isVariadic:D(V)}}function N(P){return Object.entries(P).map(Z=>w(Z[0],Z[1]))}function I(P){const V=[],Z=[];let ae=P;for(;ae.length>0;){const le=ae.indexOf("${");if(le===-1){V.push(ae);break}const se=ae.slice(0,le);ae=ae.slice(le);const fe=ae.indexOf("}");if(fe===-1){V.push(se+ae);break}const pe=ae.slice(2,fe);ae=ae.slice(fe+1);const ye=pe.startsWith("..."),Ce=pe.endsWith(":"),me=ye?pe.slice(3):Ce?pe.slice(0,-1):pe,_e={node:"function_parameter",name:me};V.push(se),ye?Z.push({node:"spread",e:_e,prefix:"",suffix:""}):Ce&&me==="order_by"?Z.push({node:"aggregate_order_by"}):Ce&&me==="limit"?Z.push({node:"aggregate_limit"}):Z.push(_e)}return{node:"genericSQLExpr",kids:{args:Z},src:V}}function k(P,V){return D(V)?{node:"spread",e:{node:"function_parameter",name:P},prefix:"",suffix:""}:{node:"function_parameter",name:P}}function $(P,V){const Z=Object.entries(V.takes),ae=Z.length>0?Z.length-1:0;return{node:"genericSQLExpr",kids:{args:Z.map(ce=>k(ce[0],ce[1]))},src:[`${P}(`,...Array(ae).fill(","),")"]}}function J(P){return"sql"in P.impl?I(P.impl.sql):"expr"in P.impl?P.impl.expr:$(P.impl.function,P)}function re(P){return{e:J(P),between:P.impl.between,needsWindowOrderBy:P.impl.needsWindowOrderBy,defaultOrderByArgIndex:P.impl.defaultOrderByArgIndex}}function ie(P){if(P!==void 0)return Object.entries(P).map(([V,Z])=>({name:V,acceptibleTypes:Z.map(ae=>S(ae,!0,!1))}))}function oe(P){return{returnType:C(P.returns),params:N(P.takes),isSymmetric:P.isSymmetric,supportsOrderBy:P.supportsOrderBy,supportsLimit:P.supportsLimit,genericTypes:ie(P.generic),...re(P)}}function U(P){return"takes"in P&&"returns"in P&&"impl"in P}function ee(P){return"function"in P||"sql"in P||"expr"in P}function K(P){return U(P)?[oe(P)]:Object.values(P).flatMap(V=>oe(V))}function te(P){const V={};for(const Z in P)V[Z]=K(P[Z]);return V}function q(P,V){return[oe({...P,impl:V})]}function H(P,V,Z){if(ee(Z)){if(!U(V))throw new Error(`Malformed function override: ${P}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(V)})`);return q(V,Z)}else{if(U(V))throw new Error(`Malformed function override: ${P}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(Z)})`);return Object.entries(Z).flatMap(([ae,ce])=>{const le=V[ae];if(le===void 0)throw new Error(`Malformed function override: ${P}. No overload named ${ae}`);return q(le,ce)})}}function Q(P,V){const Z={};for(const ae in V){if(!(ae in P))throw new Error(`Malformed function override: ${ae}. No such function in Malloy standard`);Z[ae]=H(ae,P[ae],V[ae])}return Z}function*M(P){if(typeof P!="string"){if("generic"in P)yield P;else if("record"in P)for(const V of Object.values(P.record))yield*M(V);else for(const V of["array","literal","measure","dimension","measure","constant","cacluation"])if(V in P){yield*M(P[V]);return}}}function j(P,V,Z,ae={}){let ce=!1;const le={};for(const fe of Object.values(V))for(const pe of M(fe))le[pe.generic]=["any"],ce=!0;ce&&ae.generic===void 0&&(ae.generic=le);const se={takes:V,returns:Z,impl:{function:P.toUpperCase()},...ae};return{[P]:se}}return xr}var X3={},Df={},yR;function xA(){if(yR)return Df;yR=1,Object.defineProperty(Df,"__esModule",{value:!0}),Df.decodeDottedTablePath=e,Df.validateDottedTablePath=t;function e(o,s){const{quoteChar:a,escapeStyle:l,bareIdentRegex:u,dialectName:d}=s;if(o.length===0)return{ok:!1,error:`${d} table path is empty`};const c=[];let h=0;for(;;){let f,p;if(o[h]===a){const x=r(o,h,a,l);if(x===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — unterminated quoted segment`};f=x.decoded,p=!0,h=x.end}else{const x=o.slice(h).match(u);if(!x||x.index!==0||x[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — invalid segment at position ${h}`};f=x[0],p=!1,h+=x[0].length}if(f.includes(";")||f.includes("--"))return{ok:!1,error:`Invalid ${d} table path: segment ${JSON.stringify(f)} contains forbidden character; even when quoted, table-path segments may not contain \`;\` or \`--\`.`};if(c.push({value:f,quoted:p}),h===o.length)return{ok:!0,segments:c};if(o[h]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — expected '.' at position ${h}`};if(h++,h===o.length)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — trailing dot`}}}function t(o,s){const a=e(o,s);return a.ok?{ok:!0,canonical:o}:a}function r(o,s,a,l){let u=s+1,d="";for(;u<o.length;){if(l==="backslash"&&o[u]==="\\"){if(u+1>=o.length)return null;d+=i(o[u+1]),u+=2;continue}if(o[u]===a){if(l==="doubled"&&o[u+1]===a){d+=a,u+=2;continue}return{decoded:d,end:u+1}}d+=o[u],u++}return null}function i(o){switch(o){case"n":return`
1
+ import{aF as KF,r as L,j as O,ae as Ht,R as JF,aG as XF,aH as is}from"./index-C6gZ6sSY.js";import{r as Zd,a as dA,d as ft}from"./index-JXgvyZna.js";import{r as za}from"./index-w_0OQJgZ.js";import{d as CU}from"./index-CzNqKMVl.js";import{MalloyRenderer as ZF,isCoreVizPluginInstance as AU}from"./index-OEjKNSYb.js";var vo={},K3={},xr={},J3={},mR;function Ge(){return mR||(mR=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TD=e.ValueType=void 0,e.safeRecordGet=r,e.mkSafeRecord=i,e.exprHasKids=o,e.exprHasE=s,e.exprIsLeaf=a,e.isAsymmetricExpr=l,e.mkTemporal=d,e.isRawCast=c,e.isFilterExprType=h,e.isTimeLiteral=f,e.isParameterType=p,e.paramHasValue=x,e.activeName=m,e.expressionIsScalar=g,e.expressionIsAggregate=E,e.expressionIsUngroupedAggregate=v,e.expressionInvolvesAggregate=S,e.expressionIsCalculation=C,e.expressionIsAnalytic=T,e.isExpressionTypeLEQ=_,e.maxExpressionType=R,e.maxOfExpressionTypes=D,e.hasExpression=w,e.isTemporalType=N,e.isBasicAtomicType=I,e.isAtomicFieldType=k,e.canOrderBy=$,e.fieldIsIntrinsic=J,e.mkFieldDef=re,e.mkArrayDef=ie,e.mkArrayTypeDef=oe,e.isRepeatedRecordFunctionParam=U,e.isRepeatedRecord=ee,e.isRecordOrRepeatedRecord=K,e.isBasicArray=te,e.isMatrixOperation=q,e.isJoinable=H,e.isJoined=Q,e.isJoinedSource=M,e.isDateUnit=j,e.isTimestampUnit=P,e.isExtractUnit=V,e.refIsStructDef=ae,e.segmentHasErrors=ce,e.structHasErrors=le,e.isReduceSegment=se,e.isPartialSegment=fe,e.isProjectSegment=pe,e.isQuerySegment=ye,e.isSamplingRows=Ce,e.isSamplingPercent=me,e.isSamplingEnable=_e,e.isRawSegment=we,e.isIndexSegment=Ke,e.bareFieldUsage=rt,e.fieldUsageFrom=ge,e.givenUsageFrom=Ee,e.mkRefSummary=Pe,e.mapFieldUsage=ke,e.setFieldUsage=Me,e.isSegmentSQL=Xe,e.isSegmentSource=at,e.isSourceRegistryReference=Qe,e.sourceBase=Et,e.isSourceDef=mt,e.isPersistableSourceDef=Te,e.isBaseTable=ze,e.isLiteral=st,e.mergeEvalSpaces=de,e.isBasicAtomic=he,e.isUserTypeDef=ve,e.isCompoundArrayData=be,e.isTurtle=Be,e.isAtomic=Ie,e.isValueString=We,e.isValueNumber=nt,e.isValueBoolean=gt,e.isValueTimestamp=yt,e.isValueDate=ut,e.mergeUniqueKeyRequirement=et;const t=Object.prototype.hasOwnProperty;function r(ne,Ae){return t.call(ne,Ae)?ne[Ae]:void 0}function i(){return Object.create(null)}function o(ne){return"kids"in ne}function s(ne){return"e"in ne}function a(ne){return!(o(ne)||s(ne))}function l(ne){return ne.node==="aggregate"&&["sum","avg","count","distinct"].includes(ne.function)}function u(ne){return ne.node!=="arrayLiteral"&&ne.node!=="recordLiteral"}function d(ne,Ae){if(!("typeDef"in ne)){const Ne=typeof Ae=="string"?{type:Ae}:Ae;if(u(ne))return{...ne,typeDef:{...Ne}}}return ne}function c(ne){return"dstSQLType"in ne}function h(ne){return["string","number","boolean","date","timestamp","timestamptz"].includes(ne)}function f(ne){return ne.node==="dateLiteral"||ne.node==="timestampLiteral"||ne.node==="timestamptzLiteral"}function p(ne){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ne)}function x(ne){return ne.value!==null}function m(ne){var Ae;return(Ae=ne.as)!==null&&Ae!==void 0?Ae:ne.name}function g(ne){return ne===void 0||ne==="scalar"}function E(ne){return ne==="aggregate"||ne==="ungrouped_aggregate"}function v(ne){return ne==="ungrouped_aggregate"}function S(ne){return ne==="aggregate"||ne==="ungrouped_aggregate"||ne==="aggregate_analytic"}function C(ne){return ne==="aggregate"||ne==="scalar_analytic"||ne==="aggregate_analytic"||ne==="ungrouped_aggregate"}function T(ne){return ne==="aggregate_analytic"||ne==="scalar_analytic"}function b(ne){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ne]}function _(ne,Ae){return ne===Ae||b(ne)<b(Ae)}function R(ne,Ae){let Ne="scalar";return(ne==="aggregate"||Ae==="aggregate")&&(Ne="aggregate"),(ne==="ungrouped_aggregate"||Ae==="ungrouped_aggregate")&&(Ne="ungrouped_aggregate"),(ne==="scalar_analytic"||Ae==="scalar_analytic")&&(Ne="scalar_analytic"),(ne==="aggregate_analytic"||Ae==="aggregate_analytic")&&(Ne="aggregate_analytic"),(ne==="scalar_analytic"&&Ae==="aggregate"||ne==="aggregate"&&Ae==="scalar_analytic")&&(Ne="aggregate_analytic"),Ne}function D(ne){return ne.reduce(R,"scalar")}function w(ne){return"e"in ne&&ne.e!==void 0}function N(ne){return ne==="date"||ne==="timestamp"||ne==="timestamptz"}function I(ne){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ne)}function k(ne){return I(ne)||ne==="record"||ne==="array"}function $(ne){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ne)}function J(ne){return k(ne.type)&&!w(ne)}function re(ne,Ae){if(te(ne))return ie(ne.elementTypeDef,Ae);if(ee(ne)){const{type:je,fields:it,elementTypeDef:dt}=ne;return{type:je,fields:it,elementTypeDef:dt,join:"many",name:Ae}}if(ne.type==="record"){const{type:je,fields:it}=ne;return{type:je,fields:it,join:"one",name:Ae}}const Ne={name:Ae,type:ne.type};switch(ne.type){case"sql native":return{...Ne,rawType:ne.rawType};case"number":{const je=ne.numberType;return je?{...Ne,numberType:je}:Ne}case"date":{const je=ne.timeframe;return je?{name:Ae,type:"date",timeframe:je}:Ne}case"timestamp":{const je={name:Ae,type:"timestamp"};return ne.timeframe&&(je.timeframe=ne.timeframe),je}case"timestamptz":{const je={name:Ae,type:"timestamptz"};return ne.timeframe&&(je.timeframe=ne.timeframe),je}}return Ne}function ie(ne,Ae){if(ne.type==="record")return{type:"array",join:"many",name:Ae,elementTypeDef:{type:"record_element"},fields:ne.fields};const Ne=re(ne,"value");return{type:"array",join:"many",name:Ae,elementTypeDef:ne,fields:[Ne,{...Ne,name:"each",e:{node:"field",path:["value"]}}]}}function oe(ne){return ne.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ne.fields}:{type:"array",elementTypeDef:ne}}function U(ne){return ne.type==="array"&&ne.elementTypeDef.type==="record_element"}function ee(ne){return ne.type==="array"&&ne.elementTypeDef.type==="record_element"}function K(ne){return ne.type==="record"||ne.type==="array"&&"elementTypeDef"in ne&&ne.elementTypeDef.type==="record_element"}function te(ne){return ne.type==="array"&&ne.elementTypeDef.type!=="record_element"}function q(ne){return["left","right","full","inner"].includes(ne)}function H(ne){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ne.type)}function Q(ne){return"join"in ne}function M(ne){return mt(ne)&&Q(ne)}function j(ne){return["day","week","month","quarter","year"].includes(ne)}function P(ne){return j(ne)||["hour","minute","second"].includes(ne)}function V(ne){return P(ne)||ne==="day_of_week"||ne==="day_of_year"}var Z;(function(ne){ne.Date="date",ne.Timestamp="timestamp",ne.Number="number",ne.String="string"})(Z||(e.ValueType=Z={}));function ae(ne){return typeof ne!="string"}function ce(ne){return!!((ne.type==="reduce"||ne.type==="project"||ne.type==="partial")&&(ne.extendSource&&ne.extendSource.some(Ae=>Ae.type==="error")||ne.queryFields.some(Ae=>Ae.type==="error")))}function le(ne){return ne.fields.some(Ae=>Ae.type==="error")}function se(ne){return ne.type==="reduce"}function fe(ne){return ne.type==="partial"}function pe(ne){return ne.type==="project"}function ye(ne){return pe(ne)||se(ne)}function Ce(ne){return ne.rows!==void 0}function me(ne){return ne.percent!==void 0}function _e(ne){return ne.enable!==void 0}function we(ne){return ne.type==="raw"}function Ke(ne){return ne.type==="index"}function rt(ne){return ne.uniqueKeyRequirement===void 0&&ne.analyticFunctionUse===void 0}function ge(ne){var Ae;return(Ae=ne?.fieldUsage)!==null&&Ae!==void 0?Ae:[]}function Ee(ne){var Ae;return(Ae=ne?.givenUsage)!==null&&Ae!==void 0?Ae:[]}function Pe({fieldUsage:ne,givenUsage:Ae}){if(!(ne===void 0&&Ae===void 0))return{fieldUsage:ne??[],...Ae&&{givenUsage:Ae}}}function ke(ne,Ae){return ne&&{...ne,fieldUsage:ne.fieldUsage.map(Ae)}}function Me(ne,Ae){ne.refSummary?ne.refSummary.fieldUsage=Ae:ne.refSummary={fieldUsage:Ae}}function Xe(ne){return"sql"in ne}function at(ne){return"type"in ne&&(ne.type==="sql_select"||ne.type==="query_source")}function Qe(ne){return ne.type==="source_registry_reference"}function Et(ne){return{...ne}}function mt(ne){return ne.type==="table"||ne.type==="sql_select"||ne.type==="query_source"||ne.type==="query_result"||ne.type==="finalize"||ne.type==="nest_source"||ne.type==="virtual"||ne.type==="composite"}function Te(ne){return ne.type==="sql_select"||ne.type==="query_source"}function ze(ne){return M(ne)?!1:!!mt(ne)}function st(ne){return ne==="literal"}function de(...ne){return ne.length<=1&&ne.every(Ae=>Ae==="literal")?"literal":ne.every(Ae=>Ae==="constant"||Ae==="literal")?"constant":ne.every(Ae=>Ae==="output"||Ae==="constant"||Ae==="literal")?"output":"input"}function he(ne){return ne.type==="string"||N(ne.type)||ne.type==="number"||ne.type==="boolean"||ne.type==="json"||ne.type==="sql native"||ne.type==="error"}function ve(ne){return ne.type==="userType"}function be(ne){return Array.isArray(ne)&&(ne.length===0||typeof ne[0]=="object"&&ne[0]!==null&&!Array.isArray(ne[0]))}function Be(ne){return ne.type==="turtle"}function Ie(ne){return k(ne.type)}function We(ne,Ae){return Ae.type==="string"}function nt(ne,Ae){return Ae.type==="number"}function gt(ne,Ae){return Ae.type==="boolean"}function yt(ne,Ae){return Ae.type==="timestamp"}function ut(ne,Ae){return Ae.type==="date"}e.TD={isAtomic(ne){return ne!==void 0&&k(ne.type)},isBasicAtomic(ne){return ne!==void 0&&he({type:ne.type})},isString:ne=>ne?.type==="string",isNumber:ne=>ne?.type==="number",isBoolean:ne=>ne?.type==="boolean",isJSON:ne=>ne?.type==="json",isSQL:ne=>ne?.type==="sql native",isDate:ne=>ne?.type==="date",isTimestamp:ne=>ne?.type==="timestamp",isTimestamptz:ne=>ne?.type==="timestamptz",isAnyTimestamp(ne){return ne?.type==="timestamp"||ne?.type==="timestamptz"},isTemporal(ne){var Ae;const Ne=(Ae=ne?.type)!==null&&Ae!==void 0?Ae:"";return N(Ne)},isError:ne=>ne?.type==="error",atomicDef(ne){if(!e.TD.isAtomic(ne))return{type:"error"};switch(ne.type){case"array":return ee(ne)?{type:"array",elementTypeDef:ne.elementTypeDef,fields:ne.fields}:{type:"array",elementTypeDef:ne.elementTypeDef};case"record":return{type:"record",fields:ne.fields};case"number":return ne.numberType?{type:"number",numberType:ne.numberType}:{type:"number"};case"sql native":return ne.rawType?{type:"sql native",rawType:ne.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ne.timeframe?{type:ne.type,timeframe:ne.timeframe}:{type:ne.type};default:return{type:ne.type}}},eq(ne,Ae){if(ne===void 0||Ae===void 0)return!1;function Ne(je,it){const dt={},lt=je.fields||[],xt=it.fields||[];if(lt.length!==xt.length)return!1;for(const It of lt)if(It.name)dt[It.name]=It;else return!1;for(const It of xt)if(!e.TD.eq(dt[It.name],It))return!1;return!0}return ne.type==="array"&&Ae.type==="array"?ne.elementTypeDef.type!==Ae.elementTypeDef.type?!1:ne.elementTypeDef.type!=="record_element"&&Ae.elementTypeDef.type!=="record_element"?e.TD.eq(ne.elementTypeDef,Ae.elementTypeDef):e.TD.isAtomic(ne)&&e.TD.isAtomic(Ae)&&Ne(ne,Ae):ne.type==="record"&&Ae.type==="record"?e.TD.isAtomic(ne)&&e.TD.isAtomic(Ae)&&Ne(ne,Ae):ne.type==="sql native"&&Ae.type==="sql native"?ne.rawType!==void 0&&ne.rawType===Ae.rawType:ne.type===Ae.type}};function et(ne,Ae){return ne?Ae?{isCount:ne.isCount||Ae.isCount}:ne:Ae}})(J3)),J3}var gR;function ds(){if(gR)return xr;gR=1,Object.defineProperty(xr,"__esModule",{value:!0}),xr.arg=t,xr.spread=r,xr.sql=i,xr.constant=o,xr.output=s,xr.literal=a,xr.variadicParam=l,xr.param=u,xr.makeParam=d,xr.maxScalar=c,xr.maxAggregate=h,xr.anyExprType=f,xr.maxUngroupedAggregate=p,xr.maxAnalytic=x,xr.minScalar=m,xr.minAggregate=g,xr.minAnalytic=E,xr.overload=v,xr.expandBlueprintMap=te,xr.expandOverrideMapFromBase=Q,xr.def=j;const e=Ge();function t(P){return{node:"function_parameter",name:P}}function r(P,V=void 0,Z=void 0){return{node:"spread",e:P,prefix:V,suffix:Z}}function i(P,...V){const Z={node:"genericSQLExpr",kids:{args:[]},src:[]},ae=[...V];let ce="";for(const le of P){ce+=le;const se=ae.shift();se!==void 0&&(typeof se=="string"?ce+=se:(Z.src.push(ce),Z.kids.args.push(se),ce=""))}return ce.length>0&&Z.src.push(ce),Z}function o(P){return{...P,evalSpace:"constant"}}function s(P){return{...P,evalSpace:"output"}}function a(P){return{...P,evalSpace:"literal"}}function l(P,...V){return{name:P,isVariadic:!0,allowedTypes:V}}function u(P,...V){return{name:P,isVariadic:!1,allowedTypes:V}}function d(P,...V){return{param:u(P,...V),arg:t(P)}}function c(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function h(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function f(P){return{...P,expressionType:void 0,evalSpace:"input"}}function p(P){return{...P,expressionType:"ungrouped_aggregate",evalSpace:"input"}}function x(P){return{...P,expressionType:"aggregate_analytic",evalSpace:"input"}}function m(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function g(P){return{...P,expressionType:"aggregate",evalSpace:"input"}}function E(P){return{...P,expressionType:"scalar_analytic",evalSpace:"input"}}function v(P,V,Z,ae){return{returnType:P,params:V,e:Z,needsWindowOrderBy:ae?.needsWindowOrderBy,between:ae?.between,isSymmetric:ae?.isSymmetric,supportsOrderBy:ae?.supportsOrderBy,defaultOrderByArgIndex:ae?.defaultOrderByArgIndex,supportsLimit:ae?.supportsLimit}}function S(P,V=!0,Z=!0){if(!V&&P==="any")throw new Error("Return type cannot include any");if(typeof P=="string")return{type:P};if("array"in P){const ae=V?S(P.array,!0):S(P.array,!1);return ae.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ae.fields}:{type:"array",elementTypeDef:ae}}else if("record"in P){const ae=[];for(const[ce,le]of Object.entries(P.record)){const se=V?S(le,!0):S(le,!1);e.TD.isAtomic(se)&&ae.push((0,e.mkFieldDef)(se,ce))}return{type:"record",fields:ae}}else if("generic"in P){if(!Z)throw new Error("Cannot use generic");return{type:"generic",generic:P.generic}}else if("sql_native"in P)return{type:"sql native",rawType:P.sql_native};throw new Error("Cannot figure out type")}function C(P){if(P==="any")throw new Error("Cannot return any type");if(typeof P=="string")return m({type:P});if("array"in P)return f(S(P,!1));if("record"in P)return f(S(P,!1));if("generic"in P)return m(S(P,!1));if("literal"in P)return a(m(S(P.literal,!1)));if("constant"in P)return o(m(S(P.constant,!1)));if("dimension"in P)return m(S(P.dimension,!1));if("measure"in P)return g(S(P.measure,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return E(S(P.calculation,!1));throw new Error("Invalid function blueprint")}function T(P){return typeof P=="string"||"array"in P||"record"in P||"generic"in P||"literal"in P||"constant"in P||"dimension"in P||"measure"in P||"calculation"in P||"sql_native"in P}function b(P){return T(P)?[P]:Array.isArray(P)?P:T(P.variadic)?[P.variadic]:P.variadic}function _(P){if(typeof P=="string")return f({type:P});if("generic"in P)return f(S(P));if("literal"in P)return a(c(S(P.literal)));if("constant"in P)return o(c(S(P.constant)));if("dimension"in P)return c(S(P.dimension));if("measure"in P)return h(S(P.measure));if("array"in P)return f(S(P,!1));if("record"in P)return f(S(P,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return x(S(P.calculation));throw new Error("Invalid function blueprint")}function R(P){return P.map(V=>_(V))}function D(P){return typeof P!="string"&&"variadic"in P}function w(P,V){return{name:P,allowedTypes:R(b(V)),isVariadic:D(V)}}function N(P){return Object.entries(P).map(Z=>w(Z[0],Z[1]))}function I(P){const V=[],Z=[];let ae=P;for(;ae.length>0;){const le=ae.indexOf("${");if(le===-1){V.push(ae);break}const se=ae.slice(0,le);ae=ae.slice(le);const fe=ae.indexOf("}");if(fe===-1){V.push(se+ae);break}const pe=ae.slice(2,fe);ae=ae.slice(fe+1);const ye=pe.startsWith("..."),Ce=pe.endsWith(":"),me=ye?pe.slice(3):Ce?pe.slice(0,-1):pe,_e={node:"function_parameter",name:me};V.push(se),ye?Z.push({node:"spread",e:_e,prefix:"",suffix:""}):Ce&&me==="order_by"?Z.push({node:"aggregate_order_by"}):Ce&&me==="limit"?Z.push({node:"aggregate_limit"}):Z.push(_e)}return{node:"genericSQLExpr",kids:{args:Z},src:V}}function k(P,V){return D(V)?{node:"spread",e:{node:"function_parameter",name:P},prefix:"",suffix:""}:{node:"function_parameter",name:P}}function $(P,V){const Z=Object.entries(V.takes),ae=Z.length>0?Z.length-1:0;return{node:"genericSQLExpr",kids:{args:Z.map(ce=>k(ce[0],ce[1]))},src:[`${P}(`,...Array(ae).fill(","),")"]}}function J(P){return"sql"in P.impl?I(P.impl.sql):"expr"in P.impl?P.impl.expr:$(P.impl.function,P)}function re(P){return{e:J(P),between:P.impl.between,needsWindowOrderBy:P.impl.needsWindowOrderBy,defaultOrderByArgIndex:P.impl.defaultOrderByArgIndex}}function ie(P){if(P!==void 0)return Object.entries(P).map(([V,Z])=>({name:V,acceptibleTypes:Z.map(ae=>S(ae,!0,!1))}))}function oe(P){return{returnType:C(P.returns),params:N(P.takes),isSymmetric:P.isSymmetric,supportsOrderBy:P.supportsOrderBy,supportsLimit:P.supportsLimit,genericTypes:ie(P.generic),...re(P)}}function U(P){return"takes"in P&&"returns"in P&&"impl"in P}function ee(P){return"function"in P||"sql"in P||"expr"in P}function K(P){return U(P)?[oe(P)]:Object.values(P).flatMap(V=>oe(V))}function te(P){const V={};for(const Z in P)V[Z]=K(P[Z]);return V}function q(P,V){return[oe({...P,impl:V})]}function H(P,V,Z){if(ee(Z)){if(!U(V))throw new Error(`Malformed function override: ${P}. Attempt to override multiple overloads with a single overload (missing: ${Object.keys(V)})`);return q(V,Z)}else{if(U(V))throw new Error(`Malformed function override: ${P}. Attempt to override a single overload with multiple overloads (extraneous: ${Object.keys(Z)})`);return Object.entries(Z).flatMap(([ae,ce])=>{const le=V[ae];if(le===void 0)throw new Error(`Malformed function override: ${P}. No overload named ${ae}`);return q(le,ce)})}}function Q(P,V){const Z={};for(const ae in V){if(!(ae in P))throw new Error(`Malformed function override: ${ae}. No such function in Malloy standard`);Z[ae]=H(ae,P[ae],V[ae])}return Z}function*M(P){if(typeof P!="string"){if("generic"in P)yield P;else if("record"in P)for(const V of Object.values(P.record))yield*M(V);else for(const V of["array","literal","measure","dimension","measure","constant","cacluation"])if(V in P){yield*M(P[V]);return}}}function j(P,V,Z,ae={}){let ce=!1;const le={};for(const fe of Object.values(V))for(const pe of M(fe))le[pe.generic]=["any"],ce=!0;ce&&ae.generic===void 0&&(ae.generic=le);const se={takes:V,returns:Z,impl:{function:P.toUpperCase()},...ae};return{[P]:se}}return xr}var X3={},Df={},yR;function xA(){if(yR)return Df;yR=1,Object.defineProperty(Df,"__esModule",{value:!0}),Df.decodeDottedTablePath=e,Df.validateDottedTablePath=t;function e(o,s){const{quoteChar:a,escapeStyle:l,bareIdentRegex:u,dialectName:d}=s;if(o.length===0)return{ok:!1,error:`${d} table path is empty`};const c=[];let h=0;for(;;){let f,p;if(o[h]===a){const x=r(o,h,a,l);if(x===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — unterminated quoted segment`};f=x.decoded,p=!0,h=x.end}else{const x=o.slice(h).match(u);if(!x||x.index!==0||x[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — invalid segment at position ${h}`};f=x[0],p=!1,h+=x[0].length}if(f.includes(";")||f.includes("--"))return{ok:!1,error:`Invalid ${d} table path: segment ${JSON.stringify(f)} contains forbidden character; even when quoted, table-path segments may not contain \`;\` or \`--\`.`};if(c.push({value:f,quoted:p}),h===o.length)return{ok:!0,segments:c};if(o[h]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — expected '.' at position ${h}`};if(h++,h===o.length)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — trailing dot`}}}function t(o,s){const a=e(o,s);return a.ok?{ok:!0,canonical:o}:a}function r(o,s,a,l){let u=s+1,d="";for(;u<o.length;){if(l==="backslash"&&o[u]==="\\"){if(u+1>=o.length)return null;d+=i(o[u+1]),u+=2;continue}if(o[u]===a){if(l==="doubled"&&o[u+1]===a){d+=a,u+=2;continue}return{decoded:d,end:u+1}}d+=o[u],u++}return null}function i(o){switch(o){case"n":return`
2
2
  `;case"t":return" ";case"r":return"\r";default:return o}}return Df}var ER;function Ys(){return ER||(ER=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialect=e.dayIndex=e.EscapeStyle=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=o,e.qtz=s,e.turtleGroupSetCondition=a;const t=Ge(),r=xA();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"),e.EscapeStyle={Doubled:"doubled",Backslash:"backslash",Unset:"unset"};const i=["microsecond","millisecond","second","minute","hour","day","week","month","quarter","year"];e.dayIndex=i.indexOf("day");function o(u){return i.indexOf(u)>=e.dayIndex}function s(u){const d=u.queryTimezone;if(!(d===void 0||d===u.systemTimezone))return d}function a(u,d){return u===void 0?d:d?`group_set=${u} AND ${d}`:`group_set=${u}`}class l{constructor(){this.cantPartitionWindowFunctionsOnExpressions=!1,this.supportsPipelinesInViews=!0,this.supportsNestedProjectionLimit=!1,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"}],this.tablePathBareIdentRegex=/^[A-Za-z_][A-Za-z0-9_]*/,this.identifierQuoteChar="",this.stringLiteralStyle=e.EscapeStyle.Unset,this.identifierEscapeStyle=e.EscapeStyle.Unset}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 h=BigInt(d);for(const f of this.integerTypeMappings)if(h>=f.min&&h<=f.max)return{type:"number",numberType:f.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,c,h,f,p){var x;const m=(x=d?.hasTimestamptz)!==null&&x!==void 0?x:!1;return p==="date"?{node:"dateLiteral",literal:c,typeDef:{type:"date",timeframe:f!==void 0&&(0,t.isDateUnit)(f)?f:void 0}}:h&&m?{node:"timestamptzLiteral",literal:c,typeDef:{type:"timestamptz",timeframe:f},timezone:h}:h?{node:"timestampLiteral",literal:c,typeDef:{type:"timestamp",timeframe:f},timezone:h}:{node:"timestampLiteral",literal:c,typeDef:{type:"timestamp",timeframe:f}}}sqlValidateTableName(d){if(this.identifierEscapeStyle!==e.EscapeStyle.Doubled&&this.identifierEscapeStyle!==e.EscapeStyle.Backslash)throw new Error(`${this.name}: sqlValidateTableName requires identifierEscapeStyle to be set to Doubled or Backslash (or override sqlValidateTableName).`);return(0,r.validateDottedTablePath)(d,{quoteChar:this.identifierQuoteChar,escapeStyle:this.identifierEscapeStyle,bareIdentRegex:this.tablePathBareIdentRegex,dialectName:this.name})}sqlTurtleOrderByClause(d){const c=d.map(h=>` ${h.field} ${h.dir.toUpperCase()}`);return" "+this.sqlOrderBy(c,"turtle")}sqlFinalStage(d,c){throw new Error("Dialect has no final Stage but called Anyway")}sqlDateToString(d){return this.castToString(`DATE(${d})`)}escapeBackslashStyle(d,c){let h="";for(const f of d)switch(f){case"\\":h+="\\\\";break;case`
3
3
  `:h+="\\n";break;case"\r":h+="\\r";break;case" ":h+="\\t";break;case c:h+="\\"+c;break;default:h+=f}return h}sqlQuoteIdentifier(d){const c=this.identifierQuoteChar;if(!c)throw new Error(`${this.name}: identifierQuoteChar is not set. Set it on the dialect (e.g. '"' or "\`"), or override sqlQuoteIdentifier.`);if(this.identifierEscapeStyle===e.EscapeStyle.Doubled)return c+d.split(c).join(c+c)+c;if(this.identifierEscapeStyle===e.EscapeStyle.Backslash)return c+this.escapeBackslashStyle(d,c)+c;throw new Error(`${this.name}: identifierEscapeStyle is not set. Set it to EscapeStyle.Doubled or EscapeStyle.Backslash on the dialect, or override sqlQuoteIdentifier.`)}sqlLiteralNumber(d){return d}ignoreInProject(d){return!1}needsCivilTimeComputation(d,c,h,f){const p=["day","week","month","quarter","year"],x=c!==void 0&&p.includes(c),m=h!==void 0&&p.includes(h),g=s(f);return{needed:t.TD.isAnyTimestamp(d)&&(x||m)&&g!==void 0,tz:g}}sqlTruncAndOffset(d,c,h,f){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:x,tz:m}=this.needsCivilTimeComputation(d.typeDef,h,f?.unit,c);if(x&&m){const g=this.sqlConvertToCivilTime(d.sql,m,d.typeDef);let E=g.sql;const v=g.typeDef;return h&&(E=this.sqlTruncate(E,h,v,!0,m)),f&&(E=this.sqlOffsetTime(E,f.op,f.magnitude,f.unit,v,!0,m)),this.sqlConvertFromCivilTime(E,m,d.typeDef)}}let p=d.sql;return h&&(p=this.sqlTruncate(p,h,d.typeDef,!1,s(c))),f&&(p=this.sqlOffsetTime(p,f.op,f.magnitude,f.unit,d.typeDef,!1,s(c))),p}sqlLiteralString(d){if(this.stringLiteralStyle==="doubled")return"'"+d.split("'").join("''")+"'";if(this.stringLiteralStyle==="backslash")return"'"+this.escapeBackslashStyle(d,"'")+"'";throw new Error(`${this.name}: stringLiteralStyle is not set. Set it to EscapeStyle.Doubled or EscapeStyle.Backslash on the dialect, or override sqlLiteralString.`)}sqlLiteralRegexp(d){return this.sqlLiteralString(d)}exprToSQL(d,c){switch(c.node){case"now":return this.sqlNowExpr();case"timeDiff":return this.sqlMeasureTimeExpr(c);case"delta":{const h=c.kids.base;return h.node==="trunc"?this.sqlTruncAndOffset(h.e,d,h.units,{op:c.op,magnitude:c.kids.delta.sql,unit:c.units}):this.sqlTruncAndOffset(h,d,void 0,{op:c.op,magnitude:c.kids.delta.sql,unit:c.units})}case"trunc":return this.sqlTruncAndOffset(c.e,d,c.units);case"extract":return this.sqlTimeExtractExpr(d,c);case"cast":return this.sqlCast(d,c);case"regexpMatch":return this.sqlRegexpMatch(c);case"/":return this.divisionIsInteger?`${c.kids.left.sql}*1.0/${c.kids.right.sql}`:void 0;case"%":return this.hasModOperator?void 0:`MOD(${c.kids.left.sql},${c.kids.right.sql})`;case"dateLiteral":return this.sqlDateLiteral(d,c.literal);case"timestampLiteral":return this.sqlTimestampLiteral(d,c.literal,c.timezone);case"timestamptzLiteral":return this.sqlTimestamptzLiteral(d,c.literal,c.timezone);case"stringLiteral":return this.sqlLiteralString(c.literal);case"numberLiteral":return this.sqlLiteralNumber(c.literal);case"regexpLiteral":return this.sqlLiteralRegexp(c.literal);case"recordLiteral":return this.sqlLiteralRecord(c);case"arrayLiteral":return this.sqlLiteralArray(c)}}sqlSumDistinct(d,c,h){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,c,h){return"sqlAggDistinct called but not implemented"}sqlSampleTable(d,c){if(c!==void 0)throw new Error(`Sampling is not supported on dialect ${this.name}.`);return d}sqlOrderBy(d,c){return`ORDER BY ${d.join(",")}`}sqlTzStr(d){return`"${d.queryTimezone}"`}sqlMakeUnnestKey(d,c){return this.concat(d,"'x'",c)}sqlStringAggDistinct(d,c,h){const f="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
4
4
  STRING_AGG(DISTINCT ${`concat('${f}', ${d}, '${p}', ${c})`}${h.length>0?","+h:""}),
@@ -1290,7 +1290,7 @@ ${te}`:U=te}return U}childRequest(U){var ee;const K=decodeURI(new URL(U,this.sou
1290
1290
  `)}}this.stream.write(`
1291
1291
  ]
1292
1292
  `),this.stream.close()}}Na.JSONWriter=r;class i extends t{constructor(){super(...arguments),this.columnSeparator=",",this.rowSeparator=`
1293
- `,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const a=s.includes(this.quoteCharacter),l=s.includes(this.columnSeparator),u=s.includes(this.rowSeparator),d=l||a||u;return a&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),d&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let a=s;Array.isArray(s)&&(a=s[0]);let l=0;for(const u in a){l=l+1;const d=a[u];if((0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c}}return l}getHeaderRow(s){const a=[];let l=0;for(const u in s){a.push(this.escape(u));const d=s[u];if(l++,(0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c;for(let h=0;h<c;h++)a.push(this.emptyCell)}}return{rows:[a.join(this.columnSeparator)],length:1,width:l}}mergeMatrices(s){const a=Math.max(...s.map(d=>d.length)),l=s.reduce((d,c)=>d+c.width,0),u=[];for(let d=0;d<a;d++){const c=[];for(const h of s)if(d<h.length)c.push(h.rows[d]);else{const f=Array(h.width).fill(this.emptyCell);c.push(...f)}u.push(c.join(this.columnSeparator))}return{rows:u,length:a,width:l}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const a=[],l=this.getHeaderRow(s[0]);a.push(...l.rows);const u=l.width;let d=1;for(const c of s){const h=this.getRowMatrix(c);d=d+h.length,a.push(...h.rows)}return{rows:a,length:d,width:u}}getRowMatrix(s){const a=[];for(const l in s){const u=s[l];if((0,e.isCompoundArrayData)(u)){const d=this.getChildMatrix(u);a.push(d)}else{const d={rows:[this.stringify(u)],length:1,width:1};a.push(d)}}return this.mergeMatrices(a)}async process(s){let a=!1;for await(const l of s){if(!a&&this.includeHeader){const d=this.getHeaderRow(l.toObject());this.stream.write(d.rows[0]),this.stream.write(this.rowSeparator),a=!0}const u=this.getRowMatrix(l.toObject());for(const d of u.rows)this.stream.write(d),this.stream.write(this.rowSeparator)}this.stream.close()}}return Na.CSVWriter=i,Na}var Vr={},pu={},Qy={},qn={},v8;function dx(){if(v8)return qn;v8=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.isConnectionConfigEntry=e,qn.registerConnectionType=r,qn.getConnectionProperties=i,qn.getConnectionTypeDisplayName=o,qn.getRegisteredConnectionTypes=s,qn.getConnectionTypeDef=a,qn.validateConnectionConfigProperties=l,qn.readConnectionsConfig=u,qn.writeConnectionsConfig=d,qn.createConnectionsFromConfig=c;function e(h){return typeof h=="object"&&h!==null&&typeof h.is=="string"}const t=new Map;function r(h,f){t.set(h,f)}function i(h){var f;return(f=t.get(h))===null||f===void 0?void 0:f.properties}function o(h){var f;return(f=t.get(h))===null||f===void 0?void 0:f.displayName}function s(){return[...t.keys()]}function a(h){return t.get(h)}function l(h,f,p){var x,m;const g=(m=(x=t.get(f))===null||x===void 0?void 0:x.properties)!==null&&m!==void 0?m:[];for(const E of g){if(!E.requireLiteralString)continue;const v=p[E.name];if(v!==void 0&&typeof v!="string")throw new Error(`Connection "${h}" property "${E.name}" must be a literal string`)}}function u(h){var f;const p=JSON.parse(h),x=Object.fromEntries(Object.entries((f=p.connections)!==null&&f!==void 0?f:{}).filter(([,m])=>e(m)));return{...p,connections:x}}function d(h){return JSON.stringify(h,null,2)}function c(h,f){const p=Object.entries(h.connections),x=p.length>0?p[0][0]:void 0,m=new Map;return{async lookupConnection(g){if(g===void 0&&(g=x),g===void 0)throw new Error("No connections defined in config");const E=m.get(g);if(E)return E;const v=h.connections[g];if(!v)throw new Error(`No connection named "${g}" found in config`);const S=t.get(v.is);if(!S)throw new Error(`No registered connection type "${v.is}" for connection "${g}". Did you forget to import the connection package?`);const C={name:g};for(const[b,_]of Object.entries(v))b!=="is"&&_!=null&&(C[b]=_);l(g,v.is,C);const T=await S.factory(C);return f&&f(g,T),m.set(g,T),T},async close(){const g=[...m.values()];m.clear();for(const E of g)await E.close()},async idle(){for(const g of m.values())await g.idle()}}}return qn}var _8;function Ez(){if(_8)return Qy;_8=1,Object.defineProperty(Qy,"__esModule",{value:!0}),Qy.compileConfig=o;const e=dx(),t=c9(),r={connections:s,manifestPath:u,givensPath:d,finalizeGivens:c,virtualMap:h,includeDefaultConnections:f},i=new Set(Object.keys(r));function o(v){const S=[],C={kind:"dict",entries:{}};if(!x(v))return S.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:C,log:S};for(const[T,b]of Object.entries(v)){const _=r[T];if(!_){const D=(0,t.closestMatch)(T,[...i]),w=D?`. Did you mean "${D}"?`:"";S.push(m(T,`unknown config key "${T}"${w}`));continue}const R=_(b,S);R!==void 0&&(C.entries[T]=R)}return{compiled:C,log:S}}function s(v,S){if(!x(v)){S.push(m("connections",'"connections" should be an object'));return}const C=new Set((0,e.getRegisteredConnectionTypes)()),T={kind:"dict",entries:{}};for(const[b,_]of Object.entries(v)){const R=`connections.${b}`;if(!x(_)){S.push(m(R,"should be an object"));continue}const D=_.is;if(D==null||D===""){S.push(m(R,'missing required "is" field (connection type)'));continue}if(typeof D!="string"){S.push(m(`${R}.is`,'"is" should be a string'));continue}if(!C.has(D)){const N=(0,t.closestMatch)(D,[...C]),I=N?` Did you mean "${N}"?`:"";S.push(m(`${R}.is`,`unknown connection type "${D}".${I} Available types: ${[...C].join(", ")}`));continue}const w=a(R,D,_,S);T.entries[b]=w}return T}function a(v,S,C,T){var b;const _=(b=(0,e.getConnectionProperties)(S))!==null&&b!==void 0?b:[],R=new Map(_.map(w=>[w.name,w])),D={kind:"dict",entries:{}};D.entries.is={kind:"value",value:S};for(const[w,N]of Object.entries(C)){if(w==="is")continue;const I=R.get(w);if(!I){const $=(0,t.closestMatch)(w,[...R.keys()]),J=$?`. Did you mean "${$}"?`:"";T.push(m(`${v}.${w}`,`unknown property "${w}" for connection type "${S}"${J}`));continue}const k=l(`${v}.${w}`,I,N,T);k!==void 0&&(D.entries[w]=k)}return D}function l(v,S,C,T){if(C==null)return;if(S.type==="json")return{kind:"value",value:C};const b=p(C);if(b!==void 0)return S.requireLiteralString?(T.push(m(v,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:C}):b;const _=E(C,S.type);if(_){if(S.requireLiteralString)return T.push(m(v,`must be a literal string, got ${g(C)}`)),{kind:"value",value:C};T.push(m(v,`${_} (expected ${S.type})`));return}return{kind:"value",value:C}}function u(v,S){const C=p(v);if(C!==void 0)return C;if(typeof v!="string"){S.push(m("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function d(v,S){const C=p(v);if(C!==void 0)return C;if(typeof v!="string"){S.push(m("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function c(v,S){if(!Array.isArray(v)||!v.every(C=>typeof C=="string")){S.push(m("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:v}}function h(v,S){return{kind:"value",value:v}}function f(v,S){return{kind:"value",value:v}}function p(v){if(typeof v!="object"||v===null||Array.isArray(v))return;const S=Object.keys(v);if(S.length!==1)return;const C=S[0],T=v[C];if(typeof T=="string")return{kind:"reference",source:C,path:[T]};if(Array.isArray(T)&&T.every(b=>typeof b=="string"))return{kind:"reference",source:C,path:T}}function x(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function m(v,S){return{message:`${v}: ${S}`,severity:"warn",code:"config-validation"}}function g(v){return Array.isArray(v)?"array":typeof v}function E(v,S){switch(S){case"number":if(typeof v!="number")return`should be a number, got ${typeof v}`;break;case"boolean":if(typeof v!="boolean")return`should be a boolean, got ${typeof v}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof v!="string")return`should be a string, got ${typeof v}`;break}}return Qy}var Wy={},Zc={},S8;function mT(){if(S8)return Zc;S8=1;var e={};Object.defineProperty(Zc,"__esModule",{value:!0}),Zc.envOverlay=t,Zc.contextOverlay=r,Zc.defaultConfigOverlays=i,Zc.isThenable=o;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function r(s){return a=>s[a[0]]}function i(){return{env:t(),config:()=>{}}}function o(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return Zc}var C8;function vz(){if(C8)return Wy;C8=1,Object.defineProperty(Wy,"__esModule",{value:!0}),Wy.prepareConfig=r;const e=dx(),t=mT();function r(l,u,d){let c={},h,f,p,x,m=!1;for(const[g,E]of Object.entries(l.entries))switch(g){case"connections":{if(E.kind!=="dict")break;c=o(E);break}case"manifestPath":{h=a(E,u,d,"manifestPath");break}case"givensPath":{f=a(E,u,d,"givensPath");break}case"finalizeGivens":{E.kind==="value"&&i(E.value)&&(p=E.value);break}case"virtualMap":{E.kind==="value"&&(x=E.value);break}case"includeDefaultConnections":{E.kind==="value"&&typeof E.value=="boolean"&&(m=E.value);break}}return m&&s(c),{compiledConnections:c,manifestPath:h,givensPath:f,finalizeGivens:p,virtualMap:x}}function i(l){return Array.isArray(l)&&l.every(u=>typeof u=="string")}function o(l){const u={};for(const[d,c]of Object.entries(l.entries))c.kind==="dict"&&(u[d]=c);return u}function s(l){for(const u of(0,e.getRegisteredConnectionTypes)())l[u]||(l[u]={kind:"dict",entries:{is:{kind:"value",value:u}}})}function a(l,u,d,c){if(l.kind==="value")return typeof l.value=="string"?l.value:void 0;if(l.kind==="reference"){const h=u[l.source];if(!h){d.push({message:`unknown overlay source "${l.source}" for "${c}"`,severity:"warn",code:"config-overlay"});return}const f=h(l.path);if((0,t.isThenable)(f)){d.push({message:`the \`${l.source}\` overlay returned a Promise for "${c}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof f=="string"?f:void 0}}return Wy}var zy={},A8;function _z(){if(A8)return zy;A8=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.buildManagedLookup=t;const e=dx();function t(l,u,d){const c=Object.entries(l),h=c.length>0?c[0][0]:void 0,f=new Map;return{async lookupConnection(p){if(p===void 0&&(p=h),p===void 0)throw new Error("No connections defined in config");const x=f.get(p);if(x)return x;const m=l[p];if(!m)throw new Error(`No connection named "${p}" found in config`);const g=await r(m,u,d);if(typeof g.is!="string")throw new Error(`Connection "${p}" is missing a valid "is" field`);const E=(0,e.getConnectionTypeDef)(g.is);if(!E)throw new Error(`No registered connection type "${g.is}" for connection "${p}". Did you forget to import the connection package?`);const v={name:p};for(const[C,T]of Object.entries(g))C!=="is"&&T!=null&&(v[C]=T);(0,e.validateConnectionConfigProperties)(p,g.is,v);const S=await E.factory(v);return f.set(p,S),S},async close(){const p=[...f.values()];f.clear();for(const x of p)await x.close()},async idle(){for(const p of f.values())await p.idle()}}}async function r(l,u,d){const c=await i(l,u,d);if(!(0,e.isConnectionConfigEntry)(c))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(c,u),c}async function i(l,u,d){switch(l.kind){case"value":return l.value;case"reference":return o(l,u,d);case"dict":{const c={};for(const[h,f]of Object.entries(l.entries)){const p=await i(f,u,d);p!==void 0&&(c[h]=p)}return c}}}async function o(l,u,d){const c=u[l.source];if(!c){d.push({message:`unknown overlay source "${l.source}" for reference path ${JSON.stringify(l.path)}`,severity:"warn",code:"config-overlay"});return}return await c(l.path)}async function s(l,u){var d;const c=l.is;if(typeof c!="string")return;const h=(d=(0,e.getConnectionProperties)(c))!==null&&d!==void 0?d:[];for(const f of h){if(f.default===void 0||l[f.name]!==void 0)continue;const p=await a(f.default,u);p!==void 0&&(l[f.name]=p)}}async function a(l,u){if(typeof l!="object")return l;const d=Object.keys(l);if(d.length!==1)return;const c=d[0],h=l[c],f=typeof h=="string"?[h]:h;if(!Array.isArray(f))return;const p=u[c];if(p)return await p(f)}return zy}var T8;function gT(){if(T8)return pu;T8=1,Object.defineProperty(pu,"__esModule",{value:!0}),pu.MalloyConfig=pu.Manifest=void 0,pu.isBuildManifestEntry=v;const e=Ez(),t=vz(),r=_z(),i=mT(),o=YE();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(C){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(C))}get buildManifest(){return this._manifest}get strict(){var C;return(C=this._manifest.strict)!==null&&C!==void 0?C:!1}set strict(C){this._manifest.strict=C}update(C,T){(0,o.requireCanonicalTablePathAnyDialect)(T.tableName,`Manifest entry '${C}'`),this._manifest.entries[C]=T,this._touched.add(C)}touch(C){this._touched.add(C)}get activeEntries(){const C={};for(const T of this._touched)this._manifest.entries[T]&&(C[T]=this._manifest.entries[T]);return{entries:C,strict:this._manifest.strict}}_clearEntries(){for(const C of Object.keys(this._manifest.entries))delete this._manifest.entries[C]}_loadParsed(C){typeof C.strict=="boolean"&&(this._manifest.strict=C.strict);const T=E(C.entries)?C.entries:C;for(const[b,_]of Object.entries(T))b==="strict"||!v(_)||((0,o.requireCanonicalTablePathAnyDialect)(_.tableName,`Manifest entry '${b}'`),this._manifest.entries[b]=_)}}pu.Manifest=s;class a{constructor(C,T){const b=[];let _;if(typeof C=="string")try{_=JSON.parse(C)}catch($){b.push({message:`Invalid JSON: ${$ instanceof Error?$.message:String($)}`,severity:"error",code:"config-validation"}),_={}}else _=C;const R=(0,e.compileConfig)(_);b.push(...R.log);const D=h(T,b),w=m(D.configURL,"configURL",b),N=D.rootDirectory,I={...(0,i.defaultConfigOverlays)(),...D.overlays,config:(0,i.contextOverlay)({configURL:w,rootDirectory:N})},k=(0,t.prepareConfig)(R.compiled,I,b);this._managedLookup=(0,r.buildManagedLookup)(k.compiledConnections,I,b),this._connections=this._managedLookup,this._overlays=I,this.virtualMap=g(k.virtualMap,b),this.configURL=w,this.rootDirectory=N,this.manifestPath=k.manifestPath,this.manifestURL=d(k.manifestPath,w),this.givensPath=k.givensPath,this.givensURL=c(k.givensPath,w,b),this.finalizeGivens=k.finalizeGivens,this.log=b}get connections(){return this._connections}wrapConnections(C){this._connections=C(this._connections)}async shutdown(C="close"){C==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(C,...T){var b,_;return await((_=(b=this._overlays)[C])===null||_===void 0?void 0:_.call(b,T))}}pu.MalloyConfig=a;const l="MANIFESTS",u="malloy-manifest.json";function d(S,C){if(!C)return;let T;try{T=new URL(C)}catch{return}const b=S??l;let _;try{_=new URL(b,T)}catch{return}const R=_.toString(),D=R.endsWith("/")?_:new URL(R+"/");return new URL(u,D).toString()}function c(S,C,T){if(!S)return;if(!C){T.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let b;try{b=new URL(C)}catch{return}try{return new URL(S,b).toString()}catch(_){const R=_ instanceof Error?_.message:String(_);T.push({message:`givensPath '${S}' could not be resolved against configURL '${C}': ${R}`,severity:"warn",code:"config-validation"});return}}function h(S,C){if(S===void 0)return{};if(f(S))return p(S,C);const T=S;if(T.overlays&&"config"in T.overlays){C.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:b,..._}=T.overlays;return{...T,overlays:_}}return T}function f(S){for(const C of Object.values(S))if(typeof C=="function")return!0;return!1}function p(S,C){const T=S.config;if(!T)return{overlays:S};const b=x(T,"configURL",C),_=x(T,"rootDirectory",C),{config:R,...D}=S;return{configURL:b,rootDirectory:_,overlays:D}}function x(S,C,T){const b=S([C]);if((0,i.isThenable)(b)){T.push({message:`the legacy \`config\` overlay returned a Promise for \`${C}\`; top-level FS context must resolve synchronously. ${C} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof b=="string"?b:void 0}function m(S,C,T){if(S!==void 0)try{return new URL(S),S}catch{T.push({message:`${C} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${S}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function g(S,C){if(!E(S))return;const T=new Map;for(const[b,_]of Object.entries(S)){if(!E(_))continue;const R=new Map;for(const[D,w]of Object.entries(_)){if(typeof w!="string")continue;const N=(0,o.validateCanonicalTablePathAnyDialect)(w);if(N!==void 0){C.push({message:`virtualMap entry '${b}.${D}': ${N}`,severity:"error",code:"config-validation"});continue}R.set(D,w)}R.size>0&&T.set(b,R)}return T.size>0?T:void 0}function E(S){return typeof S=="object"&&S!==null&&!Array.isArray(S)}function v(S){return E(S)&&typeof S.tableName=="string"}return pu}var e0={},bm={},b8;function Sz(){return b8||(b8=1,Object.defineProperty(bm,"__esModule",{value:!0}),bm.MALLOY_VERSION=void 0,bm.MALLOY_VERSION="0.0.421"),bm}var R8;function tk(){if(R8)return e0;R8=1,Object.defineProperty(e0,"__esModule",{value:!0}),e0.Malloy=e0.MalloyError=void 0;const e=pT(),t=dx(),r=jr(),i=F2(),o=Sz(),s=JE(),a=ZP(),l=_0(),u=XE(),d=ek();function c(x="loadModel"){return`internal://${x}/${(0,l.v4)()}`}function h(x){return[...Object.keys(x),...Object.values(x).map(h).flat()]}class f extends Error{constructor(m,g=[]){super(m),this.problems=g}}e0.MalloyError=f;class p{static get version(){return o.MALLOY_VERSION}static registerConnectionType(m,g){(0,t.registerConnectionType)(m,g)}static getConnectionProperties(m){return(0,t.getConnectionProperties)(m)}static getConnectionTypeDisplayName(m){return(0,t.getConnectionTypeDisplayName)(m)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(m,g,E,v,S){var C;g===void 0&&(g=new URL(c(v?.method)));let T=g;v?.importBaseURL&&(T=v?.importBaseURL);const b=new e.MalloyTranslator(g.toString(),T.toString(),{urls:{[g.toString()]:m}},E,(C=v?.restrictedMode)!==null&&C!==void 0?C:!1);return v?.testEnvironment&&(b.allDialectsEnabled=!0),new a.Parse(b,S)}static parse({url:m,urlReader:g,source:E,eventStream:v,options:S}){if(E!==void 0)return p._parse(E,m,v,S);if(g===void 0)throw new Error("Internal Error: urlReader is required.");if(m===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(g,m).then(({contents:C,invalidationKey:T})=>p._parse(C,m,v,S,T))}static async compile(m){var g,E,v,S,C;let{url:T,source:b,importBaseURL:_,cacheManager:R}=m;const{parse:D,urlReader:w,connections:N,model:I,refreshSchemaCache:k,noThrowOnError:$,eventStream:J,restrictedMode:re,method:ie}=m;re&&(R=void 0);let oe;if(k&&(oe=typeof k=="number"?k:Date.now()),T===void 0&&b===void 0&&D===void 0)throw new Error("Internal Error: url, source, or parse required.");T===void 0&&(D!==void 0?T=new URL(D._translator.sourceURL):T=new URL(c(ie)));const U={};if(b===void 0&&R!==void 0){const te=await R.getCachedModelDef(w,T.toString());if(te)return new u.Model(te.modelDef,[],[T.toString(),...h(te.modelDef.dependencies)])}_??(_=T);let ee;const K=T.toString();if(D!==void 0){if(re!==void 0&&D._translator.restrictedMode!==re)throw new Error(`Malloy.compile: restrictedMode (${re}) does not match the pre-parsed translator's restrictedMode (${D._translator.restrictedMode}). Set restrictedMode at parse time.`);ee=D._translator;const te=(g=D._invalidationKey)!==null&&g!==void 0?g:await(0,s.getInvalidationKey)(w,T);U[K]=te}else{if(b===void 0){const{contents:te,invalidationKey:q}=await(0,s.readURL)(w,T);U[K]=q,b=te}else{const te=await(0,s.getInvalidationKey)(w,T);U[K]=te}ee=new e.MalloyTranslator(K,_.toString(),{urls:{[K]:b}},J,re??!1)}for(;;){const te=ee.translate(I?._modelDef);if(te.final)if(te.modelDef){await R?.setCachedModelDef(T.toString(),{modelDef:te.modelDef,invalidationKeys:U});for(const H of ee.newlyTranslatedDependencies())await R?.setCachedModelDef(H.url,{modelDef:H.modelDef,invalidationKeys:U});const q=!te.modelWasModified&&I?I.getExistingQueryModel():void 0;return new u.Model(te.modelDef,te.problems||[],[...(E=I?.fromSources)!==null&&E!==void 0?E:[],...(v=te.fromSources)!==null&&v!==void 0?v:[]],q)}else if($){const q=(0,r.mkModelDef)("modelDidNotCompile"),H=I?._modelDef||q;return new u.Model(H,te.problems||[],[...(S=I?.fromSources)!==null&&S!==void 0?S:[],...(C=te.fromSources)!==null&&C!==void 0?C:[]])}else{const q=te.problems||[],H=ee.prettyErrors();throw new f(`Error(s) compiling model:
1293
+ `,this.quoteCharacter='"',this.includeHeader=!0,this.emptyCell=""}escape(s){const a=s.includes(this.quoteCharacter),l=s.includes(this.columnSeparator),u=s.includes(this.rowSeparator),d=l||a||u;return a&&(s=s.replace(new RegExp(this.quoteCharacter,"g"),this.quoteCharacter+this.quoteCharacter)),d&&(s=this.quoteCharacter+s+this.quoteCharacter),s}stringify(s){return s===null?this.emptyCell:s instanceof Date?s.toISOString():typeof s=="boolean"||typeof s=="number"?JSON.stringify(s):typeof s=="bigint"?s.toString():`${s}`}getColWeight(s){let a=s;Array.isArray(s)&&(a=s[0]);let l=0;for(const u in a){l=l+1;const d=a[u];if((0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c}}return l}getHeaderRow(s){const a=[];let l=0;for(const u in s){a.push(this.escape(u));const d=s[u];if(l++,(0,e.isCompoundArrayData)(d)){const c=this.getColWeight(d)-1;l=l+c;for(let h=0;h<c;h++)a.push(this.emptyCell)}}return{rows:[a.join(this.columnSeparator)],length:1,width:l}}mergeMatrices(s){const a=Math.max(...s.map(d=>d.length)),l=s.reduce((d,c)=>d+c.width,0),u=[];for(let d=0;d<a;d++){const c=[];for(const h of s)if(d<h.length)c.push(h.rows[d]);else{const f=Array(h.width).fill(this.emptyCell);c.push(...f)}u.push(c.join(this.columnSeparator))}return{rows:u,length:a,width:l}}getChildMatrix(s){if(Array.isArray(s)){if(s.length===0)return{rows:[""],length:1,width:1}}else return{rows:["Invalid data found, value is not an array"],length:1,width:1};const a=[],l=this.getHeaderRow(s[0]);a.push(...l.rows);const u=l.width;let d=1;for(const c of s){const h=this.getRowMatrix(c);d=d+h.length,a.push(...h.rows)}return{rows:a,length:d,width:u}}getRowMatrix(s){const a=[];for(const l in s){const u=s[l];if((0,e.isCompoundArrayData)(u)){const d=this.getChildMatrix(u);a.push(d)}else{const d={rows:[this.stringify(u)],length:1,width:1};a.push(d)}}return this.mergeMatrices(a)}async process(s){let a=!1;for await(const l of s){if(!a&&this.includeHeader){const d=this.getHeaderRow(l.toObject());this.stream.write(d.rows[0]),this.stream.write(this.rowSeparator),a=!0}const u=this.getRowMatrix(l.toObject());for(const d of u.rows)this.stream.write(d),this.stream.write(this.rowSeparator)}this.stream.close()}}return Na.CSVWriter=i,Na}var Vr={},pu={},Qy={},qn={},v8;function dx(){if(v8)return qn;v8=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.isConnectionConfigEntry=e,qn.registerConnectionType=r,qn.getConnectionProperties=i,qn.getConnectionTypeDisplayName=o,qn.getRegisteredConnectionTypes=s,qn.getConnectionTypeDef=a,qn.validateConnectionConfigProperties=l,qn.readConnectionsConfig=u,qn.writeConnectionsConfig=d,qn.createConnectionsFromConfig=c;function e(h){return typeof h=="object"&&h!==null&&typeof h.is=="string"}const t=new Map;function r(h,f){t.set(h,f)}function i(h){var f;return(f=t.get(h))===null||f===void 0?void 0:f.properties}function o(h){var f;return(f=t.get(h))===null||f===void 0?void 0:f.displayName}function s(){return[...t.keys()]}function a(h){return t.get(h)}function l(h,f,p){var x,m;const g=(m=(x=t.get(f))===null||x===void 0?void 0:x.properties)!==null&&m!==void 0?m:[];for(const E of g){if(!E.requireLiteralString)continue;const v=p[E.name];if(v!==void 0&&typeof v!="string")throw new Error(`Connection "${h}" property "${E.name}" must be a literal string`)}}function u(h){var f;const p=JSON.parse(h),x=Object.fromEntries(Object.entries((f=p.connections)!==null&&f!==void 0?f:{}).filter(([,m])=>e(m)));return{...p,connections:x}}function d(h){return JSON.stringify(h,null,2)}function c(h,f){const p=Object.entries(h.connections),x=p.length>0?p[0][0]:void 0,m=new Map;return{async lookupConnection(g){if(g===void 0&&(g=x),g===void 0)throw new Error("No connections defined in config");const E=m.get(g);if(E)return E;const v=h.connections[g];if(!v)throw new Error(`No connection named "${g}" found in config`);const S=t.get(v.is);if(!S)throw new Error(`No registered connection type "${v.is}" for connection "${g}". Did you forget to import the connection package?`);const C={name:g};for(const[b,_]of Object.entries(v))b!=="is"&&_!=null&&(C[b]=_);l(g,v.is,C);const T=await S.factory(C);return f&&f(g,T),m.set(g,T),T},async close(){const g=[...m.values()];m.clear();for(const E of g)await E.close()},async idle(){for(const g of m.values())await g.idle()}}}return qn}var _8;function Ez(){if(_8)return Qy;_8=1,Object.defineProperty(Qy,"__esModule",{value:!0}),Qy.compileConfig=o;const e=dx(),t=c9(),r={connections:s,manifestPath:u,givensPath:d,finalizeGivens:c,virtualMap:h,includeDefaultConnections:f},i=new Set(Object.keys(r));function o(v){const S=[],C={kind:"dict",entries:{}};if(!x(v))return S.push({message:"config is not a JSON object",severity:"error",code:"config-validation"}),{compiled:C,log:S};for(const[T,b]of Object.entries(v)){const _=r[T];if(!_){const D=(0,t.closestMatch)(T,[...i]),w=D?`. Did you mean "${D}"?`:"";S.push(m(T,`unknown config key "${T}"${w}`));continue}const R=_(b,S);R!==void 0&&(C.entries[T]=R)}return{compiled:C,log:S}}function s(v,S){if(!x(v)){S.push(m("connections",'"connections" should be an object'));return}const C=new Set((0,e.getRegisteredConnectionTypes)()),T={kind:"dict",entries:{}};for(const[b,_]of Object.entries(v)){const R=`connections.${b}`;if(!x(_)){S.push(m(R,"should be an object"));continue}const D=_.is;if(D==null||D===""){S.push(m(R,'missing required "is" field (connection type)'));continue}if(typeof D!="string"){S.push(m(`${R}.is`,'"is" should be a string'));continue}if(!C.has(D)){const N=(0,t.closestMatch)(D,[...C]),I=N?` Did you mean "${N}"?`:"";S.push(m(`${R}.is`,`unknown connection type "${D}".${I} Available types: ${[...C].join(", ")}`));continue}const w=a(R,D,_,S);T.entries[b]=w}return T}function a(v,S,C,T){var b;const _=(b=(0,e.getConnectionProperties)(S))!==null&&b!==void 0?b:[],R=new Map(_.map(w=>[w.name,w])),D={kind:"dict",entries:{}};D.entries.is={kind:"value",value:S};for(const[w,N]of Object.entries(C)){if(w==="is")continue;const I=R.get(w);if(!I){const $=(0,t.closestMatch)(w,[...R.keys()]),J=$?`. Did you mean "${$}"?`:"";T.push(m(`${v}.${w}`,`unknown property "${w}" for connection type "${S}"${J}`));continue}const k=l(`${v}.${w}`,I,N,T);k!==void 0&&(D.entries[w]=k)}return D}function l(v,S,C,T){if(C==null)return;if(S.type==="json")return{kind:"value",value:C};const b=p(C);if(b!==void 0)return S.requireLiteralString?(T.push(m(v,"must be a literal string and cannot use an overlay reference")),{kind:"value",value:C}):b;const _=E(C,S.type);if(_){if(S.requireLiteralString)return T.push(m(v,`must be a literal string, got ${g(C)}`)),{kind:"value",value:C};T.push(m(v,`${_} (expected ${S.type})`));return}return{kind:"value",value:C}}function u(v,S){const C=p(v);if(C!==void 0)return C;if(typeof v!="string"){S.push(m("manifestPath",'"manifestPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function d(v,S){const C=p(v);if(C!==void 0)return C;if(typeof v!="string"){S.push(m("givensPath",'"givensPath" should be a string or an overlay reference'));return}return{kind:"value",value:v}}function c(v,S){if(!Array.isArray(v)||!v.every(C=>typeof C=="string")){S.push(m("finalizeGivens",'"finalizeGivens" should be an array of given names'));return}return{kind:"value",value:v}}function h(v,S){return{kind:"value",value:v}}function f(v,S){return{kind:"value",value:v}}function p(v){if(typeof v!="object"||v===null||Array.isArray(v))return;const S=Object.keys(v);if(S.length!==1)return;const C=S[0],T=v[C];if(typeof T=="string")return{kind:"reference",source:C,path:[T]};if(Array.isArray(T)&&T.every(b=>typeof b=="string"))return{kind:"reference",source:C,path:T}}function x(v){return typeof v=="object"&&v!==null&&!Array.isArray(v)}function m(v,S){return{message:`${v}: ${S}`,severity:"warn",code:"config-validation"}}function g(v){return Array.isArray(v)?"array":typeof v}function E(v,S){switch(S){case"number":if(typeof v!="number")return`should be a number, got ${typeof v}`;break;case"boolean":if(typeof v!="boolean")return`should be a boolean, got ${typeof v}`;break;case"string":case"password":case"secret":case"file":case"text":if(typeof v!="string")return`should be a string, got ${typeof v}`;break}}return Qy}var Wy={},Zc={},S8;function mT(){if(S8)return Zc;S8=1;var e={};Object.defineProperty(Zc,"__esModule",{value:!0}),Zc.envOverlay=t,Zc.contextOverlay=r,Zc.defaultConfigOverlays=i,Zc.isThenable=o;function t(){return typeof process>"u"||!e?()=>{}:s=>e[s[0]]}function r(s){return a=>s[a[0]]}function i(){return{env:t(),config:()=>{}}}function o(s){return typeof s=="object"&&s!==null&&"then"in s&&typeof s.then=="function"}return Zc}var C8;function vz(){if(C8)return Wy;C8=1,Object.defineProperty(Wy,"__esModule",{value:!0}),Wy.prepareConfig=r;const e=dx(),t=mT();function r(l,u,d){let c={},h,f,p,x,m=!1;for(const[g,E]of Object.entries(l.entries))switch(g){case"connections":{if(E.kind!=="dict")break;c=o(E);break}case"manifestPath":{h=a(E,u,d,"manifestPath");break}case"givensPath":{f=a(E,u,d,"givensPath");break}case"finalizeGivens":{E.kind==="value"&&i(E.value)&&(p=E.value);break}case"virtualMap":{E.kind==="value"&&(x=E.value);break}case"includeDefaultConnections":{E.kind==="value"&&typeof E.value=="boolean"&&(m=E.value);break}}return m&&s(c),{compiledConnections:c,manifestPath:h,givensPath:f,finalizeGivens:p,virtualMap:x}}function i(l){return Array.isArray(l)&&l.every(u=>typeof u=="string")}function o(l){const u={};for(const[d,c]of Object.entries(l.entries))c.kind==="dict"&&(u[d]=c);return u}function s(l){for(const u of(0,e.getRegisteredConnectionTypes)())l[u]||(l[u]={kind:"dict",entries:{is:{kind:"value",value:u}}})}function a(l,u,d,c){if(l.kind==="value")return typeof l.value=="string"?l.value:void 0;if(l.kind==="reference"){const h=u[l.source];if(!h){d.push({message:`unknown overlay source "${l.source}" for "${c}"`,severity:"warn",code:"config-overlay"});return}const f=h(l.path);if((0,t.isThenable)(f)){d.push({message:`the \`${l.source}\` overlay returned a Promise for "${c}"; top-level string settings must resolve synchronously`,severity:"warn",code:"config-overlay"});return}return typeof f=="string"?f:void 0}}return Wy}var zy={},A8;function _z(){if(A8)return zy;A8=1,Object.defineProperty(zy,"__esModule",{value:!0}),zy.buildManagedLookup=t;const e=dx();function t(l,u,d){const c=Object.entries(l),h=c.length>0?c[0][0]:void 0,f=new Map;return{async lookupConnection(p){if(p===void 0&&(p=h),p===void 0)throw new Error("No connections defined in config");const x=f.get(p);if(x)return x;const m=l[p];if(!m)throw new Error(`No connection named "${p}" found in config`);const g=await r(m,u,d);if(typeof g.is!="string")throw new Error(`Connection "${p}" is missing a valid "is" field`);const E=(0,e.getConnectionTypeDef)(g.is);if(!E)throw new Error(`No registered connection type "${g.is}" for connection "${p}". Did you forget to import the connection package?`);const v={name:p};for(const[C,T]of Object.entries(g))C!=="is"&&T!=null&&(v[C]=T);(0,e.validateConnectionConfigProperties)(p,g.is,v);const S=await E.factory(v);return f.set(p,S),S},async close(){const p=[...f.values()];f.clear();for(const x of p)await x.close()},async idle(){for(const p of f.values())await p.idle()}}}async function r(l,u,d){const c=await i(l,u,d);if(!(0,e.isConnectionConfigEntry)(c))throw new Error("Connection entry did not resolve to a valid {is: string, ...} dict");return await s(c,u),c}async function i(l,u,d){switch(l.kind){case"value":return l.value;case"reference":return o(l,u,d);case"dict":{const c={};for(const[h,f]of Object.entries(l.entries)){const p=await i(f,u,d);p!==void 0&&(c[h]=p)}return c}}}async function o(l,u,d){const c=u[l.source];if(!c){d.push({message:`unknown overlay source "${l.source}" for reference path ${JSON.stringify(l.path)}`,severity:"warn",code:"config-overlay"});return}return await c(l.path)}async function s(l,u){var d;const c=l.is;if(typeof c!="string")return;const h=(d=(0,e.getConnectionProperties)(c))!==null&&d!==void 0?d:[];for(const f of h){if(f.default===void 0||l[f.name]!==void 0)continue;const p=await a(f.default,u);p!==void 0&&(l[f.name]=p)}}async function a(l,u){if(typeof l!="object")return l;const d=Object.keys(l);if(d.length!==1)return;const c=d[0],h=l[c],f=typeof h=="string"?[h]:h;if(!Array.isArray(f))return;const p=u[c];if(p)return await p(f)}return zy}var T8;function gT(){if(T8)return pu;T8=1,Object.defineProperty(pu,"__esModule",{value:!0}),pu.MalloyConfig=pu.Manifest=void 0,pu.isBuildManifestEntry=v;const e=Ez(),t=vz(),r=_z(),i=mT(),o=YE();class s{constructor(){this._manifest={entries:{},strict:!1},this._touched=new Set}loadText(C){this._clearEntries(),this._touched.clear(),this._manifest.strict=!1,this._loadParsed(JSON.parse(C))}get buildManifest(){return this._manifest}get strict(){var C;return(C=this._manifest.strict)!==null&&C!==void 0?C:!1}set strict(C){this._manifest.strict=C}update(C,T){(0,o.requireCanonicalTablePathAnyDialect)(T.tableName,`Manifest entry '${C}'`),this._manifest.entries[C]=T,this._touched.add(C)}touch(C){this._touched.add(C)}get activeEntries(){const C={};for(const T of this._touched)this._manifest.entries[T]&&(C[T]=this._manifest.entries[T]);return{entries:C,strict:this._manifest.strict}}_clearEntries(){for(const C of Object.keys(this._manifest.entries))delete this._manifest.entries[C]}_loadParsed(C){typeof C.strict=="boolean"&&(this._manifest.strict=C.strict);const T=E(C.entries)?C.entries:C;for(const[b,_]of Object.entries(T))b==="strict"||!v(_)||((0,o.requireCanonicalTablePathAnyDialect)(_.tableName,`Manifest entry '${b}'`),this._manifest.entries[b]=_)}}pu.Manifest=s;class a{constructor(C,T){const b=[];let _;if(typeof C=="string")try{_=JSON.parse(C)}catch($){b.push({message:`Invalid JSON: ${$ instanceof Error?$.message:String($)}`,severity:"error",code:"config-validation"}),_={}}else _=C;const R=(0,e.compileConfig)(_);b.push(...R.log);const D=h(T,b),w=m(D.configURL,"configURL",b),N=D.rootDirectory,I={...(0,i.defaultConfigOverlays)(),...D.overlays,config:(0,i.contextOverlay)({configURL:w,rootDirectory:N})},k=(0,t.prepareConfig)(R.compiled,I,b);this._managedLookup=(0,r.buildManagedLookup)(k.compiledConnections,I,b),this._connections=this._managedLookup,this._overlays=I,this.virtualMap=g(k.virtualMap,b),this.configURL=w,this.rootDirectory=N,this.manifestPath=k.manifestPath,this.manifestURL=d(k.manifestPath,w),this.givensPath=k.givensPath,this.givensURL=c(k.givensPath,w,b),this.finalizeGivens=k.finalizeGivens,this.log=b}get connections(){return this._connections}wrapConnections(C){this._connections=C(this._connections)}async shutdown(C="close"){C==="idle"?await this._managedLookup.idle():await this._managedLookup.close()}async releaseConnections(){await this.shutdown("close")}async readOverlay(C,...T){var b,_;return await((_=(b=this._overlays)[C])===null||_===void 0?void 0:_.call(b,T))}}pu.MalloyConfig=a;const l="MANIFESTS",u="malloy-manifest.json";function d(S,C){if(!C)return;let T;try{T=new URL(C)}catch{return}const b=S??l;let _;try{_=new URL(b,T)}catch{return}const R=_.toString(),D=R.endsWith("/")?_:new URL(R+"/");return new URL(u,D).toString()}function c(S,C,T){if(!S)return;if(!C){T.push({message:"givensPath is set but no configURL is available; per-runtime givens will not be loaded. Pass `configURL` (or use an absolute URL such as `file:///...`).",severity:"warn",code:"config-overlay"});return}let b;try{b=new URL(C)}catch{return}try{return new URL(S,b).toString()}catch(_){const R=_ instanceof Error?_.message:String(_);T.push({message:`givensPath '${S}' could not be resolved against configURL '${C}': ${R}`,severity:"warn",code:"config-validation"});return}}function h(S,C){if(S===void 0)return{};if(f(S))return p(S,C);const T=S;if(T.overlays&&"config"in T.overlays){C.push({message:"`config` is reserved by MalloyConfig; pass `configURL` and `rootDirectory` directly instead. Supplied `overlays.config` ignored.",severity:"warn",code:"config-overlay"});const{config:b,..._}=T.overlays;return{...T,overlays:_}}return T}function f(S){for(const C of Object.values(S))if(typeof C=="function")return!0;return!1}function p(S,C){const T=S.config;if(!T)return{overlays:S};const b=x(T,"configURL",C),_=x(T,"rootDirectory",C),{config:R,...D}=S;return{configURL:b,rootDirectory:_,overlays:D}}function x(S,C,T){const b=S([C]);if((0,i.isThenable)(b)){T.push({message:`the legacy \`config\` overlay returned a Promise for \`${C}\`; top-level FS context must resolve synchronously. ${C} will be undefined.`,severity:"warn",code:"config-overlay"});return}return typeof b=="string"?b:void 0}function m(S,C,T){if(S!==void 0)try{return new URL(S),S}catch{T.push({message:`${C} must be a URL-shaped string (e.g. 'file:///path/to/...'), got '${S}'. In Node, use \`url.pathToFileURL(path).toString()\`.`,severity:"warn",code:"config-validation"});return}}function g(S,C){if(!E(S))return;const T=new Map;for(const[b,_]of Object.entries(S)){if(!E(_))continue;const R=new Map;for(const[D,w]of Object.entries(_)){if(typeof w!="string")continue;const N=(0,o.validateCanonicalTablePathAnyDialect)(w);if(N!==void 0){C.push({message:`virtualMap entry '${b}.${D}': ${N}`,severity:"error",code:"config-validation"});continue}R.set(D,w)}R.size>0&&T.set(b,R)}return T.size>0?T:void 0}function E(S){return typeof S=="object"&&S!==null&&!Array.isArray(S)}function v(S){return E(S)&&typeof S.tableName=="string"}return pu}var e0={},bm={},b8;function Sz(){return b8||(b8=1,Object.defineProperty(bm,"__esModule",{value:!0}),bm.MALLOY_VERSION=void 0,bm.MALLOY_VERSION="0.0.422"),bm}var R8;function tk(){if(R8)return e0;R8=1,Object.defineProperty(e0,"__esModule",{value:!0}),e0.Malloy=e0.MalloyError=void 0;const e=pT(),t=dx(),r=jr(),i=F2(),o=Sz(),s=JE(),a=ZP(),l=_0(),u=XE(),d=ek();function c(x="loadModel"){return`internal://${x}/${(0,l.v4)()}`}function h(x){return[...Object.keys(x),...Object.values(x).map(h).flat()]}class f extends Error{constructor(m,g=[]){super(m),this.problems=g}}e0.MalloyError=f;class p{static get version(){return o.MALLOY_VERSION}static registerConnectionType(m,g){(0,t.registerConnectionType)(m,g)}static getConnectionProperties(m){return(0,t.getConnectionProperties)(m)}static getConnectionTypeDisplayName(m){return(0,t.getConnectionTypeDisplayName)(m)}static getRegisteredConnectionTypes(){return(0,t.getRegisteredConnectionTypes)()}static _parse(m,g,E,v,S){var C;g===void 0&&(g=new URL(c(v?.method)));let T=g;v?.importBaseURL&&(T=v?.importBaseURL);const b=new e.MalloyTranslator(g.toString(),T.toString(),{urls:{[g.toString()]:m}},E,(C=v?.restrictedMode)!==null&&C!==void 0?C:!1);return v?.testEnvironment&&(b.allDialectsEnabled=!0),new a.Parse(b,S)}static parse({url:m,urlReader:g,source:E,eventStream:v,options:S}){if(E!==void 0)return p._parse(E,m,v,S);if(g===void 0)throw new Error("Internal Error: urlReader is required.");if(m===void 0)throw new Error("Internal Error: url is required if source not present.");return(0,s.readURL)(g,m).then(({contents:C,invalidationKey:T})=>p._parse(C,m,v,S,T))}static async compile(m){var g,E,v,S,C;let{url:T,source:b,importBaseURL:_,cacheManager:R}=m;const{parse:D,urlReader:w,connections:N,model:I,refreshSchemaCache:k,noThrowOnError:$,eventStream:J,restrictedMode:re,method:ie}=m;re&&(R=void 0);let oe;if(k&&(oe=typeof k=="number"?k:Date.now()),T===void 0&&b===void 0&&D===void 0)throw new Error("Internal Error: url, source, or parse required.");T===void 0&&(D!==void 0?T=new URL(D._translator.sourceURL):T=new URL(c(ie)));const U={};if(b===void 0&&R!==void 0){const te=await R.getCachedModelDef(w,T.toString());if(te)return new u.Model(te.modelDef,[],[T.toString(),...h(te.modelDef.dependencies)])}_??(_=T);let ee;const K=T.toString();if(D!==void 0){if(re!==void 0&&D._translator.restrictedMode!==re)throw new Error(`Malloy.compile: restrictedMode (${re}) does not match the pre-parsed translator's restrictedMode (${D._translator.restrictedMode}). Set restrictedMode at parse time.`);ee=D._translator;const te=(g=D._invalidationKey)!==null&&g!==void 0?g:await(0,s.getInvalidationKey)(w,T);U[K]=te}else{if(b===void 0){const{contents:te,invalidationKey:q}=await(0,s.readURL)(w,T);U[K]=q,b=te}else{const te=await(0,s.getInvalidationKey)(w,T);U[K]=te}ee=new e.MalloyTranslator(K,_.toString(),{urls:{[K]:b}},J,re??!1)}for(;;){const te=ee.translate(I?._modelDef);if(te.final)if(te.modelDef){await R?.setCachedModelDef(T.toString(),{modelDef:te.modelDef,invalidationKeys:U});for(const H of ee.newlyTranslatedDependencies())await R?.setCachedModelDef(H.url,{modelDef:H.modelDef,invalidationKeys:U});const q=!te.modelWasModified&&I?I.getExistingQueryModel():void 0;return new u.Model(te.modelDef,te.problems||[],[...(E=I?.fromSources)!==null&&E!==void 0?E:[],...(v=te.fromSources)!==null&&v!==void 0?v:[]],q)}else if($){const q=(0,r.mkModelDef)("modelDidNotCompile"),H=I?._modelDef||q;return new u.Model(H,te.problems||[],[...(S=I?.fromSources)!==null&&S!==void 0?S:[],...(C=te.fromSources)!==null&&C!==void 0?C:[]])}else{const q=te.problems||[],H=ee.prettyErrors();throw new f(`Error(s) compiling model:
1294
1294
  ${H}`,q)}else{if(te.urls)for(const q of te.urls)try{if((0,s.isInternalURL)(q))throw new Error("In order to use relative imports, you must compile a file via a URL.");if(R!==void 0){const j=await R.getCachedModelDef(w,q);if(j){for(const P in j.invalidationKeys)U[P]=j.invalidationKeys[P];ee.update({translations:{[q]:j.modelDef}});continue}}const{contents:H,invalidationKey:Q}=await(0,s.readURL)(w,new URL(q)),M={[q]:H};U[q]=Q,ee.update({urls:M})}catch(H){ee.update({errors:{urls:{[q]:H.message}}})}if(te.tables){const q=new Map;for(const H in te.tables){const{connectionName:Q,tablePath:M}=te.tables[H],j=q.get(Q);j===void 0?q.set(Q,{[H]:M}):j[H]=M}for(const[H,Q]of q)try{const M=await N.lookupConnection(H),{schemas:j,errors:P}=await p.safelyFetchTableSchema(M,Q,{refreshTimestamp:oe});ee.update({tables:j,errors:{tables:P}})}catch(M){const j={},P={};for(const V in Q)P[V]=M.toString();ee.update({tables:j,errors:{tables:P}})}}if(te.connectionDialects)for(const q in te.connectionDialects){const{connectionName:H}=te.connectionDialects[q];try{const Q=await N.lookupConnection(H);ee.update({connectionDialects:{[q]:Q.dialectName}})}catch(Q){ee.update({errors:{connectionDialects:{[q]:Q.toString()}}})}}if(te.compileSQL){const q=te.compileSQL,H=q.connection,Q=(0,i.sqlKey)(q.connection,q.selectStr);try{const j=await(await N.lookupConnection(H)).fetchSchemaForSQLStruct(q,{refreshTimestamp:oe});j.error&&ee.update({errors:{compileSQL:{[Q]:j.error}}}),j.structDef&&ee.update({compileSQL:{[Q]:j.structDef}})}catch(M){const j={};j[Q]=M.toString(),ee.update({errors:{compileSQL:j}})}}}}}static async safelyFetchTableSchema(m,g,E){const v=await m.fetchSchemaForTables(g,E);for(const S of Object.keys(g))if(v.schemas[S]===void 0&&v.errors[S]===void 0)throw new Error(`Schema fetch error for ${m.name}, no response for ${S} from ${m.dialectName}`);return v}static async run({connections:m,preparedResult:g,sqlStruct:E,connection:v,options:S}){if(!v){if(!m)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const C=E?.connection||g?.connectionName;v=await m.lookupConnection(C)}if(E){const C=await v.runSQL(E.selectStr);return new d.Result({structs:[E],sql:E.selectStr,result:C.rows,totalRows:C.totalRows,runStats:C.runStats,lastStageName:E.name,malloy:"",connectionName:E.connection,sourceExplore:"",sourceFilters:[],profilingUrl:C.profilingUrl},(0,r.mkModelDef)("empty_model"))}else if(g){const C=await v.runSQL(g.sql,S);return new d.Result({...g._rawQuery,result:C.rows,totalRows:C.totalRows,runStats:C.runStats,profilingUrl:C.profilingUrl},g._modelDef)}else throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}static async*runStream({connections:m,preparedResult:g,sqlStruct:E,connection:v,options:S}){if(E===void 0&&g===void 0)throw new Error("Internal error: sqlBlock or preparedResult must be provided.");const C=E?.connection||g?.connectionName;if(v===void 0){if(m===void 0)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");v=await m.lookupConnection(C)}if(!v.canStream())throw new Error(`Connection '${C}' cannot stream results.`);let T,b;if(E)b=new u.Explore((0,u.pseudoModelFor)(E),E),T=E.selectStr;else if(g!==void 0)b=g.resultExplore,T=g.sql;else throw new Error("Internal error: sqlStruct or preparedResult must be provided.");let _=0;for await(const R of v.runSQLStream(T,S))yield new d.DataRecord(R,_,b,void 0,void 0),_+=1}static async estimateQueryCost({connections:m,preparedResult:g,sqlStruct:E}){if(!m)throw new Error("Internal Error: Connection or LookupConnection<Connection> must be provided.");const v=E?.connection||g?.connectionName,S=await m.lookupConnection(v);if(E)return await S.estimateQueryCost(E.selectStr);if(g)return await S.estimateQueryCost(g.sql);throw new Error("Internal error: sqlStruct or preparedResult must be provided.")}}return e0.Malloy=p,e0}var w8;function Cz(){if(w8)return Vr;w8=1,Object.defineProperty(Vr,"__esModule",{value:!0}),Vr.ExploreMaterializer=Vr.PreparedResultMaterializer=Vr.QueryMaterializer=Vr.ModelMaterializer=Vr.SingleConnectionRuntime=Vr.ConnectionRuntime=Vr.Runtime=void 0;const e=jr(),t=Va(),r=YE(),i=gT(),o=w2(),s=JE(),a=XE(),l=tk();class u{constructor(C,T){this.runtime=C,this._materialize=T}materialize(){return this.materialized===void 0?this.rematerialize():this.materialized}rematerialize(){return this.materialized=this._materialize(),this.materialized}makeQueryMaterializer(C,T){return new p(this.runtime,C,T)}makeExploreMaterializer(C,T){return new m(this.runtime,C,T)}makePreparedResultMaterializer(C){return new x(this.runtime,C)}}class d{constructor({urlReader:C,connections:T,connection:b,config:_,buildManifest:R,eventStream:D,cacheManager:w,givens:N}){var I,k;if(this.isTestRuntime=!1,_!==void 0)this._config=_,T=T??_.connections;else if(T===void 0){if(b===void 0)throw new Error("A MalloyConfig, LookupConnection<Connection>, or Connection is required.");T={lookupConnection:()=>Promise.resolve(b)}}if(C===void 0&&(C=new s.EmptyURLReader),this._urlReader=C,this._connections=T,this._buildManifest=R,this._eventStream=D,this._cacheManager=w,N){for(const[$,J]of Object.entries(N))if(J===void 0)throw new Error(`Runtime givens.${$}: explicit undefined is not a valid value. Omit the key to defer to declaration default or the file layer; use null for an explicit null value.`)}this._constructorGivensMap=N?new Map(Object.entries(N)):new Map,this._finalizedGivensSet=new Set((k=(I=this._config)===null||I===void 0?void 0:I.finalizeGivens)!==null&&k!==void 0?k:[])}get cacheManager(){return this._cacheManager}get urlReader(){return this._urlReader}get connections(){return this._connections}get eventStream(){return this._eventStream}get _constructorGivens(){return this._constructorGivensMap}async getGivens(){const C=await this._resolveGivens(),T=new Map;if(C)for(const[b,_]of Object.entries(C))T.set(b,_);for(const[b,_]of this._constructorGivensMap)T.set(b,_);return T}get _finalizedGivens(){return this._finalizedGivensSet}set buildManifest(C){this._buildManifest=C,this._resolvedBuildManifestPromise=void 0}_resolveBuildManifest(){var C;if(this._buildManifest)return Promise.resolve(this._buildManifest);const T=(C=this._config)===null||C===void 0?void 0:C.manifestURL;return T?(this._resolvedBuildManifestPromise||(this._resolvedBuildManifestPromise=(async()=>{let b;try{const _=await this._urlReader.readURL(new URL(T));b=typeof _=="string"?_:_.contents}catch{return}try{const _=JSON.parse(b);if(!g(_))throw new Error('manifest is not an object with an "entries" map');for(const[R,D]of Object.entries(_.entries)){if(!(0,i.isBuildManifestEntry)(D))throw new Error(`Manifest entry '${R}' is missing a string tableName`);(0,r.requireCanonicalTablePathAnyDialect)(D.tableName,`Manifest entry '${R}'`)}return _}catch(_){const R=_ instanceof Error?_.message:String(_);return{entries:{},loadError:`Manifest file at ${T} could not be parsed: ${R}`}}})()),this._resolvedBuildManifestPromise):Promise.resolve(void 0)}_resolveGivens(){var C;const T=(C=this._config)===null||C===void 0?void 0:C.givensURL;return T?(this._resolvedGivensPromise||(this._resolvedGivensPromise=(async()=>{let b;try{const R=await this._urlReader.readURL(new URL(T));b=typeof R=="string"?R:R.contents}catch(R){const D=R instanceof Error?R.message:String(R);throw new Error(`givens: failed to read givens file at ${T}: ${D}`)}let _;try{_=JSON.parse(b)}catch(R){const D=R instanceof Error?R.message:String(R);throw new Error(`givens: failed to parse JSON at ${T}: ${D}`)}if(!E(_)){const R=Array.isArray(_)?"array":_===null?"null":typeof _;throw new Error(`givens: file at ${T} must be a JSON object of name → value pairs, got ${R}`)}return _})()),this._resolvedGivensPromise):Promise.resolve(void 0)}_invalidateGivensCache(){this._resolvedGivensPromise=void 0}get virtualMap(){var C,T;return(C=this._virtualMap)!==null&&C!==void 0?C:(T=this._config)===null||T===void 0?void 0:T.virtualMap}set virtualMap(C){this._virtualMap=C}async shutdown(C="close"){var T;await((T=this._config)===null||T===void 0?void 0:T.shutdown(C))}async releaseConnections(){await this.shutdown("close")}loadModel(C,T){const{refreshSchemaCache:b,noThrowOnError:_}=T||{};this.isTestRuntime&&(T===void 0?T={testEnvironment:!0}:T={...T,testEnvironment:!0});const R=C instanceof URL?{url:C}:{source:C};return new f(this,async()=>{const D=await l.Malloy.compile({...R,urlReader:this.urlReader,connections:this.connections,refreshSchemaCache:b,noThrowOnError:_,eventStream:this.eventStream,importBaseURL:T?.importBaseURL,testEnvironment:T?.testEnvironment,cacheManager:this.cacheManager});return this._withRuntimeContext(D)},T)}_withRuntimeContext(C){return this._finalizedGivensSet.size===0?C:new a.Model(C._modelDef,C.problems,C.fromSources,C.getExistingQueryModel(),{finalizedGivens:this._finalizedGivensSet})}_loadModelFromModelDef(C,T){return new f(this,async()=>new a.Model(C,[],[],void 0,this._finalizedGivensSet.size>0?{finalizedGivens:this._finalizedGivensSet}:void 0),T)}loadQuery(C,T){return this.loadModel(C,T).loadFinalQuery()}loadQueryByIndex(C,T,b){return this.loadModel(C,b).loadQueryByIndex(T,b)}loadQueryByName(C,T,b){return this.loadModel(C,b).loadQueryByName(T,b)}getModel(C,T){return this.loadModel(C,T).getModel()}getQuery(C,T){return this.loadQuery(C,T).getPreparedQuery()}getQueryByIndex(C,T,b){return this.loadQueryByIndex(C,T,b).getPreparedQuery()}getQueryByName(C,T,b){return this.loadQueryByName(C,T,b).getPreparedQuery()}}Vr.Runtime=d;class c extends d{constructor({urlReader:C,connections:T}){super({connections:s.FixedConnectionMap.fromArray(T),urlReader:C}),this.rawConnections=T}}Vr.ConnectionRuntime=c;class h extends d{constructor({urlReader:C,connection:T,eventStream:b,cacheManager:_}){super({urlReader:C,eventStream:b,cacheManager:_,connection:T}),this.connection=T}get supportsNesting(){return(0,t.getDialect)(this.connection.dialectName).supportsNesting}quote(C){return(0,t.getDialect)(this.connection.dialectName).sqlQuoteIdentifier(C)}get dialect(){return(0,t.getDialect)(this.connection.dialectName)}getQuoter(){return C=>this.quote(C.toString())}}Vr.SingleConnectionRuntime=h;class f extends u{constructor(C,T,b){super(C,T),this.runtime=C,this.compileQueryOptions=b}loadFinalQuery(C){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQuery(),{...this.compileQueryOptions,...C})}loadQueryByIndex(C,T){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByIndex(C),{...this.compileQueryOptions,...T})}loadQueryByName(C,T){return this.makeQueryMaterializer(async()=>(await this.materialize()).getPreparedQueryByName(C),{...this.compileQueryOptions,...T})}loadQuery(C,T){const{refreshSchemaCache:b,noThrowOnError:_}=T||{};return this.makeQueryMaterializer(async()=>{const R=this.runtime.urlReader,D=this.runtime.connections;this.runtime.isTestRuntime&&(T===void 0?T={testEnvironment:!0}:T={...T,testEnvironment:!0});const w=C instanceof URL?{url:C}:{source:C},N=await this.getModel();return(await l.Malloy.compile({...w,urlReader:R,connections:D,model:N,refreshSchemaCache:b,noThrowOnError:_,importBaseURL:T?.importBaseURL,testEnvironment:T?.testEnvironment,...this.compileQueryOptions})).preparedQuery})}loadRestrictedQuery(C){return this.makeQueryMaterializer(async()=>{const T=this.runtime.urlReader,b=this.runtime.connections,_=this.runtime.isTestRuntime?!0:void 0,R=await this.getModel();return(await l.Malloy.compile({source:C,restrictedMode:!0,method:"query",urlReader:T,connections:b,model:R,testEnvironment:_,...this.compileQueryOptions})).preparedQuery})}extendModel(C,T){return this.runtime.isTestRuntime&&(T===void 0?T={testEnvironment:!0}:T={...T,testEnvironment:!0}),new f(this.runtime,async()=>{const b=this.runtime.urlReader,_=this.runtime.connections,R=C instanceof URL?{url:C}:{source:C},D=await this.getModel(),w=await l.Malloy.compile({...R,urlReader:b,connections:_,model:D,method:"extendModel",refreshSchemaCache:T?.refreshSchemaCache,noThrowOnError:T?.noThrowOnError,importBaseURL:T?.importBaseURL,testEnvironment:T?.testEnvironment,...this.compileQueryOptions});return this.runtime._withRuntimeContext(w)},T)}async search(C,T,b=1e3,_=void 0){const R=await this.materialize(),D=R.queryModel,w=R.getExploreByName(C).structDef;if(!(0,e.isSourceDef)(w))throw new Error("Source to be searched was unexpectedly, not a source");const N=w.connection,I=await this.runtime.connections.lookupConnection(N);return await D.searchIndex(I,C,T,b,_)}async searchValueMap(C,T=10,b){const R=(await this.materialize()).getExploreByName(C);if(!(0,e.isSourceDef)(R.structDef))throw new Error("Source to be searched was unexpectedly, not a source");let D="{index: *}";R.getFieldByNameIfExists("search_index")&&(D="search_index");const w=`
1295
1295
  run: ${C}
1296
1296
  -> ${D}
@@ -1,4 +1,4 @@
1
- import{aI as ci}from"./index-D2sm5RBA.js";import{r as di}from"./index-w_0OQJgZ.js";function pi(u,re){for(var j=0;j<re.length;j++){const N=re[j];if(typeof N!="string"&&!Array.isArray(N)){for(const E in N)if(E!=="default"&&!(E in u)){const S=Object.getOwnPropertyDescriptor(N,E);S&&Object.defineProperty(u,E,S.get?S:{enumerable:!0,get:()=>N[E]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var bt={},ut={},Or;function Vt(){if(Or)return ut;Or=1,Object.defineProperty(ut,"__esModule",{value:!0}),ut.isChainOp=u,ut.isStringCondition=re,ut.isStringFilter=j,ut.isBooleanFilter=N,ut.isNumberFilter=E,ut.isTemporalFilter=S,ut.isFilterExpression=w,ut.isFilterable=y;function u(o){return["and","or",","].includes(o)}function re(o){return["starts","ends","contains","="].includes(o.operator)}function j(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","empty","and","or",",","()"].includes(o.operator)}function N(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","true","false","=false","=true"].includes(o.operator)}function E(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null"].includes(o.operator)}function S(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null"].includes(o.operator)}function w(o){return typeof o=="object"&&o!==null&&"operator"in o}function y(o){return["string","number","boolean","timestamp","timestamptz","date"].includes(o)}return ut}var Pt={},Er;function hi(){return Er||(Er=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.BooleanFilterExpression=void 0,Pt.BooleanFilterExpression={parse(u){var re;if(u.match(/^\s*$/))return{parsed:null,log:[]};const j={parsed:null,log:[]};let N=u.toLowerCase().trim().replace(/\s\s+/," "),E=!1;if(N.startsWith("not ")&&(E=!0,N=N.slice(4)),N==="true")j.parsed={operator:"true"};else if(N==="=true")j.parsed={operator:"=true"};else if(N==="false")j.parsed={operator:"false"};else if(N==="=false")j.parsed={operator:"=false"};else if(N==="null")j.parsed={operator:"null"};else{const S=u.match(/[^\s]/),w=S&&(re=S.index)!==null&&re!==void 0?re:0;j.log=[{message:`Illegal boolean filter '${N}'. Must be one of true,=true,false,=false,null`,severity:"error",startIndex:w,endIndex:w+u.length-1}]}return E&&j.parsed&&(j.parsed.not=!0),j},unparse(u){return u===null?"":(u.not?"not ":"")+u.operator}}),Pt}var pr={},Ue={},kr;function Ht(){if(kr)return Ue;kr=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.maybeNot=re,Ue.unescape=j,Ue.escape=N,Ue.matchOp=S,Ue.conjoin=y,Ue.joinNumbers=o,Ue.mkRange=d,Ue.mkValues=t,Ue.numNot=D,Ue.temporalNot=x,Ue.joinTemporal=Z,Ue.timeLiteral=ee,Ue.mkUnits=ce;const u=Vt();function re(O){const[A,b]=O;return A&&b&&(0,u.isStringFilter)(b)?{...b,not:!0}:b}function j(O){return O.replace(/\\(.)/g,"$1")}function N(O){const A=O.toLowerCase();return A==="null"||A==="empty"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function E(O){let A=!1,b=!1,B=0,de=!1;const Fe=O.length;for(let ve=0;ve<Fe;ve+=1){const Ye=O[ve];if(Ye===" "||Ye===" "){B+=1;continue}B=0,Ye==="%"?(de=!0,ve===0&&(A=!0),b=!0):(b=!1,Ye==="\\"?ve+=1:Ye==="_"&&(de=!0))}return{hasLike:de,percentEnd:b&&Fe>1,percentStart:A&&Fe>1,endSpace:B}}function S(O){let A=O.trimStart();const{hasLike:b,percentEnd:B,percentStart:de,endSpace:Fe}=E(A);if(Fe>0&&(A=A.slice(0,-Fe)),b){if(de&&B){const ve=A.slice(1,-1);if(!E(ve).hasLike&&ve.length>0)return{operator:"contains",values:[j(ve)]}}else if(B){const ve=A.slice(0,-1);if(!E(ve).hasLike)return{operator:"starts",values:[j(ve)]}}else if(de){const ve=A.slice(1);if(!E(ve).hasLike)return{operator:"ends",values:[j(ve)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:{operator:"=",values:[j(A)]}}function w(O,A){var b,B;return O.operator===A.operator&&((b=O.not)!==null&&b!==void 0?b:!1)===((B=A.not)!==null&&B!==void 0?B:!1)}function y(O,A,b){if(A=A.toLowerCase(),(0,u.isStringFilter)(O)&&(0,u.isStringFilter)(b)){if(A===","){if(O.operator==="~"&&w(O,b))return{...O,escaped_values:[...O.escaped_values,...b.escaped_values]};if((0,u.isStringCondition)(O)&&w(O,b))return{...O,values:[...O.values,...b.values]}}const B=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(B)return O.operator===B?{...O,members:[...O.members,b]}:{operator:B,members:[O,b]}}return null}function o(O,A,b){if(A=A.toLowerCase(),(0,u.isNumberFilter)(O)&&(0,u.isNumberFilter)(b)){if(A==="or"&&O.operator==="="&&w(O,b)){const B={operator:"=",values:[...O.values,...b.values]};return O.not&&(B.not=!0),B}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}}return null}function d(O,A,b,B){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:b,endOperator:B===")"?"<":"<="}}function t(O,A){return{values:[O,...A]}}function D(O,A){return(0,u.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function x(O,A){if((0,u.isTemporalFilter)(O)&&A){if("not"in O){const b={...O};return O.not?delete b.not:b.not=!0,b}return{...O,not:!0}}return O}function Z(O,A,b){return A=A.toLowerCase(),(0,u.isTemporalFilter)(O)&&(0,u.isTemporalFilter)(b)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}:null}function ee(O,A){const b={moment:"literal",literal:O};return A&&(b.units=A),b}function ce(O){switch(O.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return Ue}var hr,Rr;function mi(){if(Rr)return hr;Rr=1;const{numNot:u,mkRange:re,joinNumbers:j,mkValues:N}=Ht();function E(o,d){function t(){this.constructor=o}t.prototype=d.prototype,o.prototype=new t}function S(o,d,t,D){var x=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(x,S.prototype),x.expected=d,x.found=t,x.location=D,x.name="SyntaxError",x}E(S,Error);function w(o,d,t){return t=t||" ",o.length>d?o:(d-=o.length,t+=t.repeat(d),o+t.slice(0,d))}S.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var t=null,D;for(D=0;D<o.length;D++)if(o[D].source===this.location.source){t=o[D].text.split(/\r\n|\n|\r/g);break}var x=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(x):x,ee=this.location.source+":"+Z.line+":"+Z.column;if(t){var ce=this.location.end,O=w("",Z.line.toString().length," "),A=t[x.line-1],b=x.line===ce.line?ce.column:A.length+1,B=b-x.column||1;d+=`
1
+ import{aI as ci}from"./index-C6gZ6sSY.js";import{r as di}from"./index-w_0OQJgZ.js";function pi(u,re){for(var j=0;j<re.length;j++){const N=re[j];if(typeof N!="string"&&!Array.isArray(N)){for(const E in N)if(E!=="default"&&!(E in u)){const S=Object.getOwnPropertyDescriptor(N,E);S&&Object.defineProperty(u,E,S.get?S:{enumerable:!0,get:()=>N[E]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var bt={},ut={},Or;function Vt(){if(Or)return ut;Or=1,Object.defineProperty(ut,"__esModule",{value:!0}),ut.isChainOp=u,ut.isStringCondition=re,ut.isStringFilter=j,ut.isBooleanFilter=N,ut.isNumberFilter=E,ut.isTemporalFilter=S,ut.isFilterExpression=w,ut.isFilterable=y;function u(o){return["and","or",","].includes(o)}function re(o){return["starts","ends","contains","="].includes(o.operator)}function j(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","empty","and","or",",","()"].includes(o.operator)}function N(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","true","false","=false","=true"].includes(o.operator)}function E(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null"].includes(o.operator)}function S(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null"].includes(o.operator)}function w(o){return typeof o=="object"&&o!==null&&"operator"in o}function y(o){return["string","number","boolean","timestamp","timestamptz","date"].includes(o)}return ut}var Pt={},Er;function hi(){return Er||(Er=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.BooleanFilterExpression=void 0,Pt.BooleanFilterExpression={parse(u){var re;if(u.match(/^\s*$/))return{parsed:null,log:[]};const j={parsed:null,log:[]};let N=u.toLowerCase().trim().replace(/\s\s+/," "),E=!1;if(N.startsWith("not ")&&(E=!0,N=N.slice(4)),N==="true")j.parsed={operator:"true"};else if(N==="=true")j.parsed={operator:"=true"};else if(N==="false")j.parsed={operator:"false"};else if(N==="=false")j.parsed={operator:"=false"};else if(N==="null")j.parsed={operator:"null"};else{const S=u.match(/[^\s]/),w=S&&(re=S.index)!==null&&re!==void 0?re:0;j.log=[{message:`Illegal boolean filter '${N}'. Must be one of true,=true,false,=false,null`,severity:"error",startIndex:w,endIndex:w+u.length-1}]}return E&&j.parsed&&(j.parsed.not=!0),j},unparse(u){return u===null?"":(u.not?"not ":"")+u.operator}}),Pt}var pr={},Ue={},kr;function Ht(){if(kr)return Ue;kr=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.maybeNot=re,Ue.unescape=j,Ue.escape=N,Ue.matchOp=S,Ue.conjoin=y,Ue.joinNumbers=o,Ue.mkRange=d,Ue.mkValues=t,Ue.numNot=D,Ue.temporalNot=x,Ue.joinTemporal=Z,Ue.timeLiteral=ee,Ue.mkUnits=ce;const u=Vt();function re(O){const[A,b]=O;return A&&b&&(0,u.isStringFilter)(b)?{...b,not:!0}:b}function j(O){return O.replace(/\\(.)/g,"$1")}function N(O){const A=O.toLowerCase();return A==="null"||A==="empty"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function E(O){let A=!1,b=!1,B=0,de=!1;const Fe=O.length;for(let ve=0;ve<Fe;ve+=1){const Ye=O[ve];if(Ye===" "||Ye===" "){B+=1;continue}B=0,Ye==="%"?(de=!0,ve===0&&(A=!0),b=!0):(b=!1,Ye==="\\"?ve+=1:Ye==="_"&&(de=!0))}return{hasLike:de,percentEnd:b&&Fe>1,percentStart:A&&Fe>1,endSpace:B}}function S(O){let A=O.trimStart();const{hasLike:b,percentEnd:B,percentStart:de,endSpace:Fe}=E(A);if(Fe>0&&(A=A.slice(0,-Fe)),b){if(de&&B){const ve=A.slice(1,-1);if(!E(ve).hasLike&&ve.length>0)return{operator:"contains",values:[j(ve)]}}else if(B){const ve=A.slice(0,-1);if(!E(ve).hasLike)return{operator:"starts",values:[j(ve)]}}else if(de){const ve=A.slice(1);if(!E(ve).hasLike)return{operator:"ends",values:[j(ve)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:{operator:"=",values:[j(A)]}}function w(O,A){var b,B;return O.operator===A.operator&&((b=O.not)!==null&&b!==void 0?b:!1)===((B=A.not)!==null&&B!==void 0?B:!1)}function y(O,A,b){if(A=A.toLowerCase(),(0,u.isStringFilter)(O)&&(0,u.isStringFilter)(b)){if(A===","){if(O.operator==="~"&&w(O,b))return{...O,escaped_values:[...O.escaped_values,...b.escaped_values]};if((0,u.isStringCondition)(O)&&w(O,b))return{...O,values:[...O.values,...b.values]}}const B=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(B)return O.operator===B?{...O,members:[...O.members,b]}:{operator:B,members:[O,b]}}return null}function o(O,A,b){if(A=A.toLowerCase(),(0,u.isNumberFilter)(O)&&(0,u.isNumberFilter)(b)){if(A==="or"&&O.operator==="="&&w(O,b)){const B={operator:"=",values:[...O.values,...b.values]};return O.not&&(B.not=!0),B}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}}return null}function d(O,A,b,B){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:b,endOperator:B===")"?"<":"<="}}function t(O,A){return{values:[O,...A]}}function D(O,A){return(0,u.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function x(O,A){if((0,u.isTemporalFilter)(O)&&A){if("not"in O){const b={...O};return O.not?delete b.not:b.not=!0,b}return{...O,not:!0}}return O}function Z(O,A,b){return A=A.toLowerCase(),(0,u.isTemporalFilter)(O)&&(0,u.isTemporalFilter)(b)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}:null}function ee(O,A){const b={moment:"literal",literal:O};return A&&(b.units=A),b}function ce(O){switch(O.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return Ue}var hr,Rr;function mi(){if(Rr)return hr;Rr=1;const{numNot:u,mkRange:re,joinNumbers:j,mkValues:N}=Ht();function E(o,d){function t(){this.constructor=o}t.prototype=d.prototype,o.prototype=new t}function S(o,d,t,D){var x=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(x,S.prototype),x.expected=d,x.found=t,x.location=D,x.name="SyntaxError",x}E(S,Error);function w(o,d,t){return t=t||" ",o.length>d?o:(d-=o.length,t+=t.repeat(d),o+t.slice(0,d))}S.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var t=null,D;for(D=0;D<o.length;D++)if(o[D].source===this.location.source){t=o[D].text.split(/\r\n|\n|\r/g);break}var x=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(x):x,ee=this.location.source+":"+Z.line+":"+Z.column;if(t){var ce=this.location.end,O=w("",Z.line.toString().length," "),A=t[x.line-1],b=x.line===ce.line?ce.column:A.length+1,B=b-x.column||1;d+=`
2
2
  --> `+ee+`
3
3
  `+O+` |
4
4
  `+Z.line+" | "+A+`