@arcgis/arcade-languageservice 4.32.0-next.98 → 4.32.0

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 (125) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/esm/index.d.ts +3 -79
  4. package/dist/esm/index.js +1 -1
  5. package/package.json +1 -1
  6. package/dist/assets/api/arcade-api.t9n.ar.json +0 -7937
  7. package/dist/assets/api/arcade-api.t9n.bg.json +0 -7937
  8. package/dist/assets/api/arcade-api.t9n.bs.json +0 -7937
  9. package/dist/assets/api/arcade-api.t9n.ca.json +0 -7937
  10. package/dist/assets/api/arcade-api.t9n.cs.json +0 -7937
  11. package/dist/assets/api/arcade-api.t9n.da.json +0 -7937
  12. package/dist/assets/api/arcade-api.t9n.de.json +0 -7937
  13. package/dist/assets/api/arcade-api.t9n.el.json +0 -7937
  14. package/dist/assets/api/arcade-api.t9n.en.json +0 -7937
  15. package/dist/assets/api/arcade-api.t9n.es.json +0 -7937
  16. package/dist/assets/api/arcade-api.t9n.et.json +0 -7937
  17. package/dist/assets/api/arcade-api.t9n.fi.json +0 -7937
  18. package/dist/assets/api/arcade-api.t9n.fr.json +0 -7937
  19. package/dist/assets/api/arcade-api.t9n.he.json +0 -7937
  20. package/dist/assets/api/arcade-api.t9n.hr.json +0 -7937
  21. package/dist/assets/api/arcade-api.t9n.hu.json +0 -7937
  22. package/dist/assets/api/arcade-api.t9n.id.json +0 -7937
  23. package/dist/assets/api/arcade-api.t9n.it.json +0 -7937
  24. package/dist/assets/api/arcade-api.t9n.ja.json +0 -7937
  25. package/dist/assets/api/arcade-api.t9n.ko.json +0 -7937
  26. package/dist/assets/api/arcade-api.t9n.lt.json +0 -7937
  27. package/dist/assets/api/arcade-api.t9n.lv.json +0 -7937
  28. package/dist/assets/api/arcade-api.t9n.nb.json +0 -7937
  29. package/dist/assets/api/arcade-api.t9n.nl.json +0 -7937
  30. package/dist/assets/api/arcade-api.t9n.pl.json +0 -7937
  31. package/dist/assets/api/arcade-api.t9n.pt-BR.json +0 -7937
  32. package/dist/assets/api/arcade-api.t9n.pt-PT.json +0 -7937
  33. package/dist/assets/api/arcade-api.t9n.ro.json +0 -7937
  34. package/dist/assets/api/arcade-api.t9n.ru.json +0 -7937
  35. package/dist/assets/api/arcade-api.t9n.sk.json +0 -7937
  36. package/dist/assets/api/arcade-api.t9n.sl.json +0 -7937
  37. package/dist/assets/api/arcade-api.t9n.sr.json +0 -7937
  38. package/dist/assets/api/arcade-api.t9n.sv.json +0 -7937
  39. package/dist/assets/api/arcade-api.t9n.th.json +0 -7937
  40. package/dist/assets/api/arcade-api.t9n.tr.json +0 -7937
  41. package/dist/assets/api/arcade-api.t9n.uk.json +0 -7937
  42. package/dist/assets/api/arcade-api.t9n.vi.json +0 -7937
  43. package/dist/assets/api/arcade-api.t9n.zh-CN.json +0 -7937
  44. package/dist/assets/api/arcade-api.t9n.zh-HK.json +0 -7937
  45. package/dist/assets/api/arcade-api.t9n.zh-TW.json +0 -7937
  46. package/dist/assets/profiles/arcade-profiles.t9n.ar.json +0 -809
  47. package/dist/assets/profiles/arcade-profiles.t9n.bg.json +0 -809
  48. package/dist/assets/profiles/arcade-profiles.t9n.bs.json +0 -809
  49. package/dist/assets/profiles/arcade-profiles.t9n.ca.json +0 -809
  50. package/dist/assets/profiles/arcade-profiles.t9n.cs.json +0 -809
  51. package/dist/assets/profiles/arcade-profiles.t9n.da.json +0 -809
  52. package/dist/assets/profiles/arcade-profiles.t9n.de.json +0 -809
  53. package/dist/assets/profiles/arcade-profiles.t9n.el.json +0 -809
  54. package/dist/assets/profiles/arcade-profiles.t9n.en.json +0 -803
  55. package/dist/assets/profiles/arcade-profiles.t9n.es.json +0 -809
  56. package/dist/assets/profiles/arcade-profiles.t9n.et.json +0 -809
  57. package/dist/assets/profiles/arcade-profiles.t9n.fi.json +0 -809
  58. package/dist/assets/profiles/arcade-profiles.t9n.fr.json +0 -809
  59. package/dist/assets/profiles/arcade-profiles.t9n.he.json +0 -809
  60. package/dist/assets/profiles/arcade-profiles.t9n.hr.json +0 -809
  61. package/dist/assets/profiles/arcade-profiles.t9n.hu.json +0 -809
  62. package/dist/assets/profiles/arcade-profiles.t9n.id.json +0 -809
  63. package/dist/assets/profiles/arcade-profiles.t9n.it.json +0 -809
  64. package/dist/assets/profiles/arcade-profiles.t9n.ja.json +0 -809
  65. package/dist/assets/profiles/arcade-profiles.t9n.ko.json +0 -809
  66. package/dist/assets/profiles/arcade-profiles.t9n.lt.json +0 -809
  67. package/dist/assets/profiles/arcade-profiles.t9n.lv.json +0 -809
  68. package/dist/assets/profiles/arcade-profiles.t9n.nb.json +0 -809
  69. package/dist/assets/profiles/arcade-profiles.t9n.nl.json +0 -809
  70. package/dist/assets/profiles/arcade-profiles.t9n.pl.json +0 -809
  71. package/dist/assets/profiles/arcade-profiles.t9n.pt-BR.json +0 -809
  72. package/dist/assets/profiles/arcade-profiles.t9n.pt-PT.json +0 -809
  73. package/dist/assets/profiles/arcade-profiles.t9n.ro.json +0 -809
  74. package/dist/assets/profiles/arcade-profiles.t9n.ru.json +0 -809
  75. package/dist/assets/profiles/arcade-profiles.t9n.sk.json +0 -809
  76. package/dist/assets/profiles/arcade-profiles.t9n.sl.json +0 -809
  77. package/dist/assets/profiles/arcade-profiles.t9n.sr.json +0 -809
  78. package/dist/assets/profiles/arcade-profiles.t9n.sv.json +0 -809
  79. package/dist/assets/profiles/arcade-profiles.t9n.th.json +0 -809
  80. package/dist/assets/profiles/arcade-profiles.t9n.tr.json +0 -809
  81. package/dist/assets/profiles/arcade-profiles.t9n.uk.json +0 -809
  82. package/dist/assets/profiles/arcade-profiles.t9n.vi.json +0 -809
  83. package/dist/assets/profiles/arcade-profiles.t9n.zh-CN.json +0 -809
  84. package/dist/assets/profiles/arcade-profiles.t9n.zh-HK.json +0 -809
  85. package/dist/assets/profiles/arcade-profiles.t9n.zh-TW.json +0 -809
  86. package/dist/assets/t9n/messages.ar.json +0 -35
  87. package/dist/assets/t9n/messages.bg.json +0 -35
  88. package/dist/assets/t9n/messages.bs.json +0 -35
  89. package/dist/assets/t9n/messages.ca.json +0 -35
  90. package/dist/assets/t9n/messages.cs.json +0 -35
  91. package/dist/assets/t9n/messages.da.json +0 -35
  92. package/dist/assets/t9n/messages.de.json +0 -35
  93. package/dist/assets/t9n/messages.el.json +0 -35
  94. package/dist/assets/t9n/messages.en.json +0 -35
  95. package/dist/assets/t9n/messages.es.json +0 -35
  96. package/dist/assets/t9n/messages.et.json +0 -35
  97. package/dist/assets/t9n/messages.fi.json +0 -35
  98. package/dist/assets/t9n/messages.fr.json +0 -35
  99. package/dist/assets/t9n/messages.he.json +0 -35
  100. package/dist/assets/t9n/messages.hr.json +0 -35
  101. package/dist/assets/t9n/messages.hu.json +0 -35
  102. package/dist/assets/t9n/messages.id.json +0 -35
  103. package/dist/assets/t9n/messages.it.json +0 -35
  104. package/dist/assets/t9n/messages.ja.json +0 -35
  105. package/dist/assets/t9n/messages.ko.json +0 -35
  106. package/dist/assets/t9n/messages.lt.json +0 -35
  107. package/dist/assets/t9n/messages.lv.json +0 -35
  108. package/dist/assets/t9n/messages.nl.json +0 -35
  109. package/dist/assets/t9n/messages.no.json +0 -35
  110. package/dist/assets/t9n/messages.pl.json +0 -35
  111. package/dist/assets/t9n/messages.pt-BR.json +0 -35
  112. package/dist/assets/t9n/messages.pt-PT.json +0 -35
  113. package/dist/assets/t9n/messages.ro.json +0 -35
  114. package/dist/assets/t9n/messages.ru.json +0 -35
  115. package/dist/assets/t9n/messages.sk.json +0 -35
  116. package/dist/assets/t9n/messages.sl.json +0 -35
  117. package/dist/assets/t9n/messages.sr.json +0 -35
  118. package/dist/assets/t9n/messages.sv.json +0 -35
  119. package/dist/assets/t9n/messages.th.json +0 -35
  120. package/dist/assets/t9n/messages.tr.json +0 -35
  121. package/dist/assets/t9n/messages.uk.json +0 -35
  122. package/dist/assets/t9n/messages.vi.json +0 -35
  123. package/dist/assets/t9n/messages.zh-CN.json +0 -35
  124. package/dist/assets/t9n/messages.zh-HK.json +0 -35
  125. package/dist/assets/t9n/messages.zh-TW.json +0 -35
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Licensing
2
2
 
3
- COPYRIGHT © 2024 Esri
3
+ COPYRIGHT © 2025 Esri
4
4
 
5
5
  All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
6
6
 
package/README.md CHANGED
@@ -6,7 +6,7 @@ It is not intended to be used directly, but rather used as a dependency by other
6
6
 
7
7
  ## License
8
8
 
9
- COPYRIGHT © 2024 Esri
9
+ COPYRIGHT © 2025 Esri
10
10
 
11
11
  All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
12
12
 
