@malloy-publisher/server 0.0.236 → 0.0.237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{aG as XF,r as L,j as N,ac as Ht,R as ZF,aH as e9,aI as ns}from"./index-CH2AcDzc.js";import{r as Jd,a as dA,d as xt}from"./index-VBbcc8s6.js";import{r as Wa}from"./index-w_0OQJgZ.js";import{d as AU}from"./index-DQpV7MyA.js";import{MalloyRenderer as t9,isCoreVizPluginInstance as TU}from"./index-DzaYbhnD.js";var Eo={},K3={},fr={},J3={},gR;function Ge(){return gR||(gR=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=x,e.isTimeLiteral=f,e.isParameterType=p,e.paramHasValue=h,e.activeName=g,e.expressionIsScalar=m,e.expressionIsAggregate=E,e.expressionIsUngroupedAggregate=v,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=T,e.isExpressionTypeLEQ=D,e.maxExpressionType=C,e.maxOfExpressionTypes=w,e.hasExpression=R,e.isTemporalType=O,e.isBasicAtomicType=I,e.isAtomicFieldType=k,e.canOrderBy=$,e.fieldIsIntrinsic=Y,e.mkFieldDef=ne,e.mkArrayDef=re,e.mkArrayTypeDef=oe,e.isRepeatedRecordFunctionParam=U,e.isRepeatedRecord=ee,e.isRecordOrRepeatedRecord=J,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=xe,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(ie,Ae){return t.call(ie,Ae)?ie[Ae]:void 0}function i(){return Object.create(null)}function o(ie){return"kids"in ie}function s(ie){return"e"in ie}function a(ie){return!(o(ie)||s(ie))}function l(ie){return ie.node==="aggregate"&&["sum","avg","count","distinct"].includes(ie.function)}function u(ie){return ie.node!=="arrayLiteral"&&ie.node!=="recordLiteral"}function d(ie,Ae){if(!("typeDef"in ie)){const Oe=typeof Ae=="string"?{type:Ae}:Ae;if(u(ie))return{...ie,typeDef:{...Oe}}}return ie}function c(ie){return"dstSQLType"in ie}function x(ie){return["string","number","boolean","date","timestamp","timestamptz"].includes(ie)}function f(ie){return ie.node==="dateLiteral"||ie.node==="timestampLiteral"||ie.node==="timestamptzLiteral"}function p(ie){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ie)}function h(ie){return ie.value!==null}function g(ie){var Ae;return(Ae=ie.as)!==null&&Ae!==void 0?Ae:ie.name}function m(ie){return ie===void 0||ie==="scalar"}function E(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"}function v(ie){return ie==="ungrouped_aggregate"}function _(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"||ie==="aggregate_analytic"}function S(ie){return ie==="aggregate"||ie==="scalar_analytic"||ie==="aggregate_analytic"||ie==="ungrouped_aggregate"}function T(ie){return ie==="aggregate_analytic"||ie==="scalar_analytic"}function b(ie){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ie]}function D(ie,Ae){return ie===Ae||b(ie)<b(Ae)}function C(ie,Ae){let Oe="scalar";return(ie==="aggregate"||Ae==="aggregate")&&(Oe="aggregate"),(ie==="ungrouped_aggregate"||Ae==="ungrouped_aggregate")&&(Oe="ungrouped_aggregate"),(ie==="scalar_analytic"||Ae==="scalar_analytic")&&(Oe="scalar_analytic"),(ie==="aggregate_analytic"||Ae==="aggregate_analytic")&&(Oe="aggregate_analytic"),(ie==="scalar_analytic"&&Ae==="aggregate"||ie==="aggregate"&&Ae==="scalar_analytic")&&(Oe="aggregate_analytic"),Oe}function w(ie){return ie.reduce(C,"scalar")}function R(ie){return"e"in ie&&ie.e!==void 0}function O(ie){return ie==="date"||ie==="timestamp"||ie==="timestamptz"}function I(ie){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ie)}function k(ie){return I(ie)||ie==="record"||ie==="array"}function $(ie){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ie)}function Y(ie){return k(ie.type)&&!R(ie)}function ne(ie,Ae){if(te(ie))return re(ie.elementTypeDef,Ae);if(ee(ie)){const{type:je,fields:it,elementTypeDef:dt}=ie;return{type:je,fields:it,elementTypeDef:dt,join:"many",name:Ae}}if(ie.type==="record"){const{type:je,fields:it}=ie;return{type:je,fields:it,join:"one",name:Ae}}const Oe={name:Ae,type:ie.type};switch(ie.type){case"sql native":return{...Oe,rawType:ie.rawType};case"number":{const je=ie.numberType;return je?{...Oe,numberType:je}:Oe}case"date":{const je=ie.timeframe;return je?{name:Ae,type:"date",timeframe:je}:Oe}case"timestamp":{const je={name:Ae,type:"timestamp"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}case"timestamptz":{const je={name:Ae,type:"timestamptz"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}}return Oe}function re(ie,Ae){if(ie.type==="record")return{type:"array",join:"many",name:Ae,elementTypeDef:{type:"record_element"},fields:ie.fields};const Oe=ne(ie,"value");return{type:"array",join:"many",name:Ae,elementTypeDef:ie,fields:[Oe,{...Oe,name:"each",e:{node:"field",path:["value"]}}]}}function oe(ie){return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}function U(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function ee(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function J(ie){return ie.type==="record"||ie.type==="array"&&"elementTypeDef"in ie&&ie.elementTypeDef.type==="record_element"}function te(ie){return ie.type==="array"&&ie.elementTypeDef.type!=="record_element"}function q(ie){return["left","right","full","inner"].includes(ie)}function H(ie){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ie.type)}function Q(ie){return"join"in ie}function M(ie){return mt(ie)&&Q(ie)}function j(ie){return["day","week","month","quarter","year"].includes(ie)}function P(ie){return j(ie)||["hour","minute","second"].includes(ie)}function V(ie){return P(ie)||ie==="day_of_week"||ie==="day_of_year"}var Z;(function(ie){ie.Date="date",ie.Timestamp="timestamp",ie.Number="number",ie.String="string"})(Z||(e.ValueType=Z={}));function ae(ie){return typeof ie!="string"}function ce(ie){return!!((ie.type==="reduce"||ie.type==="project"||ie.type==="partial")&&(ie.extendSource&&ie.extendSource.some(Ae=>Ae.type==="error")||ie.queryFields.some(Ae=>Ae.type==="error")))}function le(ie){return ie.fields.some(Ae=>Ae.type==="error")}function se(ie){return ie.type==="reduce"}function xe(ie){return ie.type==="partial"}function pe(ie){return ie.type==="project"}function ye(ie){return pe(ie)||se(ie)}function Ce(ie){return ie.rows!==void 0}function me(ie){return ie.percent!==void 0}function _e(ie){return ie.enable!==void 0}function we(ie){return ie.type==="raw"}function Ke(ie){return ie.type==="index"}function rt(ie){return ie.uniqueKeyRequirement===void 0&&ie.analyticFunctionUse===void 0}function ge(ie){var Ae;return(Ae=ie?.fieldUsage)!==null&&Ae!==void 0?Ae:[]}function Ee(ie){var Ae;return(Ae=ie?.givenUsage)!==null&&Ae!==void 0?Ae:[]}function Pe({fieldUsage:ie,givenUsage:Ae}){if(!(ie===void 0&&Ae===void 0))return{fieldUsage:ie??[],...Ae&&{givenUsage:Ae}}}function ke(ie,Ae){return ie&&{...ie,fieldUsage:ie.fieldUsage.map(Ae)}}function Me(ie,Ae){ie.refSummary?ie.refSummary.fieldUsage=Ae:ie.refSummary={fieldUsage:Ae}}function Xe(ie){return"sql"in ie}function at(ie){return"type"in ie&&(ie.type==="sql_select"||ie.type==="query_source")}function Qe(ie){return ie.type==="source_registry_reference"}function Et(ie){return{...ie}}function mt(ie){return ie.type==="table"||ie.type==="sql_select"||ie.type==="query_source"||ie.type==="query_result"||ie.type==="finalize"||ie.type==="nest_source"||ie.type==="virtual"||ie.type==="composite"}function Te(ie){return ie.type==="sql_select"||ie.type==="query_source"}function ze(ie){return M(ie)?!1:!!mt(ie)}function st(ie){return ie==="literal"}function de(...ie){return ie.length<=1&&ie.every(Ae=>Ae==="literal")?"literal":ie.every(Ae=>Ae==="constant"||Ae==="literal")?"constant":ie.every(Ae=>Ae==="output"||Ae==="constant"||Ae==="literal")?"output":"input"}function he(ie){return ie.type==="string"||O(ie.type)||ie.type==="number"||ie.type==="boolean"||ie.type==="json"||ie.type==="sql native"||ie.type==="error"}function ve(ie){return ie.type==="userType"}function be(ie){return Array.isArray(ie)&&(ie.length===0||typeof ie[0]=="object"&&ie[0]!==null&&!Array.isArray(ie[0]))}function Be(ie){return ie.type==="turtle"}function Ie(ie){return k(ie.type)}function We(ie,Ae){return Ae.type==="string"}function nt(ie,Ae){return Ae.type==="number"}function gt(ie,Ae){return Ae.type==="boolean"}function yt(ie,Ae){return Ae.type==="timestamp"}function ut(ie,Ae){return Ae.type==="date"}e.TD={isAtomic(ie){return ie!==void 0&&k(ie.type)},isBasicAtomic(ie){return ie!==void 0&&he({type:ie.type})},isString:ie=>ie?.type==="string",isNumber:ie=>ie?.type==="number",isBoolean:ie=>ie?.type==="boolean",isJSON:ie=>ie?.type==="json",isSQL:ie=>ie?.type==="sql native",isDate:ie=>ie?.type==="date",isTimestamp:ie=>ie?.type==="timestamp",isTimestamptz:ie=>ie?.type==="timestamptz",isAnyTimestamp(ie){return ie?.type==="timestamp"||ie?.type==="timestamptz"},isTemporal(ie){var Ae;const Oe=(Ae=ie?.type)!==null&&Ae!==void 0?Ae:"";return O(Oe)},isError:ie=>ie?.type==="error",atomicDef(ie){if(!e.TD.isAtomic(ie))return{type:"error"};switch(ie.type){case"array":return ee(ie)?{type:"array",elementTypeDef:ie.elementTypeDef,fields:ie.fields}:{type:"array",elementTypeDef:ie.elementTypeDef};case"record":return{type:"record",fields:ie.fields};case"number":return ie.numberType?{type:"number",numberType:ie.numberType}:{type:"number"};case"sql native":return ie.rawType?{type:"sql native",rawType:ie.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ie.timeframe?{type:ie.type,timeframe:ie.timeframe}:{type:ie.type};default:return{type:ie.type}}},eq(ie,Ae){if(ie===void 0||Ae===void 0)return!1;function Oe(je,it){const dt={},lt=je.fields||[],ft=it.fields||[];if(lt.length!==ft.length)return!1;for(const It of lt)if(It.name)dt[It.name]=It;else return!1;for(const It of ft)if(!e.TD.eq(dt[It.name],It))return!1;return!0}return ie.type==="array"&&Ae.type==="array"?ie.elementTypeDef.type!==Ae.elementTypeDef.type?!1:ie.elementTypeDef.type!=="record_element"&&Ae.elementTypeDef.type!=="record_element"?e.TD.eq(ie.elementTypeDef,Ae.elementTypeDef):e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="record"&&Ae.type==="record"?e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="sql native"&&Ae.type==="sql native"?ie.rawType!==void 0&&ie.rawType===Ae.rawType:ie.type===Ae.type}};function et(ie,Ae){return ie?Ae?{isCount:ie.isCount||Ae.isCount}:ie:Ae}})(J3)),J3}var yR;function cs(){if(yR)return fr;yR=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.arg=t,fr.spread=r,fr.sql=i,fr.constant=o,fr.output=s,fr.literal=a,fr.variadicParam=l,fr.param=u,fr.makeParam=d,fr.maxScalar=c,fr.maxAggregate=x,fr.anyExprType=f,fr.maxUngroupedAggregate=p,fr.maxAnalytic=h,fr.minScalar=g,fr.minAggregate=m,fr.minAnalytic=E,fr.overload=v,fr.expandBlueprintMap=te,fr.expandOverrideMapFromBase=Q,fr.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 x(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 h(P){return{...P,expressionType:"aggregate_analytic",evalSpace:"input"}}function g(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function m(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 _(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?_(P.array,!0):_(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?_(le,!0):_(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 S(P){if(P==="any")throw new Error("Cannot return any type");if(typeof P=="string")return g({type:P});if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("generic"in P)return g(_(P,!1));if("literal"in P)return a(g(_(P.literal,!1)));if("constant"in P)return o(g(_(P.constant,!1)));if("dimension"in P)return g(_(P.dimension,!1));if("measure"in P)return m(_(P.measure,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return E(_(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 D(P){if(typeof P=="string")return f({type:P});if("generic"in P)return f(_(P));if("literal"in P)return a(c(_(P.literal)));if("constant"in P)return o(c(_(P.constant)));if("dimension"in P)return c(_(P.dimension));if("measure"in P)return x(_(P.measure));if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return h(_(P.calculation));throw new Error("Invalid function blueprint")}function C(P){return P.map(V=>D(V))}function w(P){return typeof P!="string"&&"variadic"in P}function R(P,V){return{name:P,allowedTypes:C(b(V)),isVariadic:w(V)}}function O(P){return Object.entries(P).map(Z=>R(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 xe=ae.indexOf("}");if(xe===-1){V.push(se+ae);break}const pe=ae.slice(2,xe);ae=ae.slice(xe+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 w(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 Y(P){return"sql"in P.impl?I(P.impl.sql):"expr"in P.impl?P.impl.expr:$(P.impl.function,P)}function ne(P){return{e:Y(P),between:P.impl.between,needsWindowOrderBy:P.impl.needsWindowOrderBy,defaultOrderByArgIndex:P.impl.defaultOrderByArgIndex}}function re(P){if(P!==void 0)return Object.entries(P).map(([V,Z])=>({name:V,acceptibleTypes:Z.map(ae=>_(ae,!0,!1))}))}function oe(P){return{returnType:S(P.returns),params:O(P.takes),isSymmetric:P.isSymmetric,supportsOrderBy:P.supportsOrderBy,supportsLimit:P.supportsLimit,genericTypes:re(P.generic),...ne(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 J(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]=J(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 xe of Object.values(V))for(const pe of M(xe))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 fr}var X3={},Rx={},ER;function fA(){if(ER)return Rx;ER=1,Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.decodeDottedTablePath=e,Rx.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 x=0;for(;;){let f,p;if(o[x]===a){const h=r(o,x,a,l);if(h===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — unterminated quoted segment`};f=h.decoded,p=!0,x=h.end}else{const h=o.slice(x).match(u);if(!h||h.index!==0||h[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — invalid segment at position ${x}`};f=h[0],p=!1,x+=h[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}),x===o.length)return{ok:!0,segments:c};if(o[x]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — expected '.' at position ${x}`};if(x++,x===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{aJ as XF,r as L,j as N,af as Ht,R as ZF,aK as e9,aL as ns}from"./index-BRijWj6K.js";import{r as Jd,a as dA,d as xt}from"./index-Cvy0xtb7.js";import{r as Wa}from"./index-w_0OQJgZ.js";import{d as AU}from"./index-DMAhIJNC.js";import{MalloyRenderer as t9,isCoreVizPluginInstance as TU}from"./index-DzaYbhnD.js";var Eo={},K3={},fr={},J3={},gR;function Ge(){return gR||(gR=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=x,e.isTimeLiteral=f,e.isParameterType=p,e.paramHasValue=h,e.activeName=g,e.expressionIsScalar=m,e.expressionIsAggregate=E,e.expressionIsUngroupedAggregate=v,e.expressionInvolvesAggregate=_,e.expressionIsCalculation=S,e.expressionIsAnalytic=T,e.isExpressionTypeLEQ=D,e.maxExpressionType=C,e.maxOfExpressionTypes=w,e.hasExpression=R,e.isTemporalType=O,e.isBasicAtomicType=I,e.isAtomicFieldType=k,e.canOrderBy=$,e.fieldIsIntrinsic=Y,e.mkFieldDef=ne,e.mkArrayDef=re,e.mkArrayTypeDef=oe,e.isRepeatedRecordFunctionParam=U,e.isRepeatedRecord=ee,e.isRecordOrRepeatedRecord=J,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=xe,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(ie,Ae){return t.call(ie,Ae)?ie[Ae]:void 0}function i(){return Object.create(null)}function o(ie){return"kids"in ie}function s(ie){return"e"in ie}function a(ie){return!(o(ie)||s(ie))}function l(ie){return ie.node==="aggregate"&&["sum","avg","count","distinct"].includes(ie.function)}function u(ie){return ie.node!=="arrayLiteral"&&ie.node!=="recordLiteral"}function d(ie,Ae){if(!("typeDef"in ie)){const Oe=typeof Ae=="string"?{type:Ae}:Ae;if(u(ie))return{...ie,typeDef:{...Oe}}}return ie}function c(ie){return"dstSQLType"in ie}function x(ie){return["string","number","boolean","date","timestamp","timestamptz"].includes(ie)}function f(ie){return ie.node==="dateLiteral"||ie.node==="timestampLiteral"||ie.node==="timestamptzLiteral"}function p(ie){return["string","number","boolean","date","timestamp","timestamptz","filter expression","error"].includes(ie)}function h(ie){return ie.value!==null}function g(ie){var Ae;return(Ae=ie.as)!==null&&Ae!==void 0?Ae:ie.name}function m(ie){return ie===void 0||ie==="scalar"}function E(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"}function v(ie){return ie==="ungrouped_aggregate"}function _(ie){return ie==="aggregate"||ie==="ungrouped_aggregate"||ie==="aggregate_analytic"}function S(ie){return ie==="aggregate"||ie==="scalar_analytic"||ie==="aggregate_analytic"||ie==="ungrouped_aggregate"}function T(ie){return ie==="aggregate_analytic"||ie==="scalar_analytic"}function b(ie){return{scalar:0,aggregate:1,ungrouped_aggregate:2,scalar_analytic:2,aggregate_analytic:3}[ie]}function D(ie,Ae){return ie===Ae||b(ie)<b(Ae)}function C(ie,Ae){let Oe="scalar";return(ie==="aggregate"||Ae==="aggregate")&&(Oe="aggregate"),(ie==="ungrouped_aggregate"||Ae==="ungrouped_aggregate")&&(Oe="ungrouped_aggregate"),(ie==="scalar_analytic"||Ae==="scalar_analytic")&&(Oe="scalar_analytic"),(ie==="aggregate_analytic"||Ae==="aggregate_analytic")&&(Oe="aggregate_analytic"),(ie==="scalar_analytic"&&Ae==="aggregate"||ie==="aggregate"&&Ae==="scalar_analytic")&&(Oe="aggregate_analytic"),Oe}function w(ie){return ie.reduce(C,"scalar")}function R(ie){return"e"in ie&&ie.e!==void 0}function O(ie){return ie==="date"||ie==="timestamp"||ie==="timestamptz"}function I(ie){return["string","number","date","timestamp","timestamptz","boolean","json","sql native","error"].includes(ie)}function k(ie){return I(ie)||ie==="record"||ie==="array"}function $(ie){return["string","number","date","boolean","date","timestamp","timestamptz"].includes(ie)}function Y(ie){return k(ie.type)&&!R(ie)}function ne(ie,Ae){if(te(ie))return re(ie.elementTypeDef,Ae);if(ee(ie)){const{type:je,fields:it,elementTypeDef:dt}=ie;return{type:je,fields:it,elementTypeDef:dt,join:"many",name:Ae}}if(ie.type==="record"){const{type:je,fields:it}=ie;return{type:je,fields:it,join:"one",name:Ae}}const Oe={name:Ae,type:ie.type};switch(ie.type){case"sql native":return{...Oe,rawType:ie.rawType};case"number":{const je=ie.numberType;return je?{...Oe,numberType:je}:Oe}case"date":{const je=ie.timeframe;return je?{name:Ae,type:"date",timeframe:je}:Oe}case"timestamp":{const je={name:Ae,type:"timestamp"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}case"timestamptz":{const je={name:Ae,type:"timestamptz"};return ie.timeframe&&(je.timeframe=ie.timeframe),je}}return Oe}function re(ie,Ae){if(ie.type==="record")return{type:"array",join:"many",name:Ae,elementTypeDef:{type:"record_element"},fields:ie.fields};const Oe=ne(ie,"value");return{type:"array",join:"many",name:Ae,elementTypeDef:ie,fields:[Oe,{...Oe,name:"each",e:{node:"field",path:["value"]}}]}}function oe(ie){return ie.type==="record"?{type:"array",elementTypeDef:{type:"record_element"},fields:ie.fields}:{type:"array",elementTypeDef:ie}}function U(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function ee(ie){return ie.type==="array"&&ie.elementTypeDef.type==="record_element"}function J(ie){return ie.type==="record"||ie.type==="array"&&"elementTypeDef"in ie&&ie.elementTypeDef.type==="record_element"}function te(ie){return ie.type==="array"&&ie.elementTypeDef.type!=="record_element"}function q(ie){return["left","right","full","inner"].includes(ie)}function H(ie){return["composite","table","sql_select","query_source","virtual","array","record"].includes(ie.type)}function Q(ie){return"join"in ie}function M(ie){return mt(ie)&&Q(ie)}function j(ie){return["day","week","month","quarter","year"].includes(ie)}function P(ie){return j(ie)||["hour","minute","second"].includes(ie)}function V(ie){return P(ie)||ie==="day_of_week"||ie==="day_of_year"}var Z;(function(ie){ie.Date="date",ie.Timestamp="timestamp",ie.Number="number",ie.String="string"})(Z||(e.ValueType=Z={}));function ae(ie){return typeof ie!="string"}function ce(ie){return!!((ie.type==="reduce"||ie.type==="project"||ie.type==="partial")&&(ie.extendSource&&ie.extendSource.some(Ae=>Ae.type==="error")||ie.queryFields.some(Ae=>Ae.type==="error")))}function le(ie){return ie.fields.some(Ae=>Ae.type==="error")}function se(ie){return ie.type==="reduce"}function xe(ie){return ie.type==="partial"}function pe(ie){return ie.type==="project"}function ye(ie){return pe(ie)||se(ie)}function Ce(ie){return ie.rows!==void 0}function me(ie){return ie.percent!==void 0}function _e(ie){return ie.enable!==void 0}function we(ie){return ie.type==="raw"}function Ke(ie){return ie.type==="index"}function rt(ie){return ie.uniqueKeyRequirement===void 0&&ie.analyticFunctionUse===void 0}function ge(ie){var Ae;return(Ae=ie?.fieldUsage)!==null&&Ae!==void 0?Ae:[]}function Ee(ie){var Ae;return(Ae=ie?.givenUsage)!==null&&Ae!==void 0?Ae:[]}function Pe({fieldUsage:ie,givenUsage:Ae}){if(!(ie===void 0&&Ae===void 0))return{fieldUsage:ie??[],...Ae&&{givenUsage:Ae}}}function ke(ie,Ae){return ie&&{...ie,fieldUsage:ie.fieldUsage.map(Ae)}}function Me(ie,Ae){ie.refSummary?ie.refSummary.fieldUsage=Ae:ie.refSummary={fieldUsage:Ae}}function Xe(ie){return"sql"in ie}function at(ie){return"type"in ie&&(ie.type==="sql_select"||ie.type==="query_source")}function Qe(ie){return ie.type==="source_registry_reference"}function Et(ie){return{...ie}}function mt(ie){return ie.type==="table"||ie.type==="sql_select"||ie.type==="query_source"||ie.type==="query_result"||ie.type==="finalize"||ie.type==="nest_source"||ie.type==="virtual"||ie.type==="composite"}function Te(ie){return ie.type==="sql_select"||ie.type==="query_source"}function ze(ie){return M(ie)?!1:!!mt(ie)}function st(ie){return ie==="literal"}function de(...ie){return ie.length<=1&&ie.every(Ae=>Ae==="literal")?"literal":ie.every(Ae=>Ae==="constant"||Ae==="literal")?"constant":ie.every(Ae=>Ae==="output"||Ae==="constant"||Ae==="literal")?"output":"input"}function he(ie){return ie.type==="string"||O(ie.type)||ie.type==="number"||ie.type==="boolean"||ie.type==="json"||ie.type==="sql native"||ie.type==="error"}function ve(ie){return ie.type==="userType"}function be(ie){return Array.isArray(ie)&&(ie.length===0||typeof ie[0]=="object"&&ie[0]!==null&&!Array.isArray(ie[0]))}function Be(ie){return ie.type==="turtle"}function Ie(ie){return k(ie.type)}function We(ie,Ae){return Ae.type==="string"}function nt(ie,Ae){return Ae.type==="number"}function gt(ie,Ae){return Ae.type==="boolean"}function yt(ie,Ae){return Ae.type==="timestamp"}function ut(ie,Ae){return Ae.type==="date"}e.TD={isAtomic(ie){return ie!==void 0&&k(ie.type)},isBasicAtomic(ie){return ie!==void 0&&he({type:ie.type})},isString:ie=>ie?.type==="string",isNumber:ie=>ie?.type==="number",isBoolean:ie=>ie?.type==="boolean",isJSON:ie=>ie?.type==="json",isSQL:ie=>ie?.type==="sql native",isDate:ie=>ie?.type==="date",isTimestamp:ie=>ie?.type==="timestamp",isTimestamptz:ie=>ie?.type==="timestamptz",isAnyTimestamp(ie){return ie?.type==="timestamp"||ie?.type==="timestamptz"},isTemporal(ie){var Ae;const Oe=(Ae=ie?.type)!==null&&Ae!==void 0?Ae:"";return O(Oe)},isError:ie=>ie?.type==="error",atomicDef(ie){if(!e.TD.isAtomic(ie))return{type:"error"};switch(ie.type){case"array":return ee(ie)?{type:"array",elementTypeDef:ie.elementTypeDef,fields:ie.fields}:{type:"array",elementTypeDef:ie.elementTypeDef};case"record":return{type:"record",fields:ie.fields};case"number":return ie.numberType?{type:"number",numberType:ie.numberType}:{type:"number"};case"sql native":return ie.rawType?{type:"sql native",rawType:ie.rawType}:{type:"sql native"};case"timestamp":case"timestamptz":return ie.timeframe?{type:ie.type,timeframe:ie.timeframe}:{type:ie.type};default:return{type:ie.type}}},eq(ie,Ae){if(ie===void 0||Ae===void 0)return!1;function Oe(je,it){const dt={},lt=je.fields||[],ft=it.fields||[];if(lt.length!==ft.length)return!1;for(const It of lt)if(It.name)dt[It.name]=It;else return!1;for(const It of ft)if(!e.TD.eq(dt[It.name],It))return!1;return!0}return ie.type==="array"&&Ae.type==="array"?ie.elementTypeDef.type!==Ae.elementTypeDef.type?!1:ie.elementTypeDef.type!=="record_element"&&Ae.elementTypeDef.type!=="record_element"?e.TD.eq(ie.elementTypeDef,Ae.elementTypeDef):e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="record"&&Ae.type==="record"?e.TD.isAtomic(ie)&&e.TD.isAtomic(Ae)&&Oe(ie,Ae):ie.type==="sql native"&&Ae.type==="sql native"?ie.rawType!==void 0&&ie.rawType===Ae.rawType:ie.type===Ae.type}};function et(ie,Ae){return ie?Ae?{isCount:ie.isCount||Ae.isCount}:ie:Ae}})(J3)),J3}var yR;function cs(){if(yR)return fr;yR=1,Object.defineProperty(fr,"__esModule",{value:!0}),fr.arg=t,fr.spread=r,fr.sql=i,fr.constant=o,fr.output=s,fr.literal=a,fr.variadicParam=l,fr.param=u,fr.makeParam=d,fr.maxScalar=c,fr.maxAggregate=x,fr.anyExprType=f,fr.maxUngroupedAggregate=p,fr.maxAnalytic=h,fr.minScalar=g,fr.minAggregate=m,fr.minAnalytic=E,fr.overload=v,fr.expandBlueprintMap=te,fr.expandOverrideMapFromBase=Q,fr.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 x(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 h(P){return{...P,expressionType:"aggregate_analytic",evalSpace:"input"}}function g(P){return{...P,expressionType:"scalar",evalSpace:"input"}}function m(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 _(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?_(P.array,!0):_(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?_(le,!0):_(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 S(P){if(P==="any")throw new Error("Cannot return any type");if(typeof P=="string")return g({type:P});if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("generic"in P)return g(_(P,!1));if("literal"in P)return a(g(_(P.literal,!1)));if("constant"in P)return o(g(_(P.constant,!1)));if("dimension"in P)return g(_(P.dimension,!1));if("measure"in P)return m(_(P.measure,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return E(_(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 D(P){if(typeof P=="string")return f({type:P});if("generic"in P)return f(_(P));if("literal"in P)return a(c(_(P.literal)));if("constant"in P)return o(c(_(P.constant)));if("dimension"in P)return c(_(P.dimension));if("measure"in P)return x(_(P.measure));if("array"in P)return f(_(P,!1));if("record"in P)return f(_(P,!1));if("sql_native"in P)return f({type:"sql native",rawType:P.sql_native});if("calculation"in P)return h(_(P.calculation));throw new Error("Invalid function blueprint")}function C(P){return P.map(V=>D(V))}function w(P){return typeof P!="string"&&"variadic"in P}function R(P,V){return{name:P,allowedTypes:C(b(V)),isVariadic:w(V)}}function O(P){return Object.entries(P).map(Z=>R(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 xe=ae.indexOf("}");if(xe===-1){V.push(se+ae);break}const pe=ae.slice(2,xe);ae=ae.slice(xe+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 w(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 Y(P){return"sql"in P.impl?I(P.impl.sql):"expr"in P.impl?P.impl.expr:$(P.impl.function,P)}function ne(P){return{e:Y(P),between:P.impl.between,needsWindowOrderBy:P.impl.needsWindowOrderBy,defaultOrderByArgIndex:P.impl.defaultOrderByArgIndex}}function re(P){if(P!==void 0)return Object.entries(P).map(([V,Z])=>({name:V,acceptibleTypes:Z.map(ae=>_(ae,!0,!1))}))}function oe(P){return{returnType:S(P.returns),params:O(P.takes),isSymmetric:P.isSymmetric,supportsOrderBy:P.supportsOrderBy,supportsLimit:P.supportsLimit,genericTypes:re(P.generic),...ne(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 J(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]=J(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 xe of Object.values(V))for(const pe of M(xe))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 fr}var X3={},Rx={},ER;function fA(){if(ER)return Rx;ER=1,Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.decodeDottedTablePath=e,Rx.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 x=0;for(;;){let f,p;if(o[x]===a){const h=r(o,x,a,l);if(h===null)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — unterminated quoted segment`};f=h.decoded,p=!0,x=h.end}else{const h=o.slice(x).match(u);if(!h||h.index!==0||h[0].length===0)return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — invalid segment at position ${x}`};f=h[0],p=!1,x+=h[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}),x===o.length)return{ok:!0,segments:c};if(o[x]!==".")return{ok:!1,error:`Invalid ${d} table path: ${JSON.stringify(o)} — expected '.' at position ${x}`};if(x++,x===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 Rx}var vR;function Vs(){return vR||(vR=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=fA();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 x=BigInt(d);for(const f of this.integerTypeMappings)if(x>=f.min&&x<=f.max)return{type:"number",numberType:f.numberType};return{type:"number",numberType:"bigint"}}static makeTimeLiteralNode(d,c,x,f,p){var h;const g=(h=d?.hasTimestamptz)!==null&&h!==void 0?h:!1;return p==="date"?{node:"dateLiteral",literal:c,typeDef:{type:"date",timeframe:f!==void 0&&(0,t.isDateUnit)(f)?f:void 0}}:x&&g?{node:"timestamptzLiteral",literal:c,typeDef:{type:"timestamptz",timeframe:f},timezone:x}:x?{node:"timestampLiteral",literal:c,typeDef:{type:"timestamp",timeframe:f},timezone:x}:{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(x=>` ${x.field} ${x.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 x="";for(const f of d)switch(f){case"\\":x+="\\\\";break;case`
3
3
  `:x+="\\n";break;case"\r":x+="\\r";break;case" ":x+="\\t";break;case c:x+="\\"+c;break;default:x+=f}return x}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,x,f){const p=["day","week","month","quarter","year"],h=c!==void 0&&p.includes(c),g=x!==void 0&&p.includes(x),m=s(f);return{needed:t.TD.isAnyTimestamp(d)&&(h||g)&&m!==void 0,tz:m}}sqlTruncAndOffset(d,c,x,f){if(t.TD.isAnyTimestamp(d.typeDef)){const{needed:h,tz:g}=this.needsCivilTimeComputation(d.typeDef,x,f?.unit,c);if(h&&g){const m=this.sqlConvertToCivilTime(d.sql,g,d.typeDef);let E=m.sql;const v=m.typeDef;return x&&(E=this.sqlTruncate(E,x,v,!0,g)),f&&(E=this.sqlOffsetTime(E,f.op,f.magnitude,f.unit,v,!0,g)),this.sqlConvertFromCivilTime(E,g,d.typeDef)}}let p=d.sql;return x&&(p=this.sqlTruncate(p,x,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 x=c.kids.base;return x.node==="trunc"?this.sqlTruncAndOffset(x.e,d,x.units,{op:c.op,magnitude:c.kids.delta.sql,unit:c.units}):this.sqlTruncAndOffset(x,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,x){return"sqlSumDistinct called but not implemented"}sqlAggDistinct(d,c,x){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,x){const f="__STRING_AGG_KS__",p="__STRING_AGG_KE__";return`REGEXP_REPLACE(
4
4
  STRING_AGG(DISTINCT ${`concat('${f}', ${d}, '${p}', ${c})`}${x.length>0?","+x:""}),
@@ -1,4 +1,4 @@
1
- import{aJ as mi}from"./index-CH2AcDzc.js";import{r as gi}from"./index-w_0OQJgZ.js";function yi(f,ie){for(var W=0;W<ie.length;W++){const P=ie[W];if(typeof P!="string"&&!Array.isArray(P)){for(const k in P)if(k!=="default"&&!(k in f)){const $=Object.getOwnPropertyDescriptor(P,k);$&&Object.defineProperty(f,k,$.get?$:{enumerable:!0,get:()=>P[k]})}}}return Object.freeze(Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}))}var Et={},dt={},Vr;function Ct(){if(Vr)return dt;Vr=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.isChainOp=f,dt.isStringCondition=ie,dt.isStringFilter=W,dt.isBooleanFilter=P,dt.isNumberFilter=k,dt.isTemporalFilter=$,dt.isFilterExpression=w,dt.isFilterable=y;function f(o){return["and","or",","].includes(o)}function ie(o){return["starts","ends","contains","="].includes(o.operator)}function W(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","none","empty","and","or",",","()"].includes(o.operator)}function P(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","none","true","false","=false","=true"].includes(o.operator)}function k(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null","none"].includes(o.operator)}function $(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","none"].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 dt}var Mt={},Lr;function vi(){return Lr||(Lr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.BooleanFilterExpression=void 0,Mt.BooleanFilterExpression={parse(f){var ie;if(f.match(/^\s*$/))return{parsed:null,log:[]};const W={parsed:null,log:[]};let P=f.toLowerCase().trim().replace(/\s\s+/," "),k=!1;if(P.startsWith("not ")&&(k=!0,P=P.slice(4)),P==="true")W.parsed={operator:"true"};else if(P==="=true")W.parsed={operator:"=true"};else if(P==="false")W.parsed={operator:"false"};else if(P==="=false")W.parsed={operator:"=false"};else if(P==="null")W.parsed={operator:"null"};else if(P==="none")W.parsed={operator:"none"};else{const $=f.match(/[^\s]/),w=$&&(ie=$.index)!==null&&ie!==void 0?ie:0;W.log=[{message:`Illegal boolean filter '${P}'. Must be one of true,=true,false,=false,null,none`,severity:"error",startIndex:w,endIndex:w+f.length-1}]}return k&&W.parsed&&(W.parsed.not=!0),W},unparse(f){return f===null?"":(f.not?"not ":"")+f.operator}}),Mt}var yr={},ze={},Ir;function Xt(){if(Ir)return ze;Ir=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.maybeNot=ie,ze.unescape=W,ze.escape=P,ze.matchOp=$,ze.conjoin=y,ze.joinNumbers=o,ze.mkRange=d,ze.mkValues=e,ze.numNot=C,ze.temporalNot=N,ze.joinTemporal=Z,ze.timeLiteral=ne,ze.mkUnits=pe;const f=Ct();function ie(O){const[A,F]=O;return A&&F&&(0,f.isStringFilter)(F)?{...F,not:!0}:F}function W(O){return O.replace(/\\(.)/g,"$1")}function P(O){const A=O.toLowerCase();return A==="null"||A==="empty"||A==="none"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function k(O){let A=!1,F=!1,G=0,he=!1;const Fe=O.length;for(let we=0;we<Fe;we+=1){const He=O[we];if(He===" "||He===" "){G+=1;continue}G=0,He==="%"?(he=!0,we===0&&(A=!0),F=!0):(F=!1,He==="\\"?we+=1:He==="_"&&(he=!0))}return{hasLike:he,percentEnd:F&&Fe>1,percentStart:A&&Fe>1,endSpace:G}}function $(O){let A=O.trimStart();const{hasLike:F,percentEnd:G,percentStart:he,endSpace:Fe}=k(A);if(Fe>0&&(A=A.slice(0,-Fe)),F){if(he&&G){const we=A.slice(1,-1);if(!k(we).hasLike&&we.length>0)return{operator:"contains",values:[W(we)]}}else if(G){const we=A.slice(0,-1);if(!k(we).hasLike)return{operator:"starts",values:[W(we)]}}else if(he){const we=A.slice(1);if(!k(we).hasLike)return{operator:"ends",values:[W(we)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:A.toLowerCase()==="none"?{operator:"none"}:{operator:"=",values:[W(A)]}}function w(O,A){var F,G;return O.operator===A.operator&&((F=O.not)!==null&&F!==void 0?F:!1)===((G=A.not)!==null&&G!==void 0?G:!1)}function y(O,A,F){if(A=A.toLowerCase(),(0,f.isStringFilter)(O)&&(0,f.isStringFilter)(F)){if(A===","){if(O.operator==="~"&&w(O,F))return{...O,escaped_values:[...O.escaped_values,...F.escaped_values]};if((0,f.isStringCondition)(O)&&w(O,F))return{...O,values:[...O.values,...F.values]}}const G=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(G)return O.operator===G?{...O,members:[...O.members,F]}:{operator:G,members:[O,F]}}return null}function o(O,A,F){if(A=A.toLowerCase(),(0,f.isNumberFilter)(O)&&(0,f.isNumberFilter)(F)){if(A==="or"&&O.operator==="="&&w(O,F)){const G={operator:"=",values:[...O.values,...F.values]};return O.not&&(G.not=!0),G}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}}return null}function d(O,A,F,G){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:F,endOperator:G===")"?"<":"<="}}function e(O,A){return{values:[O,...A]}}function C(O,A){return(0,f.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function N(O,A){if((0,f.isTemporalFilter)(O)&&A){if("not"in O){const F={...O};return O.not?delete F.not:F.not=!0,F}return{...O,not:!0}}return O}function Z(O,A,F){return A=A.toLowerCase(),(0,f.isTemporalFilter)(O)&&(0,f.isTemporalFilter)(F)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}:null}function ne(O,A){const F={moment:"literal",literal:O};return A&&(F.units=A),F}function pe(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 ze}var vr,Cr;function wi(){if(Cr)return vr;Cr=1;const{numNot:f,mkRange:ie,joinNumbers:W,mkValues:P}=Xt();function k(o,d){function e(){this.constructor=o}e.prototype=d.prototype,o.prototype=new e}function $(o,d,e,C){var N=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(N,$.prototype),N.expected=d,N.found=e,N.location=C,N.name="SyntaxError",N}k($,Error);function w(o,d,e){return e=e||" ",o.length>d?o:(d-=o.length,e+=e.repeat(d),o+e.slice(0,d))}$.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var e=null,C;for(C=0;C<o.length;C++)if(o[C].source===this.location.source){e=o[C].text.split(/\r\n|\n|\r/g);break}var N=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(N):N,ne=this.location.source+":"+Z.line+":"+Z.column;if(e){var pe=this.location.end,O=w("",Z.line.toString().length," "),A=e[N.line-1],F=N.line===pe.line?pe.column:A.length+1,G=F-N.column||1;d+=`
1
+ import{aM as mi}from"./index-BRijWj6K.js";import{r as gi}from"./index-w_0OQJgZ.js";function yi(f,ie){for(var W=0;W<ie.length;W++){const P=ie[W];if(typeof P!="string"&&!Array.isArray(P)){for(const k in P)if(k!=="default"&&!(k in f)){const $=Object.getOwnPropertyDescriptor(P,k);$&&Object.defineProperty(f,k,$.get?$:{enumerable:!0,get:()=>P[k]})}}}return Object.freeze(Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}))}var Et={},dt={},Vr;function Ct(){if(Vr)return dt;Vr=1,Object.defineProperty(dt,"__esModule",{value:!0}),dt.isChainOp=f,dt.isStringCondition=ie,dt.isStringFilter=W,dt.isBooleanFilter=P,dt.isNumberFilter=k,dt.isTemporalFilter=$,dt.isFilterExpression=w,dt.isFilterable=y;function f(o){return["and","or",","].includes(o)}function ie(o){return["starts","ends","contains","="].includes(o.operator)}function W(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","none","empty","and","or",",","()"].includes(o.operator)}function P(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","none","true","false","=false","=true"].includes(o.operator)}function k(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null","none"].includes(o.operator)}function $(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","none"].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 dt}var Mt={},Lr;function vi(){return Lr||(Lr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.BooleanFilterExpression=void 0,Mt.BooleanFilterExpression={parse(f){var ie;if(f.match(/^\s*$/))return{parsed:null,log:[]};const W={parsed:null,log:[]};let P=f.toLowerCase().trim().replace(/\s\s+/," "),k=!1;if(P.startsWith("not ")&&(k=!0,P=P.slice(4)),P==="true")W.parsed={operator:"true"};else if(P==="=true")W.parsed={operator:"=true"};else if(P==="false")W.parsed={operator:"false"};else if(P==="=false")W.parsed={operator:"=false"};else if(P==="null")W.parsed={operator:"null"};else if(P==="none")W.parsed={operator:"none"};else{const $=f.match(/[^\s]/),w=$&&(ie=$.index)!==null&&ie!==void 0?ie:0;W.log=[{message:`Illegal boolean filter '${P}'. Must be one of true,=true,false,=false,null,none`,severity:"error",startIndex:w,endIndex:w+f.length-1}]}return k&&W.parsed&&(W.parsed.not=!0),W},unparse(f){return f===null?"":(f.not?"not ":"")+f.operator}}),Mt}var yr={},ze={},Ir;function Xt(){if(Ir)return ze;Ir=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.maybeNot=ie,ze.unescape=W,ze.escape=P,ze.matchOp=$,ze.conjoin=y,ze.joinNumbers=o,ze.mkRange=d,ze.mkValues=e,ze.numNot=C,ze.temporalNot=N,ze.joinTemporal=Z,ze.timeLiteral=ne,ze.mkUnits=pe;const f=Ct();function ie(O){const[A,F]=O;return A&&F&&(0,f.isStringFilter)(F)?{...F,not:!0}:F}function W(O){return O.replace(/\\(.)/g,"$1")}function P(O){const A=O.toLowerCase();return A==="null"||A==="empty"||A==="none"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function k(O){let A=!1,F=!1,G=0,he=!1;const Fe=O.length;for(let we=0;we<Fe;we+=1){const He=O[we];if(He===" "||He===" "){G+=1;continue}G=0,He==="%"?(he=!0,we===0&&(A=!0),F=!0):(F=!1,He==="\\"?we+=1:He==="_"&&(he=!0))}return{hasLike:he,percentEnd:F&&Fe>1,percentStart:A&&Fe>1,endSpace:G}}function $(O){let A=O.trimStart();const{hasLike:F,percentEnd:G,percentStart:he,endSpace:Fe}=k(A);if(Fe>0&&(A=A.slice(0,-Fe)),F){if(he&&G){const we=A.slice(1,-1);if(!k(we).hasLike&&we.length>0)return{operator:"contains",values:[W(we)]}}else if(G){const we=A.slice(0,-1);if(!k(we).hasLike)return{operator:"starts",values:[W(we)]}}else if(he){const we=A.slice(1);if(!k(we).hasLike)return{operator:"ends",values:[W(we)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:A.toLowerCase()==="none"?{operator:"none"}:{operator:"=",values:[W(A)]}}function w(O,A){var F,G;return O.operator===A.operator&&((F=O.not)!==null&&F!==void 0?F:!1)===((G=A.not)!==null&&G!==void 0?G:!1)}function y(O,A,F){if(A=A.toLowerCase(),(0,f.isStringFilter)(O)&&(0,f.isStringFilter)(F)){if(A===","){if(O.operator==="~"&&w(O,F))return{...O,escaped_values:[...O.escaped_values,...F.escaped_values]};if((0,f.isStringCondition)(O)&&w(O,F))return{...O,values:[...O.values,...F.values]}}const G=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(G)return O.operator===G?{...O,members:[...O.members,F]}:{operator:G,members:[O,F]}}return null}function o(O,A,F){if(A=A.toLowerCase(),(0,f.isNumberFilter)(O)&&(0,f.isNumberFilter)(F)){if(A==="or"&&O.operator==="="&&w(O,F)){const G={operator:"=",values:[...O.values,...F.values]};return O.not&&(G.not=!0),G}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}}return null}function d(O,A,F,G){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:F,endOperator:G===")"?"<":"<="}}function e(O,A){return{values:[O,...A]}}function C(O,A){return(0,f.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function N(O,A){if((0,f.isTemporalFilter)(O)&&A){if("not"in O){const F={...O};return O.not?delete F.not:F.not=!0,F}return{...O,not:!0}}return O}function Z(O,A,F){return A=A.toLowerCase(),(0,f.isTemporalFilter)(O)&&(0,f.isTemporalFilter)(F)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,F]}:{operator:A,members:[O,F]}:null}function ne(O,A){const F={moment:"literal",literal:O};return A&&(F.units=A),F}function pe(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 ze}var vr,Cr;function wi(){if(Cr)return vr;Cr=1;const{numNot:f,mkRange:ie,joinNumbers:W,mkValues:P}=Xt();function k(o,d){function e(){this.constructor=o}e.prototype=d.prototype,o.prototype=new e}function $(o,d,e,C){var N=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(N,$.prototype),N.expected=d,N.found=e,N.location=C,N.name="SyntaxError",N}k($,Error);function w(o,d,e){return e=e||" ",o.length>d?o:(d-=o.length,e+=e.repeat(d),o+e.slice(0,d))}$.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var e=null,C;for(C=0;C<o.length;C++)if(o[C].source===this.location.source){e=o[C].text.split(/\r\n|\n|\r/g);break}var N=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(N):N,ne=this.location.source+":"+Z.line+":"+Z.column;if(e){var pe=this.location.end,O=w("",Z.line.toString().length," "),A=e[N.line-1],F=N.line===pe.line?pe.column:A.length+1,G=F-N.column||1;d+=`
2
2
  --> `+ne+`
3
3
  `+O+` |
4
4
  `+Z.line+" | "+A+`
@@ -1 +1 @@
1
- import{aJ as a}from"./index-CH2AcDzc.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{aM as a}from"./index-BRijWj6K.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};
@@ -11,7 +11,7 @@
11
11
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
12
12
  />
13
13
  <title>Malloy Publisher</title>
14
- <script type="module" crossorigin src="/assets/index-CH2AcDzc.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-BRijWj6K.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-5eLCcNmP.css">
16
16
  </head>
17
17
  <body>
@@ -11505,7 +11505,7 @@ function httpError(code, message) {
11505
11505
  }
11506
11506
  };
11507
11507
  }
11508
- var NotImplementedError, BadRequestError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, ConnectionNotFoundError, ConnectionError, DestinationNotFoundError, ConnectionAuthError, UnsupportedCatalogFormatError, ModelCompilationError, MaterializationEligibilityError, FrozenConfigError, AccessDeniedError, NotQueryableError, MaterializationNotFoundError, MaterializationConflictError, InvalidStateTransitionError, ServiceUnavailableError, PayloadTooLargeError, QueryTimeoutError;
11508
+ var NotImplementedError, BadRequestError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, ConnectionNotFoundError, ConnectionError, DestinationNotFoundError, ConnectionAuthError, UnsupportedCatalogFormatError, ModelCompilationError, MaterializationEligibilityError, FrozenConfigError, AccessDeniedError, NotQueryableError, MaterializationNotFoundError, MaterializationConflictError, InvalidStateTransitionError, ServiceUnavailableError, PayloadTooLargeError, ResponseUnserializableError, QueryTimeoutError;
11509
11509
  var init_errors = __esm(() => {
11510
11510
  init_constants();
11511
11511
  NotImplementedError = class NotImplementedError extends Error {
@@ -11609,6 +11609,13 @@ var init_errors = __esm(() => {
11609
11609
  PayloadTooLargeError = class PayloadTooLargeError extends Error {
11610
11610
  constructor(message) {
11611
11611
  super(message);
11612
+ this.name = "PayloadTooLargeError";
11613
+ }
11614
+ };
11615
+ ResponseUnserializableError = class ResponseUnserializableError extends PayloadTooLargeError {
11616
+ constructor(message) {
11617
+ super(message);
11618
+ this.name = "ResponseUnserializableError";
11612
11619
  }
11613
11620
  };
11614
11621
  QueryTimeoutError = class QueryTimeoutError extends Error {
@@ -11690,8 +11697,14 @@ init_errors();
11690
11697
 
11691
11698
  // src/service/authorize.ts
11692
11699
  init_errors();
11693
- var SOURCE_PREFIX = "#(authorize)";
11694
- var FILE_PREFIX = "##(authorize)";
11700
+ var AUTHORIZE_TAG = String.raw`##?\(\s*authorize\s*\)`;
11701
+ var AUTHORIZE_ANNOTATION_ANYWHERE = new RegExp(AUTHORIZE_TAG);
11702
+ var AUTHORIZE_ANNOTATION_PREFIX = new RegExp(`^${AUTHORIZE_TAG}`);
11703
+ function assertNoCallerAuthorizeAnnotation(callerText) {
11704
+ if (!AUTHORIZE_ANNOTATION_ANYWHERE.test(callerText))
11705
+ return;
11706
+ throw new BadRequestError("An `authorize` annotation is not permitted in caller-submitted Malloy " + "text. Access gates are declared by the model author on the source; a " + "request cannot introduce, replace, or relax one. To validate a gate " + "you are authoring, save it to the package's model file and reload the " + "package — model load validates every `#(authorize)` annotation it " + "declares.");
11707
+ }
11695
11708
  function buildAuthorizeProbe(exprs, givenDecls = []) {
11696
11709
  const selects = exprs.map((expr, i) => `__auth_${i} is (${expr})`).join(`
11697
11710
  `);
@@ -11763,8 +11776,9 @@ async function runProbe(executor, probeText, givens) {
11763
11776
  }
11764
11777
  async function evaluateAuthorize(executor, exprs, givens, declaredTypes, options) {
11765
11778
  const selfContainedFirst = options?.selfContainedFirst ?? false;
11766
- for (const expr of exprs) {
11767
- if (selfContainedFirst) {
11779
+ const ambientPrefix = options?.ambientPrefix ?? 0;
11780
+ for (const [index, expr] of exprs.entries()) {
11781
+ if (selfContainedFirst && index >= ambientPrefix) {
11768
11782
  if (await evaluateSelfContainedFirst(executor, expr, givens, declaredTypes)) {
11769
11783
  return true;
11770
11784
  }
@@ -11829,15 +11843,10 @@ async function validateAuthorizeProbes(compiler, sources) {
11829
11843
  }
11830
11844
  function parseAuthorizeAnnotation(annotation) {
11831
11845
  const trimmed = annotation.trim();
11832
- let body;
11833
- if (trimmed.startsWith(FILE_PREFIX)) {
11834
- body = trimmed.slice(FILE_PREFIX.length).trim();
11835
- } else if (trimmed.startsWith(SOURCE_PREFIX)) {
11836
- body = trimmed.slice(SOURCE_PREFIX.length).trim();
11837
- } else {
11846
+ const prefix = AUTHORIZE_ANNOTATION_PREFIX.exec(trimmed);
11847
+ if (!prefix)
11838
11848
  return null;
11839
- }
11840
- return unwrapQuotedExpression(body);
11849
+ return unwrapQuotedExpression(trimmed.slice(prefix[0].length).trim());
11841
11850
  }
11842
11851
  function collectAuthorizeExprs(annotations) {
11843
11852
  const exprs = [];
@@ -12206,6 +12215,7 @@ function tokenize(input) {
12206
12215
  function extractSourcesFromModelDef(modelDef, givens, onParseError) {
12207
12216
  const filterMap = new Map;
12208
12217
  const authorizeMap = new Map;
12218
+ const ownAuthorizeSources = [];
12209
12219
  const fileLevelAuthorize = collectAuthorizeExprs((modelAnnotations(modelDef).notes ?? []).map((note) => note.text));
12210
12220
  const sources = Object.values(modelDef.contents).filter((obj) => isSourceDef(obj)).map((sourceObj) => {
12211
12221
  const struct = sourceObj;
@@ -12244,15 +12254,33 @@ function extractSourcesFromModelDef(modelDef, givens, onParseError) {
12244
12254
  }
12245
12255
  }
12246
12256
  const ownNotes = (struct.annotations?.blockNotes ?? []).map((note) => note.text);
12257
+ const ownGates = collectAuthorizeExprs(ownNotes);
12258
+ let inheritedGates = [];
12259
+ if (ownGates.length === 0) {
12260
+ for (let cur2 = struct.annotations?.inherits;cur2; cur2 = cur2.inherits) {
12261
+ const exprs = collectAuthorizeExprs((cur2.blockNotes ?? []).map((note) => note.text));
12262
+ if (exprs.length > 0) {
12263
+ inheritedGates = exprs;
12264
+ break;
12265
+ }
12266
+ }
12267
+ }
12247
12268
  const effective = [
12248
12269
  ...fileLevelAuthorize,
12249
- ...collectAuthorizeExprs(ownNotes)
12270
+ ...ownGates.length > 0 ? ownGates : inheritedGates
12250
12271
  ];
12251
12272
  let authorize;
12252
12273
  if (effective.length > 0) {
12253
12274
  authorizeMap.set(sourceName, effective);
12254
12275
  authorize = effective;
12255
12276
  }
12277
+ const ownEffective = [...fileLevelAuthorize, ...ownGates];
12278
+ if (ownEffective.length > 0) {
12279
+ ownAuthorizeSources.push({
12280
+ name: sourceName,
12281
+ authorize: ownEffective
12282
+ });
12283
+ }
12256
12284
  const views = struct.fields.filter((field) => field.type === "turtle").filter((turtle) => turtle.pipeline.map((stage) => stage.type).every((type) => type === "reduce")).map((turtle) => ({
12257
12285
  name: turtle.as || turtle.name,
12258
12286
  annotations: annotationTexts(turtle.annotations)
@@ -12266,7 +12294,7 @@ function extractSourcesFromModelDef(modelDef, givens, onParseError) {
12266
12294
  authorize
12267
12295
  };
12268
12296
  });
12269
- return { sources, filterMap, authorizeMap };
12297
+ return { sources, filterMap, authorizeMap, ownAuthorizeSources };
12270
12298
  }
12271
12299
  function extractQueriesFromModelDef(modelDef) {
12272
12300
  const isNamedQuery = (obj) => obj.type === "query";
@@ -12590,8 +12618,12 @@ function appendLocalSourceInfos(modelDef, target, importedNames) {
12590
12618
  }
12591
12619
  }
12592
12620
  function extractSources(modelDef, givens) {
12593
- const { sources, filterMap } = extractSourcesFromModelDef(modelDef, givens);
12594
- return { sources, filterMap };
12621
+ const { sources, filterMap, ownAuthorizeSources } = extractSourcesFromModelDef(modelDef, givens);
12622
+ return {
12623
+ sources,
12624
+ filterMap,
12625
+ ownAuthorizeSources
12626
+ };
12595
12627
  }
12596
12628
  function extractQueries(modelDef) {
12597
12629
  return extractQueriesFromModelDef(modelDef);
@@ -12621,9 +12653,9 @@ async function compileMalloyModel(job, malloyConfig, modelPath) {
12621
12653
  const givens = malloyGivens.length > 0 ? malloyGivens.map((g) => malloyGivenToApi(g)) : undefined;
12622
12654
  const { sourceInfos, importedNames } = await collectImportedSourceInfos(modelDef, runtime, importBaseURL);
12623
12655
  appendLocalSourceInfos(modelDef, sourceInfos, importedNames);
12624
- const { sources, filterMap } = extractSources(modelDef, givens);
12656
+ const { sources, filterMap, ownAuthorizeSources } = extractSources(modelDef, givens);
12625
12657
  const queries = extractQueries(modelDef);
12626
- await validateAuthorizeProbes(mm, sources);
12658
+ await validateAuthorizeProbes(mm, ownAuthorizeSources);
12627
12659
  return {
12628
12660
  modelPath,
12629
12661
  modelType: "model",
@@ -12732,7 +12764,7 @@ async function compileNotebookModel(job, malloyConfig, modelPath) {
12732
12764
  finalSources = extracted.sources;
12733
12765
  finalFilterMap = extracted.filterMap;
12734
12766
  finalQueries = extractQueries(finalModelDef);
12735
- await validateAuthorizeProbes(mm, finalSources);
12767
+ await validateAuthorizeProbes(mm, extracted.ownAuthorizeSources);
12736
12768
  }
12737
12769
  return {
12738
12770
  modelPath,