@malloy-publisher/app 0.0.219 → 0.0.221

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/api-doc.yaml +291 -20
  2. package/dist/assets/{EnvironmentPage-gehnjfC6.js → EnvironmentPage-D6G5n6mY.js} +1 -1
  3. package/dist/assets/{HomePage-8LQBytE4.js → HomePage-DgZluD8u.js} +1 -1
  4. package/dist/assets/LightMode-w9v0pEbg.js +1 -0
  5. package/dist/assets/MainPage-Bi_Tukvr.js +2 -0
  6. package/dist/assets/{MaterializationsPage-D7P1Kp6O.js → MaterializationsPage-BVERjnmG.js} +1 -1
  7. package/dist/assets/ModelPage-2OjS259-.js +1 -0
  8. package/dist/assets/{PackagePage-Cz9fVwSG.js → PackagePage-C8L2On4z.js} +1 -1
  9. package/dist/assets/{RouteError-UONCloyN.js → RouteError-DJoNC_Vl.js} +1 -1
  10. package/dist/assets/ThemeEditorPage-B-hJ1zgd.js +1 -0
  11. package/dist/assets/{WorkbookPage-Bhzqvbq_.js → WorkbookPage-CTbDgGeJ.js} +1 -1
  12. package/dist/assets/{core-BiGj7BML.es-kMHAa8tP.js → core-D9Hl0IDY.es-CmgzHn4c.js} +1 -1
  13. package/dist/assets/github-dark-DenFmJkN.es-DHJKELXO.js +1 -0
  14. package/dist/assets/index-8E2uLeV9.js +2541 -0
  15. package/dist/assets/index-BEjJCJjX.js +1761 -0
  16. package/dist/assets/index-BF8PkFm8.js +1 -0
  17. package/dist/assets/index-Cr-asgoV.js +527 -0
  18. package/dist/assets/index-DcCw_qxr.js +18 -0
  19. package/dist/assets/index-w_0OQJgZ.js +23 -0
  20. package/dist/index.html +1 -1
  21. package/package.json +3 -2
  22. package/dist/assets/MainPage-DDaZLJw-.js +0 -2
  23. package/dist/assets/ModelPage-Do_vhxOc.js +0 -1
  24. package/dist/assets/index-VzRbxcF7.js +0 -455
  25. package/dist/assets/index-ddq4-5hu.js +0 -1760
  26. package/dist/assets/index-qOQF9CXq.js +0 -40
  27. package/dist/assets/index.umd-B2kmxDh7.js +0 -2467