@@ -2,85 +2,11 @@ import { CompletionItem, Range, DiagnosticSeverity, TextEdit, Position, Completi
2
2
  export { DiagnosticSeverity } from 'vscode-languageserver-types';
3
3
  import { TextDocument } from 'vscode-languageserver-textdocument';
4
4
 
5
- var layer = "Layer";
6
- var featureservice = "Feature service";
7
- var mapservice = "Map service";
8
- var map = "Web Map";
9
- var webmap = "Web Map";
10
- var webscene = "Web Scene";
11
- var webmapformat = "Web map: {webMapTitle}";
12
- var item = "Item";
13
- var invoking = "Invoking";
14
- var fields = "Field names";
15
- var values = "Values";
16
- var relationships = "Related features";
17
- var layers = "Layers";
18
- var tables = "Tables";
19
- var geometry = "Geometry";
20
- var dictionary = "Dictionary";
21
- var feature = "Feature";
22
- var featureset = "Feature set";
23
- var featuresetcollection = "Feature set collection";
24
- var oid = "Feature ID";
25
- var number = "Number";
26
- var string = "String";
27
- var date = "Date";
28
- var blob = "Binary";
29
- var raster = "Raster";
30
- var guid = "GUID";
31
- var xml = "XML";
32
- var domainvalues = "Domain values";
33
- var subtypes = "Subtypes";
34
- var domainvaluesfortypeformat = "{fieldName} - Domain values for type '{typeName}'";
35
- var domainvaluesbysubtypes = "Domain values by subtypes";
36
- var ProfileSettingsStrings = {
37
- layer: layer,
38
- featureservice: featureservice,
39
- mapservice: mapservice,
40
- map: map,
41
- webmap: webmap,
42
- webscene: webscene,
43
- webmapformat: webmapformat,
44
- item: item,
45
- invoking: invoking,
46
- fields: fields,
47
- values: values,
48
- relationships: relationships,
49
- layers: layers,
50
- tables: tables,
51
- geometry: geometry,
52
- dictionary: dictionary,
53
- feature: feature,
54
- featureset: featureset,
55
- featuresetcollection: featuresetcollection,
56
- oid: oid,
57
- number: number,
58
- string: string,
59
- date: date,
60
- blob: blob,
61
- raster: raster,
62
- guid: guid,
63
- "global-id": "Global ID",
64
- xml: xml,
65
- "function": "Function",
66
- domainvalues: domainvalues,
67
- subtypes: subtypes,
68
- domainvaluesfortypeformat: domainvaluesfortypeformat,
69
- domainvaluesbysubtypes: domainvaluesbysubtypes
70
- };
71
-
72
5
  /**
73
6
  * Supported function bundles
74
7
  */
75
8
  type SqlBundleType = "core";
76
9
 
77
- /**
78
- * This file contains union types that are used to constrain
79
- * base schema types. It's a bit of a chicken and egg scenario
80
- * where fields in the base schema types need a reference
81
- * to the language specific Bundle and Profile types, creating
82
- * a bit of circular dependency. This file breaks that cycle.
83
- */
84
10
  /**
85
11
  * Union of bundle types that can be used in any sdk schema
86
12
  */
@@ -93,12 +19,12 @@ type ArcadeBundleType = "core" | "data-access" | "database" | "geometry" | "know
93
19
  /**
94
20
  * Supported profile variable types
95
21
  */
96
- type SdkVariableType = "array" | "boolean" | "date" | "dateOnly" | "dictionary" | "feature" | "featureSet" | "featureSetCollection" | "geometry" | "knowledgeGraph" | "number" | "text" | "time";
22
+ type SdkVariableType = "array" | "boolean" | "date" | "dateOnly" | "dictionary" | "feature" | "featureSet" | "featureSetCollection" | "geometry" | "knowledgeGraph" | "number" | "text" | "time" | "voxel";
97
23
 
98
24
  /**
99
25
  * The list of supported profiles
100
26
  */
101
- type ArcadeProfileId = "aggregate-field" | "alias" | "attribute-rule-calculation" | "attribute-rule-constraint" | "attribute-rule-validation" | "dashboard-data" | "dashboard-indicator-formatting" | "dashboard-list-formatting" | "dashboard-table-formatting" | "data-pipelines" | "dictionary-renderer" | "feature-display-title" | "feature-z" | "field-calculation" | "field-mapping" | "form-calculation" | "form-constraint" | "geoanalytics" | "geotrigger-notification" | "labeling" | "layout" | "location-update-constraint" | "measure-visualization" | "minimalist" | "model-builder" | "popup-element-feature-reduction" | "popup-element" | "popup-feature-reduction" | "popup" | "quick-capture" | "tasks" | "velocity" | "visualization";
27
+ type ArcadeProfileId = "aggregate-field" | "alias" | "attribute-rule-calculation" | "attribute-rule-constraint" | "attribute-rule-validation" | "dashboard-data" | "dashboard-indicator-formatting" | "dashboard-list-formatting" | "dashboard-table-formatting" | "data-pipelines" | "dictionary-renderer" | "feature-display-title" | "feature-z" | "field-calculation" | "field-mapping" | "form-calculation" | "form-constraint" | "geoanalytics" | "geotrigger-notification" | "labeling" | "layout" | "location-update-constraint" | "measure-visualization" | "minimalist" | "model-builder" | "popup-element-feature-reduction" | "popup-element-voxel" | "popup-element" | "popup-feature-reduction" | "popup-voxel" | "popup" | "quick-capture" | "tasks" | "velocity" | "visualization";
102
28
 
103
29
  /**
104
30
  * The list of supported profiles
@@ -510,6 +436,4 @@ declare class ArcadeLanguageService {
510
436
  doComplete(document: TextDocument, position: Position, context: ArcadeApiContext): Promise<CompletionList>;
511
437
  }
512
438
 
513
- type ProfileStrings = typeof ProfileSettingsStrings;
514
-
515
- export { type ArcadeApiContext, ArcadeKeywords, ArcadeLanguageService, ArcadeLiterals, ArcadeReservedKeywords, type Diagnostic, type DiagnosticCodes, type DiagnosticData, DiagnosticMessages, type ProfileStrings, ValidationDiagnosticCodes, arcadeFormat, format };
439
+ export { type ArcadeApiContext, ArcadeKeywords, ArcadeLanguageService, ArcadeLiterals, ArcadeReservedKeywords, type Diagnostic, type DiagnosticCodes, type DiagnosticData, DiagnosticMessages, ValidationDiagnosticCodes, arcadeFormat, format };
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ var V={False:"false",Null:"null",True:"true"},f={Break:"break",Continue:"continu
4
4
  `&&(this.index+=1),this.lineStart=this.index;else switch(a){case"n":e+=`
5
5
  `;break;case"r":e+="\r";break;case"t":e+=" ";break;case"u":if(this.source[this.index]==="{")this.index+=1,e+=this.scanUnicodeCodePointEscape();else{let u=this.index,c=this.scanHexEscape(a);c!==null?e+=c:(this.index=u,e+=a)}break;case"x":{let u=this.scanHexEscape(a);u===null&&this.throwUnexpectedToken(p.InvalidHexEscapeSequence),e+=u;break}case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:a==="0"?(D.isDecimalDigit(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(p.TemplateOctalLiteral),e+="\0"):D.isOctalDigit(a.charCodeAt(0))?this.throwUnexpectedToken(p.TemplateOctalLiteral):e+=a;break}continue}if(D.isLineTerminator(a.charCodeAt(0))){this.lineNumber+=1,a==="\r"&&this.source[this.index]===`
6
6
  `&&(this.index+=1),this.lineStart=this.index,e+=`
7
- `;continue}e+=a}return t||this.throwUnexpectedToken(),r||this.curlyStack.pop(),{type:h.Template,value:this.source.slice(i+1,this.index-s),cooked:e,head:r,tail:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:i,end:this.index}}lex(){if(this.eof())return{type:h.EOF,value:"",lineNumber:this.lineNumber,lineStart:this.lineStart,start:this.index,end:this.index};let e=this.source.charCodeAt(this.index);return D.isIdentifierStart(e)?this.scanIdentifier():e===40||e===41||e===59?this.scanPunctuator():e===39||e===34?this.scanStringLiteral():e===46?D.isDecimalDigit(this.source.charCodeAt(this.index+1))?this.scanNumericLiteral():this.scanPunctuator():D.isDecimalDigit(e)?this.scanNumericLiteral():e===96||e===125&&this.curlyStack[this.curlyStack.length-1]==="${"?this.scanTemplate():e>=55296&&e<57343&&D.isIdentifierStart(this.codePointAt(this.index))?this.scanIdentifier():this.scanPunctuator()}},y={None:0,Function:1,IfClause:2,ForLoop:4,ForOfLoop:8,WhileLoop:16},xe={AsObject:0,Automatic:1};function qe(e,t=0){let i=e.start-e.lineStart,r=e.lineNumber;return i<0&&(i+=t,r-=1),{index:e.start,line:r,column:i}}function He(e){return[{index:e.range[0],...e.loc.start},{index:e.range[1],...e.loc.end}]}function Ge(e){return e in q?q[e]:0}var Nt=class{constructor(e,t={},i){this.delegate=i,this.hasLineTerminator=!1,this.options={tokens:typeof t.tokens=="boolean"&&t.tokens,comments:typeof t.comments=="boolean"&&t.comments,tolerant:typeof t.tolerant=="boolean"&&t.tolerant},this.options.comments&&(this.commentHandler=new wt),this.errorHandler=new nt(this.options.tolerant),this.scanner=new st(e,this.errorHandler),this.context={isAssignmentTarget:!1,blockContext:y.None,curlyParsingType:xe.AsObject},this.rawToken={type:h.EOF,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0},this.tokens=[],this.startMarker={index:0,line:this.scanner.lineNumber,column:0},this.endMarker={index:0,line:this.scanner.lineNumber,column:0},this.readNextRawToken(),this.endMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}throwIfInvalidType(e,t,{validTypes:i,invalidTypes:r}){i?.some(n=>e.type===n)||r?.some(n=>e.type===n)&&this.throwError(p.InvalidExpression,t)}throwError(e,t,i=this.endMarker){let{index:r,line:n,column:s}=t,a=i.index-r-1;this.errorHandler.throwError({code:e,index:r,line:n,column:s+1,len:a})}tolerateError(e,t){throw new Error("######################################### !!!")}unexpectedTokenError(e={}){let{rawToken:t}=e,{code:i,data:r}=e,n;if(t){if(!i)switch(t.type){case h.EOF:i=p.UnexpectedEndOfScript;break;case h.Identifier:i=p.UnexpectedIdentifier;break;case h.NumericLiteral:i=p.UnexpectedNumber;break;case h.StringLiteral:i=p.UnexpectedString;break;case h.Template:i=p.UnexpectedTemplate;break;default:}n=t.value.toString()}else n="ILLEGAL";i??(i=p.UnexpectedToken),r||(r={value:n});let s=Fe(i,r);if(t){let c=t.start,l=t.lineNumber,g=t.start-t.lineStart+1;return new te({code:i,index:c,line:l,column:g,len:t.end-t.start-1,data:r,description:s})}let{index:a,line:u}=this.endMarker;return new te({code:i,index:a,line:u,column:this.endMarker.column+1,data:r,description:s})}throwUnexpectedToken(e={}){throw e.rawToken??(e.rawToken=this.rawToken),this.unexpectedTokenError(e)}collectComments(e){let{commentHandler:t}=this;!t||!e.length||e.forEach(i=>{let r={type:i.multiLine?o.BlockComment:o.LineComment,value:this.getSourceValue(i),range:i.range,loc:i.loc};t.collectComment(r)})}peekAhead(e){let t=()=>(this.scanner.scanComments(),this.scanner.lex()),i=this.scanner.saveState(),r=e.call(this,t);return this.scanner.restoreState(i),r}getSourceValue(e){return this.scanner.source.slice(e.start,e.end)}convertToToken(e){return{type:Xe[e.type],value:this.getSourceValue(e),range:[e.start,e.end],loc:{start:{line:this.startMarker.line,column:this.startMarker.column},end:{line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}}}readNextRawToken(){this.endMarker.index=this.scanner.index,this.endMarker.line=this.scanner.lineNumber,this.endMarker.column=this.scanner.index-this.scanner.lineStart;let e=this.rawToken;this.collectComments(this.scanner.scanComments()),this.scanner.index!==this.startMarker.index&&(this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart),this.rawToken=this.scanner.lex(),this.hasLineTerminator=e.lineNumber!==this.rawToken.lineNumber,this.options.tokens&&this.rawToken.type!==h.EOF&&this.tokens.push(this.convertToToken(this.rawToken))}captureStartMarker(){return{index:this.startMarker.index,line:this.startMarker.line,column:this.startMarker.column}}getItemLocation(e){return{range:[e.index,this.endMarker.index],loc:{start:{line:e.line,column:e.column},end:{line:this.endMarker.line,column:this.endMarker.column}}}}finalize(e){return(this.delegate??this.commentHandler)&&(this.commentHandler?.attachComments(e),this.delegate?.(e)),e}expectPunctuator(e){let t=this.rawToken;if(this.matchPunctuator(e)){this.readNextRawToken();return}this.throwUnexpectedToken({rawToken:t,code:p.PunctuatorExpected,data:{value:e}})}expectKeyword(e){if(this.rawToken.type===h.Keyword&&this.rawToken.value.toLowerCase()===e.toString()){this.readNextRawToken();return}this.throwUnexpectedToken({rawToken:this.rawToken})}expectContextualKeyword(e){if(this.rawToken.type===h.Identifier&&this.rawToken.value.toLowerCase()===e){this.readNextRawToken();return}this.throwUnexpectedToken({rawToken:this.rawToken})}matchKeyword(e){return this.rawToken.type===h.Keyword&&this.rawToken.value.toLowerCase()===e}matchContextualKeyword(e){return this.rawToken.type===h.Identifier&&this.rawToken.value===e}matchPunctuator(e){return this.rawToken.type===h.Punctuator&&this.rawToken.value===e}getMatchingPunctuator(e){if(typeof e=="string"&&(e=e.split("")),!(this.rawToken.type!==h.Punctuator||!e.length))return e.find(this.matchPunctuator.bind(this))}isolateCoverGrammar(e){let t=this.context.isAssignmentTarget;this.context.isAssignmentTarget=!0;let i=e.call(this);return this.context.isAssignmentTarget=t,i}inheritCoverGrammar(e){var t;let i=this.context.isAssignmentTarget;this.context.isAssignmentTarget=!0;let r=e.call(this);return(t=this.context).isAssignmentTarget&&(t.isAssignmentTarget=i),r}withBlockContext(e,t){let i=this.context.blockContext;this.context.blockContext|=e;let r=this.context.curlyParsingType;this.context.curlyParsingType=xe.Automatic;let n=t.call(this);return this.context.blockContext=i,this.context.curlyParsingType=r,n}consumeSemicolon(){if(this.matchPunctuator(";")){this.readNextRawToken();return}if(!this.hasLineTerminator){if(this.rawToken.type===h.EOF||this.matchPunctuator("}")){this.endMarker.index=this.startMarker.index,this.endMarker.line=this.startMarker.line,this.endMarker.column=this.startMarker.column;return}this.throwUnexpectedToken({rawToken:this.rawToken})}}parsePrimaryExpression(){let e=this.captureStartMarker(),t=this.rawToken;switch(t.type){case h.Identifier:return this.readNextRawToken(),this.finalize({type:o.Identifier,name:t.value,...this.getItemLocation(e)});case h.NumericLiteral:case h.StringLiteral:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value,raw:this.getSourceValue(t),isString:typeof t.value=="string",...this.getItemLocation(e)});case h.BooleanLiteral:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value.toLowerCase()===V.True,raw:this.getSourceValue(t),isString:!1,...this.getItemLocation(e)});case h.NullLiteral:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:o.Literal,value:null,raw:this.getSourceValue(t),isString:!1,...this.getItemLocation(e)});case h.Template:return this.parseTemplateLiteral();case h.Punctuator:switch(t.value){case"(":return this.inheritCoverGrammar(this.parseGroupExpression.bind(this));case"[":return this.inheritCoverGrammar(this.parseArrayInitializer.bind(this));case"{":return this.inheritCoverGrammar(this.parseObjectExpression.bind(this));default:return this.throwUnexpectedToken({rawToken:this.rawToken})}case h.Keyword:return this.context.isAssignmentTarget=!1,this.throwUnexpectedToken({rawToken:this.rawToken});default:return this.throwUnexpectedToken({rawToken:this.rawToken})}}parseArrayInitializer(){let e=this.captureStartMarker();this.expectPunctuator("[");let t=[];for(;!this.matchPunctuator("]");){let i=this.captureStartMarker();this.matchPunctuator(",")?(this.readNextRawToken(),this.throwError(p.InvalidExpression,i)):(t.push(this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))),this.matchPunctuator("]")||this.expectPunctuator(","))}return this.expectPunctuator("]"),this.finalize({type:o.ArrayExpression,elements:t,...this.getItemLocation(e)})}parseObjectPropertyKey(){let e=this.captureStartMarker(),t=this.rawToken;switch(t.type){case h.StringLiteral:return this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value,raw:this.getSourceValue(t),isString:!0,...this.getItemLocation(e)});case h.Identifier:case h.BooleanLiteral:case h.NullLiteral:case h.Keyword:return this.readNextRawToken(),this.finalize({type:o.Identifier,name:t.value,...this.getItemLocation(e)});default:this.throwError(p.KeyMustBeString,e)}}parseObjectProperty(){let e=this.rawToken,t=this.captureStartMarker(),i=this.parseObjectPropertyKey(),r=!1,n=null;return this.matchPunctuator(":")?(this.readNextRawToken(),n=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))):e.type===h.Identifier?(r=!0,n=this.finalize({type:o.Identifier,name:e.value,...this.getItemLocation(t)})):this.throwUnexpectedToken({rawToken:this.rawToken}),this.finalize({type:o.Property,kind:"init",key:i,value:n,shorthand:r,...this.getItemLocation(t)})}parseObjectExpression(){let e=this.captureStartMarker();this.expectPunctuator("{");let t=[];for(;!this.matchPunctuator("}");)t.push(this.parseObjectProperty()),this.matchPunctuator("}")||this.expectPunctuator(",");return this.expectPunctuator("}"),this.finalize({type:o.ObjectExpression,properties:t,...this.getItemLocation(e)})}parseTemplateElement(e=!1){let t=this.rawToken;t.type!==h.Template&&this.throwUnexpectedToken({rawToken:t}),e&&!t.head&&this.throwUnexpectedToken({code:p.InvalidTemplateHead,rawToken:t});let i=this.captureStartMarker();this.readNextRawToken();let{value:r,cooked:n,tail:s}=t,a=this.finalize({type:o.TemplateElement,value:{raw:r,cooked:n},tail:s,...this.getItemLocation(i)});return a.loc.start.column+=1,a.loc.end.column-=s?1:2,a}parseTemplateLiteral(){let e=this.captureStartMarker(),t=[],i=[],r=this.parseTemplateElement(!0);for(i.push(r);!r.tail;)t.push(this.parseExpression()),r=this.parseTemplateElement(),i.push(r);return this.finalize({type:o.TemplateLiteral,quasis:i,expressions:t,...this.getItemLocation(e)})}parseGroupExpression(){this.expectPunctuator("(");let e=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));return this.expectPunctuator(")"),e}parseArguments(){this.expectPunctuator("(");let e=[];if(!this.matchPunctuator(")"))for(;;){let t=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));if(e.push(t),this.matchPunctuator(")")||(this.expectPunctuator(","),this.matchPunctuator(")")))break}return this.expectPunctuator(")"),e}parseMemberName(){let e=this.rawToken,t=this.captureStartMarker();return this.readNextRawToken(),e.type!==h.NullLiteral&&e.type!==h.Identifier&&e.type!==h.Keyword&&e.type!==h.BooleanLiteral&&this.throwUnexpectedToken({rawToken:e}),this.finalize({type:o.Identifier,name:e.value,...this.getItemLocation(t)})}parseLeftHandSideExpression(){let e=this.captureStartMarker(),t=this.inheritCoverGrammar(this.parsePrimaryExpression.bind(this)),i=this.captureStartMarker(),r;for(;r=this.getMatchingPunctuator("([.");)switch(r){case"(":{this.context.isAssignmentTarget=!1,t.type!==o.Identifier&&t.type!==o.MemberExpression&&this.throwError(p.IdentifierExpected,e,i);let n=this.parseArguments();t=this.finalize({type:o.CallExpression,callee:t,arguments:n,...this.getItemLocation(e)});continue}case"[":{this.context.isAssignmentTarget=!0,this.expectPunctuator("[");let n=this.isolateCoverGrammar(()=>this.parseExpression());this.expectPunctuator("]"),t=this.finalize({type:o.MemberExpression,computed:!0,object:t,property:n,...this.getItemLocation(e)});continue}case".":{this.context.isAssignmentTarget=!0,this.expectPunctuator(".");let n=this.parseMemberName();t=this.finalize({type:o.MemberExpression,computed:!1,object:t,property:n,...this.getItemLocation(e)});continue}default:break}return t}parseUpdateExpression(){let e=this.captureStartMarker(),t=this.getMatchingPunctuator(Ee);if(t){this.readNextRawToken();let s=this.captureStartMarker(),a=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));return a.type!==o.Identifier&&a.type!==o.MemberExpression&&a.type!==o.CallExpression&&this.throwError(p.InvalidExpression,s),this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInAssignment,e),this.context.isAssignmentTarget=!1,this.finalize({type:o.UpdateExpression,operator:t,argument:a,prefix:!0,...this.getItemLocation(e)})}let i=this.captureStartMarker(),r=this.inheritCoverGrammar(this.parseLeftHandSideExpression.bind(this)),n=this.captureStartMarker();return this.hasLineTerminator||(t=this.getMatchingPunctuator(Ee),!t)?r:(r.type!==o.Identifier&&r.type!==o.MemberExpression&&this.throwError(p.InvalidExpression,i,n),this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInAssignment,e),this.readNextRawToken(),this.context.isAssignmentTarget=!1,this.finalize({type:o.UpdateExpression,operator:t,argument:r,prefix:!1,...this.getItemLocation(e)}))}parseUnaryExpression(){let e=this.getMatchingPunctuator(Je);if(e){let t=this.captureStartMarker();this.readNextRawToken();let i=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));return this.context.isAssignmentTarget=!1,this.finalize({type:o.UnaryExpression,operator:e,argument:i,prefix:!0,...this.getItemLocation(t)})}return this.parseUpdateExpression()}parseBinaryExpression(){let e=this.rawToken,t=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));if(this.rawToken.type!==h.Punctuator)return t;let i=this.rawToken.value,r=Ge(i);if(r===0)return t;this.readNextRawToken(),this.context.isAssignmentTarget=!1;let n=[e,this.rawToken],s=t,a=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)),u=[s,i,a],c=[r];for(;this.rawToken.type===h.Punctuator&&(r=Ge(this.rawToken.value))>0;){for(;u.length>2&&r<=c[c.length-1];){a=u.pop();let E=u.pop();c.pop(),s=u.pop(),n.pop();let M=n[n.length-1],De=qe(M,M.lineStart);u.push(this.finalize(this.createBinaryOrLogicalExpression(De,E,s,a)))}u.push(this.rawToken.value),c.push(r),n.push(this.rawToken),this.readNextRawToken(),u.push(this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)))}let l=u.length-1;t=u[l];let g=n.pop();for(;l>1;){let E=n.pop();if(!E)break;let M=g?.lineStart,De=qe(E,M),Lt=u[l-1];t=this.finalize(this.createBinaryOrLogicalExpression(De,Lt,u[l-2],t)),l-=2,g=E}return t}createBinaryOrLogicalExpression(e,t,i,r){let n=Ze.includes(t)?o.LogicalExpression:o.BinaryExpression;return n===o.BinaryExpression?{type:n,operator:t,left:i,right:r,...this.getItemLocation(e)}:((i.type===o.AssignmentExpression||i.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,...He(i)),(r.type===o.AssignmentExpression||r.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,...He(i)),{type:n,operator:t,left:i,right:r,...this.getItemLocation(e)})}parseAssignmentExpression(){let e=this.captureStartMarker(),t=this.inheritCoverGrammar(this.parseBinaryExpression.bind(this)),i=this.captureStartMarker(),r=this.getMatchingPunctuator(Qe);if(!r)return t;t.type!==o.Identifier&&t.type!==o.MemberExpression&&this.throwError(p.InvalidExpression,e,i),this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInAssignment,e),this.matchPunctuator("=")||(this.context.isAssignmentTarget=!1),this.readNextRawToken();let n=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));return this.finalize({type:o.AssignmentExpression,left:t,operator:r,right:n,...this.getItemLocation(e)})}parseExpression(){return this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this))}parseStatements(e){let t=[];for(;this.rawToken.type!==h.EOF&&!this.matchPunctuator(e);){let i=this.parseStatementListItem();H(i)||t.push(i)}return t}parseStatementListItem(){return this.context.isAssignmentTarget=!0,this.matchKeyword(f.Function)?this.parseFunctionDeclaration():this.matchKeyword(f.Export)?this.parseExportDeclaration():this.matchKeyword(f.Import)?this.parseImportDeclaration():this.parseStatement()}parseBlock(){let e=this.captureStartMarker();this.expectPunctuator("{");let t=this.parseStatements("}");return this.expectPunctuator("}"),this.finalize({type:o.BlockStatement,body:t,...this.getItemLocation(e)})}parseObjectStatement(){let e=this.captureStartMarker(),t=this.parseObjectExpression();return this.finalize({type:o.ExpressionStatement,expression:t,...this.getItemLocation(e)})}parseBlockOrObjectStatement(){return this.context.curlyParsingType===xe.AsObject?this.parseObjectStatement():this.peekAhead(e=>{let t=e();return!(t.type!==h.Identifier&&t.type!==h.StringLiteral||(t=e(),t.type!==h.Punctuator||t.value!==":"))})?this.parseObjectStatement():this.parseBlock()}parseIdentifier(){let e=this.rawToken;if(e.type!==h.Identifier)return null;let t=this.captureStartMarker();return this.readNextRawToken(),this.finalize({type:o.Identifier,name:e.value,...this.getItemLocation(t)})}parseVariableDeclarator(){let e=this.captureStartMarker(),t=this.parseIdentifier();t||this.throwUnexpectedToken({code:p.IdentifierExpected});let i=null;if(this.matchPunctuator("=")){this.readNextRawToken();let r=this.rawToken;try{i=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this))}catch{this.throwUnexpectedToken({rawToken:r,code:p.InvalidVariableAssignment})}}return this.finalize({type:o.VariableDeclarator,id:t,init:i,...this.getItemLocation(e)})}parseVariableDeclarators(){let e=[this.parseVariableDeclarator()];for(;this.matchPunctuator(",");)this.readNextRawToken(),e.push(this.parseVariableDeclarator());return e}parseVariableDeclaration(){let e=this.captureStartMarker();this.expectKeyword(f.Var);let t=this.parseVariableDeclarators();return this.consumeSemicolon(),this.finalize({type:o.VariableDeclaration,declarations:t,kind:"var",...this.getItemLocation(e)})}parseEmptyStatement(){let e=this.captureStartMarker();return this.expectPunctuator(";"),this.finalize({type:o.EmptyStatement,...this.getItemLocation(e)})}parseExpressionStatement(){let e=this.captureStartMarker(),t=this.parseExpression();return this.consumeSemicolon(),this.finalize({type:o.ExpressionStatement,expression:t,...this.getItemLocation(e)})}parseIfClause(){return this.withBlockContext(y.IfClause,this.parseStatement.bind(this))}parseIfStatement(){let e=this.captureStartMarker();this.expectKeyword(f.If),this.expectPunctuator("(");let t=this.captureStartMarker(),i=this.parseExpression(),r=this.captureStartMarker();this.expectPunctuator(")"),(i.type===o.AssignmentExpression||i.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,t,r);let n=this.parseIfClause(),s=null;return this.matchKeyword(f.Else)&&(this.readNextRawToken(),s=this.parseIfClause()),this.finalize({type:o.IfStatement,test:i,consequent:n,alternate:s,...this.getItemLocation(e)})}parseWhileStatement(){let e=this.captureStartMarker();this.expectKeyword(f.While),this.expectPunctuator("(");let t=this.captureStartMarker(),i=this.parseExpression(),r=this.captureStartMarker();this.expectPunctuator(")"),(i.type===o.AssignmentExpression||i.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,t,r);let n=this.withBlockContext(y.WhileLoop,this.parseStatement.bind(this));return this.finalize({type:o.WhileStatement,test:i,body:n,...this.getItemLocation(e)})}parseForStatement(){let e=o.ForStatement,t=null,i=null,r=null,n=null,s=null,a=this.captureStartMarker();if(this.expectKeyword(f.For),this.expectPunctuator("("),this.matchKeyword(f.Var)){let c=this.captureStartMarker();this.readNextRawToken();let l=this.parseVariableDeclarators();t=this.finalize({type:o.VariableDeclaration,declarations:l,kind:"var",...this.getItemLocation(c)});let g=this.matchKeyword(f.In),E=this.matchContextualKeyword(fe.Of);l.length===1&&(g||E)&&(l[0].init&&this.throwError(p.ForInOfLoopInitializer,c),e=g?o.ForInStatement:o.ForOfStatement,n=t)}else if(!this.matchPunctuator(";")){let c=this.context.isAssignmentTarget,l=this.captureStartMarker();t=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));let g=this.matchKeyword(f.In),E=this.matchContextualKeyword(fe.Of);g||E?(this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInForIn,l),t.type!==o.Identifier&&this.throwError(p.InvalidLeftHandSideInForIn,l),e=g?o.ForInStatement:o.ForOfStatement,n=t):this.context.isAssignmentTarget=c}e===o.ForStatement?(this.expectPunctuator(";"),i=this.matchPunctuator(";")?null:this.isolateCoverGrammar(this.parseExpression.bind(this)),this.expectPunctuator(";"),r=this.matchPunctuator(")")?null:this.isolateCoverGrammar(this.parseExpression.bind(this))):(this.readNextRawToken(),s=this.parseExpression()),this.expectPunctuator(")");let u=this.withBlockContext(e===o.ForOfStatement?y.ForOfLoop:y.ForLoop,()=>this.isolateCoverGrammar(this.parseStatement.bind(this)));return e===o.ForInStatement||e===o.ForOfStatement?this.finalize({type:e,left:n,right:s,body:u,...this.getItemLocation(a)}):this.finalize({type:e,init:t,test:i,update:r,body:u,...this.getItemLocation(a)})}parseContinueStatement(){let e=this.captureStartMarker();return this.expectKeyword(f.Continue),this.consumeSemicolon(),this.finalize({type:o.ContinueStatement,...this.getItemLocation(e)})}parseBreakStatement(){let e=this.captureStartMarker();return this.expectKeyword(f.Break),this.consumeSemicolon(),this.finalize({type:o.BreakStatement,...this.getItemLocation(e)})}parseReturnStatement(){let e=this.captureStartMarker();this.expectKeyword(f.Return);let t=!this.matchPunctuator(";")&&!this.matchPunctuator("}")&&!this.hasLineTerminator&&this.rawToken.type!==h.EOF||this.rawToken.type===h.StringLiteral||this.rawToken.type===h.Template?this.parseExpression():null;return this.consumeSemicolon(),this.finalize({type:o.ReturnStatement,argument:t,...this.getItemLocation(e)})}parseStatement(){switch(this.rawToken.type){case h.BooleanLiteral:case h.NullLiteral:case h.NumericLiteral:case h.StringLiteral:case h.Template:case h.Identifier:return this.parseExpressionStatement();case h.Punctuator:return this.rawToken.value==="{"?this.parseBlockOrObjectStatement():this.rawToken.value==="("?this.parseExpressionStatement():this.rawToken.value===";"?this.parseEmptyStatement():this.parseExpressionStatement();case h.Keyword:switch(this.rawToken.value.toLowerCase()){case f.Break:return this.parseBreakStatement();case f.Continue:return this.parseContinueStatement();case f.For:return this.parseForStatement();case f.Function:return this.parseFunctionDeclaration();case f.If:return this.parseIfStatement();case f.Return:return this.parseReturnStatement();case f.Var:return this.parseVariableDeclaration();case f.While:return this.parseWhileStatement();default:return this.parseExpressionStatement()}default:return this.throwUnexpectedToken({rawToken:this.rawToken})}}parseFormalParameters(){let e=[];if(this.expectPunctuator("("),!this.matchPunctuator(")"))for(;this.rawToken.type!==h.EOF;){let t=this.parseIdentifier();if(t||this.throwUnexpectedToken({rawToken:this.rawToken,code:p.IdentifierExpected}),e.push(t),this.matchPunctuator(")")||(this.expectPunctuator(","),this.matchPunctuator(")")))break}return this.expectPunctuator(")"),e}parseFunctionDeclaration(){(this.context.blockContext&y.Function)===y.Function&&this.throwUnexpectedToken({code:p.NoFunctionInsideFunction}),((this.context.blockContext&y.WhileLoop)===y.WhileLoop||(this.context.blockContext&y.ForOfLoop)===y.ForOfLoop||(this.context.blockContext&y.IfClause)===y.IfClause)&&this.throwUnexpectedToken({code:p.NoFunctionInsideBlock});let e=this.captureStartMarker();this.expectKeyword(f.Function);let t=this.parseIdentifier();t||this.throwUnexpectedToken({code:p.InvalidFunctionIdentifier});let i=this.parseFormalParameters(),r=this.context.blockContext;this.context.blockContext|=y.Function;let n=this.parseBlock();return this.context.blockContext=r,this.finalize({type:o.FunctionDeclaration,id:t,params:i,body:n,...this.getItemLocation(e)})}parseScript(){let e=this.captureStartMarker(),t=this.parseStatements(),i=this.finalize({type:o.Program,body:t,...this.getItemLocation(e)});return this.options.tokens&&(i.tokens=this.tokens),this.options.tolerant&&(i.errors=this.errorHandler.errors),i}parseExportDeclaration(){this.context.blockContext!==y.None&&this.throwUnexpectedToken({code:p.ModuleExportRootOnly});let e=null,t=this.captureStartMarker();return this.expectKeyword(f.Export),this.matchKeyword(f.Var)?e=this.parseVariableDeclaration():this.matchKeyword("function")?e=this.parseFunctionDeclaration():this.throwUnexpectedToken({code:p.InvalidExpression}),this.finalize({type:o.ExportNamedDeclaration,declaration:e,specifiers:[],source:null,...this.getItemLocation(t)})}parseModuleSpecifier(){let e=this.captureStartMarker(),t=this.rawToken;if(t.type===h.StringLiteral)return this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value,raw:this.getSourceValue(t),isString:!0,...this.getItemLocation(e)});this.throwError(p.InvalidModuleUri,e)}parseDefaultSpecifier(){let e=this.captureStartMarker(),t=this.parseIdentifier();return t||this.throwUnexpectedToken({code:p.IdentifierExpected}),this.finalize({type:o.ImportDefaultSpecifier,local:t,...this.getItemLocation(e)})}parseImportDeclaration(){this.context.blockContext!==y.None&&this.throwUnexpectedToken({code:p.ModuleImportRootOnly});let e=this.captureStartMarker();this.expectKeyword(f.Import);let t=this.parseDefaultSpecifier();this.expectContextualKeyword(fe.From);let i=this.parseModuleSpecifier();return this.finalize({type:o.ImportDeclaration,specifiers:[t],source:i,...this.getItemLocation(e)})}},Mt=class{constructor(e,t){this.errorHandler=new nt,this.errorHandler.tolerant=t?typeof t.tolerant=="boolean"&&t.tolerant:!1,this.scanner=new st(e,this.errorHandler),this.trackComments=t?typeof t.comment=="boolean"&&t.comment:!1,this.buffer=[]}errors(){return this.errorHandler.errors}getNextToken(){if(this.buffer.length===0){let e=this.scanner.scanComments();if(this.trackComments&&e.forEach(t=>{let i=this.scanner.source.slice(t.start,t.end),r={type:t.multiLine?o.BlockComment:o.LineComment,value:i,range:t.range,loc:t.loc};this.buffer.push(r)}),!this.scanner.eof()){let t={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},i=this.scanner.lex(),r={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},n={type:Xe[i.type],value:this.scanner.source.slice(i.start,i.end),range:[i.start,i.end],loc:{start:t,end:r}};this.buffer.push(n)}}return this.buffer.shift()}};function Z(e,t,i){return new Nt(e,t,i).parseScript()}function at(e,t,i){let r=new Mt(e,t),n=[],s;try{let a;for(;a=r.getNextToken();)i&&(a=i(a)),n.push(a)}catch(a){a instanceof Error&&r.errorHandler.tolerate(a)}return r.errorHandler.tolerant&&(s=r.errors()),{tokens:n,errors:s}}import{DiagnosticSeverity as F}from"vscode-languageserver-types";var d={AlreadyDefined:"AlreadyDefined",ApiConflict:"ApiConflict",AssignedNeverUsed:"AssignedNeverUsed",DefinedNeverAssigned:"DefinedNeverAssigned",DefinedNeverUsed:"DefinedNeverUsed",EmptyBlockStatement:"EmptyBlockStatement",ExecutionError:"ExecutionError",InvalidApiFunctionUsage:"InvalidApiFunctionUsage",InvalidConstantIdentifier:"InvalidConstantIdentifier",InvalidPropertyIdentifier:"InvalidPropertyIdentifier",NoArgumentExpected:"NoArgumentExpected",NotADictionary:"NotADictionary",NotDefined:"NotDefined",NotEnoughArguments:"NotEnoughArguments",ProfileVariablesAreImmutable:"ProfileVariablesAreImmutable",ProfileVariablesConflict:"ProfileVariablesConflict",ReservedKeyword:"ReservedKeyword",TooManyArguments:"TooManyArguments",UnexpectedEmptyFunction:"UnexpectedEmptyFunction",UnexpectedPropertyIdentifier:"UnexpectedPropertyIdentifier",UnknownPropertyIdentifier:"UnknownPropertyIdentifier"},ot={[d.AlreadyDefined]:"'${identifier}' is already defined.",[d.ApiConflict]:"'${identifier}' is already defined as an Arcade constant or function.",[d.AssignedNeverUsed]:"'${identifier}' is assigned but never used.",[d.DefinedNeverAssigned]:"'${identifier}' is defined but never assigned.",[d.DefinedNeverUsed]:"'${identifier}' is defined but never used.",[d.EmptyBlockStatement]:"Empty block statement.",[d.ExecutionError]:"Execution Error: '${stack}'",[d.InvalidApiFunctionUsage]:"Arcade function '${identifier}' not used in a call expression.",[d.InvalidConstantIdentifier]:"Invalid constant identifier, expecting ${list}.",[d.InvalidPropertyIdentifier]:"Invalid property identifier, expecting ${list}.",[d.NoArgumentExpected]:"Expecting no argument.",[d.NotADictionary]:"'${identifier}' doesn't have properties.",[d.NotDefined]:"'${identifier}' is not defined.",[d.NotEnoughArguments]:"Expecting at least ${min} argument(s).",[d.ProfileVariablesAreImmutable]:"Profile variables cannot be modified.",[d.ProfileVariablesConflict]:"'${identifier}' is already defined as a profile variable.",[d.ReservedKeyword]:"'${identifier}' is a reserved keyword.",[d.TooManyArguments]:"Too many arguments, expecting ${max}.",[d.UnexpectedEmptyFunction]:"Unexpected empty function '${identifier}'.",[d.UnexpectedPropertyIdentifier]:"Unexpected property identifier.",[d.UnknownPropertyIdentifier]:"Unknown property identifier '${identifier}'.",...ye};function re(e,t){return e.line-t.line||e.column-t.column}function ut(e,t){let i={start:e.loc.start,end:e.loc.end},r=n=>Ot(i,n.loc);return re(i.start,i.end)<0&&(i.start={...i.start},t.skipSpaces(i.start),re(i.start,i.end)<0&&(i.end={...i.end},t.skipSpaces(i.end,!0))),e.leadingComments?.forEach(r),e.trailingComments?.forEach(r),i}function Ot(e,t){re(t.start,e.start)<0&&(e.start=t.start),re(e.end,t.end)<0&&(e.end=t.end)}var Ut=/\S/u;function X(e=""){return!Ut.test(e)}var Le={indentWidth:2,wrapColumn:80,quote:null};function R(e){return{indentWidth:e?.indentWidth??Le.indentWidth,wrapColumn:e?.wrapColumn??Le.wrapColumn,quote:e?.quote??Le.quote}}var jt=/^\s*/u,Vt=/\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u,ne=class e{constructor(t){this.lineRecords=t;this.length=t.length}static fromString(t,i){if(typeof t!="string")return t;let r=i?.indentWidth;return new e(t.split(Vt).map(s=>{let a=jt.exec(s)?.[0]??"";return{line:s,indentation:zt(a,r),locked:!1,sliceStart:a.length,sliceEnd:s.length}}))}toString(){return this.sliceString(this.firstPos(),this.lastPos())}charAt(t){let{line:i,column:r}=t,n=this.lineRecords[i-1];if(typeof n>"u"||r<0)return"";let s=this.getIndentationAt(i);if(r<s)return" ";let a=r+n.sliceStart-s;return a===n.sliceEnd&&i<this.length?`
7
+ `;continue}e+=a}return t||this.throwUnexpectedToken(),r||this.curlyStack.pop(),{type:h.Template,value:this.source.slice(i+1,this.index-s),cooked:e,head:r,tail:n,lineNumber:this.lineNumber,lineStart:this.lineStart,start:i,end:this.index}}lex(){if(this.eof())return{type:h.EOF,value:"",lineNumber:this.lineNumber,lineStart:this.lineStart,start:this.index,end:this.index};let e=this.source.charCodeAt(this.index);return D.isIdentifierStart(e)?this.scanIdentifier():e===40||e===41||e===59?this.scanPunctuator():e===39||e===34?this.scanStringLiteral():e===46?D.isDecimalDigit(this.source.charCodeAt(this.index+1))?this.scanNumericLiteral():this.scanPunctuator():D.isDecimalDigit(e)?this.scanNumericLiteral():e===96||e===125&&this.curlyStack[this.curlyStack.length-1]==="${"?this.scanTemplate():e>=55296&&e<57343&&D.isIdentifierStart(this.codePointAt(this.index))?this.scanIdentifier():this.scanPunctuator()}},y={None:0,Function:1,IfClause:2,ForLoop:4,ForOfLoop:8,WhileLoop:16},xe={AsObject:0,Automatic:1};function qe(e,t=0){let i=e.start-e.lineStart,r=e.lineNumber;return i<0&&(i+=t,r-=1),{index:e.start,line:r,column:i}}function He(e){return[{index:e.range[0],...e.loc.start},{index:e.range[1],...e.loc.end}]}function Ge(e){return e in q?q[e]:0}var Nt=class{constructor(e,t={},i){this.delegate=i,this.hasLineTerminator=!1,this.options={tokens:typeof t.tokens=="boolean"&&t.tokens,comments:typeof t.comments=="boolean"&&t.comments,tolerant:typeof t.tolerant=="boolean"&&t.tolerant},this.options.comments&&(this.commentHandler=new wt),this.errorHandler=new nt(this.options.tolerant),this.scanner=new st(e,this.errorHandler),this.context={isAssignmentTarget:!1,blockContext:y.None,curlyParsingType:xe.AsObject},this.rawToken={type:h.EOF,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0},this.tokens=[],this.startMarker={index:0,line:this.scanner.lineNumber,column:0},this.endMarker={index:0,line:this.scanner.lineNumber,column:0},this.readNextRawToken(),this.endMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}throwIfInvalidType(e,t,{validTypes:i,invalidTypes:r}){i?.some(n=>e.type===n)||r?.some(n=>e.type===n)&&this.throwError(p.InvalidExpression,t)}throwError(e,t,i=this.endMarker){let{index:r,line:n,column:s}=t,a=i.index-r-1;this.errorHandler.throwError({code:e,index:r,line:n,column:s+1,len:a})}tolerateError(e,t){throw new Error("######################################### !!!")}unexpectedTokenError(e={}){let{rawToken:t}=e,{code:i,data:r}=e,n;if(t){if(!i)switch(t.type){case h.EOF:i=p.UnexpectedEndOfScript;break;case h.Identifier:i=p.UnexpectedIdentifier;break;case h.NumericLiteral:i=p.UnexpectedNumber;break;case h.StringLiteral:i=p.UnexpectedString;break;case h.Template:i=p.UnexpectedTemplate;break;default:}n=t.value.toString()}else n="ILLEGAL";i??(i=p.UnexpectedToken),r??(r={value:n});let s=Fe(i,r);if(t){let c=t.start,l=t.lineNumber,g=t.start-t.lineStart+1;return new te({code:i,index:c,line:l,column:g,len:t.end-t.start-1,data:r,description:s})}let{index:a,line:u}=this.endMarker;return new te({code:i,index:a,line:u,column:this.endMarker.column+1,data:r,description:s})}throwUnexpectedToken(e={}){throw e.rawToken??(e.rawToken=this.rawToken),this.unexpectedTokenError(e)}collectComments(e){let{commentHandler:t}=this;!t||!e.length||e.forEach(i=>{let r={type:i.multiLine?o.BlockComment:o.LineComment,value:this.getSourceValue(i),range:i.range,loc:i.loc};t.collectComment(r)})}peekAhead(e){let t=()=>(this.scanner.scanComments(),this.scanner.lex()),i=this.scanner.saveState(),r=e.call(this,t);return this.scanner.restoreState(i),r}getSourceValue(e){return this.scanner.source.slice(e.start,e.end)}convertToToken(e){return{type:Xe[e.type],value:this.getSourceValue(e),range:[e.start,e.end],loc:{start:{line:this.startMarker.line,column:this.startMarker.column},end:{line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}}}readNextRawToken(){this.endMarker.index=this.scanner.index,this.endMarker.line=this.scanner.lineNumber,this.endMarker.column=this.scanner.index-this.scanner.lineStart;let e=this.rawToken;this.collectComments(this.scanner.scanComments()),this.scanner.index!==this.startMarker.index&&(this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart),this.rawToken=this.scanner.lex(),this.hasLineTerminator=e.lineNumber!==this.rawToken.lineNumber,this.options.tokens&&this.rawToken.type!==h.EOF&&this.tokens.push(this.convertToToken(this.rawToken))}captureStartMarker(){return{index:this.startMarker.index,line:this.startMarker.line,column:this.startMarker.column}}getItemLocation(e){return{range:[e.index,this.endMarker.index],loc:{start:{line:e.line,column:e.column},end:{line:this.endMarker.line,column:this.endMarker.column}}}}finalize(e){return(this.delegate??this.commentHandler)&&(this.commentHandler?.attachComments(e),this.delegate?.(e)),e}expectPunctuator(e){let t=this.rawToken;if(this.matchPunctuator(e)){this.readNextRawToken();return}this.throwUnexpectedToken({rawToken:t,code:p.PunctuatorExpected,data:{value:e}})}expectKeyword(e){if(this.rawToken.type===h.Keyword&&this.rawToken.value.toLowerCase()===e.toString()){this.readNextRawToken();return}this.throwUnexpectedToken({rawToken:this.rawToken})}expectContextualKeyword(e){if(this.rawToken.type===h.Identifier&&this.rawToken.value.toLowerCase()===e){this.readNextRawToken();return}this.throwUnexpectedToken({rawToken:this.rawToken})}matchKeyword(e){return this.rawToken.type===h.Keyword&&this.rawToken.value.toLowerCase()===e}matchContextualKeyword(e){return this.rawToken.type===h.Identifier&&this.rawToken.value===e}matchPunctuator(e){return this.rawToken.type===h.Punctuator&&this.rawToken.value===e}getMatchingPunctuator(e){if(typeof e=="string"&&(e=e.split("")),!(this.rawToken.type!==h.Punctuator||!e.length))return e.find(this.matchPunctuator.bind(this))}isolateCoverGrammar(e){let t=this.context.isAssignmentTarget;this.context.isAssignmentTarget=!0;let i=e.call(this);return this.context.isAssignmentTarget=t,i}inheritCoverGrammar(e){var t;let i=this.context.isAssignmentTarget;this.context.isAssignmentTarget=!0;let r=e.call(this);return(t=this.context).isAssignmentTarget&&(t.isAssignmentTarget=i),r}withBlockContext(e,t){let i=this.context.blockContext;this.context.blockContext|=e;let r=this.context.curlyParsingType;this.context.curlyParsingType=xe.Automatic;let n=t.call(this);return this.context.blockContext=i,this.context.curlyParsingType=r,n}consumeSemicolon(){if(this.matchPunctuator(";")){this.readNextRawToken();return}if(!this.hasLineTerminator){if(this.rawToken.type===h.EOF||this.matchPunctuator("}")){this.endMarker.index=this.startMarker.index,this.endMarker.line=this.startMarker.line,this.endMarker.column=this.startMarker.column;return}this.throwUnexpectedToken({rawToken:this.rawToken})}}parsePrimaryExpression(){let e=this.captureStartMarker(),t=this.rawToken;switch(t.type){case h.Identifier:return this.readNextRawToken(),this.finalize({type:o.Identifier,name:t.value,...this.getItemLocation(e)});case h.NumericLiteral:case h.StringLiteral:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value,raw:this.getSourceValue(t),isString:typeof t.value=="string",...this.getItemLocation(e)});case h.BooleanLiteral:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value.toLowerCase()===V.True,raw:this.getSourceValue(t),isString:!1,...this.getItemLocation(e)});case h.NullLiteral:return this.context.isAssignmentTarget=!1,this.readNextRawToken(),this.finalize({type:o.Literal,value:null,raw:this.getSourceValue(t),isString:!1,...this.getItemLocation(e)});case h.Template:return this.parseTemplateLiteral();case h.Punctuator:switch(t.value){case"(":return this.inheritCoverGrammar(this.parseGroupExpression.bind(this));case"[":return this.inheritCoverGrammar(this.parseArrayInitializer.bind(this));case"{":return this.inheritCoverGrammar(this.parseObjectExpression.bind(this));default:return this.throwUnexpectedToken({rawToken:this.rawToken})}case h.Keyword:return this.context.isAssignmentTarget=!1,this.throwUnexpectedToken({rawToken:this.rawToken});default:return this.throwUnexpectedToken({rawToken:this.rawToken})}}parseArrayInitializer(){let e=this.captureStartMarker();this.expectPunctuator("[");let t=[];for(;!this.matchPunctuator("]");){let i=this.captureStartMarker();this.matchPunctuator(",")?(this.readNextRawToken(),this.throwError(p.InvalidExpression,i)):(t.push(this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))),this.matchPunctuator("]")||this.expectPunctuator(","))}return this.expectPunctuator("]"),this.finalize({type:o.ArrayExpression,elements:t,...this.getItemLocation(e)})}parseObjectPropertyKey(){let e=this.captureStartMarker(),t=this.rawToken;switch(t.type){case h.StringLiteral:return this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value,raw:this.getSourceValue(t),isString:!0,...this.getItemLocation(e)});case h.Identifier:case h.BooleanLiteral:case h.NullLiteral:case h.Keyword:return this.readNextRawToken(),this.finalize({type:o.Identifier,name:t.value,...this.getItemLocation(e)});default:this.throwError(p.KeyMustBeString,e)}}parseObjectProperty(){let e=this.rawToken,t=this.captureStartMarker(),i=this.parseObjectPropertyKey(),r=!1,n=null;return this.matchPunctuator(":")?(this.readNextRawToken(),n=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))):e.type===h.Identifier?(r=!0,n=this.finalize({type:o.Identifier,name:e.value,...this.getItemLocation(t)})):this.throwUnexpectedToken({rawToken:this.rawToken}),this.finalize({type:o.Property,kind:"init",key:i,value:n,shorthand:r,...this.getItemLocation(t)})}parseObjectExpression(){let e=this.captureStartMarker();this.expectPunctuator("{");let t=[];for(;!this.matchPunctuator("}");)t.push(this.parseObjectProperty()),this.matchPunctuator("}")||this.expectPunctuator(",");return this.expectPunctuator("}"),this.finalize({type:o.ObjectExpression,properties:t,...this.getItemLocation(e)})}parseTemplateElement(e=!1){let t=this.rawToken;t.type!==h.Template&&this.throwUnexpectedToken({rawToken:t}),e&&!t.head&&this.throwUnexpectedToken({code:p.InvalidTemplateHead,rawToken:t});let i=this.captureStartMarker();this.readNextRawToken();let{value:r,cooked:n,tail:s}=t,a=this.finalize({type:o.TemplateElement,value:{raw:r,cooked:n},tail:s,...this.getItemLocation(i)});return a.loc.start.column+=1,a.loc.end.column-=s?1:2,a}parseTemplateLiteral(){let e=this.captureStartMarker(),t=[],i=[],r=this.parseTemplateElement(!0);for(i.push(r);!r.tail;)t.push(this.parseExpression()),r=this.parseTemplateElement(),i.push(r);return this.finalize({type:o.TemplateLiteral,quasis:i,expressions:t,...this.getItemLocation(e)})}parseGroupExpression(){this.expectPunctuator("(");let e=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));return this.expectPunctuator(")"),e}parseArguments(){this.expectPunctuator("(");let e=[];if(!this.matchPunctuator(")"))for(;;){let t=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));if(e.push(t),this.matchPunctuator(")")||(this.expectPunctuator(","),this.matchPunctuator(")")))break}return this.expectPunctuator(")"),e}parseMemberName(){let e=this.rawToken,t=this.captureStartMarker();return this.readNextRawToken(),e.type!==h.NullLiteral&&e.type!==h.Identifier&&e.type!==h.Keyword&&e.type!==h.BooleanLiteral&&this.throwUnexpectedToken({rawToken:e}),this.finalize({type:o.Identifier,name:e.value,...this.getItemLocation(t)})}parseLeftHandSideExpression(){let e=this.captureStartMarker(),t=this.inheritCoverGrammar(this.parsePrimaryExpression.bind(this)),i=this.captureStartMarker(),r;for(;r=this.getMatchingPunctuator("([.");)switch(r){case"(":{this.context.isAssignmentTarget=!1,t.type!==o.Identifier&&t.type!==o.MemberExpression&&this.throwError(p.IdentifierExpected,e,i);let n=this.parseArguments();t=this.finalize({type:o.CallExpression,callee:t,arguments:n,...this.getItemLocation(e)});continue}case"[":{this.context.isAssignmentTarget=!0,this.expectPunctuator("[");let n=this.isolateCoverGrammar(()=>this.parseExpression());this.expectPunctuator("]"),t=this.finalize({type:o.MemberExpression,computed:!0,object:t,property:n,...this.getItemLocation(e)});continue}case".":{this.context.isAssignmentTarget=!0,this.expectPunctuator(".");let n=this.parseMemberName();t=this.finalize({type:o.MemberExpression,computed:!1,object:t,property:n,...this.getItemLocation(e)});continue}default:break}return t}parseUpdateExpression(){let e=this.captureStartMarker(),t=this.getMatchingPunctuator(Ee);if(t){this.readNextRawToken();let s=this.captureStartMarker(),a=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));return a.type!==o.Identifier&&a.type!==o.MemberExpression&&a.type!==o.CallExpression&&this.throwError(p.InvalidExpression,s),this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInAssignment,e),this.context.isAssignmentTarget=!1,this.finalize({type:o.UpdateExpression,operator:t,argument:a,prefix:!0,...this.getItemLocation(e)})}let i=this.captureStartMarker(),r=this.inheritCoverGrammar(this.parseLeftHandSideExpression.bind(this)),n=this.captureStartMarker();return this.hasLineTerminator||(t=this.getMatchingPunctuator(Ee),!t)?r:(r.type!==o.Identifier&&r.type!==o.MemberExpression&&this.throwError(p.InvalidExpression,i,n),this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInAssignment,e),this.readNextRawToken(),this.context.isAssignmentTarget=!1,this.finalize({type:o.UpdateExpression,operator:t,argument:r,prefix:!1,...this.getItemLocation(e)}))}parseUnaryExpression(){let e=this.getMatchingPunctuator(Je);if(e){let t=this.captureStartMarker();this.readNextRawToken();let i=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));return this.context.isAssignmentTarget=!1,this.finalize({type:o.UnaryExpression,operator:e,argument:i,prefix:!0,...this.getItemLocation(t)})}return this.parseUpdateExpression()}parseBinaryExpression(){let e=this.rawToken,t=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));if(this.rawToken.type!==h.Punctuator)return t;let i=this.rawToken.value,r=Ge(i);if(r===0)return t;this.readNextRawToken(),this.context.isAssignmentTarget=!1;let n=[e,this.rawToken],s=t,a=this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)),u=[s,i,a],c=[r];for(;this.rawToken.type===h.Punctuator&&(r=Ge(this.rawToken.value))>0;){for(;u.length>2&&r<=c[c.length-1];){a=u.pop();let E=u.pop();c.pop(),s=u.pop(),n.pop();let M=n[n.length-1],De=qe(M,M.lineStart);u.push(this.finalize(this.createBinaryOrLogicalExpression(De,E,s,a)))}u.push(this.rawToken.value),c.push(r),n.push(this.rawToken),this.readNextRawToken(),u.push(this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)))}let l=u.length-1;t=u[l];let g=n.pop();for(;l>1;){let E=n.pop();if(!E)break;let M=g?.lineStart,De=qe(E,M),Lt=u[l-1];t=this.finalize(this.createBinaryOrLogicalExpression(De,Lt,u[l-2],t)),l-=2,g=E}return t}createBinaryOrLogicalExpression(e,t,i,r){let n=Ze.includes(t)?o.LogicalExpression:o.BinaryExpression;return n===o.BinaryExpression?{type:n,operator:t,left:i,right:r,...this.getItemLocation(e)}:((i.type===o.AssignmentExpression||i.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,...He(i)),(r.type===o.AssignmentExpression||r.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,...He(i)),{type:n,operator:t,left:i,right:r,...this.getItemLocation(e)})}parseAssignmentExpression(){let e=this.captureStartMarker(),t=this.inheritCoverGrammar(this.parseBinaryExpression.bind(this)),i=this.captureStartMarker(),r=this.getMatchingPunctuator(Qe);if(!r)return t;t.type!==o.Identifier&&t.type!==o.MemberExpression&&this.throwError(p.InvalidExpression,e,i),this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInAssignment,e),this.matchPunctuator("=")||(this.context.isAssignmentTarget=!1),this.readNextRawToken();let n=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));return this.finalize({type:o.AssignmentExpression,left:t,operator:r,right:n,...this.getItemLocation(e)})}parseExpression(){return this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this))}parseStatements(e){let t=[];for(;this.rawToken.type!==h.EOF&&!this.matchPunctuator(e);){let i=this.parseStatementListItem();H(i)||t.push(i)}return t}parseStatementListItem(){return this.context.isAssignmentTarget=!0,this.matchKeyword(f.Function)?this.parseFunctionDeclaration():this.matchKeyword(f.Export)?this.parseExportDeclaration():this.matchKeyword(f.Import)?this.parseImportDeclaration():this.parseStatement()}parseBlock(){let e=this.captureStartMarker();this.expectPunctuator("{");let t=this.parseStatements("}");return this.expectPunctuator("}"),this.finalize({type:o.BlockStatement,body:t,...this.getItemLocation(e)})}parseObjectStatement(){let e=this.captureStartMarker(),t=this.parseObjectExpression();return this.finalize({type:o.ExpressionStatement,expression:t,...this.getItemLocation(e)})}parseBlockOrObjectStatement(){return this.context.curlyParsingType===xe.AsObject?this.parseObjectStatement():this.peekAhead(e=>{let t=e();return!(t.type!==h.Identifier&&t.type!==h.StringLiteral||(t=e(),t.type!==h.Punctuator||t.value!==":"))})?this.parseObjectStatement():this.parseBlock()}parseIdentifier(){let e=this.rawToken;if(e.type!==h.Identifier)return null;let t=this.captureStartMarker();return this.readNextRawToken(),this.finalize({type:o.Identifier,name:e.value,...this.getItemLocation(t)})}parseVariableDeclarator(){let e=this.captureStartMarker(),t=this.parseIdentifier();t||this.throwUnexpectedToken({code:p.IdentifierExpected});let i=null;if(this.matchPunctuator("=")){this.readNextRawToken();let r=this.rawToken;try{i=this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this))}catch{this.throwUnexpectedToken({rawToken:r,code:p.InvalidVariableAssignment})}}return this.finalize({type:o.VariableDeclarator,id:t,init:i,...this.getItemLocation(e)})}parseVariableDeclarators(){let e=[this.parseVariableDeclarator()];for(;this.matchPunctuator(",");)this.readNextRawToken(),e.push(this.parseVariableDeclarator());return e}parseVariableDeclaration(){let e=this.captureStartMarker();this.expectKeyword(f.Var);let t=this.parseVariableDeclarators();return this.consumeSemicolon(),this.finalize({type:o.VariableDeclaration,declarations:t,kind:"var",...this.getItemLocation(e)})}parseEmptyStatement(){let e=this.captureStartMarker();return this.expectPunctuator(";"),this.finalize({type:o.EmptyStatement,...this.getItemLocation(e)})}parseExpressionStatement(){let e=this.captureStartMarker(),t=this.parseExpression();return this.consumeSemicolon(),this.finalize({type:o.ExpressionStatement,expression:t,...this.getItemLocation(e)})}parseIfClause(){return this.withBlockContext(y.IfClause,this.parseStatement.bind(this))}parseIfStatement(){let e=this.captureStartMarker();this.expectKeyword(f.If),this.expectPunctuator("(");let t=this.captureStartMarker(),i=this.parseExpression(),r=this.captureStartMarker();this.expectPunctuator(")"),(i.type===o.AssignmentExpression||i.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,t,r);let n=this.parseIfClause(),s=null;return this.matchKeyword(f.Else)&&(this.readNextRawToken(),s=this.parseIfClause()),this.finalize({type:o.IfStatement,test:i,consequent:n,alternate:s,...this.getItemLocation(e)})}parseWhileStatement(){let e=this.captureStartMarker();this.expectKeyword(f.While),this.expectPunctuator("(");let t=this.captureStartMarker(),i=this.parseExpression(),r=this.captureStartMarker();this.expectPunctuator(")"),(i.type===o.AssignmentExpression||i.type===o.UpdateExpression)&&this.throwError(p.InvalidExpression,t,r);let n=this.withBlockContext(y.WhileLoop,this.parseStatement.bind(this));return this.finalize({type:o.WhileStatement,test:i,body:n,...this.getItemLocation(e)})}parseForStatement(){let e=o.ForStatement,t=null,i=null,r=null,n=null,s=null,a=this.captureStartMarker();if(this.expectKeyword(f.For),this.expectPunctuator("("),this.matchKeyword(f.Var)){let c=this.captureStartMarker();this.readNextRawToken();let l=this.parseVariableDeclarators();t=this.finalize({type:o.VariableDeclaration,declarations:l,kind:"var",...this.getItemLocation(c)});let g=this.matchKeyword(f.In),E=this.matchContextualKeyword(fe.Of);l.length===1&&(g||E)&&(l[0].init&&this.throwError(p.ForInOfLoopInitializer,c),e=g?o.ForInStatement:o.ForOfStatement,n=t)}else if(!this.matchPunctuator(";")){let c=this.context.isAssignmentTarget,l=this.captureStartMarker();t=this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));let g=this.matchKeyword(f.In),E=this.matchContextualKeyword(fe.Of);g||E?(this.context.isAssignmentTarget||this.tolerateError(p.InvalidLeftHandSideInForIn,l),t.type!==o.Identifier&&this.throwError(p.InvalidLeftHandSideInForIn,l),e=g?o.ForInStatement:o.ForOfStatement,n=t):this.context.isAssignmentTarget=c}e===o.ForStatement?(this.expectPunctuator(";"),i=this.matchPunctuator(";")?null:this.isolateCoverGrammar(this.parseExpression.bind(this)),this.expectPunctuator(";"),r=this.matchPunctuator(")")?null:this.isolateCoverGrammar(this.parseExpression.bind(this))):(this.readNextRawToken(),s=this.parseExpression()),this.expectPunctuator(")");let u=this.withBlockContext(e===o.ForOfStatement?y.ForOfLoop:y.ForLoop,()=>this.isolateCoverGrammar(this.parseStatement.bind(this)));return e===o.ForInStatement||e===o.ForOfStatement?this.finalize({type:e,left:n,right:s,body:u,...this.getItemLocation(a)}):this.finalize({type:e,init:t,test:i,update:r,body:u,...this.getItemLocation(a)})}parseContinueStatement(){let e=this.captureStartMarker();return this.expectKeyword(f.Continue),this.consumeSemicolon(),this.finalize({type:o.ContinueStatement,...this.getItemLocation(e)})}parseBreakStatement(){let e=this.captureStartMarker();return this.expectKeyword(f.Break),this.consumeSemicolon(),this.finalize({type:o.BreakStatement,...this.getItemLocation(e)})}parseReturnStatement(){let e=this.captureStartMarker();this.expectKeyword(f.Return);let t=!this.matchPunctuator(";")&&!this.matchPunctuator("}")&&!this.hasLineTerminator&&this.rawToken.type!==h.EOF||this.rawToken.type===h.StringLiteral||this.rawToken.type===h.Template?this.parseExpression():null;return this.consumeSemicolon(),this.finalize({type:o.ReturnStatement,argument:t,...this.getItemLocation(e)})}parseStatement(){switch(this.rawToken.type){case h.BooleanLiteral:case h.NullLiteral:case h.NumericLiteral:case h.StringLiteral:case h.Template:case h.Identifier:return this.parseExpressionStatement();case h.Punctuator:return this.rawToken.value==="{"?this.parseBlockOrObjectStatement():this.rawToken.value==="("?this.parseExpressionStatement():this.rawToken.value===";"?this.parseEmptyStatement():this.parseExpressionStatement();case h.Keyword:switch(this.rawToken.value.toLowerCase()){case f.Break:return this.parseBreakStatement();case f.Continue:return this.parseContinueStatement();case f.For:return this.parseForStatement();case f.Function:return this.parseFunctionDeclaration();case f.If:return this.parseIfStatement();case f.Return:return this.parseReturnStatement();case f.Var:return this.parseVariableDeclaration();case f.While:return this.parseWhileStatement();default:return this.parseExpressionStatement()}default:return this.throwUnexpectedToken({rawToken:this.rawToken})}}parseFormalParameters(){let e=[];if(this.expectPunctuator("("),!this.matchPunctuator(")"))for(;this.rawToken.type!==h.EOF;){let t=this.parseIdentifier();if(t||this.throwUnexpectedToken({rawToken:this.rawToken,code:p.IdentifierExpected}),e.push(t),this.matchPunctuator(")")||(this.expectPunctuator(","),this.matchPunctuator(")")))break}return this.expectPunctuator(")"),e}parseFunctionDeclaration(){(this.context.blockContext&y.Function)===y.Function&&this.throwUnexpectedToken({code:p.NoFunctionInsideFunction}),((this.context.blockContext&y.WhileLoop)===y.WhileLoop||(this.context.blockContext&y.ForOfLoop)===y.ForOfLoop||(this.context.blockContext&y.IfClause)===y.IfClause)&&this.throwUnexpectedToken({code:p.NoFunctionInsideBlock});let e=this.captureStartMarker();this.expectKeyword(f.Function);let t=this.parseIdentifier();t||this.throwUnexpectedToken({code:p.InvalidFunctionIdentifier});let i=this.parseFormalParameters(),r=this.context.blockContext;this.context.blockContext|=y.Function;let n=this.parseBlock();return this.context.blockContext=r,this.finalize({type:o.FunctionDeclaration,id:t,params:i,body:n,...this.getItemLocation(e)})}parseScript(){let e=this.captureStartMarker(),t=this.parseStatements(),i=this.finalize({type:o.Program,body:t,...this.getItemLocation(e)});return this.options.tokens&&(i.tokens=this.tokens),this.options.tolerant&&(i.errors=this.errorHandler.errors),i}parseExportDeclaration(){this.context.blockContext!==y.None&&this.throwUnexpectedToken({code:p.ModuleExportRootOnly});let e=null,t=this.captureStartMarker();return this.expectKeyword(f.Export),this.matchKeyword(f.Var)?e=this.parseVariableDeclaration():this.matchKeyword("function")?e=this.parseFunctionDeclaration():this.throwUnexpectedToken({code:p.InvalidExpression}),this.finalize({type:o.ExportNamedDeclaration,declaration:e,specifiers:[],source:null,...this.getItemLocation(t)})}parseModuleSpecifier(){let e=this.captureStartMarker(),t=this.rawToken;if(t.type===h.StringLiteral)return this.readNextRawToken(),this.finalize({type:o.Literal,value:t.value,raw:this.getSourceValue(t),isString:!0,...this.getItemLocation(e)});this.throwError(p.InvalidModuleUri,e)}parseDefaultSpecifier(){let e=this.captureStartMarker(),t=this.parseIdentifier();return t||this.throwUnexpectedToken({code:p.IdentifierExpected}),this.finalize({type:o.ImportDefaultSpecifier,local:t,...this.getItemLocation(e)})}parseImportDeclaration(){this.context.blockContext!==y.None&&this.throwUnexpectedToken({code:p.ModuleImportRootOnly});let e=this.captureStartMarker();this.expectKeyword(f.Import);let t=this.parseDefaultSpecifier();this.expectContextualKeyword(fe.From);let i=this.parseModuleSpecifier();return this.finalize({type:o.ImportDeclaration,specifiers:[t],source:i,...this.getItemLocation(e)})}},Mt=class{constructor(e,t){this.errorHandler=new nt,this.errorHandler.tolerant=t?typeof t.tolerant=="boolean"&&t.tolerant:!1,this.scanner=new st(e,this.errorHandler),this.trackComments=t?typeof t.comment=="boolean"&&t.comment:!1,this.buffer=[]}errors(){return this.errorHandler.errors}getNextToken(){if(this.buffer.length===0){let e=this.scanner.scanComments();if(this.trackComments&&e.forEach(t=>{let i=this.scanner.source.slice(t.start,t.end),r={type:t.multiLine?o.BlockComment:o.LineComment,value:i,range:t.range,loc:t.loc};this.buffer.push(r)}),!this.scanner.eof()){let t={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},i=this.scanner.lex(),r={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},n={type:Xe[i.type],value:this.scanner.source.slice(i.start,i.end),range:[i.start,i.end],loc:{start:t,end:r}};this.buffer.push(n)}}return this.buffer.shift()}};function Z(e,t,i){return new Nt(e,t,i).parseScript()}function at(e,t,i){let r=new Mt(e,t),n=[],s;try{let a;for(;a=r.getNextToken();)i&&(a=i(a)),n.push(a)}catch(a){a instanceof Error&&r.errorHandler.tolerate(a)}return r.errorHandler.tolerant&&(s=r.errors()),{tokens:n,errors:s}}import{DiagnosticSeverity as F}from"vscode-languageserver-types";var d={AlreadyDefined:"AlreadyDefined",ApiConflict:"ApiConflict",AssignedNeverUsed:"AssignedNeverUsed",DefinedNeverAssigned:"DefinedNeverAssigned",DefinedNeverUsed:"DefinedNeverUsed",EmptyBlockStatement:"EmptyBlockStatement",ExecutionError:"ExecutionError",InvalidApiFunctionUsage:"InvalidApiFunctionUsage",InvalidConstantIdentifier:"InvalidConstantIdentifier",InvalidPropertyIdentifier:"InvalidPropertyIdentifier",NoArgumentExpected:"NoArgumentExpected",NotADictionary:"NotADictionary",NotDefined:"NotDefined",NotEnoughArguments:"NotEnoughArguments",ProfileVariablesAreImmutable:"ProfileVariablesAreImmutable",ProfileVariablesConflict:"ProfileVariablesConflict",ReservedKeyword:"ReservedKeyword",TooManyArguments:"TooManyArguments",UnexpectedEmptyFunction:"UnexpectedEmptyFunction",UnexpectedPropertyIdentifier:"UnexpectedPropertyIdentifier",UnknownPropertyIdentifier:"UnknownPropertyIdentifier"},ot={[d.AlreadyDefined]:"'${identifier}' is already defined.",[d.ApiConflict]:"'${identifier}' is already defined as an Arcade constant or function.",[d.AssignedNeverUsed]:"'${identifier}' is assigned but never used.",[d.DefinedNeverAssigned]:"'${identifier}' is defined but never assigned.",[d.DefinedNeverUsed]:"'${identifier}' is defined but never used.",[d.EmptyBlockStatement]:"Empty block statement.",[d.ExecutionError]:"Execution Error: '${stack}'",[d.InvalidApiFunctionUsage]:"Arcade function '${identifier}' not used in a call expression.",[d.InvalidConstantIdentifier]:"Invalid constant identifier, expecting ${list}.",[d.InvalidPropertyIdentifier]:"Invalid property identifier, expecting ${list}.",[d.NoArgumentExpected]:"Expecting no argument.",[d.NotADictionary]:"'${identifier}' doesn't have properties.",[d.NotDefined]:"'${identifier}' is not defined.",[d.NotEnoughArguments]:"Expecting at least ${min} argument(s).",[d.ProfileVariablesAreImmutable]:"Profile variables cannot be modified.",[d.ProfileVariablesConflict]:"'${identifier}' is already defined as a profile variable.",[d.ReservedKeyword]:"'${identifier}' is a reserved keyword.",[d.TooManyArguments]:"Too many arguments, expecting ${max}.",[d.UnexpectedEmptyFunction]:"Unexpected empty function '${identifier}'.",[d.UnexpectedPropertyIdentifier]:"Unexpected property identifier.",[d.UnknownPropertyIdentifier]:"Unknown property identifier '${identifier}'.",...ye};function re(e,t){return e.line-t.line||e.column-t.column}function ut(e,t){let i={start:e.loc.start,end:e.loc.end},r=n=>Ot(i,n.loc);return re(i.start,i.end)<0&&(i.start={...i.start},t.skipSpaces(i.start),re(i.start,i.end)<0&&(i.end={...i.end},t.skipSpaces(i.end,!0))),e.leadingComments?.forEach(r),e.trailingComments?.forEach(r),i}function Ot(e,t){re(t.start,e.start)<0&&(e.start=t.start),re(e.end,t.end)<0&&(e.end=t.end)}var Ut=/\S/u;function X(e=""){return!Ut.test(e)}var Le={indentWidth:2,wrapColumn:80,quote:null};function R(e){return{indentWidth:e?.indentWidth??Le.indentWidth,wrapColumn:e?.wrapColumn??Le.wrapColumn,quote:e?.quote??Le.quote}}var jt=/^\s*/u,Vt=/\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u,ne=class e{constructor(t){this.lineRecords=t;this.length=t.length}static fromString(t,i){if(typeof t!="string")return t;let r=i?.indentWidth;return new e(t.split(Vt).map(s=>{let a=jt.exec(s)?.[0]??"";return{line:s,indentation:zt(a,r),locked:!1,sliceStart:a.length,sliceEnd:s.length}}))}toString(){return this.sliceString(this.firstPos(),this.lastPos())}charAt(t){let{line:i,column:r}=t,n=this.lineRecords[i-1];if(typeof n>"u"||r<0)return"";let s=this.getIndentationAt(i);if(r<s)return" ";let a=r+n.sliceStart-s;return a===n.sliceEnd&&i<this.length?`
8
8
  `:a>=n.sliceEnd?"":n.line.charAt(a)}getIndentationAt(t){return Math.max(this.lineRecords[t-1].indentation,0)}getLineLength(t){let i=this.lineRecords[t-1];return this.getIndentationAt(t)+i.sliceEnd-i.sliceStart}getStatementLineSeparators(t){let i=this.slice(t,this.skipSpaces({...t})??this.lastPos());return i.length===1||!X(i.lineRecords[1].line)?[`
9
9
  `]:[`
10
10
  `,`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/arcade-languageservice",
3
- "version": "4.32.0-next.98",
3
+ "version": "4.32.0",
4
4
  "description": "Arcade Language Service",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "type": "module",