@malloy-publisher/app 0.2.2 → 0.2.4

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 +1 @@
1
- import{J as o,j as e,a3 as t,ah as h}from"./index-O-tznXBH.js";function d(){const{workspace:r,workbookPath:s,environmentName:i,packageName:n}=o();if(r)if(s)if(i)if(n){const a=t({environmentName:i,packageName:n});return e.jsx(h,{workbookPath:{path:s,workspace:r},resourceUri:a},`${s}`)}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing environment name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workbook path"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workspace"})})}export{d as default};
1
+ import{J as o,j as e,a3 as t,ah as h}from"./index-sZHvyEzw.js";function d(){const{workspace:r,workbookPath:s,environmentName:i,packageName:n}=o();if(r)if(s)if(i)if(n){const a=t({environmentName:i,packageName:n});return e.jsx(h,{workbookPath:{path:s,workspace:r},resourceUri:a},`${s}`)}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing package name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing environment name"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workbook path"})});else return e.jsx("div",{children:e.jsx("h2",{children:"Missing workspace"})})}export{d as default};
@@ -1,4 +1,4 @@
1
- import{createOnigurumaEngine as At,getDefaultWasmLoader as Gr,loadWasm as Mr}from"./engine-oniguruma-C4vnmooL.es-jdkXmgTr.js";import{aE as Cn,aF as Br,aG as Or,aH as Fr,aI as jr,aJ as Dr,aK as Wr,aL as Dt,aM as xt}from"./index-O-tznXBH.js";let V=class extends Error{constructor(t){super(t),this.name="ShikiError"}},Ee=!1,wn=!1;function Zi(t=!0,e=!1){Ee=t,wn=e}function F(t,e=3){if(Ee&&!(typeof Ee=="number"&&e>Ee)){if(wn)throw new Error(`[SHIKI DEPRECATE]: ${t}`);console.trace(`[SHIKI DEPRECATE]: ${t}`)}}function Ur(t){return vt(t)}function vt(t){return Array.isArray(t)?qr(t):t instanceof RegExp?t:typeof t=="object"?Hr(t):t}function qr(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=vt(t[n]);return e}function Hr(t){let e={};for(let n in t)e[n]=vt(t[n]);return e}function Sn(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function An(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?An(t.substring(0,t.length-1)):t.substr(~e+1)}var Ke=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(t){return t===null?!1:(Ke.lastIndex=0,Ke.test(t))}static replaceCaptures(t,e,n){return t.replace(Ke,(r,s,a,o)=>{let i=n[parseInt(s||a,10)];if(i){let c=e.substring(i.start,i.end);for(;c[0]===".";)c=c.substring(1);switch(o){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function xn(t,e){return t<e?-1:t>e?1:0}function vn(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let a=xn(t[s],e[s]);if(a!==0)return a}return 0}return n-r}function Wt(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function En(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Nn=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Re=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(Qr(t),e)}static createFromParsedTheme(t,e){return Zr(t,e)}_cachedMatchRoot=new Nn(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,n=this._cachedMatchRoot.get(e).find(r=>zr(t.parent,r.parentScopes));return n?new In(n.fontStyle,n.foreground,n.background):null}},Ye=class Ne{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Ne(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Ne(n,e[r]);return n}push(e){return new Ne(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function zr(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!Vr(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function Vr(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var In=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function Qr(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,a=e.length;s<a;s++){let o=e[s];if(!o.settings)continue;let i;if(typeof o.scope=="string"){let h=o.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(o.scope)?i=o.scope:i=[""];let c=-1;if(typeof o.settings.fontStyle=="string"){c=0;let h=o.settings.fontStyle.split(" ");for(let d=0,p=h.length;d<p;d++)switch(h[d]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof o.settings.foreground=="string"&&Wt(o.settings.foreground)&&(l=o.settings.foreground);let u=null;typeof o.settings.background=="string"&&Wt(o.settings.background)&&(u=o.settings.background);for(let h=0,d=i.length;h<d;h++){let p=i[h].trim().split(" "),g=p[p.length-1],k=null;p.length>1&&(k=p.slice(0,p.length-1),k.reverse()),n[r++]=new Xr(g,k,s,c,l,u)}}return n}var Xr=class{constructor(t,e,n,r,s,a){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=a}},z=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(z||{});function Zr(t,e){t.sort((c,l)=>{let u=xn(c.scope,l.scope);return u!==0||(u=vn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let c=t.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let a=new Kr(e),o=new In(n,a.getId(r),a.getId(s)),i=new Jr(new ut(0,null,-1,0,0),[]);for(let c=0,l=t.length;c<l;c++){let u=t[c];i.insert(0,u.scope,u.parentScopes,u.fontStyle,a.getId(u.foreground),a.getId(u.background))}return new Re(a,o,i)}var Kr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},Yr=Object.freeze([]),ut=class $n{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,a){this.scopeDepth=e,this.parentScopes=n||Yr,this.fontStyle=r,this.foreground=s,this.background=a}clone(){return new $n(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Jr=class ht{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const a=n.parentScopes[s].length-e.parentScopes[r].length;if(a!==0)return a;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,a;if(r===-1?(s=e,a=""):(s=e.substring(0,r),a=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(ht._cmpBySpecificity),n}insert(e,n,r,s,a,o){if(n===""){this._doInsertHere(e,r,s,a,o);return}let i=n.indexOf("."),c,l;i===-1?(c=n,l=""):(c=n.substring(0,i),l=n.substring(i+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new ht(this._mainRule.clone(),ut.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(e+1,l,r,s,a,o)}_doInsertHere(e,n,r,s,a){if(n===null){this._mainRule.acceptOverwrite(e,r,s,a);return}for(let o=0,i=this._rulesWithParentScopes.length;o<i;o++){let c=this._rulesWithParentScopes[o];if(vn(c.parentScopes,n)===0){c.acceptOverwrite(e,r,s,a);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new ut(e,n,r,s,a))}},ie=class M{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=M.getLanguageId(e),r=M.getTokenType(e),s=M.getFontStyle(e),a=M.getForeground(e),o=M.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,a,o,i){let c=M.getLanguageId(e),l=M.getTokenType(e),u=M.containsBalancedBrackets(e)?1:0,h=M.getFontStyle(e),d=M.getForeground(e),p=M.getBackground(e);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),a!==-1&&(h=a),o!==0&&(d=o),i!==0&&(p=i),(c<<0|l<<8|u<<10|h<<11|d<<15|p<<24)>>>0}};function Pe(t,e){const n=[],r=es(t);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=o();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function a(){if(s==="-"){s=r.next();const c=a();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=i();return s===")"&&(s=r.next()),c}if(Ut(s)){const c=[];do c.push(s),s=r.next();while(Ut(s));return l=>e(c,l)}return null}function o(){const c=[];let l=a();for(;l;)c.push(l),l=a();return u=>c.every(h=>h(u))}function i(){const c=[];let l=o();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=o()}return u=>c.some(h=>h(u))}}function Ut(t){return!!t&&!!t.match(/[\w\.:]+/)}function es(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Rn(t){typeof t.dispose=="function"&&t.dispose()}var de=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},ts=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},ns=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},rs=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new de(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new ns;for(const n of t)ss(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof de){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function ss(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const a=n.lookup(e);t instanceof de?Ie({baseGrammar:a,selfGrammar:s},r):pt(t.ruleName,{baseGrammar:a,selfGrammar:s,repository:s.repository},r);const o=n.injections(t.scopeName);if(o)for(const i of o)r.add(new de(i))}function pt(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Te([r],e,n)}}function Ie(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Te(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Te(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Te(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?Sn({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Te(r.patterns,{...e,repository:s},n);const a=r.include;if(!a)continue;const o=Pn(a);switch(o.kind){case 0:Ie({...e,selfGrammar:e.baseGrammar},n);break;case 1:Ie(e,n);break;case 2:pt(o.ruleName,{...e,repository:s},n);break;case 3:case 4:const i=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(i){const c={baseGrammar:e.baseGrammar,selfGrammar:i,repository:s};o.kind===4?pt(o.ruleName,c,n):Ie(c,n)}else o.kind===4?n.add(new ts(o.scopeName,o.ruleName)):n.add(new de(o.scopeName));break}}}var as=class{kind=0},os=class{kind=1},is=class{constructor(t){this.ruleName=t}kind=2},cs=class{constructor(t){this.scopeName=t}kind=3},ls=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Pn(t){if(t==="$base")return new as;if(t==="$self")return new os;const e=t.indexOf("#");if(e===-1)return new cs(t);if(e===0)return new is(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new ls(n,r)}}var us=/\\(\d+)/,qt=/\\(\d+)/g,hs=-1,Tn=-2,ke=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${An(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:we.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,t,e)}},ps=class extends ke{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},ds=class extends ke{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new ge(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new fe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ht=class extends ke{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new fe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},dt=class extends ke{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,a,o,i,c,l){super(t,e,n,r),this._begin=new ge(s,this.id),this.beginCaptures=a,this._end=new ge(o||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new fe;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Le=class extends ke{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,a,o,i,c){super(t,e,n,r),this._begin=new ge(s,this.id),this.beginCaptures=a,this.whileCaptures=i,this._while=new ge(o,Tn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new fe;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new fe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},Ln=class R{static createCaptureRule(e,n,r,s,a){return e.registerRule(o=>new ps(n,o,r,s,a))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new ds(e.$vscodeTextmateLocation,e.id,e.name,e.match,R._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=Sn({},r,e.repository));let a=e.patterns;return typeof a>"u"&&e.include&&(a=[{include:e.include}]),new Ht(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,R._compilePatterns(a,n,r))}return e.while?new Le(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,R._compileCaptures(e.whileCaptures||e.captures,n,r),R._compilePatterns(e.patterns,n,r)):new dt(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,R._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,R._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let a=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const i=parseInt(o,10);i>a&&(a=i)}for(let o=0;o<=a;o++)s[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const i=parseInt(o,10);let c=0;e[o].patterns&&(c=R.getCompiledRuleId(e[o],n,r)),s[i]=R.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,c)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let a=0,o=e.length;a<o;a++){const i=e[a];let c=-1;if(i.include){const l=Pn(i.include);switch(l.kind){case 0:case 1:c=R.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=R.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,d=l.kind===4?l.ruleName:null,p=n.getExternalGrammar(h,r);if(p)if(d){let g=p.repository[d];g&&(c=R.getCompiledRuleId(g,n,p.repository))}else c=R.getCompiledRuleId(p.repository.$self,n,p.repository);break}}else c=R.getCompiledRuleId(i,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof Ht||l instanceof dt||l instanceof Le)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},ge=class Gn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,a=[],o=!1;for(let i=0;i<r;i++)if(e.charAt(i)==="\\"&&i+1<r){const c=e.charAt(i+1);c==="z"?(a.push(e.substring(s,i)),a.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(o=!0),i++}this.hasAnchor=o,s===0?this.source=e:(a.push(e.substring(s,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=us.test(this.source):this.hasBackReferences=!1}clone(){return new Gn(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return qt.lastIndex=0,this.source.replace(qt,(s,a)=>En(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],a,o,i,c;for(a=0,o=this.source.length;a<o;a++)i=this.source.charAt(a),e[a]=i,n[a]=i,r[a]=i,s[a]=i,i==="\\"&&a+1<o&&(c=this.source.charAt(a+1),c==="A"?(e[a+1]="￿",n[a+1]="￿",r[a+1]="A",s[a+1]="A"):c==="G"?(e[a+1]="￿",n[a+1]="G",r[a+1]="￿",s[a+1]="G"):(e[a+1]=c,n[a+1]=c,r[a+1]=c,s[a+1]=c),a++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},fe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new zt(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new zt(t,r,this._items.map(s=>s.ruleId))}},zt=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
1
+ import{createOnigurumaEngine as At,getDefaultWasmLoader as Gr,loadWasm as Mr}from"./engine-oniguruma-C4vnmooL.es-jdkXmgTr.js";import{aE as Cn,aF as Br,aG as Or,aH as Fr,aI as jr,aJ as Dr,aK as Wr,aL as Dt,aM as xt}from"./index-sZHvyEzw.js";let V=class extends Error{constructor(t){super(t),this.name="ShikiError"}},Ee=!1,wn=!1;function Zi(t=!0,e=!1){Ee=t,wn=e}function F(t,e=3){if(Ee&&!(typeof Ee=="number"&&e>Ee)){if(wn)throw new Error(`[SHIKI DEPRECATE]: ${t}`);console.trace(`[SHIKI DEPRECATE]: ${t}`)}}function Ur(t){return vt(t)}function vt(t){return Array.isArray(t)?qr(t):t instanceof RegExp?t:typeof t=="object"?Hr(t):t}function qr(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=vt(t[n]);return e}function Hr(t){let e={};for(let n in t)e[n]=vt(t[n]);return e}function Sn(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function An(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?An(t.substring(0,t.length-1)):t.substr(~e+1)}var Ke=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(t){return t===null?!1:(Ke.lastIndex=0,Ke.test(t))}static replaceCaptures(t,e,n){return t.replace(Ke,(r,s,a,o)=>{let i=n[parseInt(s||a,10)];if(i){let c=e.substring(i.start,i.end);for(;c[0]===".";)c=c.substring(1);switch(o){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function xn(t,e){return t<e?-1:t>e?1:0}function vn(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let a=xn(t[s],e[s]);if(a!==0)return a}return 0}return n-r}function Wt(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function En(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Nn=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},Re=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(Qr(t),e)}static createFromParsedTheme(t,e){return Zr(t,e)}_cachedMatchRoot=new Nn(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,n=this._cachedMatchRoot.get(e).find(r=>zr(t.parent,r.parentScopes));return n?new In(n.fontStyle,n.foreground,n.background):null}},Ye=class Ne{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Ne(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Ne(n,e[r]);return n}push(e){return new Ne(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function zr(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!Vr(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function Vr(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var In=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function Qr(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,a=e.length;s<a;s++){let o=e[s];if(!o.settings)continue;let i;if(typeof o.scope=="string"){let h=o.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(o.scope)?i=o.scope:i=[""];let c=-1;if(typeof o.settings.fontStyle=="string"){c=0;let h=o.settings.fontStyle.split(" ");for(let d=0,p=h.length;d<p;d++)switch(h[d]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof o.settings.foreground=="string"&&Wt(o.settings.foreground)&&(l=o.settings.foreground);let u=null;typeof o.settings.background=="string"&&Wt(o.settings.background)&&(u=o.settings.background);for(let h=0,d=i.length;h<d;h++){let p=i[h].trim().split(" "),g=p[p.length-1],k=null;p.length>1&&(k=p.slice(0,p.length-1),k.reverse()),n[r++]=new Xr(g,k,s,c,l,u)}}return n}var Xr=class{constructor(t,e,n,r,s,a){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=a}},z=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(z||{});function Zr(t,e){t.sort((c,l)=>{let u=xn(c.scope,l.scope);return u!==0||(u=vn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let c=t.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let a=new Kr(e),o=new In(n,a.getId(r),a.getId(s)),i=new Jr(new ut(0,null,-1,0,0),[]);for(let c=0,l=t.length;c<l;c++){let u=t[c];i.insert(0,u.scope,u.parentScopes,u.fontStyle,a.getId(u.foreground),a.getId(u.background))}return new Re(a,o,i)}var Kr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},Yr=Object.freeze([]),ut=class $n{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,a){this.scopeDepth=e,this.parentScopes=n||Yr,this.fontStyle=r,this.foreground=s,this.background=a}clone(){return new $n(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Jr=class ht{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const a=n.parentScopes[s].length-e.parentScopes[r].length;if(a!==0)return a;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,a;if(r===-1?(s=e,a=""):(s=e.substring(0,r),a=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(a)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(ht._cmpBySpecificity),n}insert(e,n,r,s,a,o){if(n===""){this._doInsertHere(e,r,s,a,o);return}let i=n.indexOf("."),c,l;i===-1?(c=n,l=""):(c=n.substring(0,i),l=n.substring(i+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new ht(this._mainRule.clone(),ut.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(e+1,l,r,s,a,o)}_doInsertHere(e,n,r,s,a){if(n===null){this._mainRule.acceptOverwrite(e,r,s,a);return}for(let o=0,i=this._rulesWithParentScopes.length;o<i;o++){let c=this._rulesWithParentScopes[o];if(vn(c.parentScopes,n)===0){c.acceptOverwrite(e,r,s,a);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),a===0&&(a=this._mainRule.background),this._rulesWithParentScopes.push(new ut(e,n,r,s,a))}},ie=class M{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=M.getLanguageId(e),r=M.getTokenType(e),s=M.getFontStyle(e),a=M.getForeground(e),o=M.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:a,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,a,o,i){let c=M.getLanguageId(e),l=M.getTokenType(e),u=M.containsBalancedBrackets(e)?1:0,h=M.getFontStyle(e),d=M.getForeground(e),p=M.getBackground(e);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),a!==-1&&(h=a),o!==0&&(d=o),i!==0&&(p=i),(c<<0|l<<8|u<<10|h<<11|d<<15|p<<24)>>>0}};function Pe(t,e){const n=[],r=es(t);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=o();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function a(){if(s==="-"){s=r.next();const c=a();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=i();return s===")"&&(s=r.next()),c}if(Ut(s)){const c=[];do c.push(s),s=r.next();while(Ut(s));return l=>e(c,l)}return null}function o(){const c=[];let l=a();for(;l;)c.push(l),l=a();return u=>c.every(h=>h(u))}function i(){const c=[];let l=o();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=o()}return u=>c.some(h=>h(u))}}function Ut(t){return!!t&&!!t.match(/[\w\.:]+/)}function es(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Rn(t){typeof t.dispose=="function"&&t.dispose()}var de=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},ts=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},ns=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},rs=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new de(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new ns;for(const n of t)ss(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof de){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function ss(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const a=n.lookup(e);t instanceof de?Ie({baseGrammar:a,selfGrammar:s},r):pt(t.ruleName,{baseGrammar:a,selfGrammar:s,repository:s.repository},r);const o=n.injections(t.scopeName);if(o)for(const i of o)r.add(new de(i))}function pt(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];Te([r],e,n)}}function Ie(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&Te(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&Te(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function Te(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?Sn({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&Te(r.patterns,{...e,repository:s},n);const a=r.include;if(!a)continue;const o=Pn(a);switch(o.kind){case 0:Ie({...e,selfGrammar:e.baseGrammar},n);break;case 1:Ie(e,n);break;case 2:pt(o.ruleName,{...e,repository:s},n);break;case 3:case 4:const i=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(i){const c={baseGrammar:e.baseGrammar,selfGrammar:i,repository:s};o.kind===4?pt(o.ruleName,c,n):Ie(c,n)}else o.kind===4?n.add(new ts(o.scopeName,o.ruleName)):n.add(new de(o.scopeName));break}}}var as=class{kind=0},os=class{kind=1},is=class{constructor(t){this.ruleName=t}kind=2},cs=class{constructor(t){this.scopeName=t}kind=3},ls=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Pn(t){if(t==="$base")return new as;if(t==="$self")return new os;const e=t.indexOf("#");if(e===-1)return new cs(t);if(e===0)return new is(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new ls(n,r)}}var us=/\\(\d+)/,qt=/\\(\d+)/g,hs=-1,Tn=-2,ke=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${An(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:we.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,t,e)}},ps=class extends ke{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},ds=class extends ke{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new ge(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new fe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ht=class extends ke{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new fe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},dt=class extends ke{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,a,o,i,c,l){super(t,e,n,r),this._begin=new ge(s,this.id),this.beginCaptures=a,this._end=new ge(o||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new fe;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},Le=class extends ke{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,a,o,i,c){super(t,e,n,r),this._begin=new ge(s,this.id),this.beginCaptures=a,this.whileCaptures=i,this._while=new ge(o,Tn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new fe;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new fe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},Ln=class R{static createCaptureRule(e,n,r,s,a){return e.registerRule(o=>new ps(n,o,r,s,a))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new ds(e.$vscodeTextmateLocation,e.id,e.name,e.match,R._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=Sn({},r,e.repository));let a=e.patterns;return typeof a>"u"&&e.include&&(a=[{include:e.include}]),new Ht(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,R._compilePatterns(a,n,r))}return e.while?new Le(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,R._compileCaptures(e.whileCaptures||e.captures,n,r),R._compilePatterns(e.patterns,n,r)):new dt(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,R._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,R._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,R._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let a=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const i=parseInt(o,10);i>a&&(a=i)}for(let o=0;o<=a;o++)s[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const i=parseInt(o,10);let c=0;e[o].patterns&&(c=R.getCompiledRuleId(e[o],n,r)),s[i]=R.createCaptureRule(n,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,c)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let a=0,o=e.length;a<o;a++){const i=e[a];let c=-1;if(i.include){const l=Pn(i.include);switch(l.kind){case 0:case 1:c=R.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=R.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,d=l.kind===4?l.ruleName:null,p=n.getExternalGrammar(h,r);if(p)if(d){let g=p.repository[d];g&&(c=R.getCompiledRuleId(g,n,p.repository))}else c=R.getCompiledRuleId(p.repository.$self,n,p.repository);break}}else c=R.getCompiledRuleId(i,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof Ht||l instanceof dt||l instanceof Le)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},ge=class Gn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,a=[],o=!1;for(let i=0;i<r;i++)if(e.charAt(i)==="\\"&&i+1<r){const c=e.charAt(i+1);c==="z"?(a.push(e.substring(s,i)),a.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(o=!0),i++}this.hasAnchor=o,s===0?this.source=e:(a.push(e.substring(s,r)),this.source=a.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=us.test(this.source):this.hasBackReferences=!1}clone(){return new Gn(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return qt.lastIndex=0,this.source.replace(qt,(s,a)=>En(r[parseInt(a,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],a,o,i,c;for(a=0,o=this.source.length;a<o;a++)i=this.source.charAt(a),e[a]=i,n[a]=i,r[a]=i,s[a]=i,i==="\\"&&a+1<o&&(c=this.source.charAt(a+1),c==="A"?(e[a+1]="￿",n[a+1]="￿",r[a+1]="A",s[a+1]="A"):c==="G"?(e[a+1]="￿",n[a+1]="G",r[a+1]="￿",s[a+1]="G"):(e[a+1]=c,n[a+1]=c,r[a+1]=c,s[a+1]=c),a++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},fe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new zt(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new zt(t,r,this._items.map(s=>s.ruleId))}},zt=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
2
2
  `)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Je=class{constructor(t,e){this.languageId=t,this.tokenType=e}},gs=class gt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new Je(e,8),this._embeddedLanguagesMatcher=new fs(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?gt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new Je(0,0);_getBasicScopeAttributes=new Nn(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new Je(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(gt.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},fs=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>En(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},Vt=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Mn(t,e,n,r,s,a,o,i){const c=e.content.length;let l=!1,u=-1;if(o){const p=ms(t,e,n,r,s,a);s=p.stack,r=p.linePos,n=p.isFirstLine,u=p.anchorPosition}const h=Date.now();for(;!l;){if(i!==0&&Date.now()-h>i)return new Vt(s,!0);d()}return new Vt(s,!1);function d(){const p=bs(t,e,n,r,s,u);if(!p){a.produce(s,c),l=!0;return}const g=p.captureIndices,k=p.matchedRuleId,m=g&&g.length>0?g[0].end>r:!1;if(k===hs){const C=s.getRule(t);a.produce(s,g[0].start),s=s.withContentNameScopesList(s.nameScopesList),ue(t,e,n,s,a,C.endCaptures,g),a.produce(s,g[0].end);const b=s;if(s=s.parent,u=b.getAnchorPos(),!m&&b.getEnterPos()===r){s=b,a.produce(s,c),l=!0;return}}else{const C=t.getRule(k);a.produce(s,g[0].start);const b=s,w=C.getName(e.content,g),I=s.contentNameScopesList.pushAttributed(w,t);if(s=s.push(k,r,u,g[0].end===c,null,I,I),C instanceof dt){const v=C;ue(t,e,n,s,a,v.beginCaptures,g),a.produce(s,g[0].end),u=g[0].end;const j=v.getContentName(e.content,g),L=I.pushAttributed(j,t);if(s=s.withContentNameScopesList(L),v.endHasBackReferences&&(s=s.withEndRule(v.getEndWithResolvedBackReferences(e.content,g))),!m&&b.hasSameRuleAs(s)){s=s.pop(),a.produce(s,c),l=!0;return}}else if(C instanceof Le){const v=C;ue(t,e,n,s,a,v.beginCaptures,g),a.produce(s,g[0].end),u=g[0].end;const j=v.getContentName(e.content,g),L=I.pushAttributed(j,t);if(s=s.withContentNameScopesList(L),v.whileHasBackReferences&&(s=s.withEndRule(v.getWhileWithResolvedBackReferences(e.content,g))),!m&&b.hasSameRuleAs(s)){s=s.pop(),a.produce(s,c),l=!0;return}}else if(ue(t,e,n,s,a,C.captures,g),a.produce(s,g[0].end),s=s.pop(),!m){s=s.safePop(),a.produce(s,c),l=!0;return}}g[0].end>r&&(r=g[0].end,n=!1)}}function ms(t,e,n,r,s,a){let o=s.beginRuleCapturedEOL?0:-1;const i=[];for(let c=s;c;c=c.pop()){const l=c.getRule(t);l instanceof Le&&i.push({rule:l,stack:c})}for(let c=i.pop();c;c=i.pop()){const{ruleScanner:l,findOptions:u}=ks(c.rule,t,c.stack.endRule,n,r===o),h=l.findNextMatchSync(e,r,u);if(h){if(h.ruleId!==Tn){s=c.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(a.produce(c.stack,h.captureIndices[0].start),ue(t,e,n,c.stack,a,c.rule.whileCaptures,h.captureIndices),a.produce(c.stack,h.captureIndices[0].end),o=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=c.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:o,isFirstLine:n}}function bs(t,e,n,r,s,a){const o=ys(t,e,n,r,s,a),i=t.getInjections();if(i.length===0)return o;const c=_s(i,t,e,n,r,s,a);if(!c)return o;if(!o)return c;const l=o.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:o}function ys(t,e,n,r,s,a){const o=s.getRule(t),{ruleScanner:i,findOptions:c}=Bn(o,t,s.endRule,n,r===a),l=i.findNextMatchSync(e,r,c);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function _s(t,e,n,r,s,a,o){let i=Number.MAX_VALUE,c=null,l,u=0;const h=a.contentNameScopesList.getScopeNames();for(let d=0,p=t.length;d<p;d++){const g=t[d];if(!g.matcher(h))continue;const k=e.getRule(g.ruleId),{ruleScanner:m,findOptions:C}=Bn(k,e,null,r,s===o),b=m.findNextMatchSync(n,s,C);if(!b)continue;const w=b.captureIndices[0].start;if(!(w>=i)&&(i=w,c=b.captureIndices,l=b.ruleId,u=g.priority,i===s))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function Bn(t,e,n,r,s){return{ruleScanner:t.compileAG(e,n,r,s),findOptions:0}}function ks(t,e,n,r,s){return{ruleScanner:t.compileWhileAG(e,n,r,s),findOptions:0}}function ue(t,e,n,r,s,a,o){if(a.length===0)return;const i=e.content,c=Math.min(a.length,o.length),l=[],u=o[0].end;for(let h=0;h<c;h++){const d=a[h];if(d===null)continue;const p=o[h];if(p.length===0)continue;if(p.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=p.start;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?s.produceFromScopes(l[l.length-1].scopes,p.start):s.produce(r,p.start),d.retokenizeCapturedWithRuleId){const k=d.getName(i,o),m=r.contentNameScopesList.pushAttributed(k,t),C=d.getContentName(i,o),b=m.pushAttributed(C,t),w=r.push(d.retokenizeCapturedWithRuleId,p.start,-1,!1,null,m,b),I=t.createOnigString(i.substring(0,p.end));Mn(t,I,n&&p.start===0,p.start,w,s,!1,0),Rn(I);continue}const g=d.getName(i,o);if(g!==null){const k=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(g,t);l.push(new Cs(k,p.end))}}for(;l.length>0;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Cs=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function ws(t,e,n,r,s,a,o,i){return new As(t,e,n,r,s,a,o,i)}function Qt(t,e,n,r,s){const a=Pe(e,Ge),o=Ln.getCompiledRuleId(n,r,s.repository);for(const i of a)t.push({debugSelector:e,matcher:i.matcher,ruleId:o,grammar:s,priority:i.priority})}function Ge(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let s=n;s<e.length;s++)if(Ss(e[s],r))return n=s+1,!0;return!1})}function Ss(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var As=class{constructor(t,e,n,r,s,a,o,i){if(this._rootScopeName=t,this.balancedBracketSelectors=a,this._onigLib=i,this._basicScopeAttributesProvider=new gs(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=Xt(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const c of Object.keys(s)){const l=Pe(c,Ge);for(const u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[c]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const s=r.injections;if(s)for(let o in s)Qt(e,o,s[o],this,r);const a=this._grammarRepository.injections(n);a&&a.forEach(o=>{const i=this.getExternalGrammar(o);if(i){const c=i.injectionSelector;c&&Qt(e,c,i,this,i)}})}return e.sort((s,a)=>s.priority-a.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=Xt(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=Ln.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===ft.NULL){s=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=ie.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),d=this.getRule(this._rootId).getName(null,null);let p;d?p=he.createRootAndLookUpScopeName(d,h,this):p=he.createRoot("unknown",h),e=new ft(null,this._rootId,-1,-1,!1,null,p,p)}else s=!1,e.reset();t=t+`
3
3
  `;const a=this.createOnigString(t),o=a.content.length,i=new vs(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Mn(this,a,s,0,e,i,!0,r);return Rn(a),{lineLength:o,lineTokens:i,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Xt(t,e){return t=Ur(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var he=class D{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(const a of n)s=Ye.push(s,a.scopeNames),r=new D(r,s,a.encodedTokenAttributes);return r}static createRoot(e,n){return new D(null,new Ye(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const s=r.getMetadataForScope(e),a=new Ye(null,e),o=r.themeProvider.themeMatch(a),i=D.mergeAttributes(n,s,o);return new D(null,a,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return D.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,a=0,o=0;return r!==null&&(s=r.fontStyle,a=r.foregroundId,o=r.backgroundId),ie.set(e,n.languageId,n.tokenType,null,s,a,o)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return D._pushAttributed(this,e,n);const r=e.split(/ /g);let s=this;for(const a of r)s=D._pushAttributed(s,a,n);return s}static _pushAttributed(e,n,r){const s=r.getMetadataForScope(n),a=e.scopePath.push(n),o=r.themeProvider.themeMatch(a),i=D.mergeAttributes(e.tokenAttributes,s,o);return new D(e,a,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},ft=class Y{constructor(e,n,r,s,a,o,i,c){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=a,this.endRule=o,this.nameScopesList=i,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new Y(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:Y._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?he.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){Y._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,s,a,o,i){return new Y(this,e,n,r,s,a,o,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new Y(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=he.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new Y(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,he.fromExtension(r,n.contentNameScopesList))}},xs=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Pe(n,Ge).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>Pe(n,Ge).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},vs=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const a=t?.getScopeNames()??[];for(const o of this._tokenTypeOverrides)o.matcher(a)&&(r=ie.set(r,0,o.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(a))}if(s&&(r=ie.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},Es=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let a=this._rawGrammars.get(t);if(!a)return null;this._grammars.set(t,ws(t,a,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},Ns=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new Es(Re.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,e){this._syncRegistry.setTheme(Re.createFromRawTheme(t,e))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,e,n){return this.loadGrammarWithConfiguration(t,e,{embeddedLanguages:n})}loadGrammarWithConfiguration(t,e,n){return this._loadGrammar(t,e,n.embeddedLanguages,n.tokenTypes,new xs(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,e,n,r,s){const a=new rs(this._syncRegistry,t);for(;a.Q.length>0;)a.Q.map(o=>this._loadSingleGrammar(o.scopeName)),a.processQueue();return this._grammarForScopeName(t,e,n,r,s)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const e=this._options.loadGrammar(t);if(e){const n=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(e,n)}}addGrammar(t,e=[],n=0,r=null){return this._syncRegistry.addGrammar(t,e),this._grammarForScopeName(t.scopeName,n,r)}_grammarForScopeName(t,e=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(t,e,n,r,s)}},mt=ft.NULL;const Is=/["&'<>`]/g,$s=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Rs=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Ps=/[|\\{}()[\]^$+*?.]/g,Zt=new WeakMap;function Ts(t,e){if(t=t.replace(e.subset?Ls(e.subset):Is,r),e.subset||e.escapeOnly)return t;return t.replace($s,n).replace(Rs,r);function n(s,a,o){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,o.charCodeAt(a+2),e)}function r(s,a,o){return e.format(s.charCodeAt(0),o.charCodeAt(a+1),e)}}function Ls(t){let e=Zt.get(t);return e||(e=Gs(t),Zt.set(t,e)),e}function Gs(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(Ps,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const Ms=/[\dA-Fa-f]/;function Bs(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!Ms.test(String.fromCharCode(e))?r:r+";"}const Os=/\d/;function Fs(t,e,n){const r="&#"+String(t);return n&&e&&!Os.test(String.fromCharCode(e))?r:r+";"}const js=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],et={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Ds=["cent","copy","divide","gt","lt","not","para","times"],On={}.hasOwnProperty,bt={};let Se;for(Se in et)On.call(et,Se)&&(bt[et[Se]]=Se);const Ws=/[^\dA-Za-z]/;function Us(t,e,n,r){const s=String.fromCharCode(t);if(On.call(bt,s)){const a=bt[s],o="&"+a;return n&&js.includes(a)&&!Ds.includes(a)&&(!r||e&&e!==61&&Ws.test(String.fromCharCode(e)))?o:o+";"}return""}function qs(t,e,n){let r=Bs(t,e,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=Us(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const a=Fs(t,e,n.omitOptionalSemicolons);a.length<r.length&&(r=a)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function ae(t,e){return Ts(t,Object.assign({format:qs},e))}const Hs=/^>|^->|<!--|-->|--!>|<!-$/g,zs=[">"],Vs=["<",">"];function Qs(t,e,n,r){return r.settings.bogusComments?"<?"+ae(t.value,Object.assign({},r.settings.characterReferences,{subset:zs}))+">":"<!--"+t.value.replace(Hs,s)+"-->";function s(a){return ae(a,Object.assign({},r.settings.characterReferences,{subset:Vs}))}}function Xs(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}const N=jn(1),Fn=jn(-1),Zs=[];function jn(t){return e;function e(n,r,s){const a=n?n.children:Zs;let o=(r||0)+t,i=a[o];if(!s)for(;i&&xt(i);)o+=t,i=a[o];return i}}const Ks={}.hasOwnProperty;function Dn(t){return e;function e(n,r,s){return Ks.call(t,n.tagName)&&t[n.tagName](n,r,s)}}const Et=Dn({body:Js,caption:tt,colgroup:tt,dd:ra,dt:na,head:tt,html:Ys,li:ta,optgroup:sa,option:aa,p:ea,rp:Kt,rt:Kt,tbody:ia,td:Yt,tfoot:ca,th:Yt,thead:oa,tr:la});function tt(t,e,n){const r=N(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&xt(r.value.charAt(0)))}function Ys(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function Js(t,e,n){const r=N(n,e);return!r||r.type!=="comment"}function ea(t,e,n){const r=N(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function ta(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="li"}function na(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function ra(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Kt(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function sa(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function aa(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function oa(t,e,n){const r=N(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function ia(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function ca(t,e,n){return!N(n,e)}function la(t,e,n){const r=N(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Yt(t,e,n){const r=N(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const ua=Dn({body:da,colgroup:ga,head:pa,html:ha,tbody:fa});function ha(t){const e=N(t,-1);return!e||e.type!=="comment"}function pa(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function da(t){const e=N(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&xt(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function ga(t,e,n){const r=Fn(n,e),s=N(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Et(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function fa(t,e,n){const r=Fn(n,e),s=N(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Et(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const Ae={name:[[`
4
4
  \f\r &/=>`.split(""),`
@@ -1,2 +1,2 @@
1
- import{aN as Je,aS as Ye}from"./index-O-tznXBH.js";import{r as He}from"./index-w_0OQJgZ.js";function Ke(i,I){for(var R=0;R<I.length;R++){const v=I[R];if(typeof v!="string"&&!Array.isArray(v)){for(const _ in v)if(_!=="default"&&!(_ in i)){const y=Object.getOwnPropertyDescriptor(v,_);y&&Object.defineProperty(i,_,y.get?y:{enumerable:!0,get:()=>v[_]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var te={},ge={},Le;function Be(){return Le||(Le=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.MALLOY_INTERFACE_TYPES=void 0,ge.MALLOY_INTERFACE_TYPES={Aggregate:{type:"struct",name:"Aggregate",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},Annotation:{type:"struct",name:"Annotation",fields:{value:{type:"string",optional:!1,array:!1}}},AnonymousQueryInfo:{type:"struct",name:"AnonymousQueryInfo",fields:{schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},ArrayCell:{type:"struct",name:"ArrayCell",fields:{array_value:{type:"Cell",array:!0,optional:!1}}},ArrayType:{type:"struct",name:"ArrayType",fields:{element_type:{type:"AtomicType",optional:!1,array:!1}}},AtomicType:{type:"union",name:"AtomicType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",timestamptz_type:"TimestamptzType"}},BooleanCell:{type:"struct",name:"BooleanCell",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanLiteral:{type:"struct",name:"BooleanLiteral",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanType:{type:"struct",name:"BooleanType",fields:{}},CalculateInfo:{type:"struct",name:"CalculateInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},CalculateOperation:{type:"struct",name:"CalculateOperation",fields:{name:{type:"string",optional:!1,array:!1},field:{type:"Field",optional:!1,array:!1}}},Cell:{type:"union",name:"Cell",options:{string_cell:"StringCell",boolean_cell:"BooleanCell",date_cell:"DateCell",timestamp_cell:"TimestampCell",number_cell:"NumberCell",json_cell:"JSONCell",record_cell:"RecordCell",array_cell:"ArrayCell",null_cell:"NullCell",sql_native_cell:"SQLNativeCell"}},CompileModelRequest:{type:"struct",name:"CompileModelRequest",fields:{model_url:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileModelResponse:{type:"struct",name:"CompileModelResponse",fields:{model:{type:"ModelInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileQueryRequest:{type:"struct",name:"CompileQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileQueryResponse:{type:"struct",name:"CompileQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileSourceRequest:{type:"struct",name:"CompileSourceRequest",fields:{model_url:{type:"string",optional:!1,array:!1},name:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileSourceResponse:{type:"struct",name:"CompileSourceResponse",fields:{source:{type:"SourceInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompilerNeeds:{type:"struct",name:"CompilerNeeds",fields:{table_schemas:{type:"SQLTable",array:!0,optional:!0},sql_schemas:{type:"SQLQuery",array:!0,optional:!0},files:{type:"File",array:!0,optional:!0},connections:{type:"Connection",array:!0,optional:!0},translations:{type:"Translation",array:!0,optional:!0}}},Connection:{type:"struct",name:"Connection",fields:{name:{type:"string",optional:!1,array:!1},dialect:{type:"string",optional:!0,array:!1}}},Data:{type:"union",name:"Data",options:{record_cell:"RecordCell",array_cell:"ArrayCell"}},DateCell:{type:"struct",name:"DateCell",fields:{date_value:{type:"string",optional:!1,array:!1}}},DateLiteral:{type:"struct",name:"DateLiteral",fields:{date_value:{type:"string",optional:!1,array:!1},granularity:{type:"DateTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},DateTimeframe:{type:"enum",name:"DateTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5}},DateType:{type:"struct",name:"DateType",fields:{timeframe:{type:"DateTimeframe",optional:!0,array:!1}}},DimensionInfo:{type:"struct",name:"DimensionInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},DocumentPosition:{type:"struct",name:"DocumentPosition",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},DocumentRange:{type:"struct",name:"DocumentRange",fields:{start:{type:"DocumentPosition",optional:!1,array:!1},end:{type:"DocumentPosition",optional:!1,array:!1}}},DrillOperation:{type:"struct",name:"DrillOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},Expression:{type:"union",name:"Expression",options:{field_reference:"Reference",time_truncation:"TimeTruncationFieldReference",filtered_field:"FilteredField",literal_value:"LiteralValueExpression",moving_average:"MovingAverage"}},Field:{type:"struct",name:"Field",fields:{expression:{type:"Expression",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},FieldInfo:{type:"union",name:"FieldInfo",options:{dimension:"DimensionInfo",measure:"MeasureInfo",join:"JoinInfo",view:"ViewInfo",calculate:"CalculateInfo"}},File:{type:"struct",name:"File",fields:{url:{type:"string",optional:!1,array:!1},contents:{type:"string",optional:!0,array:!1},invalidation_key:{type:"string",optional:!0,array:!1}}},Filter:{type:"union",name:"Filter",options:{filter_string:"FilterStringApplication",literal_equality:"LiteralEqualityComparison"}},FilterExpressionLiteral:{type:"struct",name:"FilterExpressionLiteral",fields:{filter_expression_value:{type:"string",optional:!1,array:!1}}},FilterExpressionType:{type:"struct",name:"FilterExpressionType",fields:{filter_type:{type:"FilterableType",optional:!1,array:!1}}},FilterOperation:{type:"struct",name:"FilterOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},FilterStringApplication:{type:"struct",name:"FilterStringApplication",fields:{expression:{type:"Expression",optional:!1,array:!1},filter:{type:"string",optional:!1,array:!1}}},FilterableType:{type:"union",name:"FilterableType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",date_type:"DateType",timestamp_type:"TimestampType",timestamptz_type:"TimestamptzType"}},FilteredField:{type:"struct",name:"FilteredField",fields:{field_reference:{type:"Reference",optional:!1,array:!1},where:{type:"FilterOperation",array:!0,optional:!1}}},GroupBy:{type:"struct",name:"GroupBy",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},JSONCell:{type:"struct",name:"JSONCell",fields:{json_value:{type:"string",optional:!1,array:!1}}},JSONType:{type:"struct",name:"JSONType",fields:{}},JoinInfo:{type:"struct",name:"JoinInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},relationship:{type:"Relationship",optional:!1,array:!1}}},Limit:{type:"struct",name:"Limit",fields:{limit:{type:"number",optional:!1,array:!1}}},LiteralEqualityComparison:{type:"struct",name:"LiteralEqualityComparison",fields:{expression:{type:"Expression",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},LiteralValue:{type:"union",name:"LiteralValue",options:{string_literal:"StringLiteral",number_literal:"NumberLiteral",date_literal:"DateLiteral",timestamp_literal:"TimestampLiteral",boolean_literal:"BooleanLiteral",null_literal:"NullLiteral",filter_expression_literal:"FilterExpressionLiteral"}},LiteralValueExpression:{type:"struct",name:"LiteralValueExpression",fields:{literal_value:{type:"LiteralValue",optional:!1,array:!1}}},Location:{type:"struct",name:"Location",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"Range",optional:!1,array:!1}}},LogMessage:{type:"struct",name:"LogMessage",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"DocumentRange",optional:!1,array:!1},severity:{type:"LogSeverity",optional:!1,array:!1},message:{type:"string",optional:!1,array:!1}}},LogSeverity:{type:"enum",name:"LogSeverity",values:{debug:1,info:2,warn:3,error:4}},MeasureInfo:{type:"struct",name:"MeasureInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ModelEntryValue:{type:"union",name:"ModelEntryValue",options:{source:"SourceInfo",query:"QueryInfo"}},ModelInfo:{type:"struct",name:"ModelInfo",fields:{entries:{type:"ModelEntryValue",array:!0,optional:!1},annotations:{type:"Annotation",array:!0,optional:!0},anonymous_queries:{type:"AnonymousQueryInfo",array:!0,optional:!1}}},MovingAverage:{type:"struct",name:"MovingAverage",fields:{field_reference:{type:"Reference",optional:!1,array:!1},rows_preceding:{type:"number",optional:!0,array:!1},rows_following:{type:"number",optional:!0,array:!1},partition_fields:{type:"Reference",array:!0,optional:!0}}},Nest:{type:"struct",name:"Nest",fields:{name:{type:"string",optional:!0,array:!1},view:{type:"View",optional:!1,array:!1}}},NullCell:{type:"struct",name:"NullCell",fields:{}},NullLiteral:{type:"struct",name:"NullLiteral",fields:{}},NumberCell:{type:"struct",name:"NumberCell",fields:{number_value:{type:"number",optional:!1,array:!1},subtype:{type:"NumberSubtype",optional:!0,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberLiteral:{type:"struct",name:"NumberLiteral",fields:{number_value:{type:"number",optional:!1,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberSubtype:{type:"enum",name:"NumberSubtype",values:{integer:1,decimal:2,bigint:3}},NumberType:{type:"struct",name:"NumberType",fields:{subtype:{type:"NumberSubtype",optional:!0,array:!1}}},OrderBy:{type:"struct",name:"OrderBy",fields:{field_reference:{type:"Reference",optional:!1,array:!1},direction:{type:"OrderByDirection",optional:!0,array:!1}}},OrderByDirection:{type:"enum",name:"OrderByDirection",values:{asc:1,desc:2}},ParameterInfo:{type:"struct",name:"ParameterInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"ParameterType",optional:!1,array:!1},default_value:{type:"LiteralValue",optional:!0,array:!1}}},ParameterType:{type:"union",name:"ParameterType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",filter_expression_type:"FilterExpressionType",timestamptz_type:"TimestamptzType"}},ParameterValue:{type:"struct",name:"ParameterValue",fields:{name:{type:"string",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},Position:{type:"struct",name:"Position",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},Query:{type:"struct",name:"Query",fields:{definition:{type:"QueryDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},QueryArrow:{type:"struct",name:"QueryArrow",fields:{source:{type:"QueryArrowSource",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},QueryArrowSource:{type:"union",name:"QueryArrowSource",options:{refinement:"QueryRefinement",source_reference:"Reference"}},QueryDefinition:{type:"union",name:"QueryDefinition",options:{arrow:"QueryArrow",query_reference:"Reference",refinement:"QueryRefinement"}},QueryInfo:{type:"struct",name:"QueryInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},QueryRefinement:{type:"struct",name:"QueryRefinement",fields:{base:{type:"QueryDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},Range:{type:"struct",name:"Range",fields:{start:{type:"Position",optional:!1,array:!1},end:{type:"Position",optional:!1,array:!1}}},RecordCell:{type:"struct",name:"RecordCell",fields:{record_value:{type:"Cell",array:!0,optional:!1}}},RecordType:{type:"struct",name:"RecordType",fields:{fields:{type:"DimensionInfo",array:!0,optional:!1}}},Reference:{type:"struct",name:"Reference",fields:{name:{type:"string",optional:!1,array:!1},path:{type:"string",array:!0,optional:!0},parameters:{type:"ParameterValue",array:!0,optional:!0}}},Relationship:{type:"enum",name:"Relationship",values:{one:1,many:2,cross:3}},Result:{type:"struct",name:"Result",fields:{data:{type:"Data",optional:!0,array:!1},schema:{type:"Schema",optional:!1,array:!1},sql:{type:"string",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},model_annotations:{type:"Annotation",array:!0,optional:!0},query_timezone:{type:"string",optional:!0,array:!1},source_annotations:{type:"Annotation",array:!0,optional:!0}}},RunIndexQueryRequest:{type:"struct",name:"RunIndexQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},source_name:{type:"string",optional:!1,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunIndexQueryResponse:{type:"struct",name:"RunIndexQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},RunQueryRequest:{type:"struct",name:"RunQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunQueryResponse:{type:"struct",name:"RunQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},SQLNativeCell:{type:"struct",name:"SQLNativeCell",fields:{sql_native_value:{type:"string",optional:!1,array:!1}}},SQLNativeType:{type:"struct",name:"SQLNativeType",fields:{sql_type:{type:"string",optional:!0,array:!1}}},SQLQuery:{type:"struct",name:"SQLQuery",fields:{sql:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},SQLTable:{type:"struct",name:"SQLTable",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},Schema:{type:"struct",name:"Schema",fields:{fields:{type:"FieldInfo",array:!0,optional:!1}}},SourceInfo:{type:"struct",name:"SourceInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},parameters:{type:"ParameterInfo",array:!0,optional:!0}}},StringCell:{type:"struct",name:"StringCell",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringLiteral:{type:"struct",name:"StringLiteral",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringType:{type:"struct",name:"StringType",fields:{}},TimeTruncationFieldReference:{type:"struct",name:"TimeTruncationFieldReference",fields:{field_reference:{type:"Reference",optional:!1,array:!1},truncation:{type:"TimestampTimeframe",optional:!1,array:!1}}},TimestampCell:{type:"struct",name:"TimestampCell",fields:{timestamp_value:{type:"string",optional:!1,array:!1}}},TimestampLiteral:{type:"struct",name:"TimestampLiteral",fields:{timestamp_value:{type:"string",optional:!1,array:!1},granularity:{type:"TimestampTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},TimestampTimeframe:{type:"enum",name:"TimestampTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5,hour:6,minute:7,second:8}},TimestampType:{type:"struct",name:"TimestampType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimestamptzType:{type:"struct",name:"TimestamptzType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimingInfo:{type:"struct",name:"TimingInfo",fields:{name:{type:"string",optional:!1,array:!1},duration_ms:{type:"number",optional:!1,array:!1},detailed_timing:{type:"TimingInfo",array:!0,optional:!0}}},Translation:{type:"struct",name:"Translation",fields:{url:{type:"string",optional:!1,array:!1},compiled_model_json:{type:"string",optional:!0,array:!1}}},View:{type:"struct",name:"View",fields:{definition:{type:"ViewDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ViewArrow:{type:"struct",name:"ViewArrow",fields:{source:{type:"ViewDefinition",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},ViewDefinition:{type:"union",name:"ViewDefinition",options:{arrow:"ViewArrow",view_reference:"Reference",refinement:"ViewRefinement",segment:"ViewSegment"}},ViewInfo:{type:"struct",name:"ViewInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"View",optional:!0,array:!1}}},ViewOperation:{type:"union",name:"ViewOperation",options:{group_by:"GroupBy",aggregate:"Aggregate",order_by:"OrderBy",limit:"Limit",where:"FilterOperation",nest:"Nest",having:"FilterOperation",drill:"DrillOperation",calculate:"CalculateOperation"}},ViewRefinement:{type:"struct",name:"ViewRefinement",fields:{base:{type:"ViewDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},ViewSegment:{type:"struct",name:"ViewSegment",fields:{operations:{type:"ViewOperation",array:!0,optional:!1}}}}),ge}var we={},Oe={},_e={},Pe;function Ze(){return Pe||(Pe=1,Object.defineProperty(_e,"__esModule",{value:!0}),_e.RESERVED_WORDS=void 0,_e.RESERVED_WORDS=["all","and","as","asc","avg","boolean","by","case","cast","compose","count","date","day","days","desc","distinct","else","end","exclude","export","extend","false","filter","for","from","full","has","hour","hours","import","in","include","inner","internal","is","json","left","like","max","min","minute","minutes","month","months","not","now","null","number","on","or","pick","private","public","quarter","quarters","right","second","seconds","source","sql","string","sum","table","then","this","timestamp","timestamptz","to","true","virtual","week","weeks","when","with","year","years"]),_e}var Ne;function Xe(){if(Ne)return Oe;Ne=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.maybeQuoteIdentifier=R;const i=Ze();function I(v){const _=!v.match(/^[A-Za-z_][A-Za-z_0-9]*$/),y=i.RESERVED_WORDS.includes(v.toLowerCase());return _||y}function R(v){return I(v)?`\`${v}\``:v}return Oe}var $e;function je(){if($e)return we;$e=1,Object.defineProperty(we,"__esModule",{value:!0}),we.queryToMalloy=I,we.filterToMalloy=R;const i=Xe();function I(a,{tabWidth:o}={tabWidth:2}){const u=ie(a);return c(u,{tabWidth:o})}function R(a,{tabWidth:o}={tabWidth:2}){const u=Y(a);return c(u,{tabWidth:o})}const v=Symbol("indent"),_=Symbol("newline"),y=Symbol("outdent"),l=Symbol("optional_newline_indent");function c(a,{tabWidth:o}={tabWidth:2}){let u="",d=0,g=!0;for(const w of a)if(w===_)u+=`
1
+ import{aN as Je,aS as Ye}from"./index-sZHvyEzw.js";import{r as He}from"./index-w_0OQJgZ.js";function Ke(i,I){for(var R=0;R<I.length;R++){const v=I[R];if(typeof v!="string"&&!Array.isArray(v)){for(const _ in v)if(_!=="default"&&!(_ in i)){const y=Object.getOwnPropertyDescriptor(v,_);y&&Object.defineProperty(i,_,y.get?y:{enumerable:!0,get:()=>v[_]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var te={},ge={},Le;function Be(){return Le||(Le=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.MALLOY_INTERFACE_TYPES=void 0,ge.MALLOY_INTERFACE_TYPES={Aggregate:{type:"struct",name:"Aggregate",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},Annotation:{type:"struct",name:"Annotation",fields:{value:{type:"string",optional:!1,array:!1}}},AnonymousQueryInfo:{type:"struct",name:"AnonymousQueryInfo",fields:{schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},ArrayCell:{type:"struct",name:"ArrayCell",fields:{array_value:{type:"Cell",array:!0,optional:!1}}},ArrayType:{type:"struct",name:"ArrayType",fields:{element_type:{type:"AtomicType",optional:!1,array:!1}}},AtomicType:{type:"union",name:"AtomicType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",timestamptz_type:"TimestamptzType"}},BooleanCell:{type:"struct",name:"BooleanCell",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanLiteral:{type:"struct",name:"BooleanLiteral",fields:{boolean_value:{type:"boolean",optional:!1,array:!1}}},BooleanType:{type:"struct",name:"BooleanType",fields:{}},CalculateInfo:{type:"struct",name:"CalculateInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},CalculateOperation:{type:"struct",name:"CalculateOperation",fields:{name:{type:"string",optional:!1,array:!1},field:{type:"Field",optional:!1,array:!1}}},Cell:{type:"union",name:"Cell",options:{string_cell:"StringCell",boolean_cell:"BooleanCell",date_cell:"DateCell",timestamp_cell:"TimestampCell",number_cell:"NumberCell",json_cell:"JSONCell",record_cell:"RecordCell",array_cell:"ArrayCell",null_cell:"NullCell",sql_native_cell:"SQLNativeCell"}},CompileModelRequest:{type:"struct",name:"CompileModelRequest",fields:{model_url:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileModelResponse:{type:"struct",name:"CompileModelResponse",fields:{model:{type:"ModelInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileQueryRequest:{type:"struct",name:"CompileQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileQueryResponse:{type:"struct",name:"CompileQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},translations:{type:"Translation",array:!0,optional:!0},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompileSourceRequest:{type:"struct",name:"CompileSourceRequest",fields:{model_url:{type:"string",optional:!1,array:!1},name:{type:"string",optional:!1,array:!1},extend_model_url:{type:"string",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},CompileSourceResponse:{type:"struct",name:"CompileSourceResponse",fields:{source:{type:"SourceInfo",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},CompilerNeeds:{type:"struct",name:"CompilerNeeds",fields:{table_schemas:{type:"SQLTable",array:!0,optional:!0},sql_schemas:{type:"SQLQuery",array:!0,optional:!0},files:{type:"File",array:!0,optional:!0},connections:{type:"Connection",array:!0,optional:!0},translations:{type:"Translation",array:!0,optional:!0}}},Connection:{type:"struct",name:"Connection",fields:{name:{type:"string",optional:!1,array:!1},dialect:{type:"string",optional:!0,array:!1}}},Data:{type:"union",name:"Data",options:{record_cell:"RecordCell",array_cell:"ArrayCell"}},DateCell:{type:"struct",name:"DateCell",fields:{date_value:{type:"string",optional:!1,array:!1}}},DateLiteral:{type:"struct",name:"DateLiteral",fields:{date_value:{type:"string",optional:!1,array:!1},granularity:{type:"DateTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},DateTimeframe:{type:"enum",name:"DateTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5}},DateType:{type:"struct",name:"DateType",fields:{timeframe:{type:"DateTimeframe",optional:!0,array:!1}}},DimensionInfo:{type:"struct",name:"DimensionInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},DocumentPosition:{type:"struct",name:"DocumentPosition",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},DocumentRange:{type:"struct",name:"DocumentRange",fields:{start:{type:"DocumentPosition",optional:!1,array:!1},end:{type:"DocumentPosition",optional:!1,array:!1}}},DrillOperation:{type:"struct",name:"DrillOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},Expression:{type:"union",name:"Expression",options:{field_reference:"Reference",time_truncation:"TimeTruncationFieldReference",filtered_field:"FilteredField",literal_value:"LiteralValueExpression",moving_average:"MovingAverage"}},Field:{type:"struct",name:"Field",fields:{expression:{type:"Expression",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},FieldInfo:{type:"union",name:"FieldInfo",options:{dimension:"DimensionInfo",measure:"MeasureInfo",join:"JoinInfo",view:"ViewInfo",calculate:"CalculateInfo"}},File:{type:"struct",name:"File",fields:{url:{type:"string",optional:!1,array:!1},contents:{type:"string",optional:!0,array:!1},invalidation_key:{type:"string",optional:!0,array:!1}}},Filter:{type:"union",name:"Filter",options:{filter_string:"FilterStringApplication",literal_equality:"LiteralEqualityComparison"}},FilterExpressionLiteral:{type:"struct",name:"FilterExpressionLiteral",fields:{filter_expression_value:{type:"string",optional:!1,array:!1}}},FilterExpressionType:{type:"struct",name:"FilterExpressionType",fields:{filter_type:{type:"FilterableType",optional:!1,array:!1}}},FilterOperation:{type:"struct",name:"FilterOperation",fields:{filter:{type:"Filter",optional:!1,array:!1}}},FilterStringApplication:{type:"struct",name:"FilterStringApplication",fields:{expression:{type:"Expression",optional:!1,array:!1},filter:{type:"string",optional:!1,array:!1}}},FilterableType:{type:"union",name:"FilterableType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",date_type:"DateType",timestamp_type:"TimestampType",timestamptz_type:"TimestamptzType"}},FilteredField:{type:"struct",name:"FilteredField",fields:{field_reference:{type:"Reference",optional:!1,array:!1},where:{type:"FilterOperation",array:!0,optional:!1}}},GroupBy:{type:"struct",name:"GroupBy",fields:{name:{type:"string",optional:!0,array:!1},field:{type:"Field",optional:!1,array:!1}}},JSONCell:{type:"struct",name:"JSONCell",fields:{json_value:{type:"string",optional:!1,array:!1}}},JSONType:{type:"struct",name:"JSONType",fields:{}},JoinInfo:{type:"struct",name:"JoinInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},relationship:{type:"Relationship",optional:!1,array:!1}}},Limit:{type:"struct",name:"Limit",fields:{limit:{type:"number",optional:!1,array:!1}}},LiteralEqualityComparison:{type:"struct",name:"LiteralEqualityComparison",fields:{expression:{type:"Expression",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},LiteralValue:{type:"union",name:"LiteralValue",options:{string_literal:"StringLiteral",number_literal:"NumberLiteral",date_literal:"DateLiteral",timestamp_literal:"TimestampLiteral",boolean_literal:"BooleanLiteral",null_literal:"NullLiteral",filter_expression_literal:"FilterExpressionLiteral"}},LiteralValueExpression:{type:"struct",name:"LiteralValueExpression",fields:{literal_value:{type:"LiteralValue",optional:!1,array:!1}}},Location:{type:"struct",name:"Location",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"Range",optional:!1,array:!1}}},LogMessage:{type:"struct",name:"LogMessage",fields:{url:{type:"string",optional:!1,array:!1},range:{type:"DocumentRange",optional:!1,array:!1},severity:{type:"LogSeverity",optional:!1,array:!1},message:{type:"string",optional:!1,array:!1}}},LogSeverity:{type:"enum",name:"LogSeverity",values:{debug:1,info:2,warn:3,error:4}},MeasureInfo:{type:"struct",name:"MeasureInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"AtomicType",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ModelEntryValue:{type:"union",name:"ModelEntryValue",options:{source:"SourceInfo",query:"QueryInfo"}},ModelInfo:{type:"struct",name:"ModelInfo",fields:{entries:{type:"ModelEntryValue",array:!0,optional:!1},annotations:{type:"Annotation",array:!0,optional:!0},anonymous_queries:{type:"AnonymousQueryInfo",array:!0,optional:!1}}},MovingAverage:{type:"struct",name:"MovingAverage",fields:{field_reference:{type:"Reference",optional:!1,array:!1},rows_preceding:{type:"number",optional:!0,array:!1},rows_following:{type:"number",optional:!0,array:!1},partition_fields:{type:"Reference",array:!0,optional:!0}}},Nest:{type:"struct",name:"Nest",fields:{name:{type:"string",optional:!0,array:!1},view:{type:"View",optional:!1,array:!1}}},NullCell:{type:"struct",name:"NullCell",fields:{}},NullLiteral:{type:"struct",name:"NullLiteral",fields:{}},NumberCell:{type:"struct",name:"NumberCell",fields:{number_value:{type:"number",optional:!1,array:!1},subtype:{type:"NumberSubtype",optional:!0,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberLiteral:{type:"struct",name:"NumberLiteral",fields:{number_value:{type:"number",optional:!1,array:!1},string_value:{type:"string",optional:!0,array:!1}}},NumberSubtype:{type:"enum",name:"NumberSubtype",values:{integer:1,decimal:2,bigint:3}},NumberType:{type:"struct",name:"NumberType",fields:{subtype:{type:"NumberSubtype",optional:!0,array:!1}}},OrderBy:{type:"struct",name:"OrderBy",fields:{field_reference:{type:"Reference",optional:!1,array:!1},direction:{type:"OrderByDirection",optional:!0,array:!1}}},OrderByDirection:{type:"enum",name:"OrderByDirection",values:{asc:1,desc:2}},ParameterInfo:{type:"struct",name:"ParameterInfo",fields:{name:{type:"string",optional:!1,array:!1},type:{type:"ParameterType",optional:!1,array:!1},default_value:{type:"LiteralValue",optional:!0,array:!1}}},ParameterType:{type:"union",name:"ParameterType",options:{string_type:"StringType",boolean_type:"BooleanType",number_type:"NumberType",json_type:"JSONType",sql_native_type:"SQLNativeType",date_type:"DateType",timestamp_type:"TimestampType",array_type:"ArrayType",record_type:"RecordType",filter_expression_type:"FilterExpressionType",timestamptz_type:"TimestamptzType"}},ParameterValue:{type:"struct",name:"ParameterValue",fields:{name:{type:"string",optional:!1,array:!1},value:{type:"LiteralValue",optional:!1,array:!1}}},Position:{type:"struct",name:"Position",fields:{line:{type:"number",optional:!1,array:!1},character:{type:"number",optional:!1,array:!1}}},Query:{type:"struct",name:"Query",fields:{definition:{type:"QueryDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},QueryArrow:{type:"struct",name:"QueryArrow",fields:{source:{type:"QueryArrowSource",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},QueryArrowSource:{type:"union",name:"QueryArrowSource",options:{refinement:"QueryRefinement",source_reference:"Reference"}},QueryDefinition:{type:"union",name:"QueryDefinition",options:{arrow:"QueryArrow",query_reference:"Reference",refinement:"QueryRefinement"}},QueryInfo:{type:"struct",name:"QueryInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"Query",optional:!0,array:!1},code:{type:"string",optional:!0,array:!1},location:{type:"Location",optional:!0,array:!1}}},QueryRefinement:{type:"struct",name:"QueryRefinement",fields:{base:{type:"QueryDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},Range:{type:"struct",name:"Range",fields:{start:{type:"Position",optional:!1,array:!1},end:{type:"Position",optional:!1,array:!1}}},RecordCell:{type:"struct",name:"RecordCell",fields:{record_value:{type:"Cell",array:!0,optional:!1}}},RecordType:{type:"struct",name:"RecordType",fields:{fields:{type:"DimensionInfo",array:!0,optional:!1}}},Reference:{type:"struct",name:"Reference",fields:{name:{type:"string",optional:!1,array:!1},path:{type:"string",array:!0,optional:!0},parameters:{type:"ParameterValue",array:!0,optional:!0}}},Relationship:{type:"enum",name:"Relationship",values:{one:1,many:2,cross:3}},Result:{type:"struct",name:"Result",fields:{data:{type:"Data",optional:!0,array:!1},schema:{type:"Schema",optional:!1,array:!1},sql:{type:"string",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},model_annotations:{type:"Annotation",array:!0,optional:!0},query_timezone:{type:"string",optional:!0,array:!1},source_annotations:{type:"Annotation",array:!0,optional:!0}}},RunIndexQueryRequest:{type:"struct",name:"RunIndexQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},source_name:{type:"string",optional:!1,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunIndexQueryResponse:{type:"struct",name:"RunIndexQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},RunQueryRequest:{type:"struct",name:"RunQueryRequest",fields:{model_url:{type:"string",optional:!1,array:!1},query:{type:"Query",optional:!0,array:!1},query_malloy:{type:"string",optional:!0,array:!1},default_row_limit:{type:"number",optional:!0,array:!1},exclude_references:{type:"boolean",optional:!0,array:!1},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1}}},RunQueryResponse:{type:"struct",name:"RunQueryResponse",fields:{result:{type:"Result",optional:!0,array:!1},default_row_limit_added:{type:"number",optional:!0,array:!1},logs:{type:"LogMessage",array:!0,optional:!0},compiler_needs:{type:"CompilerNeeds",optional:!0,array:!1},timing_info:{type:"TimingInfo",optional:!0,array:!1}}},SQLNativeCell:{type:"struct",name:"SQLNativeCell",fields:{sql_native_value:{type:"string",optional:!1,array:!1}}},SQLNativeType:{type:"struct",name:"SQLNativeType",fields:{sql_type:{type:"string",optional:!0,array:!1}}},SQLQuery:{type:"struct",name:"SQLQuery",fields:{sql:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},SQLTable:{type:"struct",name:"SQLTable",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!0,array:!1},connection_name:{type:"string",optional:!1,array:!1}}},Schema:{type:"struct",name:"Schema",fields:{fields:{type:"FieldInfo",array:!0,optional:!1}}},SourceInfo:{type:"struct",name:"SourceInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},parameters:{type:"ParameterInfo",array:!0,optional:!0}}},StringCell:{type:"struct",name:"StringCell",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringLiteral:{type:"struct",name:"StringLiteral",fields:{string_value:{type:"string",optional:!1,array:!1}}},StringType:{type:"struct",name:"StringType",fields:{}},TimeTruncationFieldReference:{type:"struct",name:"TimeTruncationFieldReference",fields:{field_reference:{type:"Reference",optional:!1,array:!1},truncation:{type:"TimestampTimeframe",optional:!1,array:!1}}},TimestampCell:{type:"struct",name:"TimestampCell",fields:{timestamp_value:{type:"string",optional:!1,array:!1}}},TimestampLiteral:{type:"struct",name:"TimestampLiteral",fields:{timestamp_value:{type:"string",optional:!1,array:!1},granularity:{type:"TimestampTimeframe",optional:!0,array:!1},timezone:{type:"string",optional:!0,array:!1}}},TimestampTimeframe:{type:"enum",name:"TimestampTimeframe",values:{year:1,quarter:2,month:3,week:4,day:5,hour:6,minute:7,second:8}},TimestampType:{type:"struct",name:"TimestampType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimestamptzType:{type:"struct",name:"TimestamptzType",fields:{timeframe:{type:"TimestampTimeframe",optional:!0,array:!1}}},TimingInfo:{type:"struct",name:"TimingInfo",fields:{name:{type:"string",optional:!1,array:!1},duration_ms:{type:"number",optional:!1,array:!1},detailed_timing:{type:"TimingInfo",array:!0,optional:!0}}},Translation:{type:"struct",name:"Translation",fields:{url:{type:"string",optional:!1,array:!1},compiled_model_json:{type:"string",optional:!0,array:!1}}},View:{type:"struct",name:"View",fields:{definition:{type:"ViewDefinition",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0}}},ViewArrow:{type:"struct",name:"ViewArrow",fields:{source:{type:"ViewDefinition",optional:!1,array:!1},view:{type:"ViewDefinition",optional:!1,array:!1}}},ViewDefinition:{type:"union",name:"ViewDefinition",options:{arrow:"ViewArrow",view_reference:"Reference",refinement:"ViewRefinement",segment:"ViewSegment"}},ViewInfo:{type:"struct",name:"ViewInfo",fields:{name:{type:"string",optional:!1,array:!1},schema:{type:"Schema",optional:!1,array:!1},annotations:{type:"Annotation",array:!0,optional:!0},definition:{type:"View",optional:!0,array:!1}}},ViewOperation:{type:"union",name:"ViewOperation",options:{group_by:"GroupBy",aggregate:"Aggregate",order_by:"OrderBy",limit:"Limit",where:"FilterOperation",nest:"Nest",having:"FilterOperation",drill:"DrillOperation",calculate:"CalculateOperation"}},ViewRefinement:{type:"struct",name:"ViewRefinement",fields:{base:{type:"ViewDefinition",optional:!1,array:!1},refinement:{type:"ViewDefinition",optional:!1,array:!1}}},ViewSegment:{type:"struct",name:"ViewSegment",fields:{operations:{type:"ViewOperation",array:!0,optional:!1}}}}),ge}var we={},Oe={},_e={},Pe;function Ze(){return Pe||(Pe=1,Object.defineProperty(_e,"__esModule",{value:!0}),_e.RESERVED_WORDS=void 0,_e.RESERVED_WORDS=["all","and","as","asc","avg","boolean","by","case","cast","compose","count","date","day","days","desc","distinct","else","end","exclude","export","extend","false","filter","for","from","full","has","hour","hours","import","in","include","inner","internal","is","json","left","like","max","min","minute","minutes","month","months","not","now","null","number","on","or","pick","private","public","quarter","quarters","right","second","seconds","source","sql","string","sum","table","then","this","timestamp","timestamptz","to","true","virtual","week","weeks","when","with","year","years"]),_e}var Ne;function Xe(){if(Ne)return Oe;Ne=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.maybeQuoteIdentifier=R;const i=Ze();function I(v){const _=!v.match(/^[A-Za-z_][A-Za-z_0-9]*$/),y=i.RESERVED_WORDS.includes(v.toLowerCase());return _||y}function R(v){return I(v)?`\`${v}\``:v}return Oe}var $e;function je(){if($e)return we;$e=1,Object.defineProperty(we,"__esModule",{value:!0}),we.queryToMalloy=I,we.filterToMalloy=R;const i=Xe();function I(a,{tabWidth:o}={tabWidth:2}){const u=ie(a);return c(u,{tabWidth:o})}function R(a,{tabWidth:o}={tabWidth:2}){const u=Y(a);return c(u,{tabWidth:o})}const v=Symbol("indent"),_=Symbol("newline"),y=Symbol("outdent"),l=Symbol("optional_newline_indent");function c(a,{tabWidth:o}={tabWidth:2}){let u="",d=0,g=!0;for(const w of a)if(w===_)u+=`
2
2
  `,g=!0;else if(w===y)d--;else if(w===v)d++;else{if(w===l)continue;g&&(u+=" ".repeat(d*o),g=!1),u+=w}return u}function m(a,o,u,d){var g;if(o.includes(_))return[a,_,v,...o,_,y,u];const F=((g=d?.spaces)!==null&&g!==void 0?g:!0)?" ":"";return[a,F,...o,F,u]}function h(a){return{contents:a,quoteCharacter:'"'}}function p(a,o){const u=[];for(let d=0;d<a.length;d++){const g=a[d];u.push(g),d<a.length-1&&u.push(o)}return u}function b(a){var o,u;switch(a.kind){case"filter_expression_literal":return[P(a.filter_expression_value)];case"boolean_literal":return[a.boolean_value.toString()];case"string_literal":{const{contents:d,quoteCharacter:g}=h(a.string_value);return[g,d,g]}case"number_literal":return[a.number_value.toString()];case"null_literal":return["null"];case"date_literal":return[L(S(a.date_value),(o=a.granularity)!==null&&o!==void 0?o:"day",a.timezone)];case"timestamp_literal":return[L(S(a.timestamp_value),(u=a.granularity)!==null&&u!==void 0?u:"second",a.timezone)]}}function S(a){let o;if(o=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/.exec(a)){const[u,d,g,w,F,C,ee]=o;return[d,g,w,F,C,ee]}else if(o=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/.exec(a)){const[u,d,g,w,F,C]=o;return[d,g,w,F,C,"00"]}else if(o=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d)(?:00)?/.exec(a)){const[u,d,g,w,F]=o;return[d,g,w,F,"00","00"]}else if(o=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(a)){const[u,d,g,w]=o;return[d,g,w,"00","00","00"]}else if(o=/(\d\d\d\d)-(\d\d)/.exec(a)){const[u,d,g]=o;return[d,g,"01","00","00","00"]}else if(o=/(\d\d\d\d)/.exec(a)){const[u,d]=o;return[d,"01","01","00","00","00"]}return["1970","01","01","00","00","00"]}function L([a,o,u,d,g,w],F,C){switch(F){case"year":return`@${a}`;case"quarter":{const ee=Math.floor(+o/3)+1;return`@${a}-Q${ee}`}case"month":return`@${a}-${o}`;case"week":return`@${a}-${o}-${u}-WK`;case"day":return`@${a}-${o}-${u}`;case"hour":return`@${a}-${o}-${u} ${d}`;case"minute":return`@${a}-${o}-${u} ${d}:${g}`;case"second":return C!==void 0?`@${a}-${o}-${u} ${d}:${g}:${w}[${C}]`:`@${a}-${o}-${u} ${d}:${g}:${w}`;default:throw new Error("Unknown timeframe.")}}function O(a){var o;const u=[];for(const d of(o=a.path)!==null&&o!==void 0?o:[])u.push((0,i.maybeQuoteIdentifier)(d)),u.push(".");if(u.push((0,i.maybeQuoteIdentifier)(a.name)),a.parameters){const d=[];for(let g=0;g<a.parameters.length;g++){const w=a.parameters[g];d.push((0,i.maybeQuoteIdentifier)(w.name)),d.push(" is "),d.push(...b(w.value)),g<a.parameters.length-1&&d.push(",",_)}u.push(...m("(",d,")",{spaces:!1}))}return u}function ie(a){const o=[];return o.push(...U(a.annotations)),o.push("run: "),o.push(...ae(a.definition)),o}function de(a){const o=[];switch(a.kind){case"source_reference":{o.push(...O(a));break}case"refinement":o.push(...ae(a));break}return o}function ae(a){const o=[];switch(a.kind){case"arrow":{o.push(...de(a.source)),o.push(" -> "),o.push(...q(a.view));break}case"query_reference":{o.push(...O(a));break}case"refinement":{const u=ae(a.base);a.base.kind==="arrow"?o.push(...m("(",u,")",{spaces:!1})):o.push(...u),o.push(" + "),o.push(...q(a.refinement));break}}return o}function q(a){const o=[];switch(a.kind){case"arrow":{o.push(...q(a.source)),o.push(" -> "),o.push(...q(a.view));break}case"view_reference":{o.push(...O(a));break}case"refinement":{o.push(...q(a.base)),o.push(" + "),o.push(...q(a.refinement));break}case"segment":{o.push(...Te(a));break}}return o}function Te(a){if(a.operations.length===0)return["{ }"];const o=a.operations.length>1,u=[];for(let d=0;d<a.operations.length;d++){const g=a.operations[d],w=[g];for(;d<a.operations.length-1;){const F=a.operations[d+1];if(F.kind===g.kind)w.push(F),d++;else break}u.push(...Ae(w)),o&&d<a.operations.length-1&&u.push(_)}return m("{",u,"}")}function Ae(a){switch(a[0].kind){case"aggregate":return z(a,"aggregate");case"group_by":return z(a,"group_by");case"order_by":return se(a);case"nest":return B(a);case"limit":return Q(a);case"where":return $(a);case"having":return G(a);case"drill":return ce(a);case"calculate":return z(a,"calculate")}}function x(a,o,u=""){const d=[];d.push(`${a}:`);const g=o.length>1||o.some(w=>w.includes(_));g?d.push(_,v):d.push(" ");for(let w=0;w<o.length;w++){const F=o[w];d.push(...F),o.length>1&&w<o.length-1&&d.push(u),g&&w<o.length-1&&d.push(_)}return g&&d.push(y),d}function ve(a){const o=[];return o.push(...E(a.expression)),o}function Ee(a){return a}function E(a){var o;switch(a.kind){case"field_reference":return O(a);case"time_truncation":return[...O(a.field_reference),".",a.truncation];case"filtered_field":return[...O(a.field_reference),...m(" {",$(a.where),"}")];case"literal_value":return b(a.literal_value);case"moving_average":{const u=["avg_moving",...m("(",[...O(a.field_reference),a.rows_preceding!==void 0?`, ${a.rows_preceding}`:", 0",a.rows_following!==void 0?`, ${a.rows_following}`:""],")",{spaces:!1})];return!((o=a.partition_fields)===null||o===void 0)&&o.length&&u.push(...m(" {",["partition_by",": ",...p(a.partition_fields.flatMap(d=>O(d)),", ")],"}")),u}}}function M(a,o=!1){const u=[];return o||u.push(...U(a.field.annotations)),a.name&&(u.push((0,i.maybeQuoteIdentifier)(a.name)),u.push(" is ")),u.push(...ve(a.field)),u}function z(a,o){const u=[],d=a.length===1;return d&&u.push(...U(a[0].field.annotations)),u.push(...x(o,a.map(g=>M(g,d)))),u}function se(a){return x("order_by",a.map(N),",")}function N(a){const o=[];return o.push(...O(a.field_reference)),a.direction&&(o.push(" "),o.push(a.direction)),o}function B(a){const o=[],u=a.length===1;return u&&o.push(...U(a[0].view.annotations)),o.push(...x("nest",a.map(d=>oe(d,u)))),o}function oe(a,o=!1){const u=[];return o||u.push(...U(a.view.annotations)),a.name&&(u.push((0,i.maybeQuoteIdentifier)(a.name)),u.push(" is ")),u.push(...le(a.view)),u}function le(a){return q(a.definition)}function ue(a){return[`limit: ${a.limit}`]}function Q(a){const o=[];for(let u=0;u<a.length;u++)u!==0&&o.push(_),o.push(...ue(a[u]));return o}function $(a){return x("where",a.map(H),",")}function ce(a){return x("drill",a.map(H),",")}function G(a){return x("having",a.map(H),",")}const D=["`","'",'"'];function P(a){let o,u;for(const d of D){const g=J(a,d);if(g===a)return`f${d}${a}${d}`;(u===void 0||g.length<u.length)&&(o=d,u=g)}return`f${o}${u}${o}`}function J(a,o){let u="";for(let d=0;d<a.length;d++)a.slice(d).startsWith(o)?(u+="\\"+o,d+=o.length):(u+=a[d],a[d]==="\\"&&(u+=a[++d]));return u}function Y(a){switch(a.kind){case"filter_string":return[...E(a.expression)," ~ ",P(a.filter)];case"literal_equality":return[...E(a.expression)," = ",...b(a.value)]}}function H(a){return Y(a.filter)}function U(a){return a?a.flatMap(pe):[]}function pe(a){return[a.value.trim(),_]}return we}var ne={},Qe;function et(){if(Qe)return ne;Qe=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.nestUnions=I,ne.unnestUnions=R,ne.convertFromThrift=v,ne.convertToThrift=y;const i=Be();function I(l){if(l==null)return l;if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")return l;if(Array.isArray(l))return l.map(I);{const c={};let m;for(const h in l)h==="kind"?m=l[h]:c[h]=I(l[h]);return m===void 0?c:{[m]:c}}}function R(l,c){if(l==null)return l;if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")return l;if(Array.isArray(l))return l.map(m=>R(m,c));{const m=_(c);if(m.type==="union"){for(const h in m.options)if(l[h]!==void 0){const p=R(l[h],m.options[h]);if(typeof p=="object")return{kind:h,...p}}}else if(m.type==="struct"){const h={};for(const p in l){const b=m.fields[p];if(b===void 0)throw new Error(`Unknown field ${p} in ${c}`);h[p]=R(l[p],b.type)}return h}else throw new Error(`Cannot unnest unions in an enum type ${c}`)}}function v(l,c){if(l==null)return l;if(typeof l=="string"||typeof l=="boolean")return l;if(typeof l=="number"){if(c==="number")return l;const m=_(c);if(m.type!=="enum")throw new Error(`Found a number where a ${c} was expected`);const h=Object.entries(m.values).find(([,p])=>p===l);if(h===void 0)throw new Error(`${l} is not a valid enum value for ${c}`);return h[0]}else{if(Array.isArray(l))return l.map(m=>v(m,c));{const m=_(c);if(m.type==="union"){for(const h in m.options)if(l[h]!==void 0&&l[h]!==null){const p=v(l[h],m.options[h]);if(typeof p=="object")return{kind:h,...p}}}else if(m.type==="struct"){const h={};for(const p in l){const b=m.fields[p];if(b===void 0)throw new Error(`Unknown field ${p} in ${c}`);h[p]=v(l[p],b.type)}return h}else throw new Error(`Cannot unnest unions in an enum type ${c}`)}}}function _(l){const c=i.MALLOY_INTERFACE_TYPES[l];if(c===void 0)throw new Error(`Unknown Malloy interface type ${l}`);return c}function y(l,c){if(l==null)return l;if(typeof l=="number"||typeof l=="boolean")return l;if(typeof l=="string"){if(c==="string")return l;const m=_(c);if(m.type==="enum"){const h=m.values[l];if(h===void 0)throw new Error(`${l} is not a valid enum value for ${c}`);return h}}else{if(Array.isArray(l))return l.map(m=>y(m,c));{const m=_(c);if(m.type==="union"){const h=l.kind,p=m.options[h];if(p===void 0)throw new Error(`${h} is not a valid union of ${c}`);const b=_(p);if(b.type!=="struct")throw new Error("Union fields must be structs");const S={};for(const L in l){if(L==="kind")continue;const O=b.fields[L];S[L]=y(l[L],O.type)}return{[h]:S}}else if(m.type==="struct"){const h={};for(const p in l){const b=m.fields[p];if(b===void 0)throw new Error(`Unknown field ${p} in ${c}`);h[p]=y(l[p],b.type)}return h}}}}return ne}var qe;function tt(){return qe||(qe=1,(function(i){var I=te&&te.__createBinding||(Object.create?(function(y,l,c,m){m===void 0&&(m=c);var h=Object.getOwnPropertyDescriptor(l,c);(!h||("get"in h?!l.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return l[c]}}),Object.defineProperty(y,m,h)}):(function(y,l,c,m){m===void 0&&(m=c),y[m]=l[c]})),R=te&&te.__exportStar||function(y,l){for(var c in y)c!=="default"&&!Object.prototype.hasOwnProperty.call(l,c)&&I(l,y,c)};Object.defineProperty(i,"__esModule",{value:!0}),i.thingy4sddfdfsd=i.thingy4sdfsd=i.thingy4dfdsfs=i.thingy4asdfas=i.thingy4asdfasdf=i.thingy3dfdf=i.thingy3=i.thingy2asdf=i.thingyssdfg=i.thingy123r=i.thingy1=i.res=i.test=i.convertToThrift=i.convertFromThrift=i.unnestUnions=i.nestUnions=i.filterToMalloy=i.queryToMalloy=void 0,R(Be(),i);var v=je();Object.defineProperty(i,"queryToMalloy",{enumerable:!0,get:function(){return v.queryToMalloy}}),Object.defineProperty(i,"filterToMalloy",{enumerable:!0,get:function(){return v.filterToMalloy}});var _=et();Object.defineProperty(i,"nestUnions",{enumerable:!0,get:function(){return _.nestUnions}}),Object.defineProperty(i,"unnestUnions",{enumerable:!0,get:function(){return _.unnestUnions}}),Object.defineProperty(i,"convertFromThrift",{enumerable:!0,get:function(){return _.convertFromThrift}}),Object.defineProperty(i,"convertToThrift",{enumerable:!0,get:function(){return _.convertToThrift}}),i.test={entries:[{kind:"source",name:"flights",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"boolean_type"},annotations:[{value:"# foo=1"}]},{kind:"dimension",name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}},{kind:"dimension",name:"arr_rec",type:{kind:"array_type",element_type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}}},{kind:"dimension",name:"rec",type:{kind:"record_type",fields:[{name:"arr",type:{kind:"array_type",element_type:{kind:"boolean_type"}}}]}},{kind:"join",name:"carriers",relationship:"one",schema:{fields:[{kind:"dimension",name:"code",type:{kind:"string_type"}}]}},{kind:"view",name:"by_carrier",schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]}}]},parameters:[{name:"param",type:{kind:"number_type"},default_value:{kind:"number_literal",number_value:7}}]}],anonymous_queries:[]},i.res={connection_name:"foo",data:{kind:"array_cell",array_value:[{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"UA"},{kind:"number_cell",number_value:12341234}]},{kind:"record_cell",record_value:[{kind:"string_cell",string_value:"AA"},{kind:"number_cell",number_value:2343}]}]},schema:{fields:[{kind:"dimension",name:"carrier",type:{kind:"string_type"}},{kind:"dimension",name:"flight_count",type:{kind:"number_type"}}]},sql:"SELECT * ..."},i.thingy1={definition:{kind:"query_reference",name:"flights_by_carrier"}},i.thingy123r={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},i.thingyssdfg={definition:{kind:"refinement",base:{kind:"query_reference",name:"flights"},refinement:{kind:"view_reference",name:"by_carrier"}}},i.thingy2asdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:"carrier"},filter:"WN"}}]}}}},i.thingy3={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}}},i.thingy3dfdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"view_reference",name:"top10"}}}},i.thingy4asdfasdf={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"group_by",field:{expression:{kind:"field_reference",name:"foo"}}}]}}},i.thingy4asdfas={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},i.thingy4dfdsfs={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"refinement",base:{kind:"view_reference",name:"by_carrier"},refinement:{kind:"segment",operations:[{kind:"limit",limit:10}]}}}},i.thingy4sdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[{kind:"group_by",field:{expression:{kind:"field_reference",name:"carrier"}}},{kind:"limit",limit:10}]}}},i.thingy4sddfdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[]}}}})(te)),te}var re={},W={},Ce;function nt(){return Ce||(Ce=1,(function(i){var I=W&&W.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),R=W&&W.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),v=W&&W.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&I(t,e,n[s]);return R(t,e),t}})();Object.defineProperty(i,"__esModule",{value:!0}),i.ASTAnnotationList=i.ASTLimitViewOperation=i.ASTView=i.ASTFilterWithLiteralEquality=i.ASTFilterWithFilterString=i.ASTFilter=i.ASTCalculateViewOperation=i.ASTHavingViewOperation=i.ASTDrillViewOperation=i.ASTWhereViewOperation=i.ASTNestViewOperation=i.ASTFilteredFieldExpression=i.ASTFilterOperationList=i.ASTFilterOperation=i.ASTMovingAverageExpression=i.ASTFieldReferenceList=i.ASTLiteralValueExpression=i.ASTTimeTruncationExpression=i.ASTReferenceExpression=i.ASTExpression=i.ASTField=i.ASTAggregateViewOperation=i.ASTGroupByViewOperation=i.ASTOrderByViewOperation=i.ASTViewOperation=i.ASTViewOperationList=i.ASTSegmentViewDefinition=i.ASTRefinementViewDefinition=i.ASTArrowViewDefinition=i.ASTReferenceViewDefinition=i.ASTReferenceQueryArrowSource=i.ASTReferenceQueryDefinition=i.ASTRefinementQueryDefinition=i.ASTArrowQueryDefinition=i.ASTQueryDefinition=i.ASTQueryArrowSource=i.ASTUnimplemented=i.ASTFilterExpressionLiteralValue=i.ASTTimestampLiteralValue=i.ASTDateLiteralValue=i.ASTBooleanLiteralValue=i.ASTNumberLiteralValue=i.ASTNullLiteralValue=i.ASTStringLiteralValue=i.ASTLiteralValue=i.ASTParameterValue=i.ASTParameterValueList=i.ASTFieldReference=i.ASTReference=i.ASTQuery=void 0,i.ASTAnnotation=void 0;const _=v(tt()),y=He(),l=v(Je());class c{constructor(){this.edited=!1}edit(){return this.edited=!0,this._parent&&this._parent.edit(),this}get as(){const e=this;return{Query(){if(e instanceof b)return e;throw new Error("Not an ASTQuery")},Reference(){if(e instanceof S)return e;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(e instanceof se)return e;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(e instanceof O)return e;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(e instanceof o)return e;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(e instanceof u)return e;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(e instanceof ie)return e;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(e instanceof de)return e;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(e instanceof q)return e;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(e instanceof ce)return e;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(e instanceof D)return e;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(e instanceof P)return e;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(e instanceof G)return e;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(e instanceof J)return e;throw new Error("Not an ASTField")},ReferenceExpression(){if(e instanceof Y)return e;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(e instanceof le)return e;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(e instanceof E)return e;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(e instanceof ue)return e;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(e instanceof Q)return e;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(e instanceof H)return e;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(e instanceof d)return e;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(e instanceof w)return e;throw new Error("Not an ASTNestViewOperation")},View(){if(e instanceof ke)return e;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(e instanceof $)return e;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(e instanceof Z)return e;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(e instanceof X)return e;throw new Error("Not an ASTAnnotationList")},Annotation(){if(e instanceof he)return e;throw new Error("Not an ASTAnnotation")}}}get find(){const e=this;return{Query(t){return e.findAny(t).as.Query()},Reference(t){return e.findAny(t).as.Reference()},ReferenceQueryArrowSource(t){return e.findAny(t).as.ReferenceQueryArrowSource()},ParameterValueList(t){return e.findAny(t).as.ParameterValueList()},FilterOperation(t){return e.findAny(t).as.FilterOperation()},FilterOperationList(t){return e.findAny(t).as.FilterOperationList()},ParameterValue(t){return e.findAny(t).as.ParameterValue()},StringLiteralValue(t){return e.findAny(t).as.StringLiteralValue()},NumberLiteralValue(t){return e.findAny(t).as.NumberLiteralValue()},ViewOperationList(t){return e.findAny(t).as.ViewOperationList()},GroupByViewOperation(t){return e.findAny(t).as.GroupByViewOperation()},AggregateViewOperation(t){return e.findAny(t).as.AggregateViewOperation()},OrderByViewOperation(t){return e.findAny(t).as.OrderByViewOperation()},Field(t){return e.findAny(t).as.Field()},ReferenceExpression(t){return e.findAny(t).as.ReferenceExpression()},ReferenceViewDefinition(t){return e.findAny(t).as.ReferenceViewDefinition()},ArrowQueryDefinition(t){return e.findAny(t).as.ArrowQueryDefinition()},ArrowViewDefinition(t){return e.findAny(t).as.ArrowViewDefinition()},RefinementViewDefinition(t){return e.findAny(t).as.RefinementViewDefinition()},TimeTruncationExpression(t){return e.findAny(t).as.TimeTruncationExpression()},FilteredFieldExpression(t){return e.findAny(t).as.FilteredFieldExpression()},NestViewOperation(t){return e.findAny(t).as.NestViewOperation()},View(t){return e.findAny(t).as.View()},SegmentViewDefinition(t){return e.findAny(t).as.SegmentViewDefinition()},LimitViewOperation(t){return e.findAny(t).as.LimitViewOperation()},AnnotationList(t){return e.findAny(t).as.AnnotationList()},Annotation(t){return e.findAny(t).as.Annotation()}}}get parent(){if(this._parent===void 0)throw new Error("This node does not have a parent");return this._parent}set parent(e){this._parent=e}static schemaTryGet(e,t,n){return c._schemaTryGet(e,t,n,!1)}static schemaTryGetDrillField(e,t,n){return c._schemaTryGet(e,t,n,!0)}static _schemaTryGet(e,t,n,s){let f=e.fields;for(const k of n??[]){const A=f.find(V=>V.name===k);if(A===void 0)throw new Error(`${k} not found`);if(A.kind==="join"||s&&A.kind==="view"){f=A.schema.fields;continue}if(A.kind==="dimension"||A.kind==="measure"){if(A.type.kind==="record_type"){f=A.type.fields.map(V=>({kind:A.kind,...V}));continue}else if(A.type.kind==="array_type"&&A.type.element_type.kind==="record_type"){f=A.type.element_type.fields.map(V=>({kind:A.kind,...V}));continue}}throw new Error(`${k} is not a join, record, or repeated record`)}return f.find(k=>k.name===t)}static schemaGet(e,t,n){const s=c.schemaTryGet(e,t,n);if(s===void 0)throw new Error(`${t} not found`);return s}static schemaGetDrillField(e,t,n){const s=c.schemaTryGetDrillField(e,t,n);if(s===void 0)throw new Error(`${t} not found`);return s}static schemaMerge(e,t){return{fields:[...e.fields,...t.fields]}}static tagFor(e,t="# "){var n,s;const f=(s=(n=e.annotations)===null||n===void 0?void 0:n.map(k=>k.value))===null||s===void 0?void 0:s.filter(k=>k.startsWith(t)),T=new y.TagParser;for(const k of f??[])T.parseAnnotation(k);return T.finish()}static fieldWasCalculation(e){if(e.kind!=="dimension")throw new Error(`${e.name} could not be an output field, because it is a ${e.kind}, and only dimensions can appear in output schemas`);return c.tagFor(e,"#(malloy) ").has("calculation")}}function m(r){return Array.isArray(r)||typeof r=="string"||typeof r=="number"||typeof r=="boolean"}class h extends c{constructor(e,t){super(),this.node=e,this.children=t,this.originalChildren=[...t],t.forEach(n=>n.parent=this)}*iter(){for(let e=0;e<this.length;e++)yield this.index(e)}get length(){return this.children.length}get last(){return this.children[this.children.length-1]}index(e){return this.children[e]}insert(e,t){this.edit(),this.children.splice(t,0,e),e.parent=this}add(e){this.edit(),this.children.push(e),e.parent=this}remove(e){const t=this.children.findIndex(n=>n===e);if(t===-1)return this;this.edit(),this.children.splice(t,1)}build(){if(!this.edited)return this.node;const e=this.children.map(t=>t.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=e,e}findAny(e){if(e.length===0)return this;const[t,...n]=e;if(typeof t!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${t}`);return this.children[t].findAny(n)}findIndex(e){return this.children.findIndex(e)}indexOf(e){return this.children.indexOf(e)}}class p extends c{constructor(e,t){super(),this.node=e,this.children=t;for(const n in t){const s=t[n];s&&!m(s)&&(s.parent=this)}}build(){if(!this.edited)return this.node;let e=this.node;for(const t in this.children){const n=this.children[t];n===void 0?e={...e,[t]:void 0}:m(n)?this.edited&&(e={...e,[t]:n}):e={...e,[t]:n.build()}}return this.node=e,this.edited=!1,e}findAny(e){if(e.length===0)return this;const[t,...n]=e;if(typeof t!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${t}`);const s=this.children[t];if(m(s))throw new Error(`${this.constructor.name}.${t} refers to a basic type, not an ASTNode`);return s._find(n)}}class b extends p{constructor(e){var t,n;let s=e.source;if(s===void 0){if(e.model===void 0)throw new Error("Need a model or source");if(e.query){const A=e.query.definition;if(A.kind==="arrow"&&A.source.kind==="source_reference"){const V=A.source.name;if(s=e.model.entries.find(ye=>ye.name===V),s===void 0)throw new Error(`Model does not contain source or query named ${V}`)}}if(s===void 0&&(s=e.model.entries[0]),s===void 0)throw new Error("Model does not contain any sources or queries")}const f=Ue(s),T=(t=e.query)!==null&&t!==void 0?t:{definition:{kind:"arrow",source:{kind:"source_reference",name:f.name},view:{kind:"segment",operations:[]}}},k=(n=e.model)!==null&&n!==void 0?n:{entries:[f],anonymous_queries:[]};super(T,{definition:i.ASTQueryDefinition.from(T.definition),annotations:T.annotations&&new X(T.annotations)}),this.model=k,e.source&&this.setSource(e.source.name)}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.parent=this}get annotations(){return this.children.annotations}reorderFields(e){this.definition.reorderFields(e)}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new X([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return j(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new y.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}setViewToEmptySegment(){if(!(this.definition instanceof E))throw new Error("Must set source before setting view");return this.definition=new E({kind:"arrow",source:this.definition.source.build(),view:{kind:"segment",operations:[]}}),this.definition.view.as.SegmentViewDefinition()}isRunnable(){return this.definition.isRunnable()}isEmpty(){return this.definition instanceof E&&this.definition.view instanceof $&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(e){if(this.definition instanceof E&&this.definition.source instanceof se&&this.definition.source.name===e)return;if(this.model.entries.find(n=>n.name===e)===void 0)throw new Error(`Source ${e} is not defined in model`);this.definition=new E({kind:"arrow",source:{kind:"source_reference",name:e},view:this.definition instanceof E?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(e){const t=this.model.entries.find(n=>n.name===e);if(t===void 0||t.kind!=="query")throw new Error(`No query named ${e} in the model`);this.definition=new z({kind:"query_reference",name:e})}getQueryInfo(e){const t=this.model.entries.find(n=>n.name===e);if(t===void 0)throw new Error(`Query ${e} is not defined in model`);if(t.kind!=="query")throw new Error(`Model entry ${e} is not a query`);return t}toMalloy(){return _.queryToMalloy(this.build())}build(){return super.build()}setView(e){if(!(this.definition instanceof E))throw new Error("Must set source before setting view");return this.definition=new E({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:e}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(e){var t;return e instanceof z?(t=this.getQueryInfo(e.name).annotations)!==null&&t!==void 0?t:[]:e instanceof M?this._getInheritedAnnotations(e.base):e instanceof E?e.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}i.ASTQuery=b;class S extends p{constructor(e){super(e,{name:e.name,path:e.path,parameters:e.parameters&&new O(e.parameters)}),this.reference=e}get name(){return this.children.name}set name(e){this.edit(),this.children.name=e}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}static getOrAddParameters(e){if(e.parameters)return e.parameters;e.edit();const t=new O([]);return e.parameters=t,t}static setParameter(e,t,n){const s=S.tryGetParameter(e,t);if(s!==void 0){s.value=i.ASTLiteralValue.from(i.ASTLiteralValue.makeLiteral(n));return}return e.getOrAddParameters().addParameter(t,n)}static tryGetParameter(e,t){if(e.parameters!==void 0){for(const n of e.parameters.iter())if(n.name===t)return n}}getOrAddParameters(){return S.getOrAddParameters(this)}setParameter(e,t){return S.setParameter(this,e,t)}tryGetParameter(e){return S.tryGetParameter(this,e)}}i.ASTReference=S;class L extends S{get segment(){const e=this.parent;return e instanceof d||e instanceof H?e.field.segment:e instanceof Se||e instanceof me?e.segment:e.list.segment}getReferenceSchema(){return this.parent instanceof G?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const e=this.getReferenceSchema();return c.schemaGet(e,this.name,this.path)}}i.ASTFieldReference=L;class O extends h{constructor(e){super(e,e.map(t=>new ie(t)))}get parameters(){return this.children}addParameter(e,t){this.add(new ie({name:e,value:i.ASTLiteralValue.makeLiteral(t)}))}}i.ASTParameterValueList=O;class ie extends p{constructor(e){super(e,{name:e.name,value:i.ASTLiteralValue.from(e.value)}),this.parameter=e}get name(){return this.children.name}get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}}i.ASTParameterValue=ie,i.ASTLiteralValue={from(r){switch(r.kind){case"string_literal":return new de(r);case"number_literal":return new q(r);case"boolean_literal":return new Te(r);case"date_literal":return new Ae(r);case"timestamp_literal":return new x(r);case"null_literal":return new ae(r);case"filter_expression_literal":return new ve(r)}},makeLiteral(r){if(r!==null&&typeof r=="object"&&"kind"in r)return r;if(typeof r=="string")return{kind:"string_literal",string_value:r};if(typeof r=="boolean")return{kind:"boolean_literal",boolean_value:r};if(typeof r=="number")return{kind:"number_literal",number_value:r};if(r===null)return{kind:"null_literal"};if("date"in r){const e=r.granularity,t=ze(r.date);return We(e)?{kind:"date_literal",date_value:t,granularity:e}:{kind:"timestamp_literal",timestamp_value:t,granularity:e}}throw new Error("Unknown literal type")}};class de extends p{constructor(e){super(e,{kind:e.kind,string_value:e.string_value}),this.node=e,this.kind="string_literal"}get fieldType(){return{kind:"string_type"}}}i.ASTStringLiteralValue=de;class ae extends p{constructor(e){super(e,{kind:e.kind}),this.node=e,this.kind="null_literal"}get fieldType(){}}i.ASTNullLiteralValue=ae;class q extends p{constructor(e){super(e,{kind:e.kind,number_value:e.number_value}),this.node=e,this.kind="number_literal"}get fieldType(){return{kind:"number_type",subtype:Number.isInteger(this.children.number_value)?"integer":"decimal"}}}i.ASTNumberLiteralValue=q;class Te extends p{constructor(e){super(e,{kind:e.kind,boolean_value:e.boolean_value}),this.node=e,this.kind="boolean_literal"}get fieldType(){return{kind:"boolean_type"}}}i.ASTBooleanLiteralValue=Te;class Ae extends p{constructor(e){super(e,{kind:e.kind,date_value:e.date_value,granularity:e.granularity}),this.node=e,this.kind="date_literal"}get fieldType(){return{kind:"date_type",timeframe:this.children.granularity}}}i.ASTDateLiteralValue=Ae;class x extends p{constructor(e){super(e,{kind:e.kind,timestamp_value:e.timestamp_value,granularity:e.granularity}),this.node=e,this.kind="timestamp_literal"}get fieldType(){return{kind:"timestamp_type",timeframe:this.children.granularity}}}i.ASTTimestampLiteralValue=x;class ve extends p{constructor(e){super(e,{kind:e.kind,filter_expression_value:e.filter_expression_value}),this.node=e,this.kind="filter_expression_literal"}get fieldType(){}}i.ASTFilterExpressionLiteralValue=ve;class Ee extends c{constructor(e){super(),this.node=e}get treeEdited(){return!1}build(){return this.node}findAny(){throw new Error("Tried to find a node from an unimplemented node type")}}i.ASTUnimplemented=Ee,i.ASTQueryArrowSource={from(r){switch(r.kind){case"refinement":return new M(r);case"source_reference":return new se(r)}}},i.ASTQueryDefinition={from(r){switch(r.kind){case"arrow":return new E(r);case"query_reference":return new z(r);case"refinement":return new M(r)}}};class E extends p{constructor(e){super(e,{kind:"arrow",source:i.ASTQueryArrowSource.from(e.source),view:N.from(e.view)}),this.node=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}getSourceInfo(){return this.source.getSourceInfo()}getOutputSchema(){return this.view.getRefinementSchema()}isRunnable(){return this.view.isRunnable()&&this.source.isRunnable()}get query(){return this.parent.as.Query()}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}reorderFields(e){this.view instanceof $?this.view.reorderFields(e):this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}}i.ASTArrowQueryDefinition=E;class M extends p{constructor(e){super(e,{kind:"refinement",base:i.ASTQueryDefinition.from(e.base),refinement:N.from(e.refinement)}),this.node=e}get base(){return this.children.base}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}isRunnable(){return!0}get query(){return this.parent.as.Query()}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}getOutputSchema(){const e=this.base.getOutputSchema(),t=this.refinement.getRefinementSchema();return b.schemaMerge(e,t)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.refinement),this.refinement.propagateDown(e)}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getSourceInfo(){return this.base.getSourceInfo()}}i.ASTRefinementQueryDefinition=M;class z extends p{constructor(e){super(e,{kind:"query_reference",name:e.name,path:e.path,parameters:e.parameters&&new O(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get query(){return this.parent.as.Query()}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getOrAddDefaultSegment(){const e=new M({kind:"refinement",base:this.build(),refinement:{kind:"segment",operations:[]}});return this.query.definition=e,e.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}reorderFields(e){this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}getOrAddParameters(){return S.getOrAddParameters(this)}setParameter(e,t){return S.setParameter(this,e,t)}tryGetParameter(e){return S.tryGetParameter(this,e)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const t=this.query.model.entries.find(n=>n.name===this.name);if(t===void 0)throw new Error(`Query not found with name ${this.name}`);return t}}i.ASTReferenceQueryDefinition=z;class se extends p{constructor(e){super(e,{kind:"source_reference",name:e.name,path:e.path,parameters:e.parameters&&new O(e.parameters)}),this.node=e}isRunnable(){return this.areRequiredParametersSet()}get name(){return this.children.name}get arrow(){return this.parent.as.ArrowQueryDefinition()}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get path(){return this.children.path}getSourceInfo(){const e=this.arrow.query.model.entries.find(t=>t.name===this.name);if(e===void 0)throw new Error(`No query or source named ${this.name}`);return e}getOrAddDefaultSegment(){if(this.getSourceInfo().kind!=="query")throw new Error(`Cannot refine source ${this.name}`);const t=new M({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=t,t.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}getOrAddParameters(){return S.getOrAddParameters(this)}setParameter(e,t){return S.setParameter(this,e,t)}tryGetParameter(e){return S.tryGetParameter(this,e)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var e;const t=this.getSourceInfo();return t.kind==="query"?[]:(e=t.parameters)!==null&&e!==void 0?e:[]}areRequiredParametersSet(){const e=this.getSourceParameters();for(const t of e){if(t.default_value!==void 0)continue;if(this.tryGetParameter(t.name)===void 0)return!1}return!0}}i.ASTReferenceQueryArrowSource=se;const N={from(r){switch(r.kind){case"arrow":return new ue(r);case"view_reference":return new le(r);case"segment":return new $(r);case"refinement":return new Q(r)}}};function B(r,e){const t=r.parent;t instanceof E?t.view=e:t instanceof M?t.refinement=e:t instanceof ke?t.definition=e:t instanceof ue?t.source===r?t.source=e:t.view=e:t.base===r?t.base=e:t.refinement=e}function oe(r,e,t=[]){const n=r.getInputSchema(),s=b.schemaGet(n,e,t);if(s===void 0)return{isValidViewRefinement:!1,error:`${e} is not defined`};if(s.kind!=="view")return{isValidViewRefinement:!1,error:`${e} is not a view`};const f=r.getOutputSchema();for(const T of s.schema.fields)if(b.schemaTryGet(f,T.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${e} because stage already has an output field named ${T.name}`};return{isValidViewRefinement:!0}}class le extends p{constructor(e){super(e,{kind:"view_reference",name:e.name,path:e.path,parameters:e.parameters&&new O(e.parameters)}),this.node=e}isRunnable(){return!0}get name(){return this.children.name}get path(){return this.children.path}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}getOrAddDefaultSegment(){return this.addEmptyRefinement()}addEmptyRefinement(){const e=Q.segmentRefinementOf(this.build());return B(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,t){const{error:n}=this.isValidViewRefinement(e,t);if(n)throw new Error(n);const s=Q.viewRefinementOf(this.build(),e,t);return B(this,s),s.refinement.as.ReferenceViewDefinition()}convertToNest(e){const t=N.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});B(this,t)}isValidViewRefinement(e,t){return oe(this,e,t)}getInputSchema(){return Re(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const e=this.getInputSchema(),t=c.schemaGet(e,this.name,this.path);if(t.kind!=="view")throw new Error("Not a view");return t}getRefinementSchema(){return this.getViewInfo().schema}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}getInheritedAnnotations(){var e;return(e=this.getViewInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return S.getOrAddParameters(this)}setParameter(e,t){return S.setParameter(this,e,t)}tryGetParameter(e){return S.tryGetParameter(this,e)}}i.ASTReferenceViewDefinition=le;class ue extends p{constructor(e){super(e,{kind:"arrow",source:N.from(e.source),view:N.from(e.view)}),this.node=e}isRunnable(){return this.source.isRunnable()&&this.view.isRunnable()}get source(){return this.children.source}set source(e){this.edit(),this.children.source=e}get view(){return this.children.view}set view(e){this.edit(),this.children.view=e,e.parent=this}getOrAddDefaultSegment(){return this.view.getOrAddDefaultSegment()}addEmptyRefinement(){return this.view.addEmptyRefinement()}addViewRefinement(e,t){return this.view.addViewRefinement(e,t)}convertToNest(e){const t=N.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});B(this,t)}getInputSchema(){return this.source.getOutputSchema()}getOutputSchema(){return this.view.getRefinementSchema()}getImplicitName(){return this.view.getImplicitName()}getRefinementSchema(){throw new Error("An arrow is not a valid refinement")}isValidViewRefinement(e,t){return oe(this,e,t)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}getInheritedAnnotations(){return[]}}i.ASTArrowViewDefinition=ue;class Q extends p{constructor(e){super(e,{kind:"refinement",base:N.from(e.base),refinement:N.from(e.refinement)}),this.node=e}isRunnable(){return this.getOutputSchema().fields.length>0}get refinement(){return this.children.refinement}set refinement(e){this.edit(),this.children.refinement=e,e.parent=this}get base(){return this.children.base}set base(e){this.edit(),this.children.base=e}convertToNest(e){const t=N.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});B(this,t)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(e,t){return this.refinement.addViewRefinement(e,t)}getInputSchema(){return Re(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return c.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(e,t){return oe(this,e,t)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){e(this.base),e(this.refinement),this.base.propagateDown(e),this.refinement.propagateDown(e)}getInheritedAnnotations(){return this.base.getInheritedAnnotations()}static viewRefinementOf(e,t,n){return new Q({kind:"refinement",base:e,refinement:{kind:"view_reference",name:t,path:n}})}static segmentRefinementOf(e){return new Q({kind:"refinement",base:e,refinement:{kind:"segment",operations:[]}})}}i.ASTRefinementViewDefinition=Q;class $ extends p{constructor(e){super(e,{kind:"segment",operations:new ce(e.operations)}),this.node=e,this.DEFAULT_INSERTION_ORDER=["group_by","aggregate","drill","where","having","nest","order_by","calculate","limit"]}isRunnable(){let e=!1;for(const t of this.operations.iter()){if(t instanceof P||t instanceof D)return!0;if(t instanceof w){if(!t.view.definition.isRunnable())return!1;e=!0}}return e}get operations(){return this.children.operations}convertToNest(e){const t=N.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});B(this,t)}renameOrderBys(e,t){for(const n of this.operations.iter())n instanceof G&&n.name===e&&n.setField(t)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}removeOrderBys(e){for(const t of this.operations.iter())t instanceof G&&t.name===e&&t.delete()}reorderFields(e){const t=[],n=[],s={};let f=!1;for(const A of this.operations.iter()){if((A instanceof P||A instanceof D||A instanceof w)&&e.includes(A.name)){s[A.name]=A,f=!0;continue}f?n.push(A):t.push(A)}const T=[];for(const A of e){const V=s[A];if(V===void 0)throw new Error(`No field named ${A}`);T.push(V)}const k=[...t,...T,...n];this.operations.items=k}renameField(e,t){if(e.name===t)return;const n=this.getOutputSchema();if(c.schemaTryGet(n,t,[]))throw new Error(`Output already has a field named ${t}`);const s=e.name;e.name=t,this.propagateUp(f=>{f instanceof $&&f.renameOrderBys(s,t)})}addOrderBy(e,t){const n=this.getOutputSchema();try{c.schemaGet(n,e,[])}catch{throw new Error(`No such field ${e} in stage output`)}for(const f of this.operations.iter())if(f instanceof G&&f.name===e)return f.direction=t,f;const s=new G({kind:"order_by",field_reference:{name:e},direction:t});return this.addOperation(s),s}addEmptyNest(e){const t=new w({kind:"nest",name:e,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(t),t}firstIndexOfOperationType(e){return this.operations.findIndex(t=>t.kind===e)}findInsertionPoint(e){const t=this.firstIndexOfOperationType(e);if(t>-1){let f=t;for(;this.operations.index(f)&&this.operations.index(f).kind===e;)f++;return f}const n=this.DEFAULT_INSERTION_ORDER.indexOf(e);if(n===-1)throw new Error(`Operation ${e} is not supported for \`findInsertionPoint\``);const s=this.DEFAULT_INSERTION_ORDER.slice(n+1);for(const f of s){const T=this.firstIndexOfOperationType(f);if(T>-1)return T}return this.operations.length}getFieldNamed(e){const t=this.tryGetFieldNamed(e);if(t===void 0)throw new Error("No such field");return t}hasFieldNamed(e){return this.tryGetFieldNamed(e)!==void 0}hasField(e,t){return this.tryGetField(e,t)!==void 0}getField(e,t){const n=this.tryGetField(e,t);if(n===void 0)throw new Error("No such field");return n}tryGetField(e,t){for(const n of this.operations.iter())if(n instanceof D||n instanceof P){const s=n.field.getReference();if(s&&s.name===e&&Ie(s.path,t))return n}else if(n instanceof w){if(n.view instanceof le)return n}else if(n instanceof K){const s=n.expression.field.getReference();if(s&&s.name===e&&Ie(s.path,t))return n}}tryGetFieldNamed(e){for(const t of this.operations.iter())if((t instanceof D||t instanceof P||t instanceof w||t instanceof K)&&t.name===e)return t}getGroupBy(e){for(const t of this.operations.iter())if(t instanceof D&&t.name===e)return t}removeGroupBy(e){var t;return(t=this.getGroupBy(e))===null||t===void 0||t.delete(),this}addGroupBy(e,t=[],n){const s=this.makeField(e,t,n,"dimension");return this.addOperation(s),s}addDrill(e){const t=new C({kind:"drill",...e});return this.addOperation(t),t}addWhere(e,t,n){const s=Array.isArray(t)?t:[],f=n===void 0?t:n,T=typeof f=="string"?f:be(f),k=this.getInputSchema(),A=b.schemaGet(k,e,s);Fe(A,f);const V=new F({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:T}});return this.addOperation(V),V}addHaving(e,t,n){const s=Array.isArray(t)?t:[],f=n===void 0?t:n,T=typeof f=="string"?f:be(f),k=this.getInputSchema(),A=b.schemaGet(k,e,s);Fe(A,f);const V=new ee({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:T}});return this.addOperation(V),V}addCalculateMovingAverage(e,t,n,s,f){const T=new K({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:t,path:n},rows_preceding:s,rows_following:f}}});return this.addOperation(T),T}addTimeGroupBy(e,t,n,s){const f=this.getInputSchema(),T=c.schemaGet(f,e,t);if(T===void 0)throw new Error(`No such field ${e}`);if(T.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${e}`);if(T.type.kind!==s)throw new Error(`${e} is not a ${s}`);const k=new D({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:e,path:t},truncation:n}}});return this.addOperation(k),k}addDateGroupBy(e,t,n){const s=n===void 0?t:n,f=n===void 0?[]:t;return this.addTimeGroupBy(e,f,s,"date_type")}addTimestampGroupBy(e,t,n){const s=n===void 0?t:n,f=n===void 0?[]:t;return this.addTimeGroupBy(e,f,s,"timestamp_type")}addTimestamptzGroupBy(e,t,n){const s=n===void 0?t:n,f=n===void 0?[]:t;return this.addTimeGroupBy(e,f,s,"timestamptz_type")}addAggregate(e,t=[],n){const s=this.makeField(e,t,n,"measure");return this.addOperation(s),s}addNest(e,t){const n=this.makeField(e,[],t,"view");return this.addOperation(n),n}makeField(e,t,n,s){const f=this.getInputSchema(),T=c.schemaGet(f,e,t);if(T===void 0)throw new Error(`No such field ${e}`);if(T.kind!==s){const k=xe(s),A=s;throw new Error(`Cannot ${k} non-${A} ${e}`)}return s==="dimension"?D.fromReference(e,t,n):s==="measure"?P.fromReference(e,t,n):w.fromReference(e,t,n)}addOperation(e){if((e instanceof D||e instanceof P||e instanceof w||e instanceof K)&&this.hasFieldNamed(e.name))throw new Error(`Query already has a field named ${e.name}`);const t=this.findInsertionPoint(e.kind);return this.operations.insert(e,t),e}getRefinementSchema(){const e=[];for(const t of this.operations.iter())(t instanceof D||t instanceof P||t instanceof w||t instanceof K)&&e.push(t.getFieldInfo());return{fields:e}}setLimit(e){Z.validateLimit(e);const t=[...this.operations.iter()].find(i.ASTViewOperation.isLimit);t?t.limit=e:this.operations.add(new Z({kind:"limit",limit:e}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const e=Q.segmentRefinementOf(this.build());return B(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,t){const{error:n}=this.isValidViewRefinement(e,t);if(n)throw new Error(n);const s=Q.viewRefinementOf(this.build(),e,t);return B(this,s),s.refinement.as.ReferenceViewDefinition()}getInputSchema(){return Re(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(e,t){return oe(this,e,t)}getInheritedAnnotations(){return[]}}i.ASTSegmentViewDefinition=$;class ce extends h{constructor(e){super(e,e.map(t=>i.ASTViewOperation.from(t)))}get items(){return this.children}set items(e){this.edit(),this.children=e}get segment(){return this.parent.as.SegmentViewDefinition()}}i.ASTViewOperationList=ce,i.ASTViewOperation={from(r){switch(r.kind){case"group_by":return new D(r);case"aggregate":return new P(r);case"order_by":return new G(r);case"nest":return new w(r);case"limit":return new Z(r);case"where":return new F(r);case"drill":return new C(r);case"having":return new ee(r);case"calculate":return new K(r)}},isLimit(r){return r instanceof Z}};class G extends p{constructor(e){super(e,{kind:"order_by",field_reference:new L(e.field_reference),direction:e.direction}),this.node=e,this.kind="order_by"}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get direction(){return this.children.direction}set direction(e){this.direction!==e&&(this.edit(),this.children.direction=e)}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}setField(e){const t=this.list.segment.getOutputSchema();c.schemaGet(t,e,[]),this.edit(),this.children.field_reference=new L({name:e})}setDirection(e){this.direction=e}}i.ASTOrderByViewOperation=G;class D extends p{constructor(e){super(e,{kind:"group_by",name:e.name,field:new J(e.field)}),this.node=e,this.kind="group_by"}get field(){return this.children.field}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(t===void 0)throw new Error("Group by does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}rename(e){this.list.segment.renameField(this,e)}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof $&&e.removeOrderBys(this.name)})}getFieldInfo(){return{kind:"dimension",name:this.name,type:this.field.type}}get annotations(){return this.field.annotations}set annotations(e){this.edit(),this.field.annotations=e}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return j(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new y.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}static fromReference(e,t,n){return new D({kind:"group_by",name:n,field:{expression:{kind:"field_reference",name:e,path:t}}})}}i.ASTGroupByViewOperation=D;class P extends p{constructor(e){super(e,{kind:"aggregate",name:e.name,field:new J(e.field)}),this.node=e,this.kind="aggregate"}get field(){return this.children.field}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(t===void 0)throw new Error("Aggregate does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.field.name===e?this.children.name=void 0:this.children.name=e)}get annotations(){return this.field.annotations}rename(e){this.list.segment.renameField(this,e)}convertToCalculateMovingAverage(e,t,n=0,s=[]){if(!(this.field.expression instanceof Y))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const f=new K({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:t,rows_following:n,partition_fields:s.map(T=>({name:T}))}}});return this.list.add(f),f}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof $&&e.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:y.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return j(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new y.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}addWhere(e,t,n){const s=Array.isArray(t)?t:[],f=n===void 0?t:n,T=typeof f=="string"?f:be(f),k=this.list.segment.getInputSchema(),A=b.schemaGet(k,e,s);Fe(A,f);const V={filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:s},filter:T}};if(this.field.expression instanceof d)return this.field.expression.where.add(new o(V)),this.field.expression;if(this.field.expression instanceof Y){const ye=this.field.expression.build();return this.field.expression=new d({kind:"filtered_field",field_reference:{name:ye.name,path:ye.path,parameters:ye.parameters},where:[V]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(e,t,n){return new P({kind:"aggregate",name:n,field:{expression:{kind:"field_reference",name:e,path:t}}})}}i.ASTAggregateViewOperation=P;class J extends p{constructor(e){super(e,{expression:i.ASTExpression.from(e.expression),annotations:e.annotations&&new X(e.annotations)}),this.node=e}get expression(){return this.children.expression}set expression(e){this.edit(),this.children.expression=e,e.parent=this}get name(){return this.expression.name}get type(){const e=this.expression.fieldType;if(e===void 0)throw new Error("Field expression does not have a type");return e}get annotations(){return this.children.annotations}set annotations(e){this.edit(),this.children.annotations=e}getReference(){if(!(this.expression instanceof U))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new X([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return j(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new y.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}i.ASTField=J,i.ASTExpression={from(r){switch(r.kind){case"field_reference":return new Y(r);case"filtered_field":return new d(r);case"time_truncation":return new H(r);case"literal_value":return new U(r);case"moving_average":return new a(r)}}};class Y extends p{constructor(e){super(e,{kind:e.kind,name:e.name,path:e.path,parameters:e.parameters&&new O(e.parameters)}),this.node=e,this.kind="field_reference"}get name(){return this.children.name}get parameters(){return this.children.parameters}set parameters(e){this.edit(),this.children.parameters=e}get segment(){const e=this.parent;if(e instanceof J)return e.segment;if(e instanceof Se||e instanceof me)return e.segment;throw new Error("Invalid expression parent")}get path(){return this.children.path}getReference(){return this.build()}getFieldInfo(){const e=this.segment.getInputSchema(),n=this.parent instanceof me&&this.parent.parent instanceof C?c.schemaGetDrillField(e,this.name,this.path):c.schemaGet(e,this.name,this.path);if(n.kind!=="dimension"&&n.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return n}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return S.getOrAddParameters(this)}setParameter(e,t){return S.setParameter(this,e,t)}tryGetParameter(e){return S.tryGetParameter(this,e)}}i.ASTReferenceExpression=Y;class H extends p{constructor(e){super(e,{kind:e.kind,field_reference:new L(e.field_reference),truncation:e.truncation}),this.node=e,this.kind="time_truncation"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get truncation(){return this.children.truncation}set truncation(e){this.edit(),this.children.truncation=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=c.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return t}get fieldType(){const e=this.getFieldInfo();if(e.type.kind==="date_type")return{...e.type,timeframe:g(this.truncation)};if(e.type.kind==="timestamp_type"||e.type.kind==="timestamptz_type")return{...e.type,timeframe:this.truncation};throw new Error("This type of field cannot have a time truncation")}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}i.ASTTimeTruncationExpression=H;class U extends p{constructor(e){super(e,{kind:e.kind,literal_value:i.ASTLiteralValue.from(e.literal_value)}),this.node=e,this.kind="time_truncation"}get name(){}get literalValue(){return this.children.literal_value}get fieldType(){return this.literalValue.fieldType}getInheritedAnnotations(){return[]}getFieldInfo(){}}i.ASTLiteralValueExpression=U;class pe extends h{constructor(e){super(e,e.map(t=>new L(t)))}}i.ASTFieldReferenceList=pe;class a extends p{constructor(e){super(e,{kind:e.kind,field_reference:new L(e.field_reference),rows_preceding:e.rows_preceding,rows_following:e.rows_following,partition_fields:new pe(e.partition_fields||[])}),this.node=e,this.kind="moving_average"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get rowsPreceding(){return this.children.rows_preceding}set rowsPreceding(e){this.edit(),this.children.rows_preceding=e}get rowsFollowing(){return this.children.rows_following}set rowsFollowing(e){this.edit(),this.children.rows_following=e}get name(){return this.fieldReference.name}get field(){return this.parent.as.Field()}get partitionFields(){return this.children.partition_fields}setPartitionFields(e){this.children.partition_fields=new pe(e)}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=c.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="dimension"&&t.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return t}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}i.ASTMovingAverageExpression=a;class o extends p{constructor(e){super(e,{filter:i.ASTFilter.from(e.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}i.ASTFilterOperation=o;class u extends h{constructor(e){super(e,e.map(t=>new o(t)))}get expression(){return this.parent.as.FilteredFieldExpression()}}i.ASTFilterOperationList=u;class d extends p{constructor(e){super(e,{kind:e.kind,field_reference:new L(e.field_reference),where:new u(e.where)}),this.node=e,this.kind="filtered_field"}getReference(){return this.fieldReference.build()}get fieldReference(){return this.children.field_reference}get name(){return this.fieldReference.name}get where(){return this.children.where}get field(){return this.parent.as.Field()}getFieldInfo(){const e=this.field.segment.getInputSchema(),t=c.schemaGet(e,this.name,this.fieldReference.path);if(t.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return t}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}i.ASTFilteredFieldExpression=d;function g(r){switch(r){case"day":case"week":case"month":case"year":case"quarter":return r;default:throw new Error("Invalid date timeframe")}}class w extends p{constructor(e){super(e,{kind:"nest",name:e.name,view:new ke(e.view)}),this.node=e,this.kind="nest"}get view(){return this.children.view}get annotations(){return this.view.annotations}get name(){var e;const t=(e=this.children.name)!==null&&e!==void 0?e:this.view.name;if(t===void 0)throw new Error("Nest does not have a name");return t}set name(e){this.name!==e&&(this.edit(),this.view.name===e?this.children.name=void 0:this.children.name=e)}get list(){return this.parent.as.ViewOperationList()}getOrAddAnnotations(){return this.view.getOrAddAnnotations()}getInheritedTag(e="# "){return j(e,this.view.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new y.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}delete(){this.list.remove(this)}rename(e){this.list.segment.renameField(this,e)}getFieldInfo(){return{kind:"view",name:this.name,definition:this.view.build(),schema:this.view.getOutputSchema()}}static fromReference(e,t,n){return new w({kind:"nest",name:n,view:{definition:{kind:"view_reference",name:e,path:t}}})}}i.ASTNestViewOperation=w;class F extends p{constructor(e){super(e,{kind:"where",filter:i.ASTFilter.from(e.filter)}),this.node=e,this.kind="where"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}i.ASTWhereViewOperation=F;class C extends p{constructor(e){super(e,{kind:"drill",filter:i.ASTFilter.from(e.filter)}),this.node=e,this.kind="drill"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}i.ASTDrillViewOperation=C;class ee extends p{constructor(e){super(e,{kind:"having",filter:i.ASTFilter.from(e.filter)}),this.node=e,this.kind="having"}get filter(){return this.children.filter}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}i.ASTHavingViewOperation=ee;class K extends p{constructor(e){super(e,{kind:"calculate",field:new J(e.field),name:e.name}),this.node=e,this.kind="calculate"}get expression(){return this.children.field.expression}set expression(e){this.edit(),this.children.field.expression=e,e.parent=this}get name(){return this.node.name}set name(e){this.name!==e&&(this.edit(),this.node.name=e)}getFieldInfo(){return{annotations:[{value:y.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"calculate",name:this.name,type:this.expression.fieldType}}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}}i.ASTCalculateViewOperation=K,i.ASTFilter={from(r){switch(r.kind){case"filter_string":return new Se(r);case"literal_equality":return new me(r)}},getSegment(r){const e=r.parent;return e instanceof o?e.list.expression.field.segment:e.list.segment}};class Se extends p{constructor(e){super(e,{kind:"filter_string",expression:i.ASTExpression.from(e.expression),filter:e.filter}),this.node=e,this.kind="filter_string"}get expression(){return this.children.expression}get filterString(){return this.children.filter}set filterString(e){this.edit(),this.children.filter=e}setFilterString(e){const t=this.getFilterType();Ve(this.filterString,t),this.filterString=e}get segment(){return i.ASTFilter.getSegment(this)}getFieldInfo(){const e=this.expression.getFieldInfo();if(e===void 0||e.kind!=="dimension"&&e.kind!=="measure")throw new Error("Invalid field type for filter with filter string");return e}getFilterType(){const e=this.getFieldInfo();return De(e)}setFilter(e){const t=this.getFilterType();if(t!==e.kind)throw new Error(`Invalid filter: expected type ${t}, got ${e.kind}`);this.filterString=be(e)}getFilter(){const e=this.getFilterType();return Ve(this.filterString,e)}}i.ASTFilterWithFilterString=Se;class me extends p{constructor(e){super(e,{kind:"literal_equality",expression:i.ASTExpression.from(e.expression),value:i.ASTLiteralValue.from(e.value)}),this.node=e,this.kind="literal_equality"}get expression(){return this.children.expression}get value(){return this.children.value}get segment(){return i.ASTFilter.getSegment(this)}}i.ASTFilterWithLiteralEquality=me;class ke extends p{constructor(e){super(e,{definition:N.from(e.definition),annotations:e.annotations&&new X(e.annotations)}),this.node=e}get definition(){return this.children.definition}set definition(e){this.edit(),this.children.definition=e,e.parent=this}get name(){return this.definition.getImplicitName()}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}get nest(){return this.parent.as.NestViewOperation()}getInputSchema(){return this.nest.list.segment.getInputSchema()}getOutputSchema(){return this.definition.getRefinementSchema()}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.definition),this.definition.propagateDown(e)}reorderFields(e){this.definition instanceof $?this.definition.reorderFields(e):this.getOrAddAnnotations().setTagProperty(["field_order"],e)}get annotations(){return this.children.annotations}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new X([]);return this.children.annotations=e,e.parent=this,e}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(e="# "){return j(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getIntrinsicTag(e))!==null&&n!==void 0?n:new y.Tag}getTag(e="# "){var t,n;return(n=(t=this.annotations)===null||t===void 0?void 0:t.getTag(e))!==null&&n!==void 0?n:this.getInheritedTag(e)}setTagProperty(e,t=null,n="# "){this.getOrAddAnnotations().setTagProperty(e,t,n)}removeTagProperty(e,t="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,t)}}i.ASTView=ke;class Z extends p{get limit(){return this.children.limit}set limit(e){Z.validateLimit(e),this.edit(),this.children.limit=e}constructor(e){super(e,{kind:e.kind,limit:e.limit}),this.node=e,this.kind="limit"}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this)}static validateLimit(e){if(!Number.isInteger(e))throw new Error("Limit must be an integer")}}i.ASTLimitViewOperation=Z;function xe(r){switch(r){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function at(r){return r}class X extends h{constructor(e){super(e,e.map(t=>new he(t)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(e="# "){return j(e,this.items)}getTag(e="# "){return j(e,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(e=>e.node)}setTagProperty(e,t=null,n="# "){let s;for(let f=this.items.length-1;f>=0;f--){const T=this.index(f);if(T.hasPrefix(n)&&(s=T,T.hasIntrinsicTagProperty(e))){T.setTagProperty(e,t);return}}s?s.setTagProperty(e,t):this.add(new he({value:new y.Tag({prefix:n}).set(e,t).toString()}))}removeTagProperty(e,t="# "){let n;for(let s=this.items.length-1;s>=0;s--){const f=this.index(s);if(f.hasPrefix(t)&&(n=f,f.hasIntrinsicTagProperty(e))){f.removeTagProperty(e);return}}n?n.removeTagProperty(e):this.add(new he({value:new y.Tag({prefix:t}).unset(...e).toString()}))}}i.ASTAnnotationList=X;class he extends p{get value(){return this.children.value}set value(e){this.edit(),this.children.value=e}constructor(e){super(e,{value:e.value}),this.node=e}get list(){return this.parent.as.AnnotationList()}get index(){return this.list.indexOf(this)}delete(){this.list.remove(this)}getIntrinsicTag(){const e=new y.TagParser;return e.parseAnnotation(this.value),e.finish()}getTag(){const e=new y.TagParser;for(const t of this.list.getInheritedAnnotations())e.parseAnnotation(t.value);for(let t=0;t<=this.index;t++)e.parseAnnotation(this.list.index(t).value);return e.finish()}hasPrefix(e){return this.value.startsWith(e)}hasIntrinsicTagProperty(e){return this.getIntrinsicTag().has(...e)}setTagProperty(e,t){this.value=this.getIntrinsicTag().set(e,t).toString()}removeTagProperty(e){this.value=this.getTag().unset(...e).toString()}}i.ASTAnnotation=he;function j(r,e=[],t=[]){const n=new y.TagParser;for(const f of t)n.parseAnnotation(f.value);const s=e.map(f=>f.value).filter(f=>typeof r=="string"?f.startsWith(r):f.match(r));for(const f of s)n.parseAnnotation(f);return n.finish()}function be(r){switch(r.kind){case"string":return l.StringFilterExpression.unparse(r.parsed);case"number":return l.NumberFilterExpression.unparse(r.parsed);case"boolean":return l.BooleanFilterExpression.unparse(r.parsed);case"timestamp":case"timestamptz":case"date":return l.TemporalFilterExpression.unparse(r.parsed)}}function Ve(r,e){function t(n){const s=n.filter(f=>f.severity==="error");if(s.length!==0)throw new Error(`Invalid Malloy filter string: ${s[0].message}`)}switch(e){case"string":{const n=l.StringFilterExpression.parse(r);return t(n.log),{kind:e,parsed:n.parsed}}case"number":{const n=l.NumberFilterExpression.parse(r);return t(n.log),{kind:e,parsed:n.parsed}}case"boolean":{const n=l.BooleanFilterExpression.parse(r);return t(n.log),{kind:e,parsed:n.parsed}}case"timestamp":case"timestamptz":case"date":{const n=l.TemporalFilterExpression.parse(r);return t(n.log),{kind:e,parsed:n.parsed}}case"other":throw new Error("Not implemented")}}function Ue(r){return"kind"in r?r:{...r,kind:"source"}}function We(r){switch(r){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function fe(r,e){return r.toString().padStart(e,"0")}function ze(r){const e=fe(r.getUTCFullYear(),4),t=fe(r.getUTCMonth()+1,2),n=fe(r.getUTCDate(),2),s=fe(r.getUTCHours(),2),f=fe(r.getUTCMinutes(),2),T=fe(r.getUTCSeconds(),2);return`${e}-${t}-${n} ${s}:${f}:${T}`}function Ie(r,e){const t=r??[],n=e??[];return t.length===n.length&&t.every((s,f)=>s===n[f])}function De(r){switch(r.type.kind){case"string_type":return"string";case"boolean_type":return"boolean";case"number_type":return"number";case"date_type":return"date";case"timestamp_type":return"timestamp";case"timestamptz_type":return"timestamp";default:return"other"}}function Fe(r,e){if(r.kind!=="dimension"&&r.kind!=="measure")throw new Error(`Cannot filter by field of type ${r.kind}`);const t=De(r);if(typeof e=="string")Ve(e,t);else if(e.kind!==t)throw new Error(`Invalid filter for field ${r.name}; expected type ${t}, but got ${e.kind}`)}function Re(r){if(r instanceof E)return r.getSourceInfo().schema;if(r instanceof M)throw new Error("unimplemented");return r.getInputSchema()}})(W)),W}var Me;function rt(){return Me||(Me=1,(function(i){var I=re&&re.__createBinding||(Object.create?(function(v,_,y,l){l===void 0&&(l=y);var c=Object.getOwnPropertyDescriptor(_,y);(!c||("get"in c?!_.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:function(){return _[y]}}),Object.defineProperty(v,l,c)}):(function(v,_,y,l){l===void 0&&(l=y),v[l]=_[y]})),R=re&&re.__exportStar||function(v,_){for(var y in v)y!=="default"&&!Object.prototype.hasOwnProperty.call(_,y)&&I(_,v,y)};Object.defineProperty(i,"__esModule",{value:!0}),R(nt(),i)})(re)),re}var Ge=rt();const it=Ye(Ge),lt=Ke({__proto__:null,default:it},[Ge]);export{Ge as d,lt as i,tt as r};