@@ -0,0 +1,18 @@
1
+ import{aI as ci}from"./index-Cr-asgoV.js";import{r as di}from"./index-w_0OQJgZ.js";function pi(u,re){for(var j=0;j<re.length;j++){const N=re[j];if(typeof N!="string"&&!Array.isArray(N)){for(const E in N)if(E!=="default"&&!(E in u)){const S=Object.getOwnPropertyDescriptor(N,E);S&&Object.defineProperty(u,E,S.get?S:{enumerable:!0,get:()=>N[E]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}var bt={},ut={},Or;function Vt(){if(Or)return ut;Or=1,Object.defineProperty(ut,"__esModule",{value:!0}),ut.isChainOp=u,ut.isStringCondition=re,ut.isStringFilter=j,ut.isBooleanFilter=N,ut.isNumberFilter=E,ut.isTemporalFilter=S,ut.isFilterExpression=w,ut.isFilterable=y;function u(o){return["and","or",","].includes(o)}function re(o){return["starts","ends","contains","="].includes(o.operator)}function j(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["starts","ends","contains","=","~","null","empty","and","or",",","()"].includes(o.operator)}function N(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["null","true","false","=false","=true"].includes(o.operator)}function E(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["range","<=",">=","!=","=",">","<","and","or","()","null"].includes(o.operator)}function S(o){return typeof o=="object"&&o!==null&&"operator"in o&&typeof o.operator=="string"&&["literal","before","after","to","for","in","and","or","in_last","this","last","next","()","null"].includes(o.operator)}function w(o){return typeof o=="object"&&o!==null&&"operator"in o}function y(o){return["string","number","boolean","timestamp","timestamptz","date"].includes(o)}return ut}var Pt={},Er;function hi(){return Er||(Er=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.BooleanFilterExpression=void 0,Pt.BooleanFilterExpression={parse(u){var re;if(u.match(/^\s*$/))return{parsed:null,log:[]};const j={parsed:null,log:[]};let N=u.toLowerCase().trim().replace(/\s\s+/," "),E=!1;if(N.startsWith("not ")&&(E=!0,N=N.slice(4)),N==="true")j.parsed={operator:"true"};else if(N==="=true")j.parsed={operator:"=true"};else if(N==="false")j.parsed={operator:"false"};else if(N==="=false")j.parsed={operator:"=false"};else if(N==="null")j.parsed={operator:"null"};else{const S=u.match(/[^\s]/),w=S&&(re=S.index)!==null&&re!==void 0?re:0;j.log=[{message:`Illegal boolean filter '${N}'. Must be one of true,=true,false,=false,null`,severity:"error",startIndex:w,endIndex:w+u.length-1}]}return E&&j.parsed&&(j.parsed.not=!0),j},unparse(u){return u===null?"":(u.not?"not ":"")+u.operator}}),Pt}var pr={},Ue={},kr;function Ht(){if(kr)return Ue;kr=1,Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.maybeNot=re,Ue.unescape=j,Ue.escape=N,Ue.matchOp=S,Ue.conjoin=y,Ue.joinNumbers=o,Ue.mkRange=d,Ue.mkValues=t,Ue.numNot=D,Ue.temporalNot=x,Ue.joinTemporal=Z,Ue.timeLiteral=ee,Ue.mkUnits=ce;const u=Vt();function re(O){const[A,b]=O;return A&&b&&(0,u.isStringFilter)(b)?{...b,not:!0}:b}function j(O){return O.replace(/\\(.)/g,"$1")}function N(O){const A=O.toLowerCase();return A==="null"||A==="empty"?"\\"+O:O.replace(/([,; |()\\%_-])/g,"\\$1")}function E(O){let A=!1,b=!1,B=0,de=!1;const Fe=O.length;for(let ve=0;ve<Fe;ve+=1){const Ye=O[ve];if(Ye===" "||Ye===" "){B+=1;continue}B=0,Ye==="%"?(de=!0,ve===0&&(A=!0),b=!0):(b=!1,Ye==="\\"?ve+=1:Ye==="_"&&(de=!0))}return{hasLike:de,percentEnd:b&&Fe>1,percentStart:A&&Fe>1,endSpace:B}}function S(O){let A=O.trimStart();const{hasLike:b,percentEnd:B,percentStart:de,endSpace:Fe}=E(A);if(Fe>0&&(A=A.slice(0,-Fe)),b){if(de&&B){const ve=A.slice(1,-1);if(!E(ve).hasLike&&ve.length>0)return{operator:"contains",values:[j(ve)]}}else if(B){const ve=A.slice(0,-1);if(!E(ve).hasLike)return{operator:"starts",values:[j(ve)]}}else if(de){const ve=A.slice(1);if(!E(ve).hasLike)return{operator:"ends",values:[j(ve)]}}return{operator:"~",escaped_values:[A]}}return A.toLowerCase()==="null"?{operator:"null"}:A.toLowerCase()==="empty"?{operator:"empty"}:{operator:"=",values:[j(A)]}}function w(O,A){var b,B;return O.operator===A.operator&&((b=O.not)!==null&&b!==void 0?b:!1)===((B=A.not)!==null&&B!==void 0?B:!1)}function y(O,A,b){if(A=A.toLowerCase(),(0,u.isStringFilter)(O)&&(0,u.isStringFilter)(b)){if(A===","){if(O.operator==="~"&&w(O,b))return{...O,escaped_values:[...O.escaped_values,...b.escaped_values]};if((0,u.isStringCondition)(O)&&w(O,b))return{...O,values:[...O.values,...b.values]}}const B=A===","?",":A==="|"?"or":A===";"?"and":void 0;if(B)return O.operator===B?{...O,members:[...O.members,b]}:{operator:B,members:[O,b]}}return null}function o(O,A,b){if(A=A.toLowerCase(),(0,u.isNumberFilter)(O)&&(0,u.isNumberFilter)(b)){if(A==="or"&&O.operator==="="&&w(O,b)){const B={operator:"=",values:[...O.values,...b.values]};return O.not&&(B.not=!0),B}if(A==="and"||A==="or")return O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}}return null}function d(O,A,b,B){return{operator:"range",startValue:A,startOperator:O==="("?">":">=",endValue:b,endOperator:B===")"?"<":"<="}}function t(O,A){return{values:[O,...A]}}function D(O,A){return(0,u.isNumberFilter)(O)&&A?O.operator==="="?{operator:"!=",values:O.values}:O.operator==="!="?{operator:"=",values:O.values}:{...O,not:!0}:O}function x(O,A){if((0,u.isTemporalFilter)(O)&&A){if("not"in O){const b={...O};return O.not?delete b.not:b.not=!0,b}return{...O,not:!0}}return O}function Z(O,A,b){return A=A.toLowerCase(),(0,u.isTemporalFilter)(O)&&(0,u.isTemporalFilter)(b)&&(A==="and"||A==="or")?O.operator===A?{...O,members:[...O.members,b]}:{operator:A,members:[O,b]}:null}function ee(O,A){const b={moment:"literal",literal:O};return A&&(b.units=A),b}function ce(O){switch(O.toLowerCase()){case"second":case"seconds":return"second";case"minute":case"minutes":return"minute";case"hour":case"hours":return"hour";case"day":case"days":return"day";case"week":case"weeks":return"week";case"month":case"months":return"month";case"quarter":case"quarters":return"quarter";case"year":case"years":return"year"}}return Ue}var hr,Rr;function mi(){if(Rr)return hr;Rr=1;const{numNot:u,mkRange:re,joinNumbers:j,mkValues:N}=Ht();function E(o,d){function t(){this.constructor=o}t.prototype=d.prototype,o.prototype=new t}function S(o,d,t,D){var x=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(x,S.prototype),x.expected=d,x.found=t,x.location=D,x.name="SyntaxError",x}E(S,Error);function w(o,d,t){return t=t||" ",o.length>d?o:(d-=o.length,t+=t.repeat(d),o+t.slice(0,d))}S.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var t=null,D;for(D=0;D<o.length;D++)if(o[D].source===this.location.source){t=o[D].text.split(/\r\n|\n|\r/g);break}var x=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(x):x,ee=this.location.source+":"+Z.line+":"+Z.column;if(t){var ce=this.location.end,O=w("",Z.line.toString().length," "),A=t[x.line-1],b=x.line===ce.line?ce.column:A.length+1,B=b-x.column||1;d+=`
2
+ --> `+ee+`
3
+ `+O+` |
4
+ `+Z.line+" | "+A+`
5
+ `+O+" | "+w("",x.column-1," ")+w("",B,"^")}else d+=`
6
+ at `+ee}return d},S.buildMessage=function(o,d){var t={literal:function(A){return'"'+x(A.text)+'"'},class:function(A){var b=A.parts.map(function(B){return Array.isArray(B)?Z(B[0])+"-"+Z(B[1]):Z(B)});return"["+(A.inverted?"^":"")+b.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(A){return A.description}};function D(A){return A.charCodeAt(0).toString(16).toUpperCase()}function x(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function Z(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function ee(A){return t[A.type](A)}function ce(A){var b=A.map(ee),B,de;if(b.sort(),b.length>0){for(B=1,de=1;B<b.length;B++)b[B-1]!==b[B]&&(b[de]=b[B],de++);b.length=de}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function O(A){return A?'"'+x(A)+'"':"end of input"}return"Expected "+ce(o)+" but "+O(d)+" found."};function y(o,d){d=d!==void 0?d:{};var t={},D=d.grammarSource,x={numberFilter:Lt},Z=Lt,ee="(",ce=")",O="!=",A=",",b="=",B="<=",de=">=",Fe="[",ve="]",Ye="-",Ae=".",pe="not",Pe="null",tt="and",Re="or",Ge="to",it=/^[<>]/,Ee=/^[0-9]/,at=/^[Ee]/,Ce=/^[+\-]/,De=/^[a-zA-Z]/,st=/^[ \t]/,qe=be("(",!1),Oe=be(")",!1),ke=be("!=",!1),xe=be(",",!1),Je=be("=",!1),He=be("<=",!1),je=be(">=",!1),q=yt(["<",">"],!1,!1),h=be("[",!1),$=be("]",!1),k=be("-",!1),F=yt([["0","9"]],!1,!1),z=be(".",!1),Y=yt(["E","e"],!1,!1),we=yt(["+","-"],!1,!1),Qe=be("not",!0),rt=be("null",!0),C=be("and",!0),nt=be("or",!0),ot=be("to",!0),_e=yt([["a","z"],["A","Z"]],!1,!1),Ze=Kt("whitespace"),ct=yt([" "," "],!1,!1),gt=function(g,v){return v.reduce((L,[,Q,,K])=>j(L,Q,K),g)},We=function(g,v){return u(v,g)},Ke=function(g){return g},ze=function(){return{operator:"null"}},Me=function(g){return{operator:"()",expr:g}},_=function(g,v,L,Q){return re(g,v,L,Q)},I=function(g,v){return{operator:"!=",...N(g,v.map(L=>L[3]))}},ie=function(g,v){return{operator:"=",...N(g,v.map(L=>L[3]))}},W=function(g,v){return{operator:g,values:[v]}},ue=function(g,v){return{operator:"=",...N(g,v.map(L=>L[3]))}},Se=function(){return"["},lt=function(){return"("},Xe=function(){return"]"},At=function(){return")"},m=function(g){return g},e=function(){return"or"},a=function(){return"and"},f=function(){return"not"},l=d.peg$currPos|0,R=[{line:1,column:1}],J=l,fe=d.peg$maxFailExpected||[],V=d.peg$silentFails|0,he;if(d.startRule){if(!(d.startRule in x))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');Z=x[d.startRule]}function be(g,v){return{type:"literal",text:g,ignoreCase:v}}function yt(g,v,L){return{type:"class",parts:g,inverted:v,ignoreCase:L}}function Zt(){return{type:"end"}}function Kt(g){return{type:"other",description:g}}function Bt(g){var v=R[g],L;if(v)return v;if(g>=R.length)L=R.length-1;else for(L=g;!R[--L];);for(v=R[L],v={line:v.line,column:v.column};L<g;)o.charCodeAt(L)===10?(v.line++,v.column=1):v.column++,L++;return R[g]=v,v}function Gt(g,v,L){var Q=Bt(g),K=Bt(v),P={source:D,start:{offset:g,line:Q.line,column:Q.column},end:{offset:v,line:K.line,column:K.column}};return P}function te(g){l<J||(l>J&&(J=l,fe=[]),fe.push(g))}function Xt(g,v,L){return new S(S.buildMessage(g,v),g,v,L)}function Lt(){var g,v,L,Q,K,P,G,H;if(g=l,v=It(),v!==t){for(L=[],Q=l,K=me(),P=jt(),P!==t?(G=me(),H=It(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);Q!==t;)L.push(Q),Q=l,K=me(),P=jt(),P!==t?(G=me(),H=It(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);g=gt(v,L)}else l=g,g=t;return g}function It(){var g,v,L;return g=l,v=rr(),v!==t?(me(),L=Ut(),L!==t?g=We(v,L):(l=g,g=t)):(l=g,g=t),g===t&&(g=l,v=Ut(),v!==t&&(v=Ke(v)),g=v),g}function Ut(){var g,v,L,Q,K,P,G,H,le,ge;if(g=l,v=nr(),v!==t&&(v=ze()),g=v,g===t&&(g=l,o.charCodeAt(l)===40?(v=ee,l++):(v=t,V===0&&te(qe)),v!==t?(L=me(),Q=Lt(),Q!==t?(K=me(),o.charCodeAt(l)===41?(P=ce,l++):(P=t,V===0&&te(Oe)),P!==t?g=Me(Q):(l=g,g=t)):(l=g,g=t)):(l=g,g=t),g===t&&(g=l,v=er(),v!==t?(L=me(),Q=et(),Q!==t?(K=me(),P=sr(),P!==t?(G=me(),H=et(),H!==t?(le=me(),ge=tr(),ge!==t?g=_(v,Q,H,ge):(l=g,g=t)):(l=g,g=t)):(l=g,g=t)):(l=g,g=t)):(l=g,g=t),g===t))){if(g=l,o.substr(l,2)===O?(v=O,l+=2):(v=t,V===0&&te(ke)),v!==t)if(L=me(),Q=et(),Q!==t){for(K=[],P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);P!==t;)K.push(P),P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);g=I(Q,K)}else l=g,g=t;else l=g,g=t;if(g===t){if(g=l,o.charCodeAt(l)===61?(v=b,l++):(v=t,V===0&&te(Je)),v!==t)if(L=me(),Q=et(),Q!==t){for(K=[],P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);P!==t;)K.push(P),P=l,G=me(),o.charCodeAt(l)===44?(H=A,l++):(H=t,V===0&&te(xe)),H!==t?(le=me(),ge=et(),ge!==t?(G=[G,H,le,ge],P=G):(l=P,P=t)):(l=P,P=t);g=ie(Q,K)}else l=g,g=t;else l=g,g=t;if(g===t&&(g=l,v=l,o.substr(l,2)===B?(L=B,l+=2):(L=t,V===0&&te(He)),L===t&&(o.substr(l,2)===de?(L=de,l+=2):(L=t,V===0&&te(je)),L===t&&(L=o.charAt(l),it.test(L)?l++:(L=t,V===0&&te(q)))),L!==t?v=o.substring(v,l):v=L,v!==t?(L=me(),Q=et(),Q!==t?g=W(v,Q):(l=g,g=t)):(l=g,g=t),g===t))if(g=l,v=et(),v!==t){for(L=[],Q=l,K=me(),o.charCodeAt(l)===44?(P=A,l++):(P=t,V===0&&te(xe)),P!==t?(G=me(),H=et(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);Q!==t;)L.push(Q),Q=l,K=me(),o.charCodeAt(l)===44?(P=A,l++):(P=t,V===0&&te(xe)),P!==t?(G=me(),H=et(),H!==t?(K=[K,P,G,H],Q=K):(l=Q,Q=t)):(l=Q,Q=t);g=ue(v,L)}else l=g,g=t}}return g}function er(){var g,v;return g=l,o.charCodeAt(l)===91?(v=Fe,l++):(v=t,V===0&&te(h)),v!==t&&(v=Se()),g=v,g===t&&(g=l,o.charCodeAt(l)===40?(v=ee,l++):(v=t,V===0&&te(qe)),v!==t&&(v=lt()),g=v),g}function tr(){var g,v;return g=l,o.charCodeAt(l)===93?(v=ve,l++):(v=t,V===0&&te($)),v!==t&&(v=Xe()),g=v,g===t&&(g=l,o.charCodeAt(l)===41?(v=ce,l++):(v=t,V===0&&te(Oe)),v!==t&&(v=At()),g=v),g}function et(){var g,v,L,Q,K,P,G,H,le,ge;if(g=l,v=l,L=l,o.charCodeAt(l)===45?(Q=Ye,l++):(Q=t,V===0&&te(k)),Q===t&&(Q=null),K=l,P=[],G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F)),G!==t)for(;G!==t;)P.push(G),G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F));else P=t;if(P!==t){for(o.charCodeAt(l)===46?(G=Ae,l++):(G=t,V===0&&te(z)),G===t&&(G=null),H=[],le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F));le!==t;)H.push(le),le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F));P=[P,G,H],K=P}else l=K,K=t;if(K===t){for(K=l,P=[],G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F));G!==t;)P.push(G),G=o.charAt(l),Ee.test(G)?l++:(G=t,V===0&&te(F));if(o.charCodeAt(l)===46?(G=Ae,l++):(G=t,V===0&&te(z)),G!==t){if(H=[],le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F)),le!==t)for(;le!==t;)H.push(le),le=o.charAt(l),Ee.test(le)?l++:(le=t,V===0&&te(F));else H=t;H!==t?(P=[P,G,H],K=P):(l=K,K=t)}else l=K,K=t}if(K!==t){if(P=l,G=o.charAt(l),at.test(G)?l++:(G=t,V===0&&te(Y)),G!==t){if(H=o.charAt(l),Ce.test(H)?l++:(H=t,V===0&&te(we)),H===t&&(H=null),le=[],ge=o.charAt(l),Ee.test(ge)?l++:(ge=t,V===0&&te(F)),ge!==t)for(;ge!==t;)le.push(ge),ge=o.charAt(l),Ee.test(ge)?l++:(ge=t,V===0&&te(F));else le=t;le!==t?(G=[G,H,le],P=G):(l=P,P=t)}else l=P,P=t;P===t&&(P=null),Q=[Q,K,P],L=Q}else l=L,L=t;return L!==t?v=o.substring(v,l):v=L,v!==t&&(v=m(v)),g=v,g}function jt(){var g,v;return g=l,v=ar(),v!==t&&(v=e()),g=v,g===t&&(g=l,v=ir(),v!==t&&(v=a()),g=v),g}function rr(){var g,v,L,Q;return g=l,v=o.substr(l,3),v.toLowerCase()===pe?l+=3:(v=t,V===0&&te(Qe)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?g=f():(l=g,g=t)):(l=g,g=t),g}function nr(){var g,v,L,Q;return g=l,v=o.substr(l,4),v.toLowerCase()===Pe?l+=4:(v=t,V===0&&te(rt)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function ir(){var g,v,L,Q;return g=l,v=o.substr(l,3),v.toLowerCase()===tt?l+=3:(v=t,V===0&&te(C)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function ar(){var g,v,L,Q;return g=l,v=o.substr(l,2),v.toLowerCase()===Re?l+=2:(v=t,V===0&&te(nt)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function sr(){var g,v,L,Q;return g=l,v=o.substr(l,2),v.toLowerCase()===Ge?l+=2:(v=t,V===0&&te(ot)),v!==t?(L=l,V++,Q=Tt(),V--,Q===t?L=void 0:(l=L,L=t),L!==t?(v=[v,L],g=v):(l=g,g=t)):(l=g,g=t),g}function Tt(){var g;return g=o.charAt(l),De.test(g)?l++:(g=t,V===0&&te(_e)),g}function me(){var g,v;for(V++,g=[],v=o.charAt(l),st.test(v)?l++:(v=t,V===0&&te(ct));v!==t;)g.push(v),v=o.charAt(l),st.test(v)?l++:(v=t,V===0&&te(ct));return V--,v=t,V===0&&te(Ze),g}if(he=Z(),d.peg$library)return{peg$result:he,peg$currPos:l,peg$FAILED:t,peg$maxFailExpected:fe,peg$maxFailPos:J};if(he!==t&&l===o.length)return he;throw he!==t&&l<o.length&&te(Zt()),Xt(fe,J<o.length?o.charAt(J):null,J<o.length?Gt(J,J+1):Gt(J,J))}return hr={StartRules:["numberFilter"],SyntaxError:S,parse:y},hr}var Yt={},Vr;function wr(){if(Vr)return Yt;Vr=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.run_parser=j;const u=Vt();function re(N){return N instanceof Error&&"location"in N}function j(N,E){try{const S=E(N);return(0,u.isFilterExpression)(S)?{parsed:S,log:[]}:{parsed:null,log:[]}}catch(S){if(re(S)){const w=S.location,y=w?w.start.offset:0,o=w?w.end.offset-1:N.length-1;return{parsed:null,log:[{message:S.message,startIndex:y,endIndex:Math.max(y,o),severity:"error"}]}}throw S}}return Yt}var Lr;function gi(){return Lr||(Lr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.NumberFilterExpression=void 0;const re=Vt(),j=mi(),N=wr();u.NumberFilterExpression={parse(E){if(E.match(/^\s*$/))return{parsed:null,log:[]};const S=(0,N.run_parser)(E,j.parse);return S.parsed&&(0,re.isNumberFilter)(S.parsed)?{parsed:S.parsed,log:[]}:{parsed:null,log:S.log}},unparse(E){if(E===null)return"";switch(E.operator){case"=":return E.values.join(", ");case"!=":return"!= "+E.values.join(", ");case">":case"<":case"<=":case">=":return E.not?E.values.map(S=>E.operator==="="?`not ${S}`:`not ${E.operator} ${S}`).join(", "):E.values.map(S=>`${E.operator} ${S}`).join(", ");case"range":{const S=E.startOperator===">"?"(":"[",w=E.endOperator==="<"?")":"]",y=`${S}${E.startValue} to ${E.endValue}${w}`;return E.not?`not ${y}`:y}case"null":return E.not?"not null":"null";case"and":case"or":return E.members.map(S=>u.NumberFilterExpression.unparse(S)).join(` ${E.operator} `);case"()":{const S="("+u.NumberFilterExpression.unparse(E.expr)+")";return E.not?"not "+S:S}}return`no unparse for ${JSON.stringify(E)}`}}})(pr)),pr}var mr={},gr,Ir;function yi(){if(Ir)return gr;Ir=1;const{conjoin:u,maybeNot:re,matchOp:j}=Ht();function N(y,o){function d(){this.constructor=y}d.prototype=o.prototype,y.prototype=new d}function E(y,o,d,t){var D=Error.call(this,y);return Object.setPrototypeOf&&Object.setPrototypeOf(D,E.prototype),D.expected=o,D.found=d,D.location=t,D.name="SyntaxError",D}N(E,Error);function S(y,o,d){return d=d||" ",y.length>o?y:(o-=y.length,d+=d.repeat(o),y+d.slice(0,o))}E.prototype.format=function(y){var o="Error: "+this.message;if(this.location){var d=null,t;for(t=0;t<y.length;t++)if(y[t].source===this.location.source){d=y[t].text.split(/\r\n|\n|\r/g);break}var D=this.location.start,x=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(D):D,Z=this.location.source+":"+x.line+":"+x.column;if(d){var ee=this.location.end,ce=S("",x.line.toString().length," "),O=d[D.line-1],A=D.line===ee.line?ee.column:O.length+1,b=A-D.column||1;o+=`
7
+ --> `+Z+`
8
+ `+ce+` |
9
+ `+x.line+" | "+O+`
10
+ `+ce+" | "+S("",D.column-1," ")+S("",b,"^")}else o+=`
11
+ at `+Z}return o},E.buildMessage=function(y,o){var d={literal:function(O){return'"'+D(O.text)+'"'},class:function(O){var A=O.parts.map(function(b){return Array.isArray(b)?x(b[0])+"-"+x(b[1]):x(b)});return"["+(O.inverted?"^":"")+A.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(O){return O.description}};function t(O){return O.charCodeAt(0).toString(16).toUpperCase()}function D(O){return O.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(A){return"\\x0"+t(A)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(A){return"\\x"+t(A)})}function x(O){return O.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(A){return"\\x0"+t(A)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(A){return"\\x"+t(A)})}function Z(O){return d[O.type](O)}function ee(O){var A=O.map(Z),b,B;if(A.sort(),A.length>0){for(b=1,B=1;b<A.length;b++)A[b-1]!==A[b]&&(A[B]=A[b],B++);A.length=B}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}function ce(O){return O?'"'+D(O)+'"':"end of input"}return"Expected "+ee(y)+" but "+ce(o)+" found."};function w(y,o){o=o!==void 0?o:{};var d={},t=o.grammarSource,D={stringFilter:ct},x=ct,Z="-",ee="(",ce=")",O="\\",A=",",b=";",B="|",de=/^[^\n,;()|]/,Fe=/^[ \t]/,ve=Y("-",!1),Ye=Y("(",!1),Ae=Y(")",!1),pe=C("match string"),Pe=Y("\\",!1),tt=Qe(),Re=we([`
12
+ `,",",";","(",")","|"],!0,!1),Ge=Y(",",!1),it=Y(";",!1),Ee=Y("|",!1),at=C("whitespace"),Ce=we([" "," "],!1,!1),De=function(_,I){return I.reduce((ie,[,W,,ue])=>u(ie,W,ue),_)},st=function(_){return re([!0,_])},qe=function(_){return _},Oe=function(_){return{operator:"()",expr:_}},ke=function(_){return j(_)},xe=function(_){return _},Je=function(){return","},He=function(){return";"},je=function(){return"|"},q=o.peg$currPos|0,h=[{line:1,column:1}],$=q,k=o.peg$maxFailExpected||[],F=o.peg$silentFails|0,z;if(o.startRule){if(!(o.startRule in D))throw new Error(`Can't start parsing from rule "`+o.startRule+'".');x=D[o.startRule]}function Y(_,I){return{type:"literal",text:_,ignoreCase:I}}function we(_,I,ie){return{type:"class",parts:_,inverted:I,ignoreCase:ie}}function Qe(){return{type:"any"}}function rt(){return{type:"end"}}function C(_){return{type:"other",description:_}}function nt(_){var I=h[_],ie;if(I)return I;if(_>=h.length)ie=h.length-1;else for(ie=_;!h[--ie];);for(I=h[ie],I={line:I.line,column:I.column};ie<_;)y.charCodeAt(ie)===10?(I.line++,I.column=1):I.column++,ie++;return h[_]=I,I}function ot(_,I,ie){var W=nt(_),ue=nt(I),Se={source:t,start:{offset:_,line:W.line,column:W.column},end:{offset:I,line:ue.line,column:ue.column}};return Se}function _e(_){q<$||(q>$&&($=q,k=[]),k.push(_))}function Ze(_,I,ie){return new E(E.buildMessage(_,I),_,I,ie)}function ct(){var _,I,ie,W,ue,Se,lt,Xe;if(_=q,Me(),I=gt(),I!==d){for(ie=[],W=q,ue=Me(),Se=ze(),Se!==d?(lt=Me(),Xe=gt(),Xe!==d?(ue=[ue,Se,lt,Xe],W=ue):(q=W,W=d)):(q=W,W=d);W!==d;)ie.push(W),W=q,ue=Me(),Se=ze(),Se!==d?(lt=Me(),Xe=gt(),Xe!==d?(ue=[ue,Se,lt,Xe],W=ue):(q=W,W=d)):(q=W,W=d);_=De(I,ie)}else q=_,_=d;return _}function gt(){var _,I,ie;return _=q,y.charCodeAt(q)===45?(I=Z,q++):(I=d,F===0&&_e(ve)),I!==d?(Me(),ie=We(),ie!==d?_=st(ie):(q=_,_=d)):(q=_,_=d),_===d&&(_=q,I=We(),I!==d&&(I=qe(I)),_=I),_}function We(){var _,I,ie,W;return _=q,y.charCodeAt(q)===40?(I=ee,q++):(I=d,F===0&&_e(Ye)),I!==d?(Me(),ie=ct(),ie!==d?(Me(),y.charCodeAt(q)===41?(W=ce,q++):(W=d,F===0&&_e(Ae)),W!==d?_=Oe(ie):(q=_,_=d)):(q=_,_=d)):(q=_,_=d),_===d&&(_=q,I=Ke(),I!==d&&(I=ke(I)),_=I),_}function Ke(){var _,I,ie,W,ue,Se;if(F++,_=q,I=q,ie=[],W=q,y.charCodeAt(q)===92?(ue=O,q++):(ue=d,F===0&&_e(Pe)),ue!==d?(y.length>q?(Se=y.charAt(q),q++):(Se=d,F===0&&_e(tt)),Se!==d?(ue=[ue,Se],W=ue):(q=W,W=d)):(q=W,W=d),W===d&&(W=y.charAt(q),de.test(W)?q++:(W=d,F===0&&_e(Re))),W!==d)for(;W!==d;)ie.push(W),W=q,y.charCodeAt(q)===92?(ue=O,q++):(ue=d,F===0&&_e(Pe)),ue!==d?(y.length>q?(Se=y.charAt(q),q++):(Se=d,F===0&&_e(tt)),Se!==d?(ue=[ue,Se],W=ue):(q=W,W=d)):(q=W,W=d),W===d&&(W=y.charAt(q),de.test(W)?q++:(W=d,F===0&&_e(Re)));else ie=d;return ie!==d?I=y.substring(I,q):I=ie,I!==d&&(I=xe(I)),_=I,F--,_===d&&(I=d,F===0&&_e(pe)),_}function ze(){var _,I;return _=q,y.charCodeAt(q)===44?(I=A,q++):(I=d,F===0&&_e(Ge)),I!==d&&(I=Je()),_=I,_===d&&(_=q,y.charCodeAt(q)===59?(I=b,q++):(I=d,F===0&&_e(it)),I!==d&&(I=He()),_=I,_===d&&(_=q,y.charCodeAt(q)===124?(I=B,q++):(I=d,F===0&&_e(Ee)),I!==d&&(I=je()),_=I)),_}function Me(){var _,I;for(F++,_=[],I=y.charAt(q),Fe.test(I)?q++:(I=d,F===0&&_e(Ce));I!==d;)_.push(I),I=y.charAt(q),Fe.test(I)?q++:(I=d,F===0&&_e(Ce));return F--,I=d,F===0&&_e(at),_}if(z=x(),o.peg$library)return{peg$result:z,peg$currPos:q,peg$FAILED:d,peg$maxFailExpected:k,peg$maxFailPos:$};if(z!==d&&q===y.length)return z;throw z!==d&&q<y.length&&_e(rt()),Ze(k,$<y.length?y.charAt($):null,$<y.length?ot($,$+1):ot($,$))}return gr={StartRules:["stringFilter"],SyntaxError:E,parse:w},gr}var Cr;function vi(){return Cr||(Cr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.StringFilterExpression=void 0;const re=Vt(),j=yi(),N=Ht(),E=wr();u.StringFilterExpression={parse(S){if(S.match(/^\s*$/))return{parsed:null,log:[]};const w=(0,E.run_parser)(S,j.parse);return w.parsed&&(0,re.isStringFilter)(w.parsed)?{parsed:w.parsed,log:[]}:{parsed:null,log:w.log}},unparse(S){if(S===null)return"";switch(S.operator){case"=":return S.not?S.values.map(w=>"-"+(0,N.escape)(w)).join(", "):S.values.map(w=>(0,N.escape)(w)).join(", ");case"~":return S.not?S.escaped_values.map(w=>"-"+w).join(", "):S.escaped_values.join(", ");case"starts":return S.not?S.values.map(w=>"-"+(0,N.escape)(w)+"%").join(", "):S.values.map(w=>(0,N.escape)(w)+"%").join(", ");case"ends":return S.not?S.values.map(w=>"-%"+(0,N.escape)(w)).join(", "):S.values.map(w=>"%"+(0,N.escape)(w)).join(", ");case"contains":return S.not?S.values.map(w=>"-%"+(0,N.escape)(w)+"%").join(", "):S.values.map(w=>"%"+(0,N.escape)(w)+"%").join(", ");case"or":return S.members.map(w=>u.StringFilterExpression.unparse(w)).join(" | ");case"and":return S.members.map(w=>u.StringFilterExpression.unparse(w)).join("; ");case",":return S.members.map(w=>u.StringFilterExpression.unparse(w)).join(", ");case"()":{const w="("+u.StringFilterExpression.unparse(S.expr)+")";return S.not?"-"+w:w}case"null":return S.not?"-null":"null";case"empty":return S.not?"-empty":"empty"}}}})(mr)),mr}var yr={},vr,Dr;function wi(){if(Dr)return vr;Dr=1;const{temporalNot:u,joinTemporal:re,timeLiteral:j,mkUnits:N}=Ht();function E(o,d){function t(){this.constructor=o}t.prototype=d.prototype,o.prototype=new t}function S(o,d,t,D){var x=Error.call(this,o);return Object.setPrototypeOf&&Object.setPrototypeOf(x,S.prototype),x.expected=d,x.found=t,x.location=D,x.name="SyntaxError",x}E(S,Error);function w(o,d,t){return t=t||" ",o.length>d?o:(d-=o.length,t+=t.repeat(d),o+t.slice(0,d))}S.prototype.format=function(o){var d="Error: "+this.message;if(this.location){var t=null,D;for(D=0;D<o.length;D++)if(o[D].source===this.location.source){t=o[D].text.split(/\r\n|\n|\r/g);break}var x=this.location.start,Z=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(x):x,ee=this.location.source+":"+Z.line+":"+Z.column;if(t){var ce=this.location.end,O=w("",Z.line.toString().length," "),A=t[x.line-1],b=x.line===ce.line?ce.column:A.length+1,B=b-x.column||1;d+=`
13
+ --> `+ee+`
14
+ `+O+` |
15
+ `+Z.line+" | "+A+`
16
+ `+O+" | "+w("",x.column-1," ")+w("",B,"^")}else d+=`
17
+ at `+ee}return d},S.buildMessage=function(o,d){var t={literal:function(A){return'"'+x(A.text)+'"'},class:function(A){var b=A.parts.map(function(B){return Array.isArray(B)?Z(B[0])+"-"+Z(B[1]):Z(B)});return"["+(A.inverted?"^":"")+b.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(A){return A.description}};function D(A){return A.charCodeAt(0).toString(16).toUpperCase()}function x(A){return A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function Z(A){return A.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(b){return"\\x0"+D(b)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(b){return"\\x"+D(b)})}function ee(A){return t[A.type](A)}function ce(A){var b=A.map(ee),B,de;if(b.sort(),b.length>0){for(B=1,de=1;B<b.length;B++)b[B-1]!==b[B]&&(b[de]=b[B],de++);b.length=de}switch(b.length){case 1:return b[0];case 2:return b[0]+" or "+b[1];default:return b.slice(0,-1).join(", ")+", or "+b[b.length-1]}}function O(A){return A?'"'+x(A)+'"':"end of input"}return"Expected "+ce(o)+" but "+O(d)+" found."};function y(o,d){d=d!==void 0?d:{};var t={},D=d.grammarSource,x={temporalFilter:or},Z=or,ee="(",ce=")",O="second",A="minute",b="hour",B="day",de="week",Fe="month",ve="quarter",Ye="year",Ae="s",pe="-",Pe=":",tt="not",Re="null",Ge="to",it="now",Ee="last",at="this",Ce="next",De="ago",st="from",qe="before",Oe="after",ke="through",xe="starting",Je="for",He="today",je="yesterday",q="tomorrow",h="and",$="or",k="monday",F="tuesday",z="wednesday",Y="thursday",we="friday",Qe="saturday",rt="sunday",C=/^[0-9]/,nt=/^[ Tt]/,ot=/^[.,]/,_e=/^[Ww]/,Ze=/^[Kk]/,ct=/^[Qq]/,gt=/^[1234]/,We=/^[a-zA-Z]/,Ke=/^[ \t]/,ze=ne("(",!1),Me=ne(")",!1),_=ht([["0","9"]],!1,!1),I=ne("second",!0),ie=ne("minute",!0),W=ne("hour",!0),ue=ne("day",!0),Se=ne("week",!0),lt=ne("month",!0),Xe=ne("quarter",!0),At=ne("year",!0),m=ne("s",!0),e=ne("-",!1),a=ht([" ","T","t"],!1,!1),f=ne(":",!1),l=ht([".",","],!1,!1),R=ht(["W","w"],!1,!1),J=ht(["K","k"],!1,!1),fe=ht(["Q","q"],!1,!1),V=ht(["1","2","3","4"],!1,!1),he=ne("not",!0),be=ne("null",!0),yt=ne("to",!0),Zt=ne("now",!0),Kt=ne("last",!0),Bt=ne("this",!0),Gt=ne("next",!0),te=ne("ago",!0),Xt=ne("from",!0),Lt=ne("before",!0),It=ne("after",!0),Ut=ne("through",!0),er=ne("starting",!0),tr=ne("for",!0),et=ne("today",!0),jt=ne("yesterday",!0),rr=ne("tomorrow",!0),nr=ne("and",!0),ir=ne("or",!0),ar=ne("monday",!0),sr=ne("tuesday",!0),Tt=ne("wednesday",!0),me=ne("thursday",!0),g=ne("friday",!0),v=ne("saturday",!0),L=ne("sunday",!0),Q=ht([["a","z"],["A","Z"]],!1,!1),K=_r("optional whitespace"),P=ht([" "," "],!1,!1),G=_r("whitespace"),H=function(n,s){return s.reduce((i,[,c,,M])=>re(i,c,M),n)},le=function(n){return u(n,!0)},ge=function(n){return n},Yr=function(){return{operator:"null"}},Jr=function(n){return{operator:"()",expr:n}},Hr=function(n){return{operator:"before",before:n}},Zr=function(n){return{operator:"before",before:n,not:!0}},Kr=function(n){return{operator:"after",after:n}},Xr=function(n){return{operator:"after",after:n,not:!0}},en=function(n,s){return{operator:n,...s}},tn=function(n,s){return{operator:"to",fromMoment:n,toMoment:s}},rn=function(n,s){return{...s,operator:"for",begin:n}},nn=function(n){return{operator:"in",in:n}},an=function(n){return{operator:"in_last",...n}},sn=function(){return"last"},on=function(){return"next"},ln=function(n,s){return{units:s,n}},fn=function(n){return n},un=function(n){return N(n)},cn=function(){return{moment:"now"}},dn=function(){return{moment:"today"}},pn=function(){return{moment:"yesterday"}},hn=function(){return{moment:"tomorrow"}},mn=function(n){return{moment:"ago",...n}},gn=function(n){return{moment:"from_now",...n}},yn=function(n){return{moment:n.toLowerCase(),which:"next"}},vn=function(n){return{moment:n.toLowerCase(),which:"last"}},wn=function(n,s){return{moment:n,units:s}},_n=function(n){return{moment:n.toLowerCase(),which:"last"}},An=function(n){return n},Tn=function(){return"this"},$n=function(){return"next"},Sn=function(){return"last"},bn=function(n){return j(n)},Fn=function(n){return j(n,"week")},On=function(n){return j(n,"quarter")},En=function(n){return j(n,"minute")},kn=function(n){return j(n,"hour")},Rn=function(n){return j(n,"day")},Vn=function(n){return j(n,"month")},Ln=function(n){return j(n,"year")},In=function(n){return n},Cn=function(){return"or"},Dn=function(){return"and"},r=d.peg$currPos|0,kt=[{line:1,column:1}],ft=r,Wt=d.peg$maxFailExpected||[],p=d.peg$silentFails|0,Ct;if(d.startRule){if(!(d.startRule in x))throw new Error(`Can't start parsing from rule "`+d.startRule+'".');Z=x[d.startRule]}function ne(n,s){return{type:"literal",text:n,ignoreCase:s}}function ht(n,s,i){return{type:"class",parts:n,inverted:s,ignoreCase:i}}function xn(){return{type:"end"}}function _r(n){return{type:"other",description:n}}function Ar(n){var s=kt[n],i;if(s)return s;if(n>=kt.length)i=kt.length-1;else for(i=n;!kt[--i];);for(s=kt[i],s={line:s.line,column:s.column};i<n;)o.charCodeAt(i)===10?(s.line++,s.column=1):s.column++,i++;return kt[n]=s,s}function Tr(n,s,i){var c=Ar(n),M=Ar(s),U={source:D,start:{offset:n,line:c.line,column:c.column},end:{offset:s,line:M.line,column:M.column}};return U}function T(n){r<ft||(r>ft&&(ft=r,Wt=[]),Wt.push(n))}function Nn(n,s,i){return new S(S.buildMessage(n,s),n,s,i)}function or(){var n,s,i,c,M,U,X,ae;if(n=r,s=lr(),s!==t){for(i=[],c=r,M=Rt(),U=br(),U!==t?(X=Rt(),ae=lr(),ae!==t?(M=[M,U,X,ae],c=M):(r=c,c=t)):(r=c,c=t);c!==t;)i.push(c),c=r,M=Rt(),U=br(),U!==t?(X=Rt(),ae=lr(),ae!==t?(M=[M,U,X,ae],c=M):(r=c,c=t)):(r=c,c=t);n=H(s,i)}else r=n,n=t;return n}function lr(){var n,s,i,c;return n=r,s=Bn(),s!==t?(i=Be(),i!==t?(c=$r(),c!==t?n=le(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=$r(),s!==t&&(s=ge(s)),n=s),n}function $r(){var n,s,i,c,M,U;return n=r,s=Gn(),s!==t&&(s=Yr()),n=s,n===t&&(n=r,o.charCodeAt(r)===40?(s=ee,r++):(s=t,p===0&&T(ze)),s!==t?(i=Rt(),c=or(),c!==t?(M=Rt(),o.charCodeAt(r)===41?(U=ce,r++):(U=t,p===0&&T(Me)),U!==t?n=Jr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Yn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Hr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Zn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Zr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Jn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Kr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Hn(),s!==t?(i=Be(),i!==t?(c=vt(),c!==t?n=Xr(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Pn(),s!==t?(i=Be(),i!==t?(c=Dt(),c!==t?n=en(s,c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=vt(),s!==t?(i=Be(),i!==t?(c=Un(),c!==t?(M=Be(),M!==t?(U=vt(),U!==t?n=tn(s,U):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=vt(),s!==t?(i=Be(),i!==t?(c=Kn(),c!==t?(M=Be(),M!==t?(U=Dt(),U!==t?n=rn(s,U):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=vt(),s!==t&&(s=nn(s)),n=s,n===t&&(n=r,s=Dt(),s!==t&&(s=an(s)),n=s)))))))))),n}function Pn(){var n,s;return n=r,s=ur(),s!==t&&(s=sn()),n=s,n===t&&(n=r,s=cr(),s!==t&&(s=on()),n=s),n}function Dt(){var n,s,i,c;return n=r,s=qn(),s!==t?(i=Be(),i!==t?(c=Sr(),c!==t?n=ln(s,c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n}function qn(){var n,s,i,c;if(n=r,s=r,i=[],c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t)for(;c!==t;)i.push(c),c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_));else i=t;return i!==t?s=o.substring(s,r):s=i,s!==t&&(s=fn(s)),n=s,n}function Sr(){var n,s,i,c,M;return n=r,s=r,i=o.substr(r,6),i.toLowerCase()===O?r+=6:(i=t,p===0&&T(I)),i===t&&(i=o.substr(r,6),i.toLowerCase()===A?r+=6:(i=t,p===0&&T(ie)),i===t&&(i=o.substr(r,4),i.toLowerCase()===b?r+=4:(i=t,p===0&&T(W)),i===t&&(i=o.substr(r,3),i.toLowerCase()===B?r+=3:(i=t,p===0&&T(ue)),i===t&&(i=o.substr(r,4),i.toLowerCase()===de?r+=4:(i=t,p===0&&T(Se)),i===t&&(i=o.substr(r,5),i.toLowerCase()===Fe?r+=5:(i=t,p===0&&T(lt)),i===t&&(i=o.substr(r,7),i.toLowerCase()===ve?r+=7:(i=t,p===0&&T(Xe)),i===t&&(i=o.substr(r,4),i.toLowerCase()===Ye?r+=4:(i=t,p===0&&T(At))))))))),i!==t?s=o.substring(s,r):s=i,s!==t?(i=o.charAt(r),i.toLowerCase()===Ae?r++:(i=t,p===0&&T(m)),i===t&&(i=null),c=r,p++,M=ye(),p--,M===t?c=void 0:(r=c,c=t),c!==t?n=un(s):(r=n,n=t)):(r=n,n=t),n}function vt(){var n,s,i,c,M,U;return n=r,s=Fr(),s!==t&&(s=cn()),n=s,n===t&&(n=r,s=Xn(),s!==t&&(s=dn()),n=s,n===t&&(n=r,s=ei(),s!==t&&(s=pn()),n=s,n===t&&(n=r,s=ti(),s!==t&&(s=hn()),n=s,n===t&&(n=r,s=Dt(),s!==t?(i=Be(),i!==t?(c=Wn(),c!==t?n=mn(s):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Dt(),s!==t?(i=Be(),i!==t?(c=zn(),c!==t?(M=Be(),M!==t?(U=Fr(),U!==t?n=gn(s):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=cr(),s!==t?(i=Be(),i!==t?(c=fr(),c!==t?n=yn(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=ur(),s!==t?(i=Be(),i!==t?(c=fr(),c!==t?n=vn(c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=Qn(),s!==t?(i=Be(),i!==t?(c=Sr(),c!==t?n=wn(s,c):(r=n,n=t)):(r=n,n=t)):(r=n,n=t),n===t&&(n=r,s=fr(),s!==t&&(s=_n(s)),n=s,n===t&&(n=r,s=Mn(),s!==t&&(s=An(s)),n=s)))))))))),n}function Qn(){var n,s;return n=r,s=jn(),s!==t&&(s=Tn()),n=s,n===t&&(n=r,s=cr(),s!==t&&(s=$n()),n=s,n===t&&(n=r,s=ur(),s!==t&&(s=Sn()),n=s)),n}function Mn(){var n,s,i,c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie,wt,dt,pt,zt,xt,Nt,$t,St,dr,_t;if(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t)if(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t)if(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t)if(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t)if(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t)if(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t)if(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t)if(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t)if(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t)if($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t)if(Ne=o.charAt(r),nt.test(Ne)?r++:(Ne=t,p===0&&T(a)),Ne!==t)if(Le=o.charAt(r),C.test(Le)?r++:(Le=t,p===0&&T(_)),Le!==t)if(Ie=o.charAt(r),C.test(Ie)?r++:(Ie=t,p===0&&T(_)),Ie!==t)if(o.charCodeAt(r)===58?(wt=Pe,r++):(wt=t,p===0&&T(f)),wt!==t)if(dt=o.charAt(r),C.test(dt)?r++:(dt=t,p===0&&T(_)),dt!==t)if(pt=o.charAt(r),C.test(pt)?r++:(pt=t,p===0&&T(_)),pt!==t)if(o.charCodeAt(r)===58?(zt=Pe,r++):(zt=t,p===0&&T(f)),zt!==t)if(xt=o.charAt(r),C.test(xt)?r++:(xt=t,p===0&&T(_)),xt!==t)if(Nt=o.charAt(r),C.test(Nt)?r++:(Nt=t,p===0&&T(_)),Nt!==t){if($t=r,St=o.charAt(r),ot.test(St)?r++:(St=t,p===0&&T(l)),St!==t){for(dr=[],_t=o.charAt(r),C.test(_t)?r++:(_t=t,p===0&&T(_));_t!==t;)dr.push(_t),_t=o.charAt(r),C.test(_t)?r++:(_t=t,p===0&&T(_));St=[St,dr],$t=St}else r=$t,$t=t;$t===t&&($t=null),c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie,wt,dt,pt,zt,xt,Nt,$t],i=c}else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;else r=i,i=t;return i!==t?s=o.substring(s,r):s=i,s!==t&&(s=bn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(o.charCodeAt(r)===45?(Ne=pe,r++):(Ne=t,p===0&&T(e)),Ne!==t?(Le=o.charAt(r),_e.test(Le)?r++:(Le=t,p===0&&T(R)),Le!==t?(Ie=o.charAt(r),Ze.test(Ie)?r++:(Ie=t,p===0&&T(J)),Ie!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Fn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),ct.test(se)?r++:(se=t,p===0&&T(fe)),se!==t?(oe=o.charAt(r),gt.test(oe)?r++:(oe=t,p===0&&T(V)),oe!==t?(c=[c,M,U,X,ae,se,oe],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=On(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(Ne=o.charAt(r),nt.test(Ne)?r++:(Ne=t,p===0&&T(a)),Ne!==t?(Le=o.charAt(r),C.test(Le)?r++:(Le=t,p===0&&T(_)),Le!==t?(Ie=o.charAt(r),C.test(Ie)?r++:(Ie=t,p===0&&T(_)),Ie!==t?(o.charCodeAt(r)===58?(wt=Pe,r++):(wt=t,p===0&&T(f)),wt!==t?(dt=o.charAt(r),C.test(dt)?r++:(dt=t,p===0&&T(_)),dt!==t?(pt=o.charAt(r),C.test(pt)?r++:(pt=t,p===0&&T(_)),pt!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie,wt,dt,pt],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=En(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(Ne=o.charAt(r),nt.test(Ne)?r++:(Ne=t,p===0&&T(a)),Ne!==t?(Le=o.charAt(r),C.test(Le)?r++:(Le=t,p===0&&T(_)),Le!==t?(Ie=o.charAt(r),C.test(Ie)?r++:(Ie=t,p===0&&T(_)),Ie!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e,Ne,Le,Ie],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=kn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(o.charCodeAt(r)===45?(Ve=pe,r++):(Ve=t,p===0&&T(e)),Ve!==t?(Te=o.charAt(r),C.test(Te)?r++:(Te=t,p===0&&T(_)),Te!==t?($e=o.charAt(r),C.test($e)?r++:($e=t,p===0&&T(_)),$e!==t?(c=[c,M,U,X,ae,se,oe,Ve,Te,$e],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Rn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(o.charCodeAt(r)===45?(ae=pe,r++):(ae=t,p===0&&T(e)),ae!==t?(se=o.charAt(r),C.test(se)?r++:(se=t,p===0&&T(_)),se!==t?(oe=o.charAt(r),C.test(oe)?r++:(oe=t,p===0&&T(_)),oe!==t?(c=[c,M,U,X,ae,se,oe],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Vn(s)),n=s,n===t&&(n=r,s=r,i=r,c=o.charAt(r),C.test(c)?r++:(c=t,p===0&&T(_)),c!==t?(M=o.charAt(r),C.test(M)?r++:(M=t,p===0&&T(_)),M!==t?(U=o.charAt(r),C.test(U)?r++:(U=t,p===0&&T(_)),U!==t?(X=o.charAt(r),C.test(X)?r++:(X=t,p===0&&T(_)),X!==t?(c=[c,M,U,X],i=c):(r=i,i=t)):(r=i,i=t)):(r=i,i=t)):(r=i,i=t),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=Ln(s)),n=s))))))),n}function fr(){var n,s,i;return n=r,s=r,i=ii(),i===t&&(i=ai(),i===t&&(i=si(),i===t&&(i=oi(),i===t&&(i=li(),i===t&&(i=fi(),i===t&&(i=ui())))))),i!==t?s=o.substring(s,r):s=i,s!==t&&(s=In(s)),n=s,n}function br(){var n,s;return n=r,s=ni(),s!==t&&(s=Cn()),n=s,n===t&&(n=r,s=ri(),s!==t&&(s=Dn()),n=s),n}function Bn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===tt?r+=3:(s=t,p===0&&T(he)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Gn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Re?r+=4:(s=t,p===0&&T(be)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Un(){var n,s,i,c;return n=r,s=o.substr(r,2),s.toLowerCase()===Ge?r+=2:(s=t,p===0&&T(yt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Fr(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===it?r+=3:(s=t,p===0&&T(Zt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ur(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Ee?r+=4:(s=t,p===0&&T(Kt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function jn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===at?r+=4:(s=t,p===0&&T(Bt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function cr(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===Ce?r+=4:(s=t,p===0&&T(Gt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Wn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===De?r+=3:(s=t,p===0&&T(te)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function zn(){var n,s,i,c;return n=r,s=o.substr(r,4),s.toLowerCase()===st?r+=4:(s=t,p===0&&T(Xt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Yn(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===qe?r+=6:(s=t,p===0&&T(Lt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Jn(){var n,s,i,c;return n=r,s=o.substr(r,5),s.toLowerCase()===Oe?r+=5:(s=t,p===0&&T(It)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Hn(){var n,s,i,c;return n=r,s=o.substr(r,7),s.toLowerCase()===ke?r+=7:(s=t,p===0&&T(Ut)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Zn(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===xe?r+=8:(s=t,p===0&&T(er)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Kn(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===Je?r+=3:(s=t,p===0&&T(tr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function Xn(){var n,s,i,c;return n=r,s=o.substr(r,5),s.toLowerCase()===He?r+=5:(s=t,p===0&&T(et)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ei(){var n,s,i,c;return n=r,s=o.substr(r,9),s.toLowerCase()===je?r+=9:(s=t,p===0&&T(jt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ti(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===q?r+=8:(s=t,p===0&&T(rr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ri(){var n,s,i,c;return n=r,s=o.substr(r,3),s.toLowerCase()===h?r+=3:(s=t,p===0&&T(nr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ni(){var n,s,i,c;return n=r,s=o.substr(r,2),s.toLowerCase()===$?r+=2:(s=t,p===0&&T(ir)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ii(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===k?r+=6:(s=t,p===0&&T(ar)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ai(){var n,s,i,c;return n=r,s=o.substr(r,7),s.toLowerCase()===F?r+=7:(s=t,p===0&&T(sr)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function si(){var n,s,i,c;return n=r,s=o.substr(r,9),s.toLowerCase()===z?r+=9:(s=t,p===0&&T(Tt)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function oi(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===Y?r+=8:(s=t,p===0&&T(me)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function li(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===we?r+=6:(s=t,p===0&&T(g)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function fi(){var n,s,i,c;return n=r,s=o.substr(r,8),s.toLowerCase()===Qe?r+=8:(s=t,p===0&&T(v)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ui(){var n,s,i,c;return n=r,s=o.substr(r,6),s.toLowerCase()===rt?r+=6:(s=t,p===0&&T(L)),s!==t?(i=r,p++,c=ye(),p--,c===t?i=void 0:(r=i,i=t),i!==t?(s=[s,i],n=s):(r=n,n=t)):(r=n,n=t),n}function ye(){var n;return n=o.charAt(r),We.test(n)?r++:(n=t,p===0&&T(Q)),n}function Rt(){var n,s;for(p++,n=[],s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P));s!==t;)n.push(s),s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P));return p--,s=t,p===0&&T(K),n}function Be(){var n,s;if(p++,n=[],s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P)),s!==t)for(;s!==t;)n.push(s),s=o.charAt(r),Ke.test(s)?r++:(s=t,p===0&&T(P));else n=t;return p--,n===t&&(s=t,p===0&&T(G)),n}if(Ct=Z(),d.peg$library)return{peg$result:Ct,peg$currPos:r,peg$FAILED:t,peg$maxFailExpected:Wt,peg$maxFailPos:ft};if(Ct!==t&&r===o.length)return Ct;throw Ct!==t&&r<o.length&&T(xn()),Nn(Wt,ft<o.length?o.charAt(ft):null,ft<o.length?Tr(ft,ft+1):Tr(ft,ft))}return vr={StartRules:["temporalFilter"],SyntaxError:S,parse:y},vr}var xr;function _i(){return xr||(xr=1,(function(u){Object.defineProperty(u,"__esModule",{value:!0}),u.TemporalFilterExpression=void 0;const re=Vt(),j=wi(),N=wr();u.TemporalFilterExpression={parse(y){if(y.match(/^\s*$/))return{parsed:null,log:[]};const o=(0,N.run_parser)(y,j.parse);return o.parsed&&(0,re.isTemporalFilter)(o.parsed)?{parsed:o.parsed,log:[]}:{parsed:null,log:o.log}},unparse(y){if(y===null)return"";switch(y.operator){case"null":return E(y,"null");case"in":return E(y,w(y.in));case"()":return"("+u.TemporalFilterExpression.unparse(y.expr)+")";case"in_last":return E(y,S(y));case"last":case"next":return E(y,`${y.operator} ${S(y)}`);case"before":return`${y.not?"starting":"before"} ${w(y.before)}`;case"after":return`${y.not?"through":"after"} ${w(y.after)}`;case"to":return E(y,`${w(y.fromMoment)} to ${w(y.toMoment)}`);case"for":return E(y,`${w(y.begin)} for ${S(y)}`);case"or":return y.members.map(o=>u.TemporalFilterExpression.unparse(o)).join(" or ");case"and":return y.members.map(o=>u.TemporalFilterExpression.unparse(o)).join(" and ")}}};function E(y,o){return"not"in y&&y.not?"not "+o:o}function S(y){return y.n==="1"?`1 ${y.units}`:`${y.n} ${y.units}s`}function w(y){switch(y.moment){case"literal":return y.literal;case"now":case"today":case"yesterday":case"tomorrow":return y.moment;case"monday":case"tuesday":case"wednesday":case"thursday":case"friday":case"saturday":case"sunday":return y.which==="next"?"next "+y.moment:y.moment;case"this":case"next":case"last":return`${y.moment} ${y.units}`;case"ago":return`${S(y)} ago`;case"from_now":return`${S(y)} from now`}}})(yr)),yr}var Nr;function Ai(){return Nr||(Nr=1,(function(u){var re=bt&&bt.__createBinding||(Object.create?(function(y,o,d,t){t===void 0&&(t=d);var D=Object.getOwnPropertyDescriptor(o,d);(!D||("get"in D?!o.__esModule:D.writable||D.configurable))&&(D={enumerable:!0,get:function(){return o[d]}}),Object.defineProperty(y,t,D)}):(function(y,o,d,t){t===void 0&&(t=d),y[t]=o[d]})),j=bt&&bt.__exportStar||function(y,o){for(var d in y)d!=="default"&&!Object.prototype.hasOwnProperty.call(o,d)&&re(o,y,d)};Object.defineProperty(u,"__esModule",{value:!0}),u.TemporalFilterExpression=u.StringFilterExpression=u.NumberFilterExpression=u.BooleanFilterExpression=void 0,j(Vt(),u);var N=hi();Object.defineProperty(u,"BooleanFilterExpression",{enumerable:!0,get:function(){return N.BooleanFilterExpression}});var E=gi();Object.defineProperty(u,"NumberFilterExpression",{enumerable:!0,get:function(){return E.NumberFilterExpression}});var S=vi();Object.defineProperty(u,"StringFilterExpression",{enumerable:!0,get:function(){return S.StringFilterExpression}});var w=_i();Object.defineProperty(u,"TemporalFilterExpression",{enumerable:!0,get:function(){return w.TemporalFilterExpression}})})(bt)),bt}var Ft={},qt={},Pr;function Wr(){return Pr||(Pr=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.MALLOY_INTERFACE_TYPES=void 0,qt.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}}}}),qt}var Qt={},Jt={},Mt={},qr;function Ti(){return qr||(qr=1,Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.RESERVED_WORDS=void 0,Mt.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"]),Mt}var Qr;function $i(){if(Qr)return Jt;Qr=1,Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.maybeQuoteIdentifier=j;const u=Ti();function re(N){const E=!N.match(/^[A-Za-z_][A-Za-z_0-9]*$/),S=u.RESERVED_WORDS.includes(N.toLowerCase());return E||S}function j(N){return re(N)?`\`${N}\``:N}return Jt}var Mr;function Si(){if(Mr)return Qt;Mr=1,Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.queryToMalloy=re,Qt.filterToMalloy=j;const u=$i();function re(h,{tabWidth:$}={tabWidth:2}){const k=ce(h);return y(k,{tabWidth:$})}function j(h,{tabWidth:$}={tabWidth:2}){const k=Je(h);return y(k,{tabWidth:$})}const N=Symbol("indent"),E=Symbol("newline"),S=Symbol("outdent"),w=Symbol("optional_newline_indent");function y(h,{tabWidth:$}={tabWidth:2}){let k="",F=0,z=!0;for(const Y of h)if(Y===E)k+=`
18
+ `,z=!0;else if(Y===S)F--;else if(Y===N)F++;else{if(Y===w)continue;z&&(k+=" ".repeat(F*$),z=!1),k+=Y}return k}function o(h,$,k,F){var z;if($.includes(E))return[h,E,N,...$,E,S,k];const we=((z=F?.spaces)!==null&&z!==void 0?z:!0)?" ":"";return[h,we,...$,we,k]}function d(h){return{contents:h,quoteCharacter:'"'}}function t(h,$){const k=[];for(let F=0;F<h.length;F++){const z=h[F];k.push(z),F<h.length-1&&k.push($)}return k}function D(h){var $,k;switch(h.kind){case"filter_expression_literal":return[ke(h.filter_expression_value)];case"boolean_literal":return[h.boolean_value.toString()];case"string_literal":{const{contents:F,quoteCharacter:z}=d(h.string_value);return[z,F,z]}case"number_literal":return[h.number_value.toString()];case"null_literal":return["null"];case"date_literal":return[Z(x(h.date_value),($=h.granularity)!==null&&$!==void 0?$:"day",h.timezone)];case"timestamp_literal":return[Z(x(h.timestamp_value),(k=h.granularity)!==null&&k!==void 0?k:"second",h.timezone)]}}function x(h){let $;if($=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/.exec(h)){const[k,F,z,Y,we,Qe,rt]=$;return[F,z,Y,we,Qe,rt]}else if($=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d)/.exec(h)){const[k,F,z,Y,we,Qe]=$;return[F,z,Y,we,Qe,"00"]}else if($=/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d)(?:00)?/.exec(h)){const[k,F,z,Y,we]=$;return[F,z,Y,we,"00","00"]}else if($=/(\d\d\d\d)-(\d\d)-(\d\d)/.exec(h)){const[k,F,z,Y]=$;return[F,z,Y,"00","00","00"]}else if($=/(\d\d\d\d)-(\d\d)/.exec(h)){const[k,F,z]=$;return[F,z,"01","00","00","00"]}else if($=/(\d\d\d\d)/.exec(h)){const[k,F]=$;return[F,"01","01","00","00","00"]}return["1970","01","01","00","00","00"]}function Z([h,$,k,F,z,Y],we,Qe){switch(we){case"year":return`@${h}`;case"quarter":{const rt=Math.floor(+$/3)+1;return`@${h}-Q${rt}`}case"month":return`@${h}-${$}`;case"week":return`@${h}-${$}-${k}-WK`;case"day":return`@${h}-${$}-${k}`;case"hour":return`@${h}-${$}-${k} ${F}`;case"minute":return`@${h}-${$}-${k} ${F}:${z}`;case"second":return Qe!==void 0?`@${h}-${$}-${k} ${F}:${z}:${Y}[${Qe}]`:`@${h}-${$}-${k} ${F}:${z}:${Y}`;default:throw new Error("Unknown timeframe.")}}function ee(h){var $;const k=[];for(const F of($=h.path)!==null&&$!==void 0?$:[])k.push((0,u.maybeQuoteIdentifier)(F)),k.push(".");if(k.push((0,u.maybeQuoteIdentifier)(h.name)),h.parameters){const F=[];for(let z=0;z<h.parameters.length;z++){const Y=h.parameters[z];F.push((0,u.maybeQuoteIdentifier)(Y.name)),F.push(" is "),F.push(...D(Y.value)),z<h.parameters.length-1&&F.push(",",E)}k.push(...o("(",F,")",{spaces:!1}))}return k}function ce(h){const $=[];return $.push(...je(h.annotations)),$.push("run: "),$.push(...A(h.definition)),$}function O(h){const $=[];switch(h.kind){case"source_reference":{$.push(...ee(h));break}case"refinement":$.push(...A(h));break}return $}function A(h){const $=[];switch(h.kind){case"arrow":{$.push(...O(h.source)),$.push(" -> "),$.push(...b(h.view));break}case"query_reference":{$.push(...ee(h));break}case"refinement":{const k=A(h.base);h.base.kind==="arrow"?$.push(...o("(",k,")",{spaces:!1})):$.push(...k),$.push(" + "),$.push(...b(h.refinement));break}}return $}function b(h){const $=[];switch(h.kind){case"arrow":{$.push(...b(h.source)),$.push(" -> "),$.push(...b(h.view));break}case"view_reference":{$.push(...ee(h));break}case"refinement":{$.push(...b(h.base)),$.push(" + "),$.push(...b(h.refinement));break}case"segment":{$.push(...B(h));break}}return $}function B(h){if(h.operations.length===0)return["{ }"];const $=h.operations.length>1,k=[];for(let F=0;F<h.operations.length;F++){const z=h.operations[F],Y=[z];for(;F<h.operations.length-1;){const we=h.operations[F+1];if(we.kind===z.kind)Y.push(we),F++;else break}k.push(...de(Y)),$&&F<h.operations.length-1&&k.push(E)}return o("{",k,"}")}function de(h){switch(h[0].kind){case"aggregate":return Pe(h,"aggregate");case"group_by":return Pe(h,"group_by");case"order_by":return tt(h);case"nest":return Ge(h);case"limit":return Ce(h);case"where":return De(h);case"having":return qe(h);case"drill":return st(h);case"calculate":return Pe(h,"calculate")}}function Fe(h,$,k=""){const F=[];F.push(`${h}:`);const z=$.length>1||$.some(Y=>Y.includes(E));z?F.push(E,N):F.push(" ");for(let Y=0;Y<$.length;Y++){const we=$[Y];F.push(...we),$.length>1&&Y<$.length-1&&F.push(k),z&&Y<$.length-1&&F.push(E)}return z&&F.push(S),F}function ve(h){const $=[];return $.push(...Ae(h.expression)),$}function Ye(h){return h}function Ae(h){var $;switch(h.kind){case"field_reference":return ee(h);case"time_truncation":return[...ee(h.field_reference),".",h.truncation];case"filtered_field":return[...ee(h.field_reference),...o(" {",De(h.where),"}")];case"literal_value":return D(h.literal_value);case"moving_average":{const k=["avg_moving",...o("(",[...ee(h.field_reference),h.rows_preceding!==void 0?`, ${h.rows_preceding}`:", 0",h.rows_following!==void 0?`, ${h.rows_following}`:""],")",{spaces:!1})];return!(($=h.partition_fields)===null||$===void 0)&&$.length&&k.push(...o(" {",["partition_by",": ",...t(h.partition_fields.flatMap(F=>ee(F)),", ")],"}")),k}}}function pe(h,$=!1){const k=[];return $||k.push(...je(h.field.annotations)),h.name&&(k.push((0,u.maybeQuoteIdentifier)(h.name)),k.push(" is ")),k.push(...ve(h.field)),k}function Pe(h,$){const k=[],F=h.length===1;return F&&k.push(...je(h[0].field.annotations)),k.push(...Fe($,h.map(z=>pe(z,F)))),k}function tt(h){return Fe("order_by",h.map(Re),",")}function Re(h){const $=[];return $.push(...ee(h.field_reference)),h.direction&&($.push(" "),$.push(h.direction)),$}function Ge(h){const $=[],k=h.length===1;return k&&$.push(...je(h[0].view.annotations)),$.push(...Fe("nest",h.map(F=>it(F,k)))),$}function it(h,$=!1){const k=[];return $||k.push(...je(h.view.annotations)),h.name&&(k.push((0,u.maybeQuoteIdentifier)(h.name)),k.push(" is ")),k.push(...Ee(h.view)),k}function Ee(h){return b(h.definition)}function at(h){return[`limit: ${h.limit}`]}function Ce(h){const $=[];for(let k=0;k<h.length;k++)k!==0&&$.push(E),$.push(...at(h[k]));return $}function De(h){return Fe("where",h.map(He),",")}function st(h){return Fe("drill",h.map(He),",")}function qe(h){return Fe("having",h.map(He),",")}const Oe=["`","'",'"'];function ke(h){let $,k;for(const F of Oe){const z=xe(h,F);if(z===h)return`f${F}${h}${F}`;(k===void 0||z.length<k.length)&&($=F,k=z)}return`f${$}${k}${$}`}function xe(h,$){let k="";for(let F=0;F<h.length;F++)h.slice(F).startsWith($)?(k+="\\"+$,F+=$.length):(k+=h[F],h[F]==="\\"&&(k+=h[++F]));return k}function Je(h){switch(h.kind){case"filter_string":return[...Ae(h.expression)," ~ ",ke(h.filter)];case"literal_equality":return[...Ae(h.expression)," = ",...D(h.value)]}}function He(h){return Je(h.filter)}function je(h){return h?h.flatMap(q):[]}function q(h){return[h.value.trim(),E]}return Qt}var Ot={},Br;function bi(){if(Br)return Ot;Br=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.nestUnions=re,Ot.unnestUnions=j,Ot.convertFromThrift=N,Ot.convertToThrift=S;const u=Wr();function re(w){if(w==null)return w;if(typeof w=="string"||typeof w=="number"||typeof w=="boolean")return w;if(Array.isArray(w))return w.map(re);{const y={};let o;for(const d in w)d==="kind"?o=w[d]:y[d]=re(w[d]);return o===void 0?y:{[o]:y}}}function j(w,y){if(w==null)return w;if(typeof w=="string"||typeof w=="number"||typeof w=="boolean")return w;if(Array.isArray(w))return w.map(o=>j(o,y));{const o=E(y);if(o.type==="union"){for(const d in o.options)if(w[d]!==void 0){const t=j(w[d],o.options[d]);if(typeof t=="object")return{kind:d,...t}}}else if(o.type==="struct"){const d={};for(const t in w){const D=o.fields[t];if(D===void 0)throw new Error(`Unknown field ${t} in ${y}`);d[t]=j(w[t],D.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${y}`)}}function N(w,y){if(w==null)return w;if(typeof w=="string"||typeof w=="boolean")return w;if(typeof w=="number"){if(y==="number")return w;const o=E(y);if(o.type!=="enum")throw new Error(`Found a number where a ${y} was expected`);const d=Object.entries(o.values).find(([,t])=>t===w);if(d===void 0)throw new Error(`${w} is not a valid enum value for ${y}`);return d[0]}else{if(Array.isArray(w))return w.map(o=>N(o,y));{const o=E(y);if(o.type==="union"){for(const d in o.options)if(w[d]!==void 0&&w[d]!==null){const t=N(w[d],o.options[d]);if(typeof t=="object")return{kind:d,...t}}}else if(o.type==="struct"){const d={};for(const t in w){const D=o.fields[t];if(D===void 0)throw new Error(`Unknown field ${t} in ${y}`);d[t]=N(w[t],D.type)}return d}else throw new Error(`Cannot unnest unions in an enum type ${y}`)}}}function E(w){const y=u.MALLOY_INTERFACE_TYPES[w];if(y===void 0)throw new Error(`Unknown Malloy interface type ${w}`);return y}function S(w,y){if(w==null)return w;if(typeof w=="number"||typeof w=="boolean")return w;if(typeof w=="string"){if(y==="string")return w;const o=E(y);if(o.type==="enum"){const d=o.values[w];if(d===void 0)throw new Error(`${w} is not a valid enum value for ${y}`);return d}}else{if(Array.isArray(w))return w.map(o=>S(o,y));{const o=E(y);if(o.type==="union"){const d=w.kind,t=o.options[d];if(t===void 0)throw new Error(`${d} is not a valid union of ${y}`);const D=E(t);if(D.type!=="struct")throw new Error("Union fields must be structs");const x={};for(const Z in w){if(Z==="kind")continue;const ee=D.fields[Z];x[Z]=S(w[Z],ee.type)}return{[d]:x}}else if(o.type==="struct"){const d={};for(const t in w){const D=o.fields[t];if(D===void 0)throw new Error(`Unknown field ${t} in ${y}`);d[t]=S(w[t],D.type)}return d}}}}return Ot}var Gr;function Fi(){return Gr||(Gr=1,(function(u){var re=Ft&&Ft.__createBinding||(Object.create?(function(S,w,y,o){o===void 0&&(o=y);var d=Object.getOwnPropertyDescriptor(w,y);(!d||("get"in d?!w.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return w[y]}}),Object.defineProperty(S,o,d)}):(function(S,w,y,o){o===void 0&&(o=y),S[o]=w[y]})),j=Ft&&Ft.__exportStar||function(S,w){for(var y in S)y!=="default"&&!Object.prototype.hasOwnProperty.call(w,y)&&re(w,S,y)};Object.defineProperty(u,"__esModule",{value:!0}),u.thingy4sddfdfsd=u.thingy4sdfsd=u.thingy4dfdsfs=u.thingy4asdfas=u.thingy4asdfasdf=u.thingy3dfdf=u.thingy3=u.thingy2asdf=u.thingyssdfg=u.thingy123r=u.thingy1=u.res=u.test=u.convertToThrift=u.convertFromThrift=u.unnestUnions=u.nestUnions=u.filterToMalloy=u.queryToMalloy=void 0,j(Wr(),u);var N=Si();Object.defineProperty(u,"queryToMalloy",{enumerable:!0,get:function(){return N.queryToMalloy}}),Object.defineProperty(u,"filterToMalloy",{enumerable:!0,get:function(){return N.filterToMalloy}});var E=bi();Object.defineProperty(u,"nestUnions",{enumerable:!0,get:function(){return E.nestUnions}}),Object.defineProperty(u,"unnestUnions",{enumerable:!0,get:function(){return E.unnestUnions}}),Object.defineProperty(u,"convertFromThrift",{enumerable:!0,get:function(){return E.convertFromThrift}}),Object.defineProperty(u,"convertToThrift",{enumerable:!0,get:function(){return E.convertToThrift}}),u.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:[]},u.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 * ..."},u.thingy1={definition:{kind:"query_reference",name:"flights_by_carrier"}},u.thingy123r={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},u.thingyssdfg={definition:{kind:"refinement",base:{kind:"query_reference",name:"flights"},refinement:{kind:"view_reference",name:"by_carrier"}}},u.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"}}]}}}},u.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"}}}]}}}},u.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"}}}},u.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"}}}]}}},u.thingy4asdfas={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"view_reference",name:"by_carrier"}}},u.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}]}}}},u.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}]}}},u.thingy4sddfdfsd={definition:{kind:"arrow",source:{kind:"source_reference",name:"flights"},view:{kind:"segment",operations:[]}}}})(Ft)),Ft}var Et={},mt={},Ur;function Oi(){return Ur||(Ur=1,(function(u){var re=mt&&mt.__createBinding||(Object.create?(function(m,e,a,f){f===void 0&&(f=a);var l=Object.getOwnPropertyDescriptor(e,a);(!l||("get"in l?!e.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(m,f,l)}):(function(m,e,a,f){f===void 0&&(f=a),m[f]=e[a]})),j=mt&&mt.__setModuleDefault||(Object.create?(function(m,e){Object.defineProperty(m,"default",{enumerable:!0,value:e})}):function(m,e){m.default=e}),N=mt&&mt.__importStar||(function(){var m=function(e){return m=Object.getOwnPropertyNames||function(a){var f=[];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(f[f.length]=l);return f},m(e)};return function(e){if(e&&e.__esModule)return e;var a={};if(e!=null)for(var f=m(e),l=0;l<f.length;l++)f[l]!=="default"&&re(a,e,f[l]);return j(a,e),a}})();Object.defineProperty(u,"__esModule",{value:!0}),u.ASTAnnotationList=u.ASTLimitViewOperation=u.ASTView=u.ASTFilterWithLiteralEquality=u.ASTFilterWithFilterString=u.ASTFilter=u.ASTCalculateViewOperation=u.ASTHavingViewOperation=u.ASTDrillViewOperation=u.ASTWhereViewOperation=u.ASTNestViewOperation=u.ASTFilteredFieldExpression=u.ASTFilterOperationList=u.ASTFilterOperation=u.ASTMovingAverageExpression=u.ASTFieldReferenceList=u.ASTLiteralValueExpression=u.ASTTimeTruncationExpression=u.ASTReferenceExpression=u.ASTExpression=u.ASTField=u.ASTAggregateViewOperation=u.ASTGroupByViewOperation=u.ASTOrderByViewOperation=u.ASTViewOperation=u.ASTViewOperationList=u.ASTSegmentViewDefinition=u.ASTRefinementViewDefinition=u.ASTArrowViewDefinition=u.ASTReferenceViewDefinition=u.ASTReferenceQueryArrowSource=u.ASTReferenceQueryDefinition=u.ASTRefinementQueryDefinition=u.ASTArrowQueryDefinition=u.ASTQueryDefinition=u.ASTQueryArrowSource=u.ASTUnimplemented=u.ASTFilterExpressionLiteralValue=u.ASTTimestampLiteralValue=u.ASTDateLiteralValue=u.ASTBooleanLiteralValue=u.ASTNumberLiteralValue=u.ASTNullLiteralValue=u.ASTStringLiteralValue=u.ASTLiteralValue=u.ASTParameterValue=u.ASTParameterValueList=u.ASTFieldReference=u.ASTReference=u.ASTQuery=void 0,u.ASTAnnotation=void 0;const E=N(Fi()),S=di(),w=N(Ai());class y{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 D)return e;throw new Error("Not an ASTQuery")},Reference(){if(e instanceof x)return e;throw new Error("Not an ASTReference")},ReferenceQueryArrowSource(){if(e instanceof tt)return e;throw new Error("Not an ASTReferenceQueryArrowSource")},ParameterValueList(){if(e instanceof ee)return e;throw new Error("Not an ASTParameterValueList")},FilterOperation(){if(e instanceof $)return e;throw new Error("Not an ASTFilterOperation")},FilterOperationList(){if(e instanceof k)return e;throw new Error("Not an ASTFilterOperationList")},ParameterValue(){if(e instanceof ce)return e;throw new Error("Not an ASTParameterValue")},StringLiteralValue(){if(e instanceof O)return e;throw new Error("Not an ASTStringLiteralValue")},NumberLiteralValue(){if(e instanceof b)return e;throw new Error("Not an ASTNumberLiteralValue")},ViewOperationList(){if(e instanceof st)return e;throw new Error("Not an ASTViewOperationList")},GroupByViewOperation(){if(e instanceof Oe)return e;throw new Error("Not an ASTGroupByViewOperation")},AggregateViewOperation(){if(e instanceof ke)return e;throw new Error("Not an ASTAggregateViewOperation")},OrderByViewOperation(){if(e instanceof qe)return e;throw new Error("Not an ASTOrderByViewOperation")},Field(){if(e instanceof xe)return e;throw new Error("Not an ASTField")},ReferenceExpression(){if(e instanceof Je)return e;throw new Error("Not an ASTReferenceExpression")},ReferenceViewDefinition(){if(e instanceof Ee)return e;throw new Error("Not an ASTReferenceViewDefinition")},ArrowQueryDefinition(){if(e instanceof Ae)return e;throw new Error("Not an ASTArrowQueryDefinition")},ArrowViewDefinition(){if(e instanceof at)return e;throw new Error("Not an ASTArrowViewDefinition")},RefinementViewDefinition(){if(e instanceof Ce)return e;throw new Error("Not an ASTRefinementViewDefinition")},TimeTruncationExpression(){if(e instanceof He)return e;throw new Error("Not an ASTTimeTruncationExpression")},FilteredFieldExpression(){if(e instanceof F)return e;throw new Error("Not an ASTFilteredFieldExpression")},NestViewOperation(){if(e instanceof Y)return e;throw new Error("Not an ASTNestViewOperation")},View(){if(e instanceof _e)return e;throw new Error("Not an ASTView")},SegmentViewDefinition(){if(e instanceof De)return e;throw new Error("Not an ASTSegmentViewDefinition")},LimitViewOperation(){if(e instanceof Ze)return e;throw new Error("Not an ASTLimitViewOperation")},AnnotationList(){if(e instanceof We)return e;throw new Error("Not an ASTAnnotationList")},Annotation(){if(e instanceof Ke)return e;throw new Error("Not an ASTAnnotation")}}}get find(){const e=this;return{Query(a){return e.findAny(a).as.Query()},Reference(a){return e.findAny(a).as.Reference()},ReferenceQueryArrowSource(a){return e.findAny(a).as.ReferenceQueryArrowSource()},ParameterValueList(a){return e.findAny(a).as.ParameterValueList()},FilterOperation(a){return e.findAny(a).as.FilterOperation()},FilterOperationList(a){return e.findAny(a).as.FilterOperationList()},ParameterValue(a){return e.findAny(a).as.ParameterValue()},StringLiteralValue(a){return e.findAny(a).as.StringLiteralValue()},NumberLiteralValue(a){return e.findAny(a).as.NumberLiteralValue()},ViewOperationList(a){return e.findAny(a).as.ViewOperationList()},GroupByViewOperation(a){return e.findAny(a).as.GroupByViewOperation()},AggregateViewOperation(a){return e.findAny(a).as.AggregateViewOperation()},OrderByViewOperation(a){return e.findAny(a).as.OrderByViewOperation()},Field(a){return e.findAny(a).as.Field()},ReferenceExpression(a){return e.findAny(a).as.ReferenceExpression()},ReferenceViewDefinition(a){return e.findAny(a).as.ReferenceViewDefinition()},ArrowQueryDefinition(a){return e.findAny(a).as.ArrowQueryDefinition()},ArrowViewDefinition(a){return e.findAny(a).as.ArrowViewDefinition()},RefinementViewDefinition(a){return e.findAny(a).as.RefinementViewDefinition()},TimeTruncationExpression(a){return e.findAny(a).as.TimeTruncationExpression()},FilteredFieldExpression(a){return e.findAny(a).as.FilteredFieldExpression()},NestViewOperation(a){return e.findAny(a).as.NestViewOperation()},View(a){return e.findAny(a).as.View()},SegmentViewDefinition(a){return e.findAny(a).as.SegmentViewDefinition()},LimitViewOperation(a){return e.findAny(a).as.LimitViewOperation()},AnnotationList(a){return e.findAny(a).as.AnnotationList()},Annotation(a){return e.findAny(a).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,a,f){return y._schemaTryGet(e,a,f,!1)}static schemaTryGetDrillField(e,a,f){return y._schemaTryGet(e,a,f,!0)}static _schemaTryGet(e,a,f,l){let R=e.fields;for(const fe of f??[]){const V=R.find(he=>he.name===fe);if(V===void 0)throw new Error(`${fe} not found`);if(V.kind==="join"||l&&V.kind==="view"){R=V.schema.fields;continue}if(V.kind==="dimension"||V.kind==="measure"){if(V.type.kind==="record_type"){R=V.type.fields.map(he=>({kind:V.kind,...he}));continue}else if(V.type.kind==="array_type"&&V.type.element_type.kind==="record_type"){R=V.type.element_type.fields.map(he=>({kind:V.kind,...he}));continue}}throw new Error(`${fe} is not a join, record, or repeated record`)}return R.find(fe=>fe.name===a)}static schemaGet(e,a,f){const l=y.schemaTryGet(e,a,f);if(l===void 0)throw new Error(`${a} not found`);return l}static schemaGetDrillField(e,a,f){const l=y.schemaTryGetDrillField(e,a,f);if(l===void 0)throw new Error(`${a} not found`);return l}static schemaMerge(e,a){return{fields:[...e.fields,...a.fields]}}static tagFor(e,a="# "){var f,l;const R=(l=(f=e.annotations)===null||f===void 0?void 0:f.map(fe=>fe.value))===null||l===void 0?void 0:l.filter(fe=>fe.startsWith(a)),J=new S.TagParser;for(const fe of R??[])J.parseAnnotation(fe);return J.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 y.tagFor(e,"#(malloy) ").has("calculation")}}function o(m){return Array.isArray(m)||typeof m=="string"||typeof m=="number"||typeof m=="boolean"}class d extends y{constructor(e,a){super(),this.node=e,this.children=a,this.originalChildren=[...a],a.forEach(f=>f.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,a){this.edit(),this.children.splice(a,0,e),e.parent=this}add(e){this.edit(),this.children.push(e),e.parent=this}remove(e){const a=this.children.findIndex(f=>f===e);if(a===-1)return this;this.edit(),this.children.splice(a,1)}build(){if(!this.edited)return this.node;const e=this.children.map(a=>a.build());return this.edited=!1,this.originalChildren=[...this.children],this.node=e,e}findAny(e){if(e.length===0)return this;const[a,...f]=e;if(typeof a!="number")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);return this.children[a].findAny(f)}findIndex(e){return this.children.findIndex(e)}indexOf(e){return this.children.indexOf(e)}}class t extends y{constructor(e,a){super(),this.node=e,this.children=a;for(const f in a){const l=a[f];l&&!o(l)&&(l.parent=this)}}build(){if(!this.edited)return this.node;let e=this.node;for(const a in this.children){const f=this.children[a];f===void 0?e={...e,[a]:void 0}:o(f)?this.edited&&(e={...e,[a]:f}):e={...e,[a]:f.build()}}return this.node=e,this.edited=!1,e}findAny(e){if(e.length===0)return this;const[a,...f]=e;if(typeof a!="string")throw new Error(`${this.constructor.name} is a ASTListNode and thus cannot contain a ${a}`);const l=this.children[a];if(o(l))throw new Error(`${this.constructor.name}.${a} refers to a basic type, not an ASTNode`);return l._find(f)}}class D extends t{constructor(e){var a,f;let l=e.source;if(l===void 0){if(e.model===void 0)throw new Error("Need a model or source");if(e.query){const V=e.query.definition;if(V.kind==="arrow"&&V.source.kind==="source_reference"){const he=V.source.name;if(l=e.model.entries.find(be=>be.name===he),l===void 0)throw new Error(`Model does not contain source or query named ${he}`)}}if(l===void 0&&(l=e.model.entries[0]),l===void 0)throw new Error("Model does not contain any sources or queries")}const R=I(l),J=(a=e.query)!==null&&a!==void 0?a:{definition:{kind:"arrow",source:{kind:"source_reference",name:R.name},view:{kind:"segment",operations:[]}}},fe=(f=e.model)!==null&&f!==void 0?f:{entries:[R],anonymous_queries:[]};super(J,{definition:u.ASTQueryDefinition.from(J.definition),annotations:J.annotations&&new We(J.annotations)}),this.model=fe,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 We([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return ze(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}setViewToEmptySegment(){if(!(this.definition instanceof Ae))throw new Error("Must set source before setting view");return this.definition=new Ae({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 Ae&&this.definition.view instanceof De&&this.definition.view.operations.length===0}getOrAddDefaultSegment(){return this.definition.getOrAddDefaultSegment()}setSource(e){if(this.definition instanceof Ae&&this.definition.source instanceof tt&&this.definition.source.name===e)return;if(this.model.entries.find(f=>f.name===e)===void 0)throw new Error(`Source ${e} is not defined in model`);this.definition=new Ae({kind:"arrow",source:{kind:"source_reference",name:e},view:this.definition instanceof Ae?this.definition.view.build():{kind:"segment",operations:[]}})}setQueryHead(e){const a=this.model.entries.find(f=>f.name===e);if(a===void 0||a.kind!=="query")throw new Error(`No query named ${e} in the model`);this.definition=new Pe({kind:"query_reference",name:e})}getQueryInfo(e){const a=this.model.entries.find(f=>f.name===e);if(a===void 0)throw new Error(`Query ${e} is not defined in model`);if(a.kind!=="query")throw new Error(`Model entry ${e} is not a query`);return a}toMalloy(){return E.queryToMalloy(this.build())}build(){return super.build()}setView(e){if(!(this.definition instanceof Ae))throw new Error("Must set source before setting view");return this.definition=new Ae({kind:"arrow",source:this.definition.source.build(),view:{kind:"view_reference",name:e}}),this.definition.view.as.ReferenceViewDefinition()}_getInheritedAnnotations(e){var a;return e instanceof Pe?(a=this.getQueryInfo(e.name).annotations)!==null&&a!==void 0?a:[]:e instanceof pe?this._getInheritedAnnotations(e.base):e instanceof Ae?e.view.getInheritedAnnotations():[]}getInheritedAnnotations(){return this._getInheritedAnnotations(this.definition)}}u.ASTQuery=D;class x extends t{constructor(e){super(e,{name:e.name,path:e.path,parameters:e.parameters&&new ee(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 a=new ee([]);return e.parameters=a,a}static setParameter(e,a,f){const l=x.tryGetParameter(e,a);if(l!==void 0){l.value=u.ASTLiteralValue.from(u.ASTLiteralValue.makeLiteral(f));return}return e.getOrAddParameters().addParameter(a,f)}static tryGetParameter(e,a){if(e.parameters!==void 0){for(const f of e.parameters.iter())if(f.name===a)return f}}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}}u.ASTReference=x;class Z extends x{get segment(){const e=this.parent;return e instanceof F||e instanceof He?e.field.segment:e instanceof nt||e instanceof ot?e.segment:e.list.segment}getReferenceSchema(){return this.parent instanceof qe?this.segment.getOutputSchema():this.segment.getInputSchema()}getFieldInfo(){const e=this.getReferenceSchema();return y.schemaGet(e,this.name,this.path)}}u.ASTFieldReference=Z;class ee extends d{constructor(e){super(e,e.map(a=>new ce(a)))}get parameters(){return this.children}addParameter(e,a){this.add(new ce({name:e,value:u.ASTLiteralValue.makeLiteral(a)}))}}u.ASTParameterValueList=ee;class ce extends t{constructor(e){super(e,{name:e.name,value:u.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}}u.ASTParameterValue=ce,u.ASTLiteralValue={from(m){switch(m.kind){case"string_literal":return new O(m);case"number_literal":return new b(m);case"boolean_literal":return new B(m);case"date_literal":return new de(m);case"timestamp_literal":return new Fe(m);case"null_literal":return new A(m);case"filter_expression_literal":return new ve(m)}},makeLiteral(m){if(m!==null&&typeof m=="object"&&"kind"in m)return m;if(typeof m=="string")return{kind:"string_literal",string_value:m};if(typeof m=="boolean")return{kind:"boolean_literal",boolean_value:m};if(typeof m=="number")return{kind:"number_literal",number_value:m};if(m===null)return{kind:"null_literal"};if("date"in m){const e=m.granularity,a=ue(m.date);return ie(e)?{kind:"date_literal",date_value:a,granularity:e}:{kind:"timestamp_literal",timestamp_value:a,granularity:e}}throw new Error("Unknown literal type")}};class O extends t{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"}}}u.ASTStringLiteralValue=O;class A extends t{constructor(e){super(e,{kind:e.kind}),this.node=e,this.kind="null_literal"}get fieldType(){}}u.ASTNullLiteralValue=A;class b extends t{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"}}}u.ASTNumberLiteralValue=b;class B extends t{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"}}}u.ASTBooleanLiteralValue=B;class de extends t{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}}}u.ASTDateLiteralValue=de;class Fe extends t{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}}}u.ASTTimestampLiteralValue=Fe;class ve extends t{constructor(e){super(e,{kind:e.kind,filter_expression_value:e.filter_expression_value}),this.node=e,this.kind="filter_expression_literal"}get fieldType(){}}u.ASTFilterExpressionLiteralValue=ve;class Ye extends y{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")}}u.ASTUnimplemented=Ye,u.ASTQueryArrowSource={from(m){switch(m.kind){case"refinement":return new pe(m);case"source_reference":return new tt(m)}}},u.ASTQueryDefinition={from(m){switch(m.kind){case"arrow":return new Ae(m);case"query_reference":return new Pe(m);case"refinement":return new pe(m)}}};class Ae extends t{constructor(e){super(e,{kind:"arrow",source:u.ASTQueryArrowSource.from(e.source),view:Re.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 De?this.view.reorderFields(e):this.query.getOrAddAnnotations().setTagProperty(["field_order"],e)}}u.ASTArrowQueryDefinition=Ae;class pe extends t{constructor(e){super(e,{kind:"refinement",base:u.ASTQueryDefinition.from(e.base),refinement:Re.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(),a=this.refinement.getRefinementSchema();return D.schemaMerge(e,a)}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()}}u.ASTRefinementQueryDefinition=pe;class Pe extends t{constructor(e){super(e,{kind:"query_reference",name:e.name,path:e.path,parameters:e.parameters&&new ee(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 pe({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 x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}getOutputSchema(){return this.getSourceInfo().schema}getSourceInfo(){const a=this.query.model.entries.find(f=>f.name===this.name);if(a===void 0)throw new Error(`Query not found with name ${this.name}`);return a}}u.ASTReferenceQueryDefinition=Pe;class tt extends t{constructor(e){super(e,{kind:"source_reference",name:e.name,path:e.path,parameters:e.parameters&&new ee(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(a=>a.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 a=new pe({kind:"refinement",base:{...this.build(),kind:"query_reference"},refinement:{kind:"segment",operations:[]}});return this.arrow.source=a,a.refinement.as.SegmentViewDefinition()}propagateUp(e){}propagateDown(e){}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}get query(){return this.parent.parent.as.Query()}getSourceParameters(){var e;const a=this.getSourceInfo();return a.kind==="query"?[]:(e=a.parameters)!==null&&e!==void 0?e:[]}areRequiredParametersSet(){const e=this.getSourceParameters();for(const a of e){if(a.default_value!==void 0)continue;if(this.tryGetParameter(a.name)===void 0)return!1}return!0}}u.ASTReferenceQueryArrowSource=tt;const Re={from(m){switch(m.kind){case"arrow":return new at(m);case"view_reference":return new Ee(m);case"segment":return new De(m);case"refinement":return new Ce(m)}}};function Ge(m,e){const a=m.parent;a instanceof Ae?a.view=e:a instanceof pe?a.refinement=e:a instanceof _e?a.definition=e:a instanceof at?a.source===m?a.source=e:a.view=e:a.base===m?a.base=e:a.refinement=e}function it(m,e,a=[]){const f=m.getInputSchema(),l=D.schemaGet(f,e,a);if(l===void 0)return{isValidViewRefinement:!1,error:`${e} is not defined`};if(l.kind!=="view")return{isValidViewRefinement:!1,error:`${e} is not a view`};const R=m.getOutputSchema();for(const J of l.schema.fields)if(D.schemaTryGet(R,J.name,[]))return{isValidViewRefinement:!1,error:`Cannot refine with ${e} because stage already has an output field named ${J.name}`};return{isValidViewRefinement:!0}}class Ee extends t{constructor(e){super(e,{kind:"view_reference",name:e.name,path:e.path,parameters:e.parameters&&new ee(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=Ce.segmentRefinementOf(this.build());return Ge(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,a){const{error:f}=this.isValidViewRefinement(e,a);if(f)throw new Error(f);const l=Ce.viewRefinementOf(this.build(),e,a);return Ge(this,l),l.refinement.as.ReferenceViewDefinition()}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}isValidViewRefinement(e,a){return it(this,e,a)}getInputSchema(){return At(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){return this.name}getViewInfo(){const e=this.getInputSchema(),a=y.schemaGet(e,this.name,this.path);if(a.kind!=="view")throw new Error("Not a view");return a}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 x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}}u.ASTReferenceViewDefinition=Ee;class at extends t{constructor(e){super(e,{kind:"arrow",source:Re.from(e.source),view:Re.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,a){return this.view.addViewRefinement(e,a)}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}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,a){return it(this,e,a)}propagateUp(e){this.propagateDown(e)}propagateDown(e){e(this.view),this.view.propagateDown(e)}getInheritedAnnotations(){return[]}}u.ASTArrowViewDefinition=at;class Ce extends t{constructor(e){super(e,{kind:"refinement",base:Re.from(e.base),refinement:Re.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 a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}getOrAddDefaultSegment(){return this.refinement.getOrAddDefaultSegment()}addEmptyRefinement(){return this.refinement.addEmptyRefinement()}addViewRefinement(e,a){return this.refinement.addViewRefinement(e,a)}getInputSchema(){return At(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getRefinementSchema(){return y.schemaMerge(this.base.getRefinementSchema(),this.refinement.getRefinementSchema())}getImplicitName(){return this.base.getImplicitName()}isValidViewRefinement(e,a){return it(this,e,a)}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,a,f){return new Ce({kind:"refinement",base:e,refinement:{kind:"view_reference",name:a,path:f}})}static segmentRefinementOf(e){return new Ce({kind:"refinement",base:e,refinement:{kind:"segment",operations:[]}})}}u.ASTRefinementViewDefinition=Ce;class De extends t{constructor(e){super(e,{kind:"segment",operations:new st(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 a of this.operations.iter()){if(a instanceof ke||a instanceof Oe)return!0;if(a instanceof Y){if(!a.view.definition.isRunnable())return!1;e=!0}}return e}get operations(){return this.children.operations}convertToNest(e){const a=Re.from({kind:"segment",operations:[{kind:"nest",name:e,view:{definition:this.build()}}]});Ge(this,a)}renameOrderBys(e,a){for(const f of this.operations.iter())f instanceof qe&&f.name===e&&f.setField(a)}propagateUp(e){this.parent.propagateUp(e)}propagateDown(e){}removeOrderBys(e){for(const a of this.operations.iter())a instanceof qe&&a.name===e&&a.delete()}reorderFields(e){const a=[],f=[],l={};let R=!1;for(const V of this.operations.iter()){if((V instanceof ke||V instanceof Oe||V instanceof Y)&&e.includes(V.name)){l[V.name]=V,R=!0;continue}R?f.push(V):a.push(V)}const J=[];for(const V of e){const he=l[V];if(he===void 0)throw new Error(`No field named ${V}`);J.push(he)}const fe=[...a,...J,...f];this.operations.items=fe}renameField(e,a){if(e.name===a)return;const f=this.getOutputSchema();if(y.schemaTryGet(f,a,[]))throw new Error(`Output already has a field named ${a}`);const l=e.name;e.name=a,this.propagateUp(R=>{R instanceof De&&R.renameOrderBys(l,a)})}addOrderBy(e,a){const f=this.getOutputSchema();try{y.schemaGet(f,e,[])}catch{throw new Error(`No such field ${e} in stage output`)}for(const R of this.operations.iter())if(R instanceof qe&&R.name===e)return R.direction=a,R;const l=new qe({kind:"order_by",field_reference:{name:e},direction:a});return this.addOperation(l),l}addEmptyNest(e){const a=new Y({kind:"nest",name:e,view:{definition:{kind:"segment",operations:[]}}});return this.addOperation(a),a}firstIndexOfOperationType(e){return this.operations.findIndex(a=>a.kind===e)}findInsertionPoint(e){const a=this.firstIndexOfOperationType(e);if(a>-1){let R=a;for(;this.operations.index(R)&&this.operations.index(R).kind===e;)R++;return R}const f=this.DEFAULT_INSERTION_ORDER.indexOf(e);if(f===-1)throw new Error(`Operation ${e} is not supported for \`findInsertionPoint\``);const l=this.DEFAULT_INSERTION_ORDER.slice(f+1);for(const R of l){const J=this.firstIndexOfOperationType(R);if(J>-1)return J}return this.operations.length}getFieldNamed(e){const a=this.tryGetFieldNamed(e);if(a===void 0)throw new Error("No such field");return a}hasFieldNamed(e){return this.tryGetFieldNamed(e)!==void 0}hasField(e,a){return this.tryGetField(e,a)!==void 0}getField(e,a){const f=this.tryGetField(e,a);if(f===void 0)throw new Error("No such field");return f}tryGetField(e,a){for(const f of this.operations.iter())if(f instanceof Oe||f instanceof ke){const l=f.field.getReference();if(l&&l.name===e&&Se(l.path,a))return f}else if(f instanceof Y){if(f.view instanceof Ee)return f}else if(f instanceof C){const l=f.expression.field.getReference();if(l&&l.name===e&&Se(l.path,a))return f}}tryGetFieldNamed(e){for(const a of this.operations.iter())if((a instanceof Oe||a instanceof ke||a instanceof Y||a instanceof C)&&a.name===e)return a}getGroupBy(e){for(const a of this.operations.iter())if(a instanceof Oe&&a.name===e)return a}removeGroupBy(e){var a;return(a=this.getGroupBy(e))===null||a===void 0||a.delete(),this}addGroupBy(e,a=[],f){const l=this.makeField(e,a,f,"dimension");return this.addOperation(l),l}addDrill(e){const a=new Qe({kind:"drill",...e});return this.addOperation(a),a}addWhere(e,a,f){const l=Array.isArray(a)?a:[],R=f===void 0?a:f,J=typeof R=="string"?R:Me(R),fe=this.getInputSchema(),V=D.schemaGet(fe,e,l);Xe(V,R);const he=new we({kind:"where",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:l},filter:J}});return this.addOperation(he),he}addHaving(e,a,f){const l=Array.isArray(a)?a:[],R=f===void 0?a:f,J=typeof R=="string"?R:Me(R),fe=this.getInputSchema(),V=D.schemaGet(fe,e,l);Xe(V,R);const he=new rt({kind:"having",filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:l},filter:J}});return this.addOperation(he),he}addCalculateMovingAverage(e,a,f,l,R){const J=new C({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:a,path:f},rows_preceding:l,rows_following:R}}});return this.addOperation(J),J}addTimeGroupBy(e,a,f,l){const R=this.getInputSchema(),J=y.schemaGet(R,e,a);if(J===void 0)throw new Error(`No such field ${e}`);if(J.kind!=="dimension")throw new Error(`Cannot group by non-dimension ${e}`);if(J.type.kind!==l)throw new Error(`${e} is not a ${l}`);const fe=new Oe({kind:"group_by",field:{expression:{kind:"time_truncation",field_reference:{name:e,path:a},truncation:f}}});return this.addOperation(fe),fe}addDateGroupBy(e,a,f){const l=f===void 0?a:f,R=f===void 0?[]:a;return this.addTimeGroupBy(e,R,l,"date_type")}addTimestampGroupBy(e,a,f){const l=f===void 0?a:f,R=f===void 0?[]:a;return this.addTimeGroupBy(e,R,l,"timestamp_type")}addTimestamptzGroupBy(e,a,f){const l=f===void 0?a:f,R=f===void 0?[]:a;return this.addTimeGroupBy(e,R,l,"timestamptz_type")}addAggregate(e,a=[],f){const l=this.makeField(e,a,f,"measure");return this.addOperation(l),l}addNest(e,a){const f=this.makeField(e,[],a,"view");return this.addOperation(f),f}makeField(e,a,f,l){const R=this.getInputSchema(),J=y.schemaGet(R,e,a);if(J===void 0)throw new Error(`No such field ${e}`);if(J.kind!==l){const fe=ct(l),V=l;throw new Error(`Cannot ${fe} non-${V} ${e}`)}return l==="dimension"?Oe.fromReference(e,a,f):l==="measure"?ke.fromReference(e,a,f):Y.fromReference(e,a,f)}addOperation(e){if((e instanceof Oe||e instanceof ke||e instanceof Y||e instanceof C)&&this.hasFieldNamed(e.name))throw new Error(`Query already has a field named ${e.name}`);const a=this.findInsertionPoint(e.kind);return this.operations.insert(e,a),e}getRefinementSchema(){const e=[];for(const a of this.operations.iter())(a instanceof Oe||a instanceof ke||a instanceof Y||a instanceof C)&&e.push(a.getFieldInfo());return{fields:e}}setLimit(e){Ze.validateLimit(e);const a=[...this.operations.iter()].find(u.ASTViewOperation.isLimit);a?a.limit=e:this.operations.add(new Ze({kind:"limit",limit:e}))}getOrAddDefaultSegment(){return this}addEmptyRefinement(){const e=Ce.segmentRefinementOf(this.build());return Ge(this,e),e.refinement.as.SegmentViewDefinition()}addViewRefinement(e,a){const{error:f}=this.isValidViewRefinement(e,a);if(f)throw new Error(f);const l=Ce.viewRefinementOf(this.build(),e,a);return Ge(this,l),l.refinement.as.ReferenceViewDefinition()}getInputSchema(){return At(this.parent)}getOutputSchema(){return this.parent.getOutputSchema()}getImplicitName(){}isValidViewRefinement(e,a){return it(this,e,a)}getInheritedAnnotations(){return[]}}u.ASTSegmentViewDefinition=De;class st extends d{constructor(e){super(e,e.map(a=>u.ASTViewOperation.from(a)))}get items(){return this.children}set items(e){this.edit(),this.children=e}get segment(){return this.parent.as.SegmentViewDefinition()}}u.ASTViewOperationList=st,u.ASTViewOperation={from(m){switch(m.kind){case"group_by":return new Oe(m);case"aggregate":return new ke(m);case"order_by":return new qe(m);case"nest":return new Y(m);case"limit":return new Ze(m);case"where":return new we(m);case"drill":return new Qe(m);case"having":return new rt(m);case"calculate":return new C(m)}},isLimit(m){return m instanceof Ze}};class qe extends t{constructor(e){super(e,{kind:"order_by",field_reference:new Z(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 a=this.list.segment.getOutputSchema();y.schemaGet(a,e,[]),this.edit(),this.children.field_reference=new Z({name:e})}setDirection(e){this.direction=e}}u.ASTOrderByViewOperation=qe;class Oe extends t{constructor(e){super(e,{kind:"group_by",name:e.name,field:new xe(e.field)}),this.node=e,this.kind="group_by"}get field(){return this.children.field}get name(){var e;const a=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(a===void 0)throw new Error("Group by does not have a name");return a}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 De&&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 ze(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}static fromReference(e,a,f){return new Oe({kind:"group_by",name:f,field:{expression:{kind:"field_reference",name:e,path:a}}})}}u.ASTGroupByViewOperation=Oe;class ke extends t{constructor(e){super(e,{kind:"aggregate",name:e.name,field:new xe(e.field)}),this.node=e,this.kind="aggregate"}get field(){return this.children.field}get name(){var e;const a=(e=this.children.name)!==null&&e!==void 0?e:this.field.name;if(a===void 0)throw new Error("Aggregate does not have a name");return a}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,a,f=0,l=[]){if(!(this.field.expression instanceof Je))throw new Error("Cannot convert aggregate to smoothed metric unless it is a field reference");this.list.remove(this);const R=new C({kind:"calculate",name:e,field:{expression:{kind:"moving_average",field_reference:{name:this.field.expression.name,path:this.field.expression.path},rows_preceding:a,rows_following:f,partition_fields:l.map(J=>({name:J}))}}});return this.list.add(R),R}get list(){return this.parent.as.ViewOperationList()}delete(){this.list.remove(this),this.list.segment.propagateUp(e=>{e instanceof De&&e.removeOrderBys(this.name)})}getFieldInfo(){return{annotations:[{value:S.Tag.withPrefix("#(malloy) ").set(["calculation"]).toString()}],kind:"dimension",name:this.name,type:this.field.type}}getOrAddAnnotations(){return this.field.getOrAddAnnotations()}getInheritedTag(e="# "){return ze(e,this.field.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}addWhere(e,a,f){const l=Array.isArray(a)?a:[],R=f===void 0?a:f,J=typeof R=="string"?R:Me(R),fe=this.list.segment.getInputSchema(),V=D.schemaGet(fe,e,l);Xe(V,R);const he={filter:{kind:"filter_string",expression:{kind:"field_reference",name:e,path:l},filter:J}};if(this.field.expression instanceof F)return this.field.expression.where.add(new $(he)),this.field.expression;if(this.field.expression instanceof Je){const be=this.field.expression.build();return this.field.expression=new F({kind:"filtered_field",field_reference:{name:be.name,path:be.path,parameters:be.parameters},where:[he]}),this.field.expression}else throw new Error("This kind of expression does not support addWhere")}static fromReference(e,a,f){return new ke({kind:"aggregate",name:f,field:{expression:{kind:"field_reference",name:e,path:a}}})}}u.ASTAggregateViewOperation=ke;class xe extends t{constructor(e){super(e,{expression:u.ASTExpression.from(e.expression),annotations:e.annotations&&new We(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 je))return this.expression.getReference()}getOrAddAnnotations(){if(this.annotations)return this.annotations;this.edit();const e=new We([]);return this.children.annotations=e,e.parent=this,e}getInheritedTag(e="# "){return ze(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}get segment(){return this.parent.list.segment}getInheritedAnnotations(){return this.expression.getInheritedAnnotations()}}u.ASTField=xe,u.ASTExpression={from(m){switch(m.kind){case"field_reference":return new Je(m);case"filtered_field":return new F(m);case"time_truncation":return new He(m);case"literal_value":return new je(m);case"moving_average":return new h(m)}}};class Je extends t{constructor(e){super(e,{kind:e.kind,name:e.name,path:e.path,parameters:e.parameters&&new ee(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 xe)return e.segment;if(e instanceof nt||e instanceof ot)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(),f=this.parent instanceof ot&&this.parent.parent instanceof Qe?y.schemaGetDrillField(e,this.name,this.path):y.schemaGet(e,this.name,this.path);if(f.kind!=="dimension"&&f.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return f}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}getOrAddParameters(){return x.getOrAddParameters(this)}setParameter(e,a){return x.setParameter(this,e,a)}tryGetParameter(e){return x.tryGetParameter(this,e)}}u.ASTReferenceExpression=Je;class He extends t{constructor(e){super(e,{kind:e.kind,field_reference:new Z(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(),a=y.schemaGet(e,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){const e=this.getFieldInfo();if(e.type.kind==="date_type")return{...e.type,timeframe:z(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:[]}}u.ASTTimeTruncationExpression=He;class je extends t{constructor(e){super(e,{kind:e.kind,literal_value:u.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(){}}u.ASTLiteralValueExpression=je;class q extends d{constructor(e){super(e,e.map(a=>new Z(a)))}}u.ASTFieldReferenceList=q;class h extends t{constructor(e){super(e,{kind:e.kind,field_reference:new Z(e.field_reference),rows_preceding:e.rows_preceding,rows_following:e.rows_following,partition_fields:new q(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 q(e)}getFieldInfo(){const e=this.field.segment.getInputSchema(),a=y.schemaGet(e,this.name,this.fieldReference.path);if(a.kind!=="dimension"&&a.kind!=="measure")throw new Error("Invalid field for ASTReferenceExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}u.ASTMovingAverageExpression=h;class $ extends t{constructor(e){super(e,{filter:u.ASTFilter.from(e.filter)})}get filter(){return this.children.filter}get list(){return this.parent.as.FilterOperationList()}delete(){this.list.remove(this)}}u.ASTFilterOperation=$;class k extends d{constructor(e){super(e,e.map(a=>new $(a)))}get expression(){return this.parent.as.FilteredFieldExpression()}}u.ASTFilterOperationList=k;class F extends t{constructor(e){super(e,{kind:e.kind,field_reference:new Z(e.field_reference),where:new k(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(),a=y.schemaGet(e,this.name,this.fieldReference.path);if(a.kind!=="measure")throw new Error("Invalid field for ASTFilteredFieldExpression");return a}get fieldType(){return this.getFieldInfo().type}getInheritedAnnotations(){var e;return(e=this.getFieldInfo().annotations)!==null&&e!==void 0?e:[]}}u.ASTFilteredFieldExpression=F;function z(m){switch(m){case"day":case"week":case"month":case"year":case"quarter":return m;default:throw new Error("Invalid date timeframe")}}class Y extends t{constructor(e){super(e,{kind:"nest",name:e.name,view:new _e(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 a=(e=this.children.name)!==null&&e!==void 0?e:this.view.name;if(a===void 0)throw new Error("Nest does not have a name");return a}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 ze(e,this.view.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}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,a,f){return new Y({kind:"nest",name:f,view:{definition:{kind:"view_reference",name:e,path:a}}})}}u.ASTNestViewOperation=Y;class we extends t{constructor(e){super(e,{kind:"where",filter:u.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)}}u.ASTWhereViewOperation=we;class Qe extends t{constructor(e){super(e,{kind:"drill",filter:u.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)}}u.ASTDrillViewOperation=Qe;class rt extends t{constructor(e){super(e,{kind:"having",filter:u.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)}}u.ASTHavingViewOperation=rt;class C extends t{constructor(e){super(e,{kind:"calculate",field:new xe(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:S.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)}}u.ASTCalculateViewOperation=C,u.ASTFilter={from(m){switch(m.kind){case"filter_string":return new nt(m);case"literal_equality":return new ot(m)}},getSegment(m){const e=m.parent;return e instanceof $?e.list.expression.field.segment:e.list.segment}};class nt extends t{constructor(e){super(e,{kind:"filter_string",expression:u.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 a=this.getFilterType();_(this.filterString,a),this.filterString=e}get segment(){return u.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 lt(e)}setFilter(e){const a=this.getFilterType();if(a!==e.kind)throw new Error(`Invalid filter: expected type ${a}, got ${e.kind}`);this.filterString=Me(e)}getFilter(){const e=this.getFilterType();return _(this.filterString,e)}}u.ASTFilterWithFilterString=nt;class ot extends t{constructor(e){super(e,{kind:"literal_equality",expression:u.ASTExpression.from(e.expression),value:u.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 u.ASTFilter.getSegment(this)}}u.ASTFilterWithLiteralEquality=ot;class _e extends t{constructor(e){super(e,{definition:Re.from(e.definition),annotations:e.annotations&&new We(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 De?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 We([]);return this.children.annotations=e,e.parent=this,e}getInheritedAnnotations(){return this.definition.getInheritedAnnotations()}getInheritedTag(e="# "){return ze(e,this.getInheritedAnnotations())}getIntrinsicTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getIntrinsicTag(e))!==null&&f!==void 0?f:new S.Tag}getTag(e="# "){var a,f;return(f=(a=this.annotations)===null||a===void 0?void 0:a.getTag(e))!==null&&f!==void 0?f:this.getInheritedTag(e)}setTagProperty(e,a=null,f="# "){this.getOrAddAnnotations().setTagProperty(e,a,f)}removeTagProperty(e,a="# "){this.getTag().has(...e)&&this.getOrAddAnnotations().removeTagProperty(e,a)}}u.ASTView=_e;class Ze extends t{get limit(){return this.children.limit}set limit(e){Ze.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")}}u.ASTLimitViewOperation=Ze;function ct(m){switch(m){case"dimension":return"group by";case"measure":return"aggregate";case"view":return"nest";case"join":return"join";case"calculate":return"calculate"}}function gt(m){return m}class We extends d{constructor(e){super(e,e.map(a=>new Ke(a)))}get items(){return this.children}getInheritedAnnotations(){return this.parent.getInheritedAnnotations()}getIntrinsicTag(e="# "){return ze(e,this.items)}getTag(e="# "){return ze(e,this.items,this.getInheritedAnnotations())}get annotations(){return this.children.map(e=>e.node)}setTagProperty(e,a=null,f="# "){let l;for(let R=this.items.length-1;R>=0;R--){const J=this.index(R);if(J.hasPrefix(f)&&(l=J,J.hasIntrinsicTagProperty(e))){J.setTagProperty(e,a);return}}l?l.setTagProperty(e,a):this.add(new Ke({value:new S.Tag({prefix:f}).set(e,a).toString()}))}removeTagProperty(e,a="# "){let f;for(let l=this.items.length-1;l>=0;l--){const R=this.index(l);if(R.hasPrefix(a)&&(f=R,R.hasIntrinsicTagProperty(e))){R.removeTagProperty(e);return}}f?f.removeTagProperty(e):this.add(new Ke({value:new S.Tag({prefix:a}).unset(...e).toString()}))}}u.ASTAnnotationList=We;class Ke extends t{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 S.TagParser;return e.parseAnnotation(this.value),e.finish()}getTag(){const e=new S.TagParser;for(const a of this.list.getInheritedAnnotations())e.parseAnnotation(a.value);for(let a=0;a<=this.index;a++)e.parseAnnotation(this.list.index(a).value);return e.finish()}hasPrefix(e){return this.value.startsWith(e)}hasIntrinsicTagProperty(e){return this.getIntrinsicTag().has(...e)}setTagProperty(e,a){this.value=this.getIntrinsicTag().set(e,a).toString()}removeTagProperty(e){this.value=this.getTag().unset(...e).toString()}}u.ASTAnnotation=Ke;function ze(m,e=[],a=[]){const f=new S.TagParser;for(const R of a)f.parseAnnotation(R.value);const l=e.map(R=>R.value).filter(R=>typeof m=="string"?R.startsWith(m):R.match(m));for(const R of l)f.parseAnnotation(R);return f.finish()}function Me(m){switch(m.kind){case"string":return w.StringFilterExpression.unparse(m.parsed);case"number":return w.NumberFilterExpression.unparse(m.parsed);case"boolean":return w.BooleanFilterExpression.unparse(m.parsed);case"timestamp":case"timestamptz":case"date":return w.TemporalFilterExpression.unparse(m.parsed)}}function _(m,e){function a(f){const l=f.filter(R=>R.severity==="error");if(l.length!==0)throw new Error(`Invalid Malloy filter string: ${l[0].message}`)}switch(e){case"string":{const f=w.StringFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"number":{const f=w.NumberFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"boolean":{const f=w.BooleanFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"timestamp":case"timestamptz":case"date":{const f=w.TemporalFilterExpression.parse(m);return a(f.log),{kind:e,parsed:f.parsed}}case"other":throw new Error("Not implemented")}}function I(m){return"kind"in m?m:{...m,kind:"source"}}function ie(m){switch(m){case"year":case"quarter":case"month":case"week":case"day":return!0;default:return!1}}function W(m,e){return m.toString().padStart(e,"0")}function ue(m){const e=W(m.getUTCFullYear(),4),a=W(m.getUTCMonth()+1,2),f=W(m.getUTCDate(),2),l=W(m.getUTCHours(),2),R=W(m.getUTCMinutes(),2),J=W(m.getUTCSeconds(),2);return`${e}-${a}-${f} ${l}:${R}:${J}`}function Se(m,e){const a=m??[],f=e??[];return a.length===f.length&&a.every((l,R)=>l===f[R])}function lt(m){switch(m.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 Xe(m,e){if(m.kind!=="dimension"&&m.kind!=="measure")throw new Error(`Cannot filter by field of type ${m.kind}`);const a=lt(m);if(typeof e=="string")_(e,a);else if(e.kind!==a)throw new Error(`Invalid filter for field ${m.name}; expected type ${a}, but got ${e.kind}`)}function At(m){if(m instanceof Ae)return m.getSourceInfo().schema;if(m instanceof pe)throw new Error("unimplemented");return m.getInputSchema()}})(mt)),mt}var jr;function Ei(){return jr||(jr=1,(function(u){var re=Et&&Et.__createBinding||(Object.create?(function(N,E,S,w){w===void 0&&(w=S);var y=Object.getOwnPropertyDescriptor(E,S);(!y||("get"in y?!E.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return E[S]}}),Object.defineProperty(N,w,y)}):(function(N,E,S,w){w===void 0&&(w=S),N[w]=E[S]})),j=Et&&Et.__exportStar||function(N,E){for(var S in N)S!=="default"&&!Object.prototype.hasOwnProperty.call(E,S)&&re(E,N,S)};Object.defineProperty(u,"__esModule",{value:!0}),j(Oi(),u)})(Et)),Et}var zr=Ei();const ki=ci(zr),Li=pi({__proto__:null,default:ki},[zr]);export{Fi as a,zr as d,Li as i,Ai as r};
@@ -0,0 +1,23 @@
1
+ var te={},ae={},me;function $e(){if(me)return ae;me=1,Object.defineProperty(ae,"__esModule",{value:!0}),ae.Tag=void 0,ae.interfaceFromTag=E,ae.interfaceFromDict=M;class a{get parent(){return this._parent}get root(){let i=this;for(;i._parent!==void 0;)i=i._parent;return i}static id(i){let e=a.ids.get(i);return e===void 0&&(e=a.nextTagId,a.ids.set(i,e),a.nextTagId+=1),e}peek(i=0){const e=" ".repeat(i);let t=`#${a.id(this)}`;if(this.properties===void 0&&this.eq&&typeof this.eq=="string")return t+`=${this.eq}`;if(t+=" {",this.eq!==void 0&&(Array.isArray(this.eq)?t+=`
2
+ ${e} =: [
3
+ ${e} ${this.eq.map(n=>n.peek(i+4)).join(`
4
+ ${e} `)}
5
+ ${e} ]`:t+=`
6
+ ${e} =: ${this.eq}`),this.properties)for(const n in this.properties)t+=`
7
+ ${e} ${n}: ${this.properties[n].peek(i+2)}`;return t+=`
8
+ ${e}}`,t}constructor(i={},e){if(this._read=!1,e!==void 0&&(this._parent=e),i.eq!==void 0&&(Array.isArray(i.eq)?this.eq=i.eq.map(t=>t instanceof a?t:new a(t,this)):this.eq=i.eq),i.properties){this.properties={};for(const[t,n]of Object.entries(i.properties))this.properties[t]=n instanceof a?n:new a(n,this)}i.deleted&&(this.deleted=i.deleted),i.prefix&&(this.prefix=i.prefix)}static withPrefix(i){return new a({prefix:i})}tag(...i){return this.find(i)}text(...i){var e;const t=(e=this.find(i))===null||e===void 0?void 0:e.getEq();if(!(t===void 0||Array.isArray(t)))return t instanceof Date?t.toISOString():String(t)}scalarType(...i){var e;const t=i.length>0?(e=this.find(i))===null||e===void 0?void 0:e.getEq():this.getEq();if(!(t===void 0||Array.isArray(t)))return t instanceof Date?"date":typeof t}numeric(...i){var e;const t=(e=this.find(i))===null||e===void 0?void 0:e.getEq();if(typeof t=="number")return t;if(typeof t=="string"){const n=Number.parseFloat(t);if(!Number.isNaN(n))return n}}boolean(...i){var e;const t=(e=this.find(i))===null||e===void 0?void 0:e.getEq();if(typeof t=="boolean")return t}isTrue(...i){var e;return((e=this.find(i))===null||e===void 0?void 0:e.getEq())===!0}isFalse(...i){var e;return((e=this.find(i))===null||e===void 0?void 0:e.getEq())===!1}date(...i){var e;const t=(e=this.find(i))===null||e===void 0?void 0:e.getEq();if(t instanceof Date)return t}bare(...i){const e=this.find(i);if(e!==void 0)return!e.hasProperties()}getEq(){return this.eq}getProperty(i){var e;return(e=this.properties)===null||e===void 0?void 0:e[i]}getArrayElement(i){if(Array.isArray(this.eq)&&i<this.eq.length)return this.eq[i]}get dict(){var i;return(i=this.properties)!==null&&i!==void 0?i:{}}*entries(){if(this.properties)for(const i in this.properties)yield[i,this.properties[i]]}*keys(){if(this.properties)for(const i in this.properties)yield i}hasProperties(){return this.properties!==void 0&&Object.keys(this.properties).length>0}array(...i){const e=this.find(i);if(e===void 0)return;const t=e.getEq();if(Array.isArray(t))return t.map((n,u)=>e.getArrayElement(u))}textArray(...i){const e=this.find(i);if(e===void 0)return;const t=e.getEq();if(Array.isArray(t))return t.reduce((n,u,d)=>{const s=e.getArrayElement(d),o=s?.getEq();return o===void 0||Array.isArray(o)?n:o instanceof Date?n.concat(o.toISOString()):n.concat(String(o))},[])}numericArray(...i){const e=this.find(i);if(e===void 0)return;const t=e.getEq();if(Array.isArray(t))return t.reduce((n,u,d)=>{const s=e.getArrayElement(d),o=s?.getEq();if(typeof o=="number")return n.concat(o);if(typeof o=="string"){const g=Number.parseFloat(o);if(!Number.isNaN(g))return n.concat(g)}return n},[])}getProperties(){return this.properties===void 0&&(this.properties={}),this.properties}clone(i){this._read=!0;const e=new a({},i);if(e.prefix=this.prefix,e.deleted=this.deleted,e.location=this.location,e._clonedFrom=this,this.eq!==void 0&&(Array.isArray(this.eq)?e.eq=this.eq.map(t=>t.clone(e)):e.eq=this.eq instanceof Date?new Date(this.eq):this.eq),this.properties){e.properties={};for(const[t,n]of Object.entries(this.properties))e.properties[t]=n.clone(e)}return e}toJSON(){const i={};if(this.eq!==void 0&&(Array.isArray(this.eq)?i.eq=this.eq.map(e=>e.toJSON()):i.eq=this.eq),this.properties!==void 0){i.properties={};for(const[e,t]of Object.entries(this.properties))i.properties[e]=t.toJSON()}return this.deleted&&(i.deleted=!0),this.prefix&&(i.prefix=this.prefix),this.location&&(i.location=this.location),i}validateReferences(){const i=[];return this.collectReferenceErrors(i,[]),i}collectReferenceErrors(i,e){if(this.properties)for(const[t,n]of Object.entries(this.properties))n.deleted||n.collectReferenceErrors(i,[...e,t]);Array.isArray(this.eq)&&this.eq.forEach((t,n)=>{t.collectReferenceErrors(i,[...e,`[${n}]`])})}static escapeString(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}static escapeProp(i){return i.replace(/\\/g,"\\\\").replace(/`/g,"\\`")}static quoteAndEscape(i,e=!1){return i.match(/^[0-9A-Za-z_]+$/)?i:e?`\`${a.escapeProp(i)}\``:`"${a.escapeString(i)}"`}static serializeScalar(i){return typeof i=="boolean"?i?"@true":"@false":i instanceof Date?`@${i.toISOString()}`:typeof i=="number"?String(i):a.quoteAndEscape(i)}toString(){var i;let e=(i=this.prefix)!==null&&i!==void 0?i:"# ";function t(d){var s;const o=Object.keys((s=d.properties)!==null&&s!==void 0?s:{});for(let g=0;g<o.length;g++)u(o[g],d.properties[o[g]]),g<o.length-1&&(e+=" ")}function n(d,s=!1){if(d.eq!==void 0)if(s||(e+=" = "),Array.isArray(d.eq)){e+="[";for(let o=0;o<d.eq.length;o++)n(d.eq[o],!0),o!==d.eq.length-1&&(e+=", ");e+="]"}else e+=a.serializeScalar(d.eq);if(d.properties){const o=Object.keys(d.properties);!s&&o.length===1&&!o.some(g=>{var y;return((y=d.properties)!==null&&y!==void 0?y:{})[g].deleted})&&d.eq===void 0?(e+=".",t(d)):((!s||d.eq!==void 0)&&(e+=" "),e+="{ ",t(d),e+=" }")}}function u(d,s){if(s.deleted){e+=`-${a.quoteAndEscape(d,!0)}`;return}e+=a.quoteAndEscape(d,!0),n(s)}return t(this),e+=`
9
+ `,e}find(i){let e=this;for(const t of i){let n;if(typeof t=="number"?n=e.getArrayElement(t):n=e.getProperty(t),n===void 0)return;n.markRead(),e=n}return e.deleted?void 0:e}markRead(){this._read=!0,this._clonedFrom&&(this._clonedFrom._read=!0)}get wasRead(){return this._read}*walk(i=[]){if(this.properties)for(const[e,t]of Object.entries(this.properties)){if(t.deleted)continue;const n=[...i,e];yield{path:n,tag:t},yield*t.walk(n)}if(Array.isArray(this.eq))for(let e=0;e<this.eq.length;e++){const t=[...i,e.toString()];yield{path:t,tag:this.eq[e]},yield*this.eq[e].walk(t)}}resetReadTracking(){this._read=!1;for(const{tag:i}of this.walk())i._read=!1}getUnreadProperties(i=[]){const e=[];if(this.properties)for(const[t,n]of Object.entries(this.properties)){if(n.deleted)continue;const u=[...i,t];n._read?e.push(...n.getUnreadProperties(u)):e.push(u)}return e}has(...i){return this.find(i)!==void 0}set(i,e=null){let t=this,n,u;for(const d of i)if(n=t,u=d,typeof d=="number"){if(t.eq===void 0||!Array.isArray(t.eq))t.eq=Array.from({length:d+1}).map(()=>new a({},t));else if(t.eq.length<=d){const s=t.eq,o=Array.from({length:d+1}).map((g,y)=>y<s.length?s[y]:new a({},t));t.eq=o}t=t.eq[d]}else{const s=t.properties;s===void 0?(t.properties={[d]:new a({},t)},t=t.properties[d]):d in s?(t=s[d],t.deleted&&(t.deleted=!1)):(s[d]=new a({},t),t=s[d])}if(e===null)t.eq=void 0;else if(e instanceof a){const d=e.clone(n);n&&u!==void 0&&(typeof u=="number"&&Array.isArray(n.eq)?n.eq[u]=d:typeof u=="string"&&n.properties&&(n.properties[u]=d))}else typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e instanceof Date?t.eq=e:Array.isArray(e)&&(t.eq=e.map(d=>new a({eq:d},t)));return this}delete(...i){return this.remove(i,!1)}unset(...i){return this.remove(i,!0)}remove(i,e=!1){var t;let n=this;for(const d of i.slice(0,i.length-1))if(typeof d=="number"){if(n.eq===void 0||!Array.isArray(n.eq)){if(!e)return this;n.eq=Array.from({length:d}).map(()=>new a({},n))}else if(n.eq.length<=d){if(!e)return this;const s=n.eq,o=Array.from({length:d}).map((g,y)=>y<s.length?s[y]:new a({},n));n.eq=o}n=n.eq[d]}else{const s=n.properties;if(s===void 0){if(!e)return this;n.properties={[d]:new a({},n)},n=n.properties[d]}else if(d in s)n=s[d];else{if(!e)return this;s[d]=new a({},n),n=s[d]}}const u=i[i.length-1];return typeof u=="string"?n.properties&&u in n.properties?delete n.properties[u]:e&&((t=n.properties)!==null&&t!==void 0||(n.properties={}),n.properties[u]=new a({deleted:!0},n)):Array.isArray(n.eq)&&n.eq.splice(u,1),this}}ae.Tag=a,a.ids=new Map,a.nextTagId=1e3;function E(C){const i={};return C.eq!==void 0&&(Array.isArray(C.eq)?i.eq=C.eq.map(e=>E(e)):i.eq=C.eq),C.properties!==void 0&&(i.properties=M(C.properties)),C.deleted&&(i.deleted=!0),i}function M(C){const i={};for(const[e,t]of Object.entries(C))i[e]=E(t);return i}return ae}var ue={},ve={},se={},ke;function le(){if(ke)return se;ke=1,Object.defineProperty(se,"__esModule",{value:!0}),se.formatRef=a,se.isRef=E,se.isDataNode=M,se.isEnvRef=C,se.isMotlyError=i;function a(e){let t="$";for(let u=0;u<e.linkUps;u++)t+="^";let n=!0;for(const u of e.linkTo)typeof u=="string"?((!n||e.linkUps>0)&&(t+="."),t+=u,n=!1):t+=`[${u}]`;return t}function E(e){return typeof e=="object"&&e!==null&&"linkTo"in e&&"linkUps"in e&&!Array.isArray(e)&&!(e instanceof Date)}function M(e){return typeof e=="object"&&e!==null&&!E(e)}function C(e){return typeof e=="object"&&e!==null&&"env"in e&&!Array.isArray(e)&&!(e instanceof Date)}function i(e){return typeof e=="object"&&e!==null&&"code"in e&&"message"in e&&"begin"in e&&"end"in e}return se}var oe={},be;function Pe(){if(be)return oe;be=1,Object.defineProperty(oe,"__esModule",{value:!0}),oe.MotValue=oe.Mot=void 0,oe.buildMot=d;const a=le();class E{text(...o){return this.get(...o)._text()}numeric(...o){return this.get(...o)._numeric()}boolean(...o){return this.get(...o)._boolean()}date(...o){return this.get(...o)._date()}valueType(...o){return this.get(...o)._valueType()}values(...o){return this.get(...o)._values()}texts(...o){const g=this.get(...o)._values();if(!g)return;const y=[];for(const P of g){const I=P._text();if(I===void 0)return;y.push(I)}return y}numerics(...o){const g=this.get(...o)._values();if(!g)return;const y=[];for(const P of g){const I=P._numeric();if(I===void 0)return;y.push(I)}return y}booleans(...o){const g=this.get(...o)._values();if(!g)return;const y=[];for(const P of g){const I=P._boolean();if(I===void 0)return;y.push(I)}return y}dates(...o){const g=this.get(...o)._values();if(!g)return;const y=[];for(const P of g){const I=P._date();if(I===void 0)return;y.push(I)}return y}has(...o){return this.get(...o).exists}}oe.Mot=E;class M extends E{constructor(o,g,y=!0){super(),this.isRef=!1,this._val=o,this._props=g,this.exists=y}_text(){return this._val?.type==="string"?this._val.value:void 0}_numeric(){return this._val?.type==="number"?this._val.value:void 0}_boolean(){return this._val?.type==="boolean"?this._val.value:void 0}_date(){return this._val?.type==="date"?this._val.value:void 0}_values(){return this._val?.type==="array"?this._val.value:void 0}_valueType(){return this._val?.type}get keys(){return this._props.keys()}get entries(){return this._props.entries()}get(...o){let g=this;for(const y of o){if(typeof y=="number"){const P=g.values();if(!P||!Number.isInteger(y)||y<0||y>=P.length)return t;g=P[y]}else g===this?g=this._props.get(y)??t:g=g.get(y);if(!g.exists)return t}return g}}oe.MotValue=M;class C extends E{constructor(o,g){super(),this.exists=!0,this.isRef=!0,this._target=g}_text(){return this._target.text()}_numeric(){return this._target.numeric()}_boolean(){return this._target.boolean()}_date(){return this._target.date()}_values(){return this._target.values()}_valueType(){return this._target.valueType()}get keys(){return this._target.keys}get entries(){return this._target.entries}get(...o){return this._target.get(...o)}}const i={[Symbol.iterator]:()=>({next:()=>({done:!0,value:void 0})})};class e extends E{constructor(){super(...arguments),this.exists=!1,this.isRef=!1}_text(){}_numeric(){}_boolean(){}_date(){}_values(){}_valueType(){}get keys(){return i}get entries(){return i}get(...o){return this}}const t=new e,n={createMot(s,o){return new M(s,o)},createRefMot(s,o){return new C(s,o)},undefinedMot:t};function u(s,o,g,y){let P,I;if(s.linkUps===0)P=o,I=[];else{const O=g.length-s.linkUps;if(O<0||O>=g.length)return;P=g[O],I=g.slice(0,O)}let N=P,W=I,Q=P;for(let O=0;O<s.linkTo.length;O++){if((0,a.isRef)(N)){if(y.has(N))return;y.add(N);const H=u(N,o,W,y);if(y.delete(N),!H)return;N=H.target,W=H.ancestors,Q=N,O--;continue}const B=N,z=s.linkTo[O];if(typeof z=="string"){if(!B.properties||!(z in B.properties))return;O>0&&(W=[...W,Q]),Q=B,N=B.properties[z]}else{if(!B.eq||!Array.isArray(B.eq)||z>=B.eq.length)return;O>0&&(W=[...W,Q]),Q=B,N=B.eq[z]}}if((0,a.isRef)(N)){if(y.has(N))return;y.add(N);const O=u(N,o,W,y);return y.delete(N),O}return{target:N,ancestors:W}}function d(s,o){const g=o?.env,y=o?.factory??n,P=y.undefinedMot,I=new Map;function N(O,B,z){if(O.deleted)return P;if(I.has(O))return I.get(O);const H=new Map,Y=Q(O.eq,B,z,O),J=y.createMot(Y,H);if(I.set(O,J),O.properties)for(const[K,c]of Object.entries(O.properties)){const m=W(c,B,z,O);m.exists&&H.set(K,m)}return J}function W(O,B,z,H){if((0,a.isRef)(O)){const J=new Set;J.add(O);const K=u(O,B,z,J);if(!K||K.target.deleted)return P;const c=N(K.target,B,K.ancestors);return y.createRefMot(O,c)}const Y=O;return Y.deleted?P:N(Y,B,[...z,H])}function Q(O,B,z,H){if(O!==void 0){if((0,a.isEnvRef)(O)){const Y=g?g[O.env]:void 0;return Y===void 0?void 0:{type:"string",value:Y}}if(Array.isArray(O)){const Y=[...z,H],J=[];for(const K of O)J.push(W(K,B,Y,H));return{type:"array",value:J}}if(typeof O=="string")return{type:"string",value:O};if(typeof O=="number")return{type:"number",value:O};if(typeof O=="boolean")return{type:"boolean",value:O};if(O instanceof Date)return{type:"date",value:O}}}return N(s,s,[s])}return oe}var ne={},de={},qe;function Me(){if(qe)return de;qe=1,Object.defineProperty(de,"__esModule",{value:!0}),de.parse=C;class a{constructor(e){this.input=e,this.pos=0}peekChar(){return this.pos<this.input.length?this.input[this.pos]:void 0}advance(e){this.pos+=e}startsWith(e){return this.input.startsWith(e,this.pos)}eatChar(e){return this.peekChar()===e?(this.advance(1),!0):!1}expectChar(e){if(!this.eatChar(e)){const t=this.peekChar();throw this.errorPoint(`Expected '${e}', found ${t===void 0?"end of input":`'${t}'`}`)}}position(){const e=this.input.substring(0,this.pos),t=(e.match(/\n/g)||[]).length,n=e.lastIndexOf(`
10
+ `),u=this.pos-(n===-1?0:n+1);return{line:t,column:u,offset:this.pos}}errorPoint(e){const t=this.position();return{code:"tag-parse-syntax-error",message:e,begin:t,end:t}}errorSpan(e,t){return{code:"tag-parse-syntax-error",message:e,begin:t,end:this.position()}}skipWs(){for(;;){for(;this.pos<this.input.length;){const e=this.input[this.pos];if(e===" "||e===" "||e==="\r"||e===`
11
+ `)this.pos++;else break}if(this.peekChar()==="#")for(;this.pos<this.input.length;){const e=this.input[this.pos];if(e==="\r"||e===`
12
+ `)break;this.pos++}else break}}skipWsAndCommas(){for(this.skipWs();this.peekChar()===",";)this.advance(1),this.skipWs()}parseStatements(){const e=[];for(this.skipWsAndCommas();this.pos<this.input.length;)e.push(this.parseStatement()),this.skipWsAndCommas();return e}parseStatement(){const e=this.position();if(this.startsWith("-..."))return this.advance(4),{kind:"clearAll",span:{begin:e,end:this.position()}};if(this.peekChar()==="-")return this.advance(1),{kind:"define",path:this.parsePropName(),deleted:!0,span:{begin:e,end:this.position()}};const t=this.parsePropName();this.skipWs();const n=this.peekChar();if(n===":"&&this.startsWith(":=")){this.advance(2),this.skipWs();const u=this.parseEqValue();if(this.skipWs(),this.peekChar()==="{"){const d=this.parsePropertiesBlock();return{kind:"assignBoth",path:t,value:u,properties:d,span:{begin:e,end:this.position()}}}return{kind:"assignBoth",path:t,value:u,properties:null,span:{begin:e,end:this.position()}}}if(n==="="){if(this.advance(1),this.skipWs(),this.peekChar()==="{")throw this.errorPoint("'=' requires a value; use ': { ... }' to replace properties");const u=this.parseEqValue();if(this.skipWs(),this.peekChar()==="{"){const d=this.parsePropertiesBlock();return{kind:"setEq",path:t,value:u,properties:d,span:{begin:e,end:this.position()}}}return{kind:"setEq",path:t,value:u,properties:null,span:{begin:e,end:this.position()}}}if(n===":"){this.advance(1),this.skipWs();const u=this.parsePropertiesBlock();return{kind:"replaceProperties",path:t,properties:u,span:{begin:e,end:this.position()}}}if(n==="{"){const u=this.parsePropertiesBlock();return{kind:"updateProperties",path:t,properties:u,span:{begin:e,end:this.position()}}}return{kind:"define",path:t,deleted:!1,span:{begin:e,end:this.position()}}}parsePropName(){const t=[this.parseIdentifier()];for(;this.peekChar()===".";)this.advance(1),t.push(this.parseIdentifier());return t}parseIdentifier(){return this.peekChar()==="`"?this.parseBacktickString():this.parseBareString()}parseEqValue(e=!0){const t=this.peekChar();if(e&&t==="[")return{kind:"array",elements:this.parseArray()};if(this.startsWith("<<<"))return{kind:"scalar",value:{kind:"string",value:this.parseHeredoc()}};if(t==="@")return{kind:"scalar",value:this.parseAtValue()};if(t==="$")return{kind:"scalar",value:this.parseReference()};if(t==='"')return this.startsWith('"""')?{kind:"scalar",value:{kind:"string",value:this.parseTripleString()}}:{kind:"scalar",value:{kind:"string",value:this.parseDoubleQuotedString()}};if(t==="'")return this.startsWith("'''")?{kind:"scalar",value:{kind:"string",value:this.parseTripleSingleQuotedString()}}:{kind:"scalar",value:{kind:"string",value:this.parseSingleQuotedString()}};if(t!==void 0&&(t==="-"||t>="0"&&t<="9"||t==="."))return this.parseNumberOrString();if(t!==void 0&&E(t))return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}};throw this.errorPoint("Expected a value")}parseAtValue(){const e=this.position();if(this.expectChar("@"),this.startsWith("true")&&!this.isBareCharAt(4))return this.advance(4),{kind:"boolean",value:!0};if(this.startsWith("false")&&!this.isBareCharAt(5))return this.advance(5),{kind:"boolean",value:!1};if(this.startsWith("none")&&!this.isBareCharAt(4))return this.advance(4),{kind:"none"};if(this.startsWith("env."))return this.advance(4),{kind:"env",name:this.parseIdentifier()};const t=this.peekChar();if(t!==void 0&&t>="0"&&t<="9")return this.parseDate(e);const n=this.pos;for(;this.pos<this.input.length&&E(this.input[this.pos]);)this.pos++;const u=this.pos>n?this.input.substring(n,this.pos):"";throw this.errorSpan(`Illegal constant @${u}; expected @true, @false, @none, @env.NAME, or @date`,e)}isBareCharAt(e){const t=this.pos+e;return t<this.input.length&&E(this.input[t])}parseDate(e){const t=this.pos;if(this.consumeDigits(4,e),this.expectChar("-"),this.consumeDigits(2,e),this.expectChar("-"),this.consumeDigits(2,e),this.peekChar()==="T"){if(this.advance(1),this.consumeDigits(2,e),this.expectChar(":"),this.consumeDigits(2,e),this.peekChar()===":"&&(this.advance(1),this.consumeDigits(2,e),this.peekChar()===".")){this.advance(1);const d=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.pos++;if(this.pos===d)throw this.errorSpan("Expected fractional digits in date",e)}const u=this.peekChar();u==="Z"?this.advance(1):(u==="+"||u==="-")&&(this.advance(1),this.consumeDigits(2,e),this.peekChar()===":"&&this.advance(1),this.consumeDigits(2,e))}return{kind:"date",value:this.input.substring(t,this.pos)}}consumeDigits(e,t){for(let n=0;n<e;n++){const u=this.peekChar();if(u===void 0||u<"0"||u>"9")throw this.errorSpan("Expected digit",t);this.advance(1)}}parseOptionalExponent(e){const t=this.peekChar();if(t!=="e"&&t!=="E")return;this.advance(1);const n=this.peekChar();(n==="+"||n==="-")&&this.advance(1);const u=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===u)throw this.errorSpan("Expected exponent digits",e)}parseNumberOrString(){const e=this.pos,t=this.position(),n=this.peekChar()==="-";n&&this.advance(1);let u=!1,d=!1;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)u=!0,this.advance(1);if(this.peekChar()==="."){d=!0,this.advance(1);const y=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===y)return this.pos=e,this.parseIntegerOrBare(e,n)}if(!u&&!d){if(this.pos=e,n)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}this.parseOptionalExponent(t);const s=this.peekChar();if(s!==void 0&&E(s)&&!(s>="0"&&s<="9")){if(this.pos=e,n)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}const o=this.input.substring(e,this.pos),g=parseFloat(o);if(isNaN(g))throw this.errorSpan(`Invalid number: ${o}`,t);return{kind:"scalar",value:{kind:"number",value:g}}}parseIntegerOrBare(e,t){this.pos=e;const n=this.position();t&&this.advance(1);const u=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.advance(1);if(this.pos===u){if(this.pos=e,t)throw this.errorPoint("Expected a value");return{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}if(!t){const o=this.peekChar();if(o!==void 0&&E(o)&&!(o>="0"&&o<="9"))return this.pos=e,{kind:"scalar",value:{kind:"string",value:this.parseBareString()}}}this.parseOptionalExponent(n);const d=this.input.substring(e,this.pos),s=parseFloat(d);if(isNaN(s))throw this.errorSpan(`Invalid number: ${d}`,n);return{kind:"scalar",value:{kind:"number",value:s}}}parseBareString(){const e=this.pos;for(;this.pos<this.input.length&&E(this.input[this.pos]);)this.pos++;if(this.pos===e)throw this.errorPoint("Expected an identifier");return this.input.substring(e,this.pos)}parseDoubleQuotedString(){const e=this.position();this.expectChar('"');let t="";for(;;){const n=this.peekChar();if(n===void 0||n==="\r"||n===`
13
+ `)throw this.errorSpan("Unterminated string",e);if(n==='"')return this.advance(1),t;n==="\\"?(this.advance(1),t+=this.parseEscapeChar()):(this.advance(1),t+=n)}}parseSingleQuotedString(){const e=this.position();this.expectChar("'");let t="";for(;;){const n=this.peekChar();if(n===void 0||n==="\r"||n===`
14
+ `)throw this.errorSpan("Unterminated string",e);if(n==="'")return this.advance(1),t;if(n==="\\"){this.advance(1),t+="\\";const u=this.peekChar();if(u===void 0||u==="\r"||u===`
15
+ `)throw this.errorSpan("Unterminated string",e);this.advance(1),t+=u}else this.advance(1),t+=n}}parseTripleSingleQuotedString(){const e=this.position();if(!this.startsWith("'''"))throw this.errorPoint("Expected triple-single-quoted string");this.advance(3);let t="";for(;;){if(this.startsWith("'''"))return this.advance(3),t;const n=this.peekChar();if(n===void 0)throw this.errorSpan("Unterminated triple-single-quoted string",e);if(n==="\\"){this.advance(1),t+="\\";const u=this.peekChar();if(u===void 0)throw this.errorSpan("Unterminated triple-single-quoted string",e);this.advance(1),t+=u}else this.advance(1),t+=n}}parseBacktickString(){const e=this.position();this.expectChar("`");let t="";for(;;){const n=this.peekChar();if(n===void 0||n==="\r"||n===`
16
+ `)throw this.errorSpan("Unterminated backtick string",e);if(n==="`")return this.advance(1),t;n==="\\"?(this.advance(1),t+=this.parseEscapeChar()):(this.advance(1),t+=n)}}parseTripleString(){const e=this.position();if(!this.startsWith('"""'))throw this.errorPoint("Expected triple-quoted string");this.advance(3);let t="";for(;;){if(this.startsWith('"""'))return this.advance(3),t;const n=this.peekChar();if(n===void 0)throw this.errorSpan("Unterminated triple-quoted string",e);n==="\\"?(this.advance(1),t+=this.parseEscapeChar()):(this.advance(1),t+=n)}}parseEscapeChar(){const e=this.peekChar();if(e===void 0)throw this.errorPoint("Unterminated escape sequence");switch(e){case"b":return this.advance(1),"\b";case"f":return this.advance(1),"\f";case"n":return this.advance(1),`
17
+ `;case"r":return this.advance(1),"\r";case"t":return this.advance(1)," ";case"u":{const t=this.position();this.advance(1);const n=this.pos;for(let s=0;s<4;s++){const o=this.peekChar();if(o===void 0||!M(o))throw this.errorSpan("Expected 4 hex digits in \\uXXXX",t);this.advance(1)}const u=this.input.substring(n,this.pos),d=parseInt(u,16);return String.fromCharCode(d)}default:return this.advance(1),e}}parseHeredoc(){const e=this.position();for(this.advance(3);this.pos<this.input.length;){const s=this.input[this.pos];if(s===" "||s===" ")this.pos++;else break}if(this.pos<this.input.length&&this.input[this.pos]==="\r"&&this.advance(1),this.pos>=this.input.length||this.input[this.pos]!==`
18
+ `)throw this.errorSpan("Expected newline after <<<",e);this.advance(1);const t=[];let n=!1;for(;this.pos<this.input.length;){const s=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]!==`
19
+ `;)this.pos++;let o=this.input.substring(s,this.pos);if(o.endsWith("\r")&&(o=o.substring(0,o.length-1)),this.pos<this.input.length&&this.input[this.pos]===`
20
+ `&&this.advance(1),o.trim()===">>>"){n=!0;break}t.push(o)}if(!n)throw this.errorSpan("Unterminated heredoc (expected >>>)",e);if(t.length===0)return"";let u=0;for(const s of t){const o=s.trimStart();if(o.length>0){u=s.length-o.length;break}}return t.map(s=>s.trimStart().length===0?"":u<=s.length?s.substring(u):s).join(`
21
+ `)+`
22
+ `}parseArray(){const e=this.position();if(this.expectChar("["),this.skipWs(),this.eatChar("]"))return[];const t=[];for(t.push(this.parseArrayElement());;){if(this.skipWs(),this.eatChar("]"))return t;if(this.eatChar(",")){if(this.skipWs(),this.peekChar()==="]")return this.advance(1),t;t.push(this.parseArrayElement())}else throw this.pos>=this.input.length?this.errorSpan("Unclosed '['",e):this.errorPoint("Expected ',' or ']' in array")}}parseArrayElement(){this.skipWs();const e=this.position(),t=this.peekChar();if(t==="{")return{value:null,properties:this.parsePropertiesBlock(),span:{begin:e,end:this.position()}};if(t==="["){const u=this.parseArray();if(this.skipWs(),this.peekChar()==="{"){const d=this.parsePropertiesBlock();return{value:{kind:"array",elements:u},properties:d,span:{begin:e,end:this.position()}}}return{value:{kind:"array",elements:u},properties:null,span:{begin:e,end:this.position()}}}const n=this.parseEqValue(!1);if(this.skipWs(),this.peekChar()==="{"){const u=this.parsePropertiesBlock();return{value:n,properties:u,span:{begin:e,end:this.position()}}}return{value:n,properties:null,span:{begin:e,end:this.position()}}}parsePropertiesBlock(){const e=this.position();this.expectChar("{");const t=[];for(;;){if(this.skipWsAndCommas(),this.eatChar("}"))return t;if(this.pos>=this.input.length)throw this.errorSpan("Unclosed '{'",e);t.push(this.parseStatement())}}parseReference(){this.expectChar("$");let e=0;for(;this.peekChar()==="^";)this.advance(1),e++;if(e>0){if(this.peekChar()!==".")return{kind:"reference",ups:e,path:[]};this.advance(1)}const t=[],n=this.parseIdentifier();if(t.push({kind:"name",name:n}),this.peekChar()==="["){this.advance(1),this.skipWs();const u=this.parseRefIndex();t.push({kind:"index",index:u}),this.skipWs(),this.expectChar("]")}for(;this.peekChar()===".";){this.advance(1);const u=this.parseIdentifier();if(t.push({kind:"name",name:u}),this.peekChar()==="["){this.advance(1),this.skipWs();const d=this.parseRefIndex();t.push({kind:"index",index:d}),this.skipWs(),this.expectChar("]")}}return{kind:"reference",ups:e,path:t}}parseRefIndex(){const e=this.position(),t=this.pos;for(;this.pos<this.input.length&&this.input[this.pos]>="0"&&this.input[this.pos]<="9";)this.pos++;if(this.pos===t)throw this.errorPoint("Expected array index");const n=parseInt(this.input.substring(t,this.pos),10);if(isNaN(n))throw this.errorSpan("Invalid array index",e);return n}}function E(i){const e=i.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e>=192&&e<=591||e>=7680&&e<=7935}function M(i){const e=i.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function C(i){return new a(i).parseStatements()}return de}var fe={},re={},we;function Oe(){if(we)return re;we=1,Object.defineProperty(re,"__esModule",{value:!0}),re.clonePropertyValue=re.cloneValue=void 0,re.cloneNode=E,re.cloneMotlyNode=M;const a=le();function E(C){const i={};if(C.deleted&&(i.deleted=!0),C.eq!==void 0&&(C.eq instanceof Date?i.eq=new Date(C.eq.getTime()):Array.isArray(C.eq)?i.eq=C.eq.map(M):(0,a.isEnvRef)(C.eq)?i.eq={env:C.eq.env}:i.eq=C.eq),C.properties){const e={};for(const t of Object.keys(C.properties))e[t]=M(C.properties[t]);i.properties=e}return C.location&&(i.location={parseId:C.location.parseId,begin:{...C.location.begin},end:{...C.location.end}}),i}function M(C){return(0,a.isRef)(C)?{linkTo:[...C.linkTo],linkUps:C.linkUps}:E(C)}return re.cloneValue=E,re.clonePropertyValue=M,re}var Ae;function Te(){if(Ae)return fe;Ae=1,Object.defineProperty(fe,"__esModule",{value:!0}),fe.flatten=M,fe.chunk=e,fe.topoSort=o,fe.executeChunked=g;const a=le(),E=Oe();function M(r,l){const p=[];return C(r,[],l.parseId,p),p}function C(r,l,p,h){for(const f of r)i(f,l,p,h)}function i(r,l,p,h){switch(r.kind){case"setEq":{const f=[...l,...r.path];if(r.value.kind==="scalar"&&r.value.value.kind==="reference"){const b=r.value.value;h.push({path:f,op:{kind:"link",ups:b.ups,refPath:b.path},span:r.span,parseId:p})}else h.push({path:f,op:{kind:"setValue",value:r.value},span:r.span,parseId:p}),r.properties!==null&&C(r.properties,f,p,h);break}case"assignBoth":{const f=[...l,...r.path];if(r.value.kind==="scalar"&&r.value.value.kind==="reference"){const b=r.value.value;h.push({path:f,op:{kind:"clone",ups:b.ups,refPath:b.path},span:r.span,parseId:p}),r.properties!==null&&(h.push({path:f,op:{kind:"clearProperties"},span:r.span,parseId:p}),C(r.properties,f,p,h))}else h.push({path:f,op:{kind:"assignValue",value:r.value},span:r.span,parseId:p}),r.properties!==null&&C(r.properties,f,p,h);break}case"replaceProperties":{const f=[...l,...r.path];h.push({path:f,op:{kind:"clearProperties"},span:r.span,parseId:p}),C(r.properties,f,p,h);break}case"updateProperties":{const f=[...l,...r.path];h.push({path:f,op:{kind:"define"},span:r.span,parseId:p}),C(r.properties,f,p,h);break}case"define":{const f=[...l,...r.path];h.push({path:f,op:{kind:r.deleted?"delete":"define"},span:r.span,parseId:p});break}case"clearAll":{h.push({path:[...l],op:{kind:"clearAll"},span:r.span,parseId:p});break}}}function e(r){const l=r.length;if(l===0)return{splits:[0],deps:[]};const p=new Map;for(let D=0;D<l;D++)p.set(t(r[D].path),D);const h=new Set([0,l]),f=new Set,b=[];for(let D=0;D<l;D++){const F=r[D],G=t(F.path);if(F.op.kind==="link"||F.op.kind==="clone"){const Z=d(F.path,F.op.ups,F.op.refPath);if(!n(f,Z)){b.push({refIdx:D,targetKey:Z}),h.add(D),h.add(D+1);const ie=u(p,Z);ie>D&&h.add(ie)}}f.add(G)}const w=Array.from(h).sort((D,F)=>D-F),$=w.length-1,_=Array.from({length:$},()=>new Set);for(const{refIdx:D,targetKey:F}of b){const G=s(w,D),Z=u(p,F);if(Z!==-1){const ee=s(w,Z);ee!==G&&_[G].add(ee)}const ie=t(r[D].path);for(let ee=D+1;ee<l;ee++){const ce=t(r[ee].path);if(ce===ie||ce.startsWith(ie+"\0")){const he=s(w,ee);he!==G&&_[he].add(G)}}}const x=_.map(D=>Array.from(D));return{splits:w,deps:x}}function t(r){return r.join("\0")}function n(r,l){for(const p of r)if(p===l||p.startsWith(l+"\0"))return!0;return!1}function u(r,l){let p=-1;for(const[h,f]of r)(h===l||h.startsWith(l+"\0")||l.startsWith(h+"\0"))&&(p=Math.max(p,f));return p}function d(r,l,p){const h=[];if(l>0){const f=Math.max(0,r.length-1-l);for(let b=0;b<f;b++)h.push(r[b])}for(const f of p)f.kind==="name"?h.push(f.name):h.push(`[${f.index}]`);return h.join("\0")}function s(r,l){let p=0,h=r.length-2;for(;p<h;){const f=p+h+1>>1;r[f]<=l?p=f:h=f-1}return p}function o(r){const l=r.length,p=new Array(l).fill(0),h=Array.from({length:l},()=>[]);for(let _=0;_<l;_++)for(const x of r[_])h[x].push(_),p[_]++;const f=[];for(let _=0;_<l;_++)p[_]===0&&f.push(_);const b=[];let w=0;for(;w<f.length;){const _=f[w++];b.push(_);for(const x of h[_])--p[x]===0&&f.push(x)}const $=[];if(b.length<l){const _=new Set(b);for(let x=0;x<l;x++)_.has(x)||$.push(x)}return{order:b,cycles:$}}function g(r,l,p,h,f){const b=[],w=[];for(const $ of p){const _=l[$],x=l[$+1];for(let D=_;D<x;D++)P(r[D],h,f,b,w)}return y(b,w),b}function y(r,l){if(l.length<2)return;const p=new Map;for(const w of l)p.set(w.sourcePath,w);const h=new Set,f=new Set;for(const w of l){if(f.has(w.sourcePath))continue;const $=[],_=new Set;let x=w;for(;x&&!_.has(x.sourcePath)&&!f.has(x.sourcePath);)$.push(x),_.add(x.sourcePath),x=p.get(x.targetPath);if(x&&_.has(x.sourcePath)){const D=x.sourcePath,F=[];let G=!1;for(const X of $)X.sourcePath===D&&(G=!0),G&&F.push(X);const Z=X=>X.replace(/\0/g,"."),ie=F.map(X=>Z(X.sourcePath)),ee=F.map(X=>`$${Z(X.targetPath)}`);let ce=ie[0];for(let X=0;X<ee.length;X++)ce+=` clones ${ee[X]}`,X<ee.length-1&&(ce+=`, ${ie[X+1]}`);for(const X of F)h.add(X.errorIndex);const he=F[0].errorIndex,ye={line:0,column:0,offset:0};r[he]={code:"circular-reference",message:`Circular clone dependency: ${ce}`,begin:ye,end:ye}}for(const D of $)f.add(D.sourcePath)}const b=Array.from(h).sort((w,$)=>$-w);for(const w of b)r[w].code!=="circular-reference"&&r.splice(w,1)}function P(r,l,p,h,f){const b={parseId:r.parseId,options:p};switch(r.op.kind){case"setValue":I(r.path,r.op.value,l,b,r.span,h);break;case"assignValue":N(r.path,r.op.value,l,b,r.span,h);break;case"clearProperties":W(r.path,l,b,r.span,h);break;case"clearAll":Q(r.path,l,b,r.span,h);break;case"define":O(r.path,l,b,r.span,h);break;case"delete":B(r.path,l,b,r.span,h);break;case"link":z(r.path,r.op.ups,r.op.refPath,l,b,r.span,h);break;case"clone":H(r.path,r.op.ups,r.op.refPath,l,b,r.span,h,f);break}}function I(r,l,p,h,f,b){if(r.length===0){c(p,l,h,b);return}const w=K(p,r,h,f,b);if(!w)return;const[$,_]=w,x=T(_);x[$]===void 0&&(x[$]={});const D=V(x,$);J(D,h,f),c(D,l,h,b)}function N(r,l,p,h,f,b){if(r.length===0){delete p.properties,p.location=Y(h,f),c(p,l,h,b);return}const w=K(p,r,h,f,b);if(!w)return;const[$,_]=w,x={};x.location=Y(h,f),c(x,l,h,b),T(_)[$]=x}function W(r,l,p,h,f){if(r.length===0){delete l.properties;return}const b=K(l,r,p,h,f);if(!b)return;const[w,$]=b,_=T($),x=_[w];if(x!==void 0&&!(0,a.isRef)(x))delete x.properties;else{const D={};D.location=Y(p,h),_[w]=D}}function Q(r,l,p,h,f){if(r.length===0){delete l.eq,l.properties={};return}const b=K(l,r,p,h,f);if(!b)return;const[w,$]=b,_=T($),x=_[w];x!==void 0&&!(0,a.isRef)(x)?(delete x.eq,x.properties={}):_[w]={}}function O(r,l,p,h,f){const b=K(l,r,p,h,f);if(!b)return;const[w,$]=b,_=T($);if(_[w]===void 0){const x={};x.location=Y(p,h),_[w]=x}}function B(r,l,p,h,f){const b=K(l,r,p,h,f);if(!b)return;const[w,$]=b,_={deleted:!0};_.location=Y(p,h),T($)[w]=_}function z(r,l,p,h,f,b,w){f.options.disableReferences&&w.push({code:"ref-not-allowed",message:"References are not allowed in this session. Use := for cloning.",begin:b.begin,end:b.end});const $=K(h,r,f,b,w);if(!$)return;const[_,x]=$;T(x)[_]=v(l,p)}function H(r,l,p,h,f,b,w,$){const _=K(h,r,f,b,w);if(!_)return;const[x,D]=_;let F;try{F=R(h,r,l,p)}catch(G){if((0,a.isMotlyError)(G)){const Z=w.length;w.push(G),$.push({sourcePath:t(r),targetPath:d(r,l,p),errorIndex:Z})}return}j(F,0,w),F.location=Y(f,b),T(D)[x]=F}function Y(r,l){return{parseId:r.parseId,begin:l.begin,end:l.end}}function J(r,l,p){r.location||(r.location=Y(l,p))}function K(r,l,p,h,f){let b=r;for(let w=0;w<l.length-1;w++){const $=l[w],_=T(b);if(_[$]!==void 0&&(0,a.isRef)(_[$]))return f.push({code:"write-through-link",message:`Cannot write through link reference "${$}"`,begin:h.begin,end:h.end}),null;if(_[$]===void 0){const x={};x.location=Y(p,h),_[$]=x}b=V(_,$),J(b,p,h)}return[l[l.length-1],b]}function c(r,l,p,h){if(l.kind==="array")r.eq=m(l.elements,h,p);else{const f=l.value;switch(f.kind){case"string":r.eq=f.value;break;case"number":r.eq=f.value;break;case"boolean":r.eq=f.value;break;case"date":r.eq=new Date(f.value);break;case"reference":throw new Error("References should be handled before calling setEqSlot");case"env":r.eq={env:f.name};break;case"none":delete r.eq;break}}}function m(r,l,p){return r.map(h=>q(h,l,p))}function q(r,l,p){if(r.value!==null&&r.value.kind==="scalar"&&r.value.value.kind==="reference"){if(p.options.disableReferences&&l.push({code:"ref-not-allowed",message:"References are not allowed in this session. Use := for cloning.",begin:r.span.begin,end:r.span.end}),r.properties!==null){const f={line:0,column:0,offset:0};l.push({code:"ref-with-properties",message:"Cannot add properties to a reference. Did you mean := (clone)?",begin:f,end:f})}return v(r.value.value.ups,r.value.value.path)}const h={};if(h.location=Y(p,r.span),r.value!==null&&c(h,r.value,p,l),r.properties!==null){const f=M(r.properties,p),{splits:b,deps:w}=e(f),{order:$}=o(w);l.push(...g(f,b,$,h,p.options))}return h}function v(r,l){return{linkTo:l.map(p=>p.kind==="name"?p.name:p.index),linkUps:r}}function k(r,l){let p="$";for(let f=0;f<r;f++)p+="^";let h=!0;for(const f of l)f.kind==="name"?((!h||r>0)&&(p+="."),p+=f.name,h=!1):p+=`[${f.index}]`;return p}function R(r,l,p,h){const f=k(p,h);let b;if(p===0)b=r;else{const $=l.length-1-p;if($<0)throw A(`Clone reference ${f} goes ${p} level(s) up but only ${l.length-1} ancestor(s) available`);b=r;for(let _=0;_<$;_++){if(!b.properties)throw A(`Clone reference ${f} could not be resolved: path segment "${l[_]}" not found`);const x=b.properties[l[_]];if(x===void 0)throw A(`Clone reference ${f} could not be resolved: path segment "${l[_]}" not found`);if((0,a.isRef)(x)){const D=S(r,x);if(!D)throw A(`Clone reference ${f} could not be resolved: path segment "${l[_]}" is an unresolvable link reference`);b=D;continue}b=x}}let w=b;for(const $ of h)if($.kind==="name"){if(!w.properties)throw A(`Clone reference ${f} could not be resolved: property "${$.name}" not found`);const _=w.properties[$.name];if(_===void 0)throw A(`Clone reference ${f} could not be resolved: property "${$.name}" not found`);if((0,a.isRef)(_)){const x=S(r,_);if(!x)throw A(`Clone reference ${f} could not be resolved: property "${$.name}" is an unresolvable link reference`);w=x;continue}w=_}else{if(!w.eq||!Array.isArray(w.eq))throw A(`Clone reference ${f} could not be resolved: index [${$.index}] used on non-array`);if($.index>=w.eq.length)throw A(`Clone reference ${f} could not be resolved: index [${$.index}] out of bounds (array length ${w.eq.length})`);const _=w.eq[$.index];if((0,a.isRef)(_)){const x=S(r,_);if(!x)throw A(`Clone reference ${f} could not be resolved: index [${$.index}] is an unresolvable link reference`);w=x;continue}w=_}return(0,E.cloneNode)(w)}function A(r){const l={line:0,column:0,offset:0};return{code:"unresolved-clone-reference",message:r,begin:l,end:l}}function S(r,l,p){p||(p=new Set);const h=(0,a.formatRef)(l);if(p.has(h)||(p.add(h),l.linkUps>0))return null;let f=r;for(const b of l.linkTo){if(f===void 0)return null;if((0,a.isRef)(f)){const $=S(r,f,p);if(!$)return null;f=$}if(!(0,a.isDataNode)(f))return null;const w=f;if(typeof b=="string"){if(!w.properties||!(b in w.properties))return null;f=w.properties[b]}else{if(!w.eq||!Array.isArray(w.eq)||b>=w.eq.length)return null;f=w.eq[b]}}return f!==void 0&&(0,a.isRef)(f)?S(r,f,p):f??null}function j(r,l,p){if(r.eq!==void 0&&Array.isArray(r.eq))for(let h=0;h<r.eq.length;h++)U(r.eq,h,l+1,p);if(r.properties)for(const h of Object.keys(r.properties))L(r.properties,h,l+1,p)}function U(r,l,p,h){const f=r[l];if((0,a.isRef)(f)){if(f.linkUps>0&&f.linkUps>p){const b={line:0,column:0,offset:0};h.push({code:"clone-reference-out-of-scope",message:`Cloned reference "${(0,a.formatRef)(f)}" escapes the clone boundary (${f.linkUps} level(s) up from depth ${p})`,begin:b,end:b}),r[l]={}}}else j(f,p,h)}function L(r,l,p,h){const f=r[l];if((0,a.isRef)(f)){if(f.linkUps>0&&f.linkUps>p){const b={line:0,column:0,offset:0};h.push({code:"clone-reference-out-of-scope",message:`Cloned reference "${(0,a.formatRef)(f)}" escapes the clone boundary (${f.linkUps} level(s) up from depth ${p})`,begin:b,end:b}),r[l]={}}}else j(f,p,h)}function T(r){return r.properties||(r.properties={}),r.properties}function V(r,l){const p=r[l];if((0,a.isRef)(p)){const h={};return r[l]=h,h}return p}return fe}var pe={},Re;function je(){if(Re)return pe;Re=1,Object.defineProperty(pe,"__esModule",{value:!0}),pe.validateReferences=M,pe.validateSchema=d;const a=le();function E(c,m,q,v,k){const R={code:m,message:q,path:v};k?.location&&(R.location=k.location),c.push(R)}function M(c){const m=[];return C(c,[],[c],c,m),m}function C(c,m,q,v,k){if(c.eq!==void 0&&Array.isArray(c.eq)&&i(c.eq,m,q,c,v,k),c.properties)for(const R of Object.keys(c.properties)){const A=c.properties[R];if(m.push(R),(0,a.isRef)(A)){const S=e(A,q,v);if(S!==null){const j={message:S,path:[...m],code:"unresolved-reference"};c.location&&(j.location=c.location),k.push(j)}}else q.push(c),C(A,m,q,v,k),q.pop();m.pop()}}function i(c,m,q,v,k,R){for(let A=0;A<c.length;A++){const S=c[A],j=`[${A}]`;if(m.push(j),(0,a.isRef)(S)){const U=e(S,q,k);U!==null&&R.push({message:U,path:[...m],code:"unresolved-reference"})}else q.push(v),C(S,m,q,k,R),q.pop();m.pop()}}function e(c,m,q){const v=(0,a.formatRef)(c);let k;if(c.linkUps===0)k=q;else{const R=m.length-c.linkUps;if(R<0||R>=m.length)return`Reference "${v}" goes ${c.linkUps} level(s) up but only ${m.length} ancestor(s) available`;k=m[R]}return t(k,c.linkTo,v)}function t(c,m,q){let v=c;for(const k of m){if(v==="terminal")return`Reference "${q}" could not be resolved: cannot follow path through a link`;if(typeof k=="string"){if(!v.properties)return`Reference "${q}" could not be resolved: property "${k}" not found (node has no properties)`;const R=v.properties[k];if(R===void 0)return`Reference "${q}" could not be resolved: property "${k}" not found`;(0,a.isRef)(R)?v="terminal":v=R}else{if(v.eq===void 0||!Array.isArray(v.eq))return`Reference "${q}" could not be resolved: index [${k}] used on non-array`;if(k>=v.eq.length)return`Reference "${q}" could not be resolved: index [${k}] out of bounds (array length ${v.eq.length})`;const R=v.eq[k];(0,a.isRef)(R)?v="terminal":v=R}}return null}const n=64,u={string:{properties:{VALUE:{eq:"string"}}},number:{properties:{VALUE:{eq:"number"}}},integer:{properties:{VALUE:{eq:"integer"}}},boolean:{properties:{VALUE:{eq:"boolean"}}},date:{properties:{VALUE:{eq:"date"}}},flag:{properties:{ADDITIONAL:{eq:"reject"}}},tag:{properties:{ADDITIONAL:{eq:"accept"}}},any:{properties:{ADDITIONAL:{eq:"accept"}}}};function d(c,m){const q=[],v=s(m,q);return g(c,m,v,[],q,0),q}function s(c,m){const q={...u},v=o(c,"TYPES");if(v?.properties){for(const[k,R]of Object.entries(v.properties))if(!(0,a.isRef)(R)){if(k in u){m.push({message:`Type "${k}" cannot shadow pre-loaded type`,path:["TYPES",k],code:"invalid-schema"});continue}q[k]=R}}return q}function o(c,m){if(!c.properties)return;const q=c.properties[m];if(!(q===void 0||(0,a.isRef)(q)))return q}function g(c,m,q,v,k,R){if(R>n){E(k,"invalid-schema","Maximum validation depth exceeded (possible recursive type cycle)",[...v],c);return}const A=o(m,"ONEOF");if(A&&Array.isArray(A.eq)){Y(c,A.eq,q,v,k,R);return}const S=o(m,"VALUE");S&&y(c,S,q,v,k),O(c,m,q,v,k,R)}function y(c,m,q,v,k,R){const A=typeof m.eq=="string"?m.eq:void 0;if(!A)return;const S=c.eq;switch(A){case"string":if(typeof S!="string"){E(k,"wrong-type",`Expected string, got ${P(S)}`,[...v],c);return}I(S,m,v,k,c);break;case"number":if(typeof S!="number"){E(k,"wrong-type",`Expected number, got ${P(S)}`,[...v],c);return}N(S,m,v,k,c);break;case"integer":if(typeof S!="number"||!Number.isInteger(S)){E(k,"wrong-type",`Expected integer, got ${P(S)}`,[...v],c);return}N(S,m,v,k,c);break;case"boolean":if(typeof S!="boolean"){E(k,"wrong-type",`Expected boolean, got ${P(S)}`,[...v],c);return}W(S,m,v,k,c);break;case"date":if(!(S instanceof Date)){E(k,"wrong-type",`Expected date, got ${P(S)}`,[...v],c);return}W(S,m,v,k,c);break;default:{const j=q[A];if(!j){E(k,"invalid-schema",`Unknown VALUE type "${A}"`,[...v],c);return}const U=o(j,"VALUE");if(!U){E(k,"invalid-schema",`Type "${A}" cannot be used as a VALUE type (no VALUE constraint)`,[...v],c);return}y(c,U,q,v,k)}}}function P(c){return c===void 0?"no value":c instanceof Date?`date ${c.toISOString()}`:Array.isArray(c)?"array":typeof c=="string"?`string ${JSON.stringify(c)}`:typeof c=="number"||typeof c=="boolean"?`${typeof c} ${c}`:typeof c}function I(c,m,q,v,k){W(c,m,q,v,k);const R=o(m,"MATCHES");if(R&&typeof R.eq=="string")try{new RegExp(R.eq).test(c)||E(v,"pattern-mismatch",`Value "${c}" does not match pattern "${R.eq}"`,[...q],k)}catch(j){E(v,"invalid-schema",`Invalid regex pattern "${R.eq}": ${j}`,[...q],k)}const A=o(m,"MIN_LENGTH");A&&typeof A.eq=="number"&&c.length<A.eq&&E(v,"length-violation",`String length ${c.length} is less than minimum ${A.eq}`,[...q],k);const S=o(m,"MAX_LENGTH");S&&typeof S.eq=="number"&&c.length>S.eq&&E(v,"length-violation",`String length ${c.length} exceeds maximum ${S.eq}`,[...q],k)}function N(c,m,q,v,k){W(c,m,q,v,k);const R=o(m,"MIN");R&&typeof R.eq=="number"&&c<R.eq&&E(v,"out-of-range",`Value ${c} is less than minimum ${R.eq}`,[...q],k);const A=o(m,"MAX");A&&typeof A.eq=="number"&&c>A.eq&&E(v,"out-of-range",`Value ${c} exceeds maximum ${A.eq}`,[...q],k)}function W(c,m,q,v,k){const R=o(m,"ENUM");if(!R||!Array.isArray(R.eq))return;if(!R.eq.some(S=>{if((0,a.isRef)(S))return!1;const j=S.eq;return j instanceof Date&&c instanceof Date?j.getTime()===c.getTime():j===c})){const S=R.eq.filter(j=>!(0,a.isRef)(j)).map(j=>String(j.eq));E(v,"invalid-enum-value",`${P(c)} is not one of: [${S.join(", ")}]`,[...q],k)}}function Q(c){if(!c.properties)return{kind:"reject"};const m=c.properties.ADDITIONAL;return m===void 0?{kind:"reject"}:(0,a.isRef)(m)?{kind:"reject"}:typeof m.eq=="string"?m.eq==="reject"?{kind:"reject"}:m.eq==="accept"?{kind:"accept"}:{kind:"type",typeName:m.eq}:m.properties&&Object.keys(m.properties).some(v=>v==="VALUE"||v==="REQUIRED"||v==="OPTIONAL"||v==="ADDITIONAL"||v==="ONEOF")?{kind:"inline",constraint:m}:{kind:"accept"}}function O(c,m,q,v,k,R){const A=o(m,"REQUIRED")?.properties,S=o(m,"OPTIONAL")?.properties,j=Q(m),U=c.properties;if(A)for(const[L,T]of Object.entries(A)){if((0,a.isRef)(T))continue;const V=[...v,L],r=U?.[L];r===void 0?E(k,"missing-required",`Missing required property "${L}"`,V,c):B(r,T,q,V,k,R)}if(S&&U)for(const[L,T]of Object.entries(S)){if((0,a.isRef)(T))continue;const V=U[L];V!==void 0&&B(V,T,q,[...v,L],k,R)}if(U){const L=new Set;if(A)for(const T of Object.keys(A))L.add(T);if(S)for(const T of Object.keys(S))L.add(T);for(const T of Object.keys(U)){if(L.has(T))continue;const V=[...v,T];switch(j.kind){case"reject":{const r=U[T];E(k,"unknown-property",`Unknown property "${T}"`,V,(0,a.isRef)(r)?void 0:r);break}case"accept":break;case"type":B(U[T],{eq:j.typeName},q,V,k,R);break;case"inline":{const r=U[T];(0,a.isRef)(r)?E(k,"wrong-type",`Expected a value but found a link ${(0,a.formatRef)(r)}`,V):g(r,j.constraint,q,V,k,R+1);break}}}}J(A,S,U,v,k),K(A,S,U,v,k)}function B(c,m,q,v,k,R){if((0,a.isRef)(c)){E(k,"wrong-type",`Expected a value but found a link ${(0,a.formatRef)(c)}`,[...v]);return}const A=typeof m.eq=="string"?m.eq:void 0;if(A){z(c,A,q,v,k,R);return}g(c,m,q,v,k,R+1)}function z(c,m,q,v,k,R){if(m.endsWith("[]")){H(c,m.slice(0,-2),q,v,k,R);return}const A=q[m];if(!A){E(k,"invalid-schema",`Unknown type "${m}" in schema`,[...v],c);return}if(Array.isArray(A.eq)){Y(c,A.eq,q,v,k,R);return}g(c,A,q,v,k,R+1)}function H(c,m,q,v,k,R){if(!Array.isArray(c.eq)){E(k,"wrong-type",`Expected ${m}[], got ${P(c.eq)}`,[...v],c);return}for(let A=0;A<c.eq.length;A++){const S=[...v,`[${A}]`],j=c.eq[A];(0,a.isRef)(j)?E(k,"wrong-type",`Expected ${m}, got link ${(0,a.formatRef)(j)}`,S):z(j,m,q,S,k,R)}}function Y(c,m,q,v,k,R){const A=[];let S,j;for(const L of m){if((0,a.isRef)(L))continue;const T=typeof L.eq=="string"?L.eq:void 0;if(!T)continue;A.push(T);const V=[];if(z(c,T,q,v,V,R),V.length===0)return;(!S||V.length<S.length)&&(S=V,j=T)}let U=`Value does not match any type in oneOf: [${A.join(", ")}]`;if(S&&S.length>0&&A.length>1){const L=S.map(T=>T.message).join("; ");U+=`. Closest match "${j}": ${L}`}E(k,"wrong-type",U,[...v],c)}function J(c,m,q,v,k){if(!q)return;const R={};function A(S){if(S)for(const[j,U]of Object.entries(S)){if((0,a.isRef)(U))continue;const L=o(U,"EXCLUSIVE");if(!L)continue;let T;if(typeof L.eq=="string")T=[L.eq];else if(Array.isArray(L.eq))T=L.eq.filter(V=>!(0,a.isRef)(V)).map(V=>String(V.eq));else continue;for(const V of T)R[V]||(R[V]=[]),R[V].push(j)}}A(c),A(m);for(const[S,j]of Object.entries(R)){const U=j.filter(L=>q[L]!==void 0);U.length>1&&E(k,"exclusive-violation",`Properties [${U.join(", ")}] are mutually exclusive (group "${S}")`,[...v])}}function K(c,m,q,v,k){if(!q)return;function R(A){if(A)for(const[S,j]of Object.entries(A)){if((0,a.isRef)(j)||q[S]===void 0)continue;const U=o(j,"REQUIRES");if(!(!U||!Array.isArray(U.eq)))for(const L of U.eq){if((0,a.isRef)(L))continue;const T=typeof L.eq=="string"?L.eq:void 0;T&&q[T]===void 0&&E(k,"requires-violation",`Property "${S}" requires "${T}" to be present`,[...v,S])}}}R(c),R(m)}return pe}var Ee;function De(){if(Ee)return ne;Ee=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.MOTLYSchema=ne.MOTLYResult=ne.MOTLYSession=void 0;const a=le(),E=Me(),M=Te(),C=je(),i=Oe(),e=Pe();class t{constructor(s){this.accumulated=[],this.nextParseId=0,this.finished=!1,this.disposed=!1,this.options=s??{}}parse(s){if(this.ensureAlive(),this.finished)throw new Error("MOTLYSession is spent after finish() — create a new session");const o=this.nextParseId++;try{const g=(0,E.parse)(s);return this.accumulated.push({stmts:g,parseId:o}),{parseId:o,errors:[]}}catch(g){if((0,a.isMotlyError)(g))return{parseId:o,errors:[g]};throw g}}finish(){if(this.ensureAlive(),this.finished)throw new Error("finish() has already been called on this session");this.finished=!0;const s=[],o={},g=[];for(const{stmts:W,parseId:Q}of this.accumulated){const O={parseId:Q,options:{disableReferences:this.options.disableReferences}};g.push(...(0,M.flatten)(W,O))}const{splits:y,deps:P}=(0,M.chunk)(g),{order:I}=(0,M.topoSort)(P),N=(0,M.executeChunked)(g,y,I,o,this.options);if(s.push(...N),!this.options.disableReferences){const W=(0,C.validateReferences)(o);for(const Q of W)s.push({code:Q.code,message:Q.message,begin:{line:0,column:0,offset:0},end:{line:0,column:0,offset:0}})}return new n(o,s)}dispose(){this.disposed=!0}ensureAlive(){if(this.disposed)throw new Error("MOTLYSession has been disposed")}}ne.MOTLYSession=t;class n{constructor(s,o){this.value=s,this.errors=o}getValue(){return(0,i.cloneNode)(this.value)}getMot(s){return(0,e.buildMot)(this.value,s)}}ne.MOTLYResult=n;class u{constructor(s){this.tree=s}static parse(s){const o={disableReferences:!0},g={parseId:0,options:o};try{const y=(0,E.parse)(s),P={},I=(0,M.flatten)(y,g),{splits:N,deps:W}=(0,M.chunk)(I),{order:Q}=(0,M.topoSort)(W),O=(0,M.executeChunked)(I,N,Q,P,o);return{schema:new u(P),errors:O}}catch(y){if((0,a.isMotlyError)(y))return{schema:new u({}),errors:[y]};throw y}}validate(s){return(0,C.validateSchema)(s,this.tree)}}return ne.MOTLYSchema=u,ne}var Se;function Ie(){return Se||(Se=1,(function(a){Object.defineProperty(a,"__esModule",{value:!0}),a.MOTLYSchema=a.MOTLYResult=a.MOTLYSession=a.MotValue=a.Mot=a.formatRef=a.isMotlyError=a.isEnvRef=a.isDataNode=a.isRef=void 0;var E=le();Object.defineProperty(a,"isRef",{enumerable:!0,get:function(){return E.isRef}}),Object.defineProperty(a,"isDataNode",{enumerable:!0,get:function(){return E.isDataNode}}),Object.defineProperty(a,"isEnvRef",{enumerable:!0,get:function(){return E.isEnvRef}}),Object.defineProperty(a,"isMotlyError",{enumerable:!0,get:function(){return E.isMotlyError}}),Object.defineProperty(a,"formatRef",{enumerable:!0,get:function(){return E.formatRef}});var M=Pe();Object.defineProperty(a,"Mot",{enumerable:!0,get:function(){return M.Mot}}),Object.defineProperty(a,"MotValue",{enumerable:!0,get:function(){return M.MotValue}});var C=De();Object.defineProperty(a,"MOTLYSession",{enumerable:!0,get:function(){return C.MOTLYSession}}),Object.defineProperty(a,"MOTLYResult",{enumerable:!0,get:function(){return C.MOTLYResult}}),Object.defineProperty(a,"MOTLYSchema",{enumerable:!0,get:function(){return C.MOTLYSchema}})})(ve)),ve}var _e;function Ne(){if(_e)return ue;_e=1;var a={};Object.defineProperty(ue,"__esModule",{value:!0}),ue.TagParser=void 0,ue.parseTag=u,ue.parseAnnotation=d;const E=Ie(),M=$e();function C(s){const o=s.search(/[ \t\r\n]/);return o>0?s.slice(o):""}function i(s){return{code:s.code,message:s.message,line:s.begin.line,offset:s.begin.column}}function e(s,o){const g=o.get(s.parseId);if(g)return{url:g.url,range:{start:{line:g.startLine+s.begin.line,character:s.begin.line===0?g.startColumn+s.begin.column:s.begin.column},end:{line:g.startLine+s.end.line,character:s.end.line===0?g.startColumn+s.end.column:s.end.column}}}}function t(s,o,g){if((0,E.isRef)(s))return new M.Tag({deleted:!0},o);const y=new M.Tag({},o);if(s.location&&g&&(y.location=e(s.location,g)),s.eq!==void 0)if(Array.isArray(s.eq))y.eq=s.eq.map(P=>t(P,y,g));else if((0,E.isEnvRef)(s.eq)){const P=a[s.eq.env];P!==void 0&&(y.eq=P)}else s.eq instanceof Date?y.eq=new Date(s.eq):y.eq=s.eq;if(s.properties!==void 0){y.properties={};for(const[P,I]of Object.entries(s.properties))y.properties[P]=t(I,y,g)}return s.deleted&&(y.deleted=!0),y}class n{constructor(){this.origins=new Map,this.session=new E.MOTLYSession}parse(o,g){return this.parseSource(o,0,g)}parseAnnotation(o,g){const y=C(o),P=o.length-y.length;return this.parseSource(y,P,g)}parseSource(o,g,y){const{parseId:P,errors:I}=this.session.parse(o);y&&this.origins.set(P,{url:y.url,startLine:y.startLine,startColumn:y.startColumn+g});const N=I.map(i);return{tag:new M.Tag,log:N}}finish(){const g=this.session.finish().getValue();return this.session.dispose(),t(g,void 0,this.origins)}}ue.TagParser=n;function u(s){const o=new n;if(typeof s=="string"){const{log:y}=o.parse(s);return{tag:o.finish(),log:y}}const g=[];for(let y=0;y<s.length;y++){const P=o.parse(s[y]);for(const I of P.log)g.push({...I,line:y+I.line})}return{tag:o.finish(),log:g}}function d(s){const o=new n;if(typeof s=="string"){const{log:y}=o.parseAnnotation(s);return{tag:o.finish(),log:y}}const g=[];for(let y=0;y<s.length;y++){const P=o.parseAnnotation(s[y]);for(const I of P.log)g.push({...I,line:y+I.line})}return{tag:o.finish(),log:g}}return ue}var ge={},Ce;function Ue(){if(Ce)return ge;Ce=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.parseString=E;var a;(function(M){M[M.Normal=0]="Normal",M[M.ReverseVirgule=1]="ReverseVirgule",M[M.Unicode=2]="Unicode"})(a||(a={}));function E(M,C=""){let i=M.slice(C.length),e=a.Normal;C.length&&(i=i.slice(0,-C.length));let t="",n="";for(const u of i)switch(e){case a.Normal:{u==="\\"?e=a.ReverseVirgule:t+=u;break}case a.ReverseVirgule:{let d=u;if(u==="u"){e=a.Unicode,n="";continue}u==="b"?d="\b":u==="f"?d="\f":u==="n"?d=`
23
+ `:u==="r"?d="\r":u==="t"&&(d=" "),t+=d,e=a.Normal;break}case a.Unicode:"ABCDEFabcdef0123456789".includes(u)?(n+=u,n.length===4&&(t+=String.fromCharCode(parseInt(n,16)),e=a.Normal)):e=a.Normal}return t}return ge}var xe;function Le(){return xe||(xe=1,(function(a){var E=te&&te.__createBinding||(Object.create?(function(t,n,u,d){d===void 0&&(d=u);var s=Object.getOwnPropertyDescriptor(n,u);(!s||("get"in s?!n.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return n[u]}}),Object.defineProperty(t,d,s)}):(function(t,n,u,d){d===void 0&&(d=u),t[d]=n[u]})),M=te&&te.__setModuleDefault||(Object.create?(function(t,n){Object.defineProperty(t,"default",{enumerable:!0,value:n})}):function(t,n){t.default=n}),C=te&&te.__exportStar||function(t,n){for(var u in t)u!=="default"&&!Object.prototype.hasOwnProperty.call(n,u)&&E(n,t,u)},i=te&&te.__importStar||(function(){var t=function(n){return t=Object.getOwnPropertyNames||function(u){var d=[];for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(d[d.length]=s);return d},t(n)};return function(n){if(n&&n.__esModule)return n;var u={};if(n!=null)for(var d=t(n),s=0;s<d.length;s++)d[s]!=="default"&&E(u,n,d[s]);return M(u,n),u}})();Object.defineProperty(a,"__esModule",{value:!0}),a.ParseUtil=a.TagParser=a.parseAnnotation=a.parseTag=void 0,C($e(),a);var e=Ne();Object.defineProperty(a,"parseTag",{enumerable:!0,get:function(){return e.parseTag}}),Object.defineProperty(a,"parseAnnotation",{enumerable:!0,get:function(){return e.parseAnnotation}}),Object.defineProperty(a,"TagParser",{enumerable:!0,get:function(){return e.TagParser}}),a.ParseUtil=i(Ue())})(te)),te}export{Le as r};
package/dist/index.html CHANGED
@@ -11,7 +11,7 @@
11
11
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
12
12
  />
13
13
  <title>Malloy Publisher</title>
14
- <script type="module" crossorigin src="/assets/index-VzRbxcF7.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-Cr-asgoV.js"></script>
15
15
  <link rel="stylesheet" crossorigin href="/assets/index-5eLCcNmP.css">
16
16
  </head>
17
17
  <body>