@cratis/screenplay-language 4.61.0 → 4.62.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 (40) hide show
  1. package/dist/AuthoredCommandRoute.d.ts +14 -0
  2. package/dist/AuthoredCommandRoute.d.ts.map +1 -0
  3. package/dist/AuthoredEventSource.d.ts +12 -0
  4. package/dist/AuthoredEventSource.d.ts.map +1 -0
  5. package/dist/AuthoredStream.d.ts +10 -0
  6. package/dist/AuthoredStream.d.ts.map +1 -0
  7. package/dist/AuthoringDocument.d.ts +1 -0
  8. package/dist/AuthoringDocument.d.ts.map +1 -1
  9. package/dist/EventSourceAnalysis.d.ts +29 -0
  10. package/dist/EventSourceAnalysis.d.ts.map +1 -0
  11. package/dist/bundles/chunk-ZWIZSFH3.js +16 -0
  12. package/dist/bundles/chunk-ZWIZSFH3.js.map +7 -0
  13. package/dist/bundles/index.js +47 -36
  14. package/dist/bundles/index.js.map +4 -4
  15. package/dist/bundles/sub-languages/projection/index.js +1 -1
  16. package/dist/bundles/sub-languages/projection/index.js.map +1 -1
  17. package/dist/completion-items.d.ts.map +1 -1
  18. package/dist/completions.d.ts +3 -0
  19. package/dist/completions.d.ts.map +1 -1
  20. package/dist/diagnostic-codes.d.ts +5 -0
  21. package/dist/diagnostic-codes.d.ts.map +1 -1
  22. package/dist/diagnostics.d.ts +3 -2
  23. package/dist/diagnostics.d.ts.map +1 -1
  24. package/dist/event-source-authoring.d.ts +39 -0
  25. package/dist/event-source-authoring.d.ts.map +1 -0
  26. package/dist/hover-content.d.ts.map +1 -1
  27. package/dist/index.d.ts +6 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/language.d.ts.map +1 -1
  30. package/dist/response-analysis.d.ts +3 -1
  31. package/dist/response-analysis.d.ts.map +1 -1
  32. package/dist/response-tokens.d.ts +2 -1
  33. package/dist/response-tokens.d.ts.map +1 -1
  34. package/dist/symbols.d.ts +4 -0
  35. package/dist/symbols.d.ts.map +1 -1
  36. package/dist/tokens.d.ts.map +1 -1
  37. package/dist/validation.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/bundles/chunk-UNPNNHWD.js +0 -14
  40. package/dist/bundles/chunk-UNPNNHWD.js.map +0 -7
@@ -0,0 +1,16 @@
1
+ import{a}from"./chunk-AYDF3IFZ.js";var to="screenplay",Rc={id:to,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Tc=["domain","import","concept","type","policy","persona","authentication","module","layout","theme","ui","feature","slice","event","system","eventsource","operation","command","query","projection","capture","reaction","reducer","trigger","screen","dialog","form","contribute","constraint","specification","seed","behavior"];var Pt=["description","template","profile","require","authenticated","role","claim","subject","authorize","validate","produces","reads","as","handler","performer","observable","identifier","reason","from","when","given","then","arguments","result","clock","exactly","error","message","not","empty","rule","matches","all","max","min","length","today","true","false","and","or","by","filter","data","via","action","navigate","to","label","section","table","summary","title","column","field","on","unique","file","concurrency","eventSource","sourceType","streamType","streamId","tag","for","readmodel","no","when","every","at","where","invokes","contains","starts","with","provider","uses","parameter","order","execute","open","close","refresh","set","notify","confirm","raise","interval","success","failure","click","double","select","submit","change","load","unload","enter","leave","info","warning"],Lc=["csharp","typescript","react","html","sql"],An=["command","arguments","tenant","causedBy","causation","occurred","identity"],Dn=["subject","name","userName"],On=["id","name","userName","isAuthenticated","roles","claims"],Rn=["StateChange","StateView","Automation","Translate"],Je=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Mc=["@pii","@sensitive"],xc={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},indentationRules:{increaseIndentPattern:/^\s*(module|feature|slice|policy|persona|authentication|provider|event|command|query|type|screen|projection|capture|reaction|trigger|constraint|specification|layout|template|validate|produces|handler|implementation(?=\s*$)|performer|rule|section|concurrency|seed|for|when|then|arguments|result|every|at)\b.*$/,decreaseIndentPattern:/(?!)/}};function xe(n){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(n);return{name:e?.[1]??n,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}a(xe,"typeReferenceSymbol");function Yc(n){return`${n.name}${n.isCollection?"[]":""}${n.isOptional?" optional":""}`}a(Yc,"typeReferenceText");function ke(n){let e=!1,t=!1;for(let i=0;i<n.length;i++){let o=n[i];if(o==="\\"&&e&&i+1<n.length)i++;else if(o==='"'&&!t)e=!e;else if(o==="`"&&!e)t=!t;else if(!e&&!t&&o==="/"&&n[i+1]==="/")return n.slice(0,i)}return n}a(ke,"withoutComment");function U(n){return n.length-n.trimStart().length}a(U,"indentOf");function Tn(n){return n.trim().split(/\s+/)[0]??""}a(Tn,"firstWord");function X(n){let e=new Array(n.length).fill(!1),t=!1;for(let i=0;i<n.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(n[i])&&(!t||/^\s*```\s*$/.test(n[i]))){e[i]=!0,t=!t;continue}e[i]=t}return e}a(X,"fenceMap");function Ct(n,e,t,i){let o=[],r=i;for(let s=t-1;s>=0&&r>0;s--){if(e[s])continue;let c=ke(n[s]);if(c.trim().length===0)continue;let p=U(c);p<r&&(o.push(Tn(c)),r=p)}return o}a(Ct,"enclosingChain");function Fc(n,e,t,i){for(let o=t-1;o>=0&&i>0;o--){if(e[o])continue;let r=ke(n[o]);if(r.trim().length!==0&&U(r)<i)return r.trim()}}a(Fc,"nearestEnclosingLine");var d={InvalidProducesDeclaration:"PLAY0042",ProducesWhenWithoutEvent:"PLAY0043",InvalidPropertyMapping:"PLAY0044",DuplicateProducesTarget:"PLAY0193",EventSourceIdInPayload:"PLAY0469",ExplicitProducesTargetsRequired:"PLAY0470",RedundantEventId:"PLAY0471",InvalidEventId:"PLAY0472",InlineEventCollision:"PLAY0473",InlineEventOutsideCommand:"PLAY0474",InlineEventGeneration:"PLAY0475",ReservedProductionMetadata:"PLAY0476",InvalidEventDocumentation:"PLAY0477",UnknownTopLevelConstruct:"PLAY0001",InvalidDomainDeclaration:"PLAY0002",DuplicateDomain:"PLAY0003",DomainNotFirst:"PLAY0004",InvalidImportDeclaration:"PLAY0005",TabIndentation:"PLAY0006",InvalidConceptDeclaration:"PLAY0007",UnknownPrimitiveType:"PLAY0008",InvalidEnumerationValue:"PLAY0009",UnknownConceptDirective:"PLAY0010",ValidateReadAsEnumerationBlock:"PLAY0011",AttributeReasonWithoutAttribute:"PLAY0012",DuplicateAttributeReason:"PLAY0013",InvalidTypeDeclaration:"PLAY0014",TypeWithoutProperties:"PLAY0015",InvalidPropertyDeclaration:"PLAY0016",IdentifierOutsideCommand:"PLAY0017",InvalidEventDeclaration:"PLAY0018",IdentifierOnEventProperty:"PLAY0019",TagPropertyReadAsTag:"PLAY0020",InvalidModuleDeclaration:"PLAY0021",UnknownModuleDirective:"PLAY0022",InvalidFeatureDeclaration:"PLAY0023",UnknownFeatureDirective:"PLAY0024",InvalidSliceDeclaration:"PLAY0027",UnknownSliceType:"PLAY0028",UnknownSliceDirective:"PLAY0029",InvalidPersonaDeclaration:"PLAY0030",InvalidPersonaPolicyReference:"PLAY0031",UnknownPersonaDirective:"PLAY0032",InvalidCommandDeclaration:"PLAY0033",UnknownCommandDirective:"PLAY0034",DuplicateCommandIdentifier:"PLAY0036",InvalidQueryDeclaration:"PLAY0047",UnknownQueryDirective:"PLAY0048",InvalidQueryParameter:"PLAY0049",InvalidProjectionDeclaration:"PLAY0056",EmptyProjection:"PLAY0057",UnknownProjectionDirective:"PLAY0058",FromWithoutEvent:"PLAY0061",InvalidEventReference:"PLAY0062",InvalidJoinDeclaration:"PLAY0063",JoinWithoutEvent:"PLAY0064",InvalidChildrenDeclaration:"PLAY0065",InvalidNestedDeclaration:"PLAY0066",NestedBlockWithoutFrom:"PLAY0067",InvalidRemoveDeclaration:"PLAY0068",UnknownRemoveDirective:"PLAY0069",InvalidClearDeclaration:"PLAY0070",ClearWithOutsideNestedBlock:"PLAY0071",InvalidSpecificationDeclaration:"PLAY0094",UnknownSpecificationDirective:"PLAY0095",InvalidSpecificationWhen:"PLAY0096",DuplicateSpecificationWhen:"PLAY0097",InvalidThenError:"PLAY0098",InvalidReadModelStep:"PLAY0099",InvalidEventStep:"PLAY0100",InvalidSpecificationValue:"PLAY0101",InvalidScreenDeclaration:"PLAY0102",UnknownScreenDirective:"PLAY0103",InvalidDataDirective:"PLAY0104",InvalidActionDirective:"PLAY0105",UnknownActionDirective:"PLAY0106",InvalidNavigation:"PLAY0107",InvalidScreenLayoutSlot:"PLAY0108",InvalidTitleDirective:"PLAY0109",UnknownTableDirective:"PLAY0110",UnknownSummaryDirective:"PLAY0111",AuthorizeWithoutPolicy:"PLAY0122",InvalidPolicyReference:"PLAY0123",InvalidConstraintDeclaration:"PLAY0132",ConstraintWithoutRule:"PLAY0133",InvalidConstraintBody:"PLAY0134",DuplicateConstraintBody:"PLAY0135",InvalidReactionDeclaration:"PLAY0136",InvalidReactionTrigger:"PLAY0137",ReactionWithoutTrigger:"PLAY0138",InvalidValidateDeclaration:"PLAY0140",InvalidValidationRule:"PLAY0141",InvalidRuleName:"PLAY0143",InvalidDescription:"PLAY0145",EmptyDescription:"PLAY0146",DuplicateDescription:"PLAY0147",TagWithoutValue:"PLAY0148",InvalidTagValue:"PLAY0149",UnknownContextPath:"PLAY0153",UnknownContextCausedByProperty:"PLAY0154",UnknownContextIdentityProperty:"PLAY0155",ExpectedCodeFence:"PLAY0163",UnclosedCodeBlock:"PLAY0164",DuplicateDeclaration:"PLAY0168",RepeatedSingularDeclarationAcrossFiles:"PLAY0172",RepeatedDeclarationAcrossFiles:"PLAY0173",ConflictingDescriptionAcrossFiles:"PLAY0174",UnexpectedTokenInAuthorize:"PLAY0184",UnclosedAuthorizeGroup:"PLAY0185",InvalidReadModelDeclaration:"PLAY0186",InvalidInvokesDeclaration:"PLAY0194",InvalidScopeDeclaration:"PLAY0199",DuplicateScope:"PLAY0200",InvalidIntervalTrigger:"PLAY0249",InvalidScheduleTrigger:"PLAY0250",DuplicateReactionTrigger:"PLAY0253",InvalidSpecificationEventSource:"PLAY0275",DuplicateSpecificationEventSource:"PLAY0276",InvalidProjectionVariantDeclaration:"PLAY0277",InvalidEntersOnDeclaration:"PLAY0279",NestedProjectionVariantNotAllowed:"PLAY0280",InvalidStructuredValue:"PLAY0291",DuplicateStructuredValueMember:"PLAY0294",ConflictingSpecificationActions:"PLAY0358",InvalidSpecificationEventOrder:"PLAY0359",InvalidValidationSeverity:"PLAY0368",VariantRequiresEnteringEvent:"PLAY0382",DuplicateProjectionVariant:"PLAY0384",DuplicateVariantEnteringEvent:"PLAY0385",InvalidSpecificationDenied:"PLAY0388",DuplicateAuthorizationAcrossFiles:"PLAY0394",FileConstraintOnlySupportsUniqueness:"PLAY0396",LegacyInlineCodeFence:"PLAY0397",InvalidEventGeneration:"PLAY0446",InvalidFileImport:"PLAY0454",FileImportMatchesNothing:"PLAY0455",ImportedFileNotFound:"PLAY0456",ConflictingImportPlacement:"PLAY0457",ImportCycle:"PLAY0458",ModuleInPlacedFile:"PLAY0459",UnexpectedInPlacedFile:"PLAY0460",InvalidSpecificationClock:"PLAY0461",InvalidSpecificationTrigger:"PLAY0462",InvalidSpecificationCapture:"PLAY0463",InvalidSpecificationQueryAction:"PLAY0464",LegacyOptionalSuffix:"PLAY0479",InvalidOptionalModifierOrder:"PLAY0480",OptionalReadsNotSupported:"PLAY0481",DuplicateSpecificationCallerOrDenied:"PLAY0387",GeneratedPropertyOutsideCommand:"PLAY0482",InvalidGeneratedType:"PLAY0483",InvalidGeneratedModifierOrder:"PLAY0484",GeneratedPropertySuppliedAsInput:"PLAY0485",InvalidCommandResponse:"PLAY0486",InvalidResponseSource:"PLAY0487",DuplicateResponseField:"PLAY0488",InvalidResponseShape:"PLAY0489",InvalidGeneratedFixture:"PLAY0490",InvalidReturnExpectation:"PLAY0491",InvalidImplementationBlock:"PLAY0492",InvalidImplementationHint:"PLAY0493",ConflictingImplementationSources:"PLAY0494",UnknownType:"PLAY0165",InvalidSystemDeclaration:"PLAY0495",InvalidOperationDeclaration:"PLAY0496",InvalidProductionReference:"PLAY0497",ProductionDeclarationCollision:"PLAY0498",OperationOutsideCommand:"PLAY0499",InvalidSystemReference:"PLAY0500",InvalidOperationMapping:"PLAY0501",InvalidOperationSpecification:"PLAY0502",InvalidEventSourceDeclaration:"PLAY0503",InvalidCommandStream:"PLAY0504",AmbiguousCommandStream:"PLAY0505",UnsupportedStreamIdType:"PLAY0506",RedundantSourceStreamId:"PLAY0507",HandlerWithoutImplementation:"PLAY0045",UnknownHandlerDirective:"PLAY0046",CommandWithProducesAndHandler:"PLAY0035",AbsoluteFileReference:"PLAY0264",InvalidTriggerData:"PLAY0246"};function Pe(n,e=!1,t){let i=[],o=0,r=0;for(let s of n.split(`
2
+ `)){o++;let c=s.endsWith("\r")?s.replace(/\r+$/,""):s,p=c.length-c.trimStart().length,f=io(c.substring(p),e).trimEnd();i.push(t===void 0?{number:o,raw:c,indent:p,content:f,startOffset:r}:{number:o,raw:c,indent:p,content:f,path:t,startOffset:r}),r+=s.length+1}return i}a(Pe,"splitLines");function Ln(n,e=!1){let t=!1,i=!1;for(let o=0;o<n.length;o++){let r=n[o];if(r==="\\"&&t&&o+1<n.length)o++;else if(r==='"'&&!i)t=!t;else if(r==="`"&&!t)i=!i;else if(!t&&!i&&(r==="/"&&o+1<n.length&&n[o+1]==="/"||e&&r==="#"))return o}return-1}a(Ln,"commentStart");function io(n,e){let t=Ln(n,e);return t<0?n:n.substring(0,t)}a(io,"stripComment");var Se=[],Ne=a(n=>n.length===0,"isDocumentPlacement");function Ke(n){return n.length===0?"the application":n.length===1?`module '${n[0]}'`:`feature '${n.join(".")}'`}a(Ke,"describePlacement");var It="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}";function v(n){let e="",t=!1;for(let i=0;i<n.length;i++){let o=n[i];if(o==="\\"&&i+1<n.length){let r=n[i+1];i++,r==="w"?e+=t?It:`[${It}]`:r==="d"?e+="\\p{Nd}":e+=`\\${r}`;continue}o==="["&&!t?t=!0:o==="]"&&t&&(t=!1),e+=o}return new RegExp(e,"u")}a(v,"pattern");var Ye=a((n,e,t)=>t===void 0?{line:n,column:e}:{line:n,column:e,path:t},"sourceLocation");var $t=a(n=>n.content.length===0,"isBlank"),l=a(n=>Ye(n.number,n.indent+1,n.path),"locationOf"),Et=a(n=>Ye(n.number,1,n.path),"startOf");var oo=v("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),ro=new RegExp(v("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),so=v("^[A-Z]\\w*$");function he(n,e){let t=e.content.substring(9);for(let c=n.peekChild(e.indent);c!==void 0&&oo.test(c.content);c=n.peekChild(e.indent))n.reader.takeSignificant(),t+=` ${c.content}`;let i=ao(t),o=l(e);if(i.length===0)return n.error(d.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",o),null;let s=new Mn(n,i,o).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:o}}a(he,"parseAuthorize");function ae(n,e){return n===null?e:e===null?n:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:n.requirement,operator:"And",right:e.requirement,location:n.location},location:n.location}}a(ae,"combineAuthorize");function ao(n){let e=[];for(let t of n.match(ro)??[])e.length>0&&co(e[e.length-1])&&lo(t)&&e.push("and"),e.push(t);return e}a(ao,"tokenize");var At=a(n=>n!=="("&&n!==")"&&n!=="and"&&n!=="or","isName"),co=a(n=>n===")"||At(n),"isOperandEnd"),lo=a(n=>n==="("||At(n),"isOperandStart"),Mn=class{static{a(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,t,i){this.context=e,this.tokens=t,this.location=i}parse(){let e=this.#n();return e!==null&&this.#e<this.tokens.length&&this.context.error(d.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#n(){return this.#t("or","Or",()=>this.#i())}#i(){return this.#t("and","And",()=>this.#o())}#t(e,t,i){let o=i();for(;o!==null&&this.tokens[this.#e]===e;){this.#e++;let r=i();if(r===null)return null;o={kind:"LogicalPolicyRequirementSyntax",left:o,operator:t,right:r,location:this.location}}return o}#o(){if(this.tokens[this.#e]!=="(")return this.#a();this.#e++;let e=this.#n();return this.tokens[this.#e]===")"?this.#e++:this.context.error(d.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#a(){if(this.#e>=this.tokens.length)return this.context.error(d.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return so.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(d.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};var H='(?:[^"\\\\]|\\\\.)*',po={"\\":"\\",'"':'"',n:`
3
+ `,r:"\r",t:" "};function G(n){if(!n.includes("\\"))return n;let e="";for(let t=0;t<n.length;t++){let i=t+1<n.length?po[n[t+1]]:void 0;n[t]==="\\"&&i!==void 0?(e+=i,t++):e+=n[t]}return e}a(G,"unescapeString");function Ce(n,e,t,i=!1){let r=t.content.startsWith("```")?t:n.reader.peekSignificant(),s=e==="description"?"```text":`\`\`\`${e}`;if(r===void 0||r!==t&&r.indent<=t.indent||r.content!==s&&!(i&&e==="description"&&r.content==="```markdown")&&!(r.content==="```"&&r!==t))return n.error(d.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,l(t)),null;r!==t&&n.reader.takeSignificant(),e==="description"&&r.content==="```"&&n.warning(d.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",l(r));let c=[];for(;;){let p=n.reader.takeRaw();if(p===void 0){n.error(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",l(r));break}if(p.raw.trim()==="```")break;let f=0;for(;f<r.indent&&f<p.raw.length&&p.raw[f]===" ";)f++;c.push(p.raw.substring(f))}return c.join(`
4
+ `)}a(Ce,"parseFencedText");var uo=v(`^description\\s+"(${H})"$`);function j(n,e,t,i,o=!1){if(e.content==="description"){let s=Ce(n,"description",e,o);return s===null?t:s.trim().length===0?(n.error(d.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,l(e)),t):Dt(n,e,t,i,s)}let r=uo.exec(e.content);return r===null?(n.error(d.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,l(e)),t):Dt(n,e,t,i,G(r[1]))}a(j,"parseDescription");function Dt(n,e,t,i,o){return t!==null?(n.error(d.DuplicateDescription,`${i} already declares a description - at most one is allowed`,l(e)),t):o}a(Dt,"keep");var fo=v('^import\\s+"([^"\\\\]+)"$'),mo=v('^import\\s+"'),Ot=a(n=>mo.test(n),"isFileImport");function Rt(n){let e=fo.exec(n.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:l(n)}}a(Rt,"tryParseFileImport");function Ie(n,e,t){let i=Rt(e);if(i!==void 0){t.push(i);return}n.error(d.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,l(e)),n.skipBlock(e.indent)}a(Ie,"parseFileImport");var R=a(n=>{let e=n.indexOf(" ");return e===-1?n:n.substring(0,e)},"firstWord"),V=a(n=>n.replaceAll("@",""),"unescapeIdentifier");function Tt(n,e){let t=[],i=0,o=!1,r=!1;for(let s=0;s<n.length;s++){let c=n[s];c==="\\"&&o&&s+1<n.length?s++:c==='"'&&!r?o=!o:c==="`"&&!o?r=!r:c===e&&!o&&!r&&(t.push(n.substring(i,s)),i=s+1)}return t.push(n.substring(i)),t}a(Tt,"splitTopLevel");var ho=v("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),vo=v("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),go=v("^field\\s+([\\w.]+)(?:\\s|$)"),yo=v("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),ko=v("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),So=v("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),wo=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on"]);function te(n,e){let t=[],i=new Set,o=[],r=R(e.content)==="behavior",s=a(c=>{for(;t.length>0&&t[t.length-1].indent>=c.indent;)t.pop();let p=r&&t.length===0?So.exec(c.content):null;p!==null&&i.add(p[1]);let f=ho.exec(c.content),b=vo.exec(c.content);if(f!==null)t.push({command:f[1],kind:"form",indent:c.indent});else if(b!==null)t.push({command:b[2],kind:b[1],indent:c.indent});else if(wo.has(R(c.content)))t.push({command:"",kind:"other",indent:c.indent});else{let u=t.at(-1);if(u===void 0||u.kind==="other")return;let k=(u.kind==="form"?go:u.kind==="execute"?yo:ko).exec(c.content);k!==null&&o.push({command:u.command,property:V(k[1]),scope:n.scope,location:l(c)})}},"recognize");s(e);for(let c=n.peekChild(e.indent);c!==void 0;c=n.peekChild(e.indent))n.reader.takeSignificant(),c.content.startsWith("```")?n.skipFencedBody():s(c);for(let c of o)n.inputUses.push(i.has(c.command)?{...c,isParameter:!0}:c)}a(te,"collectInputUses");var Lt=["StateChange","StateView","Automation","Translate"];var bo=v("^capture\\s+([A-Za-z_]\\w*)$"),Po=v("^append\\s+([A-Z]\\w*)$"),Co=v("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),Io=v("^nested\\s+([\\w.]+)$");function xt(n,e){let t=bo.exec(e.content)?.[1]??"",i=null,o=null,r=[],s=[],c=[];for(let p=n.peekChild(e.indent);p!==void 0;p=n.peekChild(e.indent))switch(n.reader.takeSignificant(),R(p.content)){case"source":i=$o(n,p);break;case"key":o=p.content.substring(3).trim();break;case"append":Nt(n,p,r);break;case"children":{let f=Co.exec(p.content),b=Mt(n,p);f!==null&&s.push({kind:"CaptureChildrenSyntax",property:f[1],identifiedBy:f[2],appends:b,location:l(p)});break}case"nested":{let f=Io.exec(p.content),b=Mt(n,p);f!==null&&c.push({kind:"CaptureNestedSyntax",property:f[1],appends:b,location:l(p)});break}default:n.skipOpaqueBlock(p.indent)}return{kind:"CaptureSyntax",name:t,source:i,key:o,appends:r,children:s,nested:c,location:l(e)}}a(xt,"parseCapture");function $o(n,e){let t=[];for(let i=n.peekChild(e.indent);i!==void 0;i=n.peekChild(e.indent)){n.reader.takeSignificant();let o=R(i.content);t.push({kind:"CaptureSourceSettingSyntax",name:o,value:i.content.substring(o.length).trim(),location:l(i)})}return{kind:"CaptureSourceSyntax",syntaxKind:e.content.substring(6).trim(),settings:t,location:l(e)}}a($o,"parseSource");function Mt(n,e){let t=[];for(let i=n.peekChild(e.indent);i!==void 0;i=n.peekChild(e.indent))n.reader.takeSignificant(),R(i.content)==="append"?Nt(n,i,t):n.skipOpaqueBlock(i.indent);return t}a(Mt,"appendsOf");function Nt(n,e,t){let i=Po.exec(e.content);n.skipOpaqueBlock(e.indent),i!==null&&t.push({kind:"CaptureAppendSyntax",event:i[1],location:l(e)})}a(Nt,"pushAppend");function ue(n){return v(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${n}`)}a(ue,"sourceStreamPattern");var Eo=ue("^[A-Za-z_]\\w*(?![\\s\\S])"),Ao=ue("^[\\w.]+(?![\\s\\S])");function xn(n){return typeof n=="string"&&Eo.test(n)}a(xn,"isSourceStreamName");function Nn(n){return typeof n=="string"&&Ao.test(n)}a(Nn,"isSourceStreamTypeName");var Yt=64,ne=class extends Error{static{a(this,"InvalidStructuredValue")}},Xe=class{static{a(this,"StructuredValueParser")}text;start;context;#e=0;constructor(e,t,i){this.text=e,this.start=t,this.context=i}parse(){let e=this.#n(0);if(this.#r(),this.#e<this.text.length)throw new ne(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#n(e){this.#r();let t=this.#l(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=Yt)throw new ne(`The value nests deeper than ${Yt} levels.`);return i==="["?this.#i(e,t):this.#t(e,t)}if(i==='"')return{kind:"LiteralExpressionSyntax",value:this.#o(),location:t};for(let[o,r]of[["true",!0],["false",!1],["null",null]])if(this.text.startsWith(o,this.#e))return this.#e+=o.length,{kind:"LiteralExpressionSyntax",value:r,location:t};return{kind:"LiteralExpressionSyntax",value:this.#d(),location:t}}#i(e,t){this.#e++;let i=[];if(this.#r(),this.#s("]"))return{kind:"ListExpressionSyntax",items:i,location:t};for(;;){if(i.push(this.#n(e+1)),this.#r(),this.#s("]"))return{kind:"ListExpressionSyntax",items:i,location:t};this.#c(",")}}#t(e,t){this.#e++;let i=[],o=new Set;if(this.#r(),this.#s("}"))return{kind:"ObjectExpressionSyntax",members:i,location:t};for(;;){this.#r();let r=this.#l();if(this.text[this.#e]!=='"')throw new ne("Expected a property name in double quotes.");let s=this.#o();this.#r(),this.#c(":");let c=this.#n(e+1);if(o.has(s)?this.context?.error(d.DuplicateStructuredValueMember,`Duplicate property '${s}' in structured value`,r):(o.add(s),i.push({kind:"ObjectMemberSyntax",name:s,value:c,location:r})),this.#r(),this.#s("}"))return{kind:"ObjectExpressionSyntax",members:i,location:t};this.#c(",")}}#o(){let e=this.#a(this.#e),t=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(t)}catch{throw new ne(`${t} is not a valid JSON string.`)}}#a(e){for(let t=e+1;t<this.text.length;t++)if(this.text[t]==="\\")t++;else if(this.text[t]==='"')return t+1;throw new ne("A string is not closed.")}#d(){let e=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(e===null)throw new ne(`'${this.text[this.#e]??""}' is an invalid start of a value.`);this.#e+=e[0].length;let t=Number(e[0]);if(!Number.isFinite(t))throw new ne("JSON number is outside the finite Double range.");return t}#l(){return{...this.start,column:this.start.column+this.#e}}#r(){for(;this.#e<this.text.length&&`
5
+ \r`.includes(this.text[this.#e]);)this.#e++}#s(e){return this.text[this.#e]!==e?!1:(this.#e++,!0)}#c(e){if(!this.#s(e))throw new ne(`Expected '${e}' at position ${this.#e}.`)}};var Do=v("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Oo=v("^-?\\d+(\\.\\d+)?$"),Bt=["command","arguments","tenant","causedBy","causation","occurred","identity"],qt=["subject","name","userName"],Ft=["id","name","userName","isAuthenticated","roles","claims"];function J(n,e,t){if(n=n.trim(),n.startsWith("$context.")){let o=n.substring(9);return Ro(o,e,t),{kind:"ContextExpressionSyntax",path:o,location:e}}if(n.startsWith("$env."))return{kind:"EnvironmentExpressionSyntax",name:n.substring(5),location:e};if(n.startsWith("$strings."))return{kind:"StringsExpressionSyntax",key:n.substring(9),location:e};if(n.startsWith("$."))return{kind:"SourceItemExpressionSyntax",path:n.substring(2),location:e};if(n.startsWith("{")||n.startsWith("["))try{return new Xe(n,e,t).parse()}catch(o){if(!(o instanceof ne))throw o;return t?.error(d.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:n,location:e}}let i=To(n,e);return i!==void 0?i:Do.test(n)?{kind:"PathExpressionSyntax",path:n,location:e}:{kind:"RawExpressionSyntax",text:n,location:e}}a(J,"parseMappingSource");function Ro(n,e,t){let[i,o]=n.split(".");Bt.includes(i)?o!==void 0&&i==="causedBy"&&!qt.includes(o)?t?.warning(d.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${o}' - expected ${qt.join(", ")}`,e):o!==void 0&&i==="identity"&&!Ft.includes(o)&&t?.warning(d.UnknownContextIdentityProperty,`Unknown $context.identity property '${o}' - expected ${Ft.join(", ")}`,e):t?.warning(d.UnknownContextPath,`Unknown $context path '${n}' - expected one of ${Bt.join(", ")}`,e)}a(Ro,"warnOnUnknownContextPath");function To(n,e){let t=a(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(n){case"true":return t(!0);case"false":return t(!1);case"null":return t(null)}if(n.length>=2&&(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")))return t(G(n.substring(1,n.length-1)));if(Oo.test(n)&&!Number.isNaN(Number(n)))return t(Number(n))}a(To,"parseLiteral");var Lo=v("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?$"),Mo=v("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier)(?:\\s+(?:optional|generated|identifier))*)$"),xo=v("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function we(n){let e=Lo.exec(n.content);if(e===null)return;let t=l(n);return{kind:"PropertySyntax",name:V(e[1]),type:ie(e[2],{...t,column:t.column+n.content.indexOf(e[2],e[1].length)}),isGenerated:e[3]!==void 0,nameWasEscaped:e[1].startsWith("@"),isIdentifier:e[4]!==void 0,location:t}}a(we,"tryParseProperty");function ie(n,e){let t=n.endsWith("?"),i=/\soptional$/.test(n),o=t||i;o&&(n=n.substring(0,n.length-(t?1:8)).trimEnd());let r=n.endsWith("[]");return r&&(n=n.substring(0,n.length-2)),{kind:"TypeRefSyntax",name:n,isCollection:r,isOptional:o,location:e}}a(ie,"parseTypeRef");function ce(n,e){let t=we(e);return t!==void 0?le(n,t.type,e):en(n,e),t}a(ce,"parseProperty");function le(n,e,t){let i=e.name.length+(e.isCollection?2:0),o=e.location.column-t.indent-1+i;if(e.isOptional&&t.content[o]==="?"){let r=e.name+(e.isCollection?"[]":"");n.information(d.LegacyOptionalSuffix,`Write '${r} optional' instead of '${r}?'.`,e.location)}}a(le,"reportLegacyOptionalSuffix");function en(n,e){if(xo.test(e.content))return n.error(d.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",l(e)),!0;{let t=Mo.exec(e.content);if(t!==null&&t[1].split(/\s+/).some(i=>i==="generated"||i==="identifier"))return n.error(d.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",l(e)),!0}return!1}a(en,"reportInvalidModifierOrder");var No=v(`^id\\s+"(${H})"$`),Yo=ue("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Bo=ue("^eventsource\\s+([A-Za-z_]\\w*)$"),qo=ue("^stream\\s+([A-Za-z_]\\w*)$");function zt(n,e){let t=Bo.exec(e.content)?.[1]??"";t===""&&$e(n,e,"Expected 'eventsource <Name>'.");let i=[],o=null,r=null,s=null;for(let c=n.peekChild(e.indent);c!==void 0;c=n.peekChild(e.indent))switch(n.reader.takeSignificant(),R(c.content)){case"stream":i.push(Fo(n,c));break;case"identifier":o=Ut(n,c,"identifier",o);break;case"description":r=j(n,c,r,`Event source '${t}'`,!0);break;case"id":s=Wt(n,c,t,s);break;default:$e(n,c,"An event source accepts description, id, identifier and stream declarations."),n.skipBlock(c.indent);break}return{kind:"EventSourceSyntax",name:t,streams:i,identifier:o,description:r,id:s,location:l(e)}}a(zt,"parseEventSource");function Fo(n,e){let t=qo.exec(e.content)?.[1]??"";t===""&&$e(n,e,"Expected 'stream <Name>'.");let i=null,o=null,r=null;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),R(s.content)){case"streamId":i=Ut(n,s,"streamId",i);break;case"description":o=j(n,s,o,`Stream '${t}'`,!0);break;case"id":r=Wt(n,s,t,r);break;default:$e(n,s,"A stream accepts description, id and streamId declarations."),n.skipBlock(s.indent);break}return{kind:"EventStreamSyntax",name:t,streamId:i,description:o,id:r,location:l(e)}}a(Fo,"parseEventStream");function Ut(n,e,t,i){let o=Yo.exec(e.content);return o===null||i!==null?$e(n,e,`Declare at most one '${t} <Type>'.`):(i=ie(o[2],{...l(e),column:e.indent+1+e.content.indexOf(o[2],t.length)}),le(n,i,e)),Yn(n,e,d.InvalidEventSourceDeclaration),i}a(Ut,"parseType");function Wt(n,e,t,i){let o=No.exec(e.content),r=o===null?null:G(o[1]);return r===null||r.trim()===""||i!==null?$e(n,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=r,r===t&&n.information(d.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",l(e))),Yn(n,e,d.InvalidEventSourceDeclaration),i}a(Wt,"parsePin");function jt(n,e,t,i){let[o,r]=t.type.name.split("."),s={kind:"CommandStreamSyntax",eventSource:o,stream:r,streamId:null,propertyCandidate:null,referenceLocation:t.type.location,referenceLength:t.type.name.length,location:l(e)};if(i)return n.error(d.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,l(e)),{...s,propertyCandidate:t};let c=null;for(let p=n.peekChild(e.indent);p!==void 0;p=n.peekChild(e.indent)){n.reader.takeSignificant();let f=/^streamId\s*=\s*(.+)$/.exec(p.content);if(f===null||c!==null)n.error(d.InvalidCommandStream,"A command stream accepts at most one 'streamId = <source>' mapping.",l(p)),n.skipBlock(p.indent);else{let b={...l(p),column:p.indent+1+p.content.indexOf(f[1],p.content.indexOf("=")+1)};c={kind:"PropertyMappingSyntax",property:"streamId",source:J(f[1],b,n),location:l(p)},Yn(n,p,d.InvalidCommandStream)}}return{...s,streamId:c}}a(jt,"parseCommandStream");function Yn(n,e,t){let i=n.peekChild(e.indent);i!==void 0&&(n.error(t,"This directive cannot have children.",l(i)),n.skipBlock(e.indent))}a(Yn,"rejectChildren");function $e(n,e,t){n.error(d.InvalidEventSourceDeclaration,t,l(e))}a($e,"invalid");var Bn=v("^returns\\s+(@?[A-Za-z_]\\w*)$"),zo=v("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function qn(n,e){let t=l(e);if(e.content!=="returns"){let o=Bn.exec(e.content);if(o===null)return n.error(d.InvalidCommandResponse,"Expected 'returns <property>' or an unconditional 'returns' block.",t),n.skipBlock(e.indent),null;let r=n.peekChild(e.indent);r!==void 0&&(n.error(d.InvalidCommandResponse,"A scalar response cannot have child directives.",l(r)),n.skipBlock(e.indent));let s=o.index+o[0].length-o[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:V(o[1]),location:{...t,column:t.column+s}},location:t}}let i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){n.reader.takeSignificant();let r=zo.exec(o.content);if(r===null){n.error(d.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",l(o)),n.skipBlock(o.indent);continue}let s=l(o),c=r[2]===void 0?null:ie(r[2],{...s,column:s.column+o.content.indexOf(r[2],r[1].length)});c!==null&&le(n,c,o),i.push({kind:"ResponseFieldSyntax",name:V(r[1]),type:c,source:{kind:"PropertyResponseSourceSyntax",property:V(r[3]),location:{...s,column:s.column+o.content.lastIndexOf(r[3])}},location:s});let p=n.peekChild(o.indent);p!==void 0&&(n.error(d.InvalidCommandResponse,"A response field cannot have child directives.",l(p)),n.skipBlock(o.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:t}}a(qn,"parseCommandResponse");var Uo=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function nn(n){if(n===null)return!0;for(let e of n){let t=e.charCodeAt(0);if(!(t>=9&&t<=13||t>=8192&&t<=8202||Uo.has(t)))return!1}return!0}a(nn,"isBlankImplementationHint");var Vt=new Set(["csharp","typescript","react","html","sql"]),Wo=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),Fn=a(n=>R(n.content)==="file"&&n.content.substring(4).trim().length>0,"isFile"),Zt=a(n=>n.content.startsWith("```")||Vt.has(n.content),"isCode");function tn(n,e){let t=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(t)&&n.warning(d.AbsoluteFileReference,`'${t}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,l(e)),{kind:"FileReferenceSyntax",path:t,location:l(e)}}a(tn,"parseFile");function Be(n,e){let t=e.content.startsWith("```")?e.content.substring(3):e.content;if(!Vt.has(t))return n.error(d.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,l(e)),null;let i=e;if(!e.content.startsWith("```")){n.warning(d.LegacyInlineCodeFence,`'${t}' on its own line is deprecated - use '\`\`\`${t}' instead`,l(e));let r=n.reader.peekSignificant();if(r===void 0||r.indent<=e.indent||r.content!=="```"&&r.content!==`\`\`\`${t}`)return n.error(d.ExpectedCodeFence,`Expected an opening \`\`\`${t} fence after '${t}'`,l(e)),null;i=n.reader.takeSignificant()}let o=[];for(;;){let r=n.reader.takeRaw();if(r===void 0){n.error(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",l(i));break}if(r.raw.trim()==="```")break;let s=0;for(;s<i.indent&&r.raw[s]===" ";)s++;o.push(r.raw.substring(s))}return{kind:"CodeBlockSyntax",language:t,code:o.join(`
6
+ `),location:l(e)}}a(Be,"parseCode");function _t(n,e){let t=n.peekChild(e.indent);if(t===void 0)return n.error(d.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",l(e)),null;if(n.reader.takeSignificant(),R(t.content)==="implementation")return jo(n,e,t);let i=Fn(t)?tn(n,t):null,o=i===null&&Zt(t)?Be(n,t):null;if(i!==null||o!==null){let r=n.peekChild(e.indent);return r!==void 0&&R(r.content)==="implementation"&&(n.error(d.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",l(r)),n.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:o,implementation:null,location:l(e)}}return n.error(d.UnknownHandlerDirective,`Unexpected '${t.content}' in handler - expected 'file <path>' or an inline code block`,l(t)),n.skipBlock(e.indent),null}a(_t,"parseHandler");function jo(n,e,t){let i=zn(n,t);for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent))n.reader.takeSignificant(),n.error(R(o.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",l(o)),Zt(o)?Be(n,o):n.skipBlock(o.indent);return{kind:"HandlerSyntax",...i,location:l(e)}}a(jo,"parseImplementation");function zn(n,e){let t=[],i=null,o=null,r=!1;e.content!=="implementation"&&n.error(d.InvalidImplementationBlock,"Expected 'implementation' with no operand.",l(e));for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))if(n.reader.takeSignificant(),R(s.content)==="hint"){let c=Wo.exec(s.content),p=c===null?null:G(c[1]);nn(p)?n.error(d.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",l(s)):t.push({kind:"ImplementationHintSyntax",text:p,location:l(s)});let f=n.peekChild(s.indent);f!==void 0&&(n.error(d.InvalidImplementationHint,"A hint cannot have children.",l(f)),n.skipBlock(s.indent))}else if(Fn(s)||s.content.startsWith("```")){r&&n.error(d.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",l(s));let c=Fn(s)?tn(n,s):null,p=c===null?Be(n,s):null;r||(i=c,o=p),r=!0;let f=n.peekChild(s.indent);c!==null&&f!==void 0&&(n.error(d.InvalidImplementationBlock,"A file directive cannot have children.",l(f)),n.skipBlock(s.indent))}else n.error(d.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,l(s)),n.skipBlock(s.indent);return{file:i,code:o,implementation:{kind:"ImplementationSyntax",hints:t,location:l(e)}}}a(zn,"parseImplementationWrapper");var de=class{static{a(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];streamCandidates;constructor(e,t){this.reader=e,this.path=t}get start(){return Ye(1,1,this.path)}get diagnostics(){return this.#e}information(e,t,i){this.#e.push({severity:"information",code:e,message:t,location:i})}error(e,t,i){this.#e.push({severity:"error",code:e,message:t,location:i})}warning(e,t,i){this.#e.push({severity:"warning",code:e,message:t,location:i})}peekChild(e){let t=this.reader.peekSignificant();return t!==void 0&&t.indent>e?t:void 0}skipBlock(e){for(;this.peekChild(e)!==void 0;)this.reader.takeSignificant()}skipOpaqueBlock(e){let t=this.peekChild(e);for(;t!==void 0;)this.reader.takeSignificant(),t.content.startsWith("```")&&this.skipFencedBody(),t=this.peekChild(e)}skipFencedBody(){for(let e=this.reader.takeRaw();e!==void 0;e=this.reader.takeRaw())if(e.raw.trim()==="```")return}};var on=new WeakMap;var qe=["tag"];var Vo=v(`^id\\s+"(${H})"$`),Ee=class{static{a(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,t){let i=l(t);switch(R(t.content)){case"id":{let o=Vo.exec(t.content),r=o===null?"":G(o[1]);return r.trim().length===0||this.value.id!==null?e.error(d.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=r,r===this.name&&e.information(d.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=j(e,t,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":{if(t.content!=="documentation"||e.peekChild(t.indent)?.content!=="```markdown")return e.error(d.InvalidEventDocumentation,`Event '${this.name}' documentation requires a fenced markdown block`,i),e.skipOpaqueBlock(t.indent),!0;let o=Ce(e,"markdown",t);return o===null||o.trim().length===0||this.value.documentation!==null?e.error(d.InvalidEventDocumentation,`Event '${this.name}' accepts one nonempty documentation block`,i):this.value.documentation=o,!0}default:return!1}}};var Zo=v("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Gt=a(n=>R(n.content)==="file"?n.content.substring(4).trim():"","pathOf"),Q=a(n=>Gt(n).length>0,"isFileDirective"),rn=a(n=>Q(n)&&!Zo.test(Gt(n)),"isFileDirectiveAmongProperties");var _o=v("^type\\s+([A-Za-z_]\\w*)$"),Go=v("^event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+([0-9]+))?$"),Ho=v("^readmodel\\s+([A-Za-z_]\\w*)$"),Ht=4294967295,Qo=v("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Jo=v("^[A-Za-z_]\\w*$"),Qt=a(n=>R(n.content)==="description"&&we(n)===void 0,"isDescription");function Un(n,e,t,i,o){return e.isIdentifier?(n.error(i,o,l(t)),{...e,isIdentifier:!1}):e}a(Un,"withoutIdentifier");function Jt(n,e){let t=_o.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,l(e));let i=[],o=null;for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent)){if(n.reader.takeSignificant(),Qt(r)){o=j(n,r,o,`Type '${t}'`);continue}if(rn(r))continue;let s=ce(n,r);if(s===void 0){n.error(d.InvalidPropertyDeclaration,`Invalid property '${r.content}' - expected '<name> <Type>'`,l(r));continue}i.push(Un(n,s,r,d.IdentifierOutsideCommand,`Property '${s.name}' of type '${t}' cannot be marked identifier - only a command property can be`))}return i.length===0&&n.error(d.TypeWithoutProperties,`Type '${t}' must declare at least one property`,l(e)),{kind:"TypeSyntax",name:t,properties:i,description:o,location:l(e)}}a(Jt,"parseType");function Kt(n,e){let t=Go.exec(e.content),i=t?.[1]??"";t===null&&n.error(d.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected 'event <Name> [generation <N>]'`,l(e));let o=t?.[2]!==void 0,r=1;if(o){let f=Number(t[2]);!Number.isSafeInteger(f)||f===0||f>=Ht?n.error(d.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Ht-1}`,l(e)):r=f}let s=[],c=[],p=new Ee(i);for(let f=n.peekChild(e.indent);f!==void 0;f=n.peekChild(e.indent)){if(n.reader.takeSignificant(),rn(f))continue;if(qe.includes(R(f.content))){let u=Wn(n,f);u!==void 0&&c.push(u);continue}let b=ce(n,f);if(b===void 0){p.tryParse(n,f)||n.error(d.InvalidPropertyDeclaration,`Invalid property '${f.content}' - expected '<name> <Type>'`,l(f));continue}s.push(Un(n,b,f,d.IdentifierOnEventProperty,`Property '${b.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:s,tags:c,generation:r,hasGenerationMarker:o,...p.value,location:l(e)}}a(Kt,"parseEvent");function Wn(n,e,t=!0){let i=e.content.substring(3).trim();if(t&&Qo.test(i)&&n.warning(d.TagPropertyReadAsTag,`'${e.content}' declares a static tag with the value '${i}', not a property named 'tag' - write 'tag "${i}"' for the tag, or '@${e.content}' for the property`,l(e)),i.length===0){n.error(d.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",l(e));return}if(Jo.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:l(e)},location:l(e)};let o=J(i,l(e),n);if(o.kind==="RawExpressionSyntax"){n.error(d.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,l(e));return}return{kind:"TagSyntax",value:o,location:l(e)}}a(Wn,"parseTag");function Xt(n,e){let t=Ho.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,l(e));let i=[],o=null;for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent))if(n.reader.takeSignificant(),Qt(r))o=j(n,r,o,`Read model '${t}'`);else{if(rn(r))continue;{let s=ce(n,r);if(s===void 0){n.error(d.InvalidPropertyDeclaration,`Invalid property '${r.content}' - expected '<name> <Type>'`,l(r));continue}i.push(Un(n,s,r,d.IdentifierOutsideCommand,`Property '${s.name}' of read model '${t}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:t,properties:i,description:o,location:l(e)}}a(Xt,"parseReadModel");var Ko=v("^system\\s+([A-Za-z_]\\w*)$"),Xo=v("^operation\\s+([A-Za-z_]\\w*)$"),er=v("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),jn=v("^uses\\s+([A-Za-z_]\\w*)$"),nr=v("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),tr=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function Fe(n,e,t,i){let o=n.peekChild(e.indent);o!==void 0&&(n.error(t,i,l(o)),n.skipBlock(e.indent))}a(Fe,"rejectOperationChildren");function ei(n,e){let t=Ko.exec(e.content);t===null&&n.error(d.InvalidSystemDeclaration,"Expected 'system <Name>'.",l(e));let i=null;for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent))n.reader.takeSignificant(),R(o.content)==="description"?i=j(n,o,i,`System '${t?.[1]??""}'`):(n.error(d.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",l(o)),n.skipBlock(o.indent));return{kind:"SystemSyntax",name:t?.[1]??"",description:i,location:l(e)}}a(ei,"parseSystem");function sn(n,e,t=!1){let i=(t?er:Xo).exec(e.content),o=i?.[1]??"";i===null&&n.error(d.InvalidOperationDeclaration,"Expected an operation declaration with one name.",l(e));let r=null,s=null,c=l(e),p=null,f=null,b=[],u=[],k=new Set;for(let y=n.peekChild(e.indent);y!==void 0;y=n.peekChild(e.indent)){n.reader.takeSignificant();let T=nr.exec(y.content),D=t&&T!==null?{...y,content:T[1].trimEnd()}:y;if(T===null&&tr.has(R(y.content))){n.error(d.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",l(y)),n.skipBlock(y.indent);continue}if(!jn.test(y.content)&&we(D)!==void 0){let g=ce(n,D);t&&T===null&&n.error(d.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",l(y)),(g.isIdentifier||g.isGenerated)&&n.error(d.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",l(y)),k.has(g.name)&&n.error(d.DuplicateDeclaration,`Operation '${o}' already declares input '${g.name}'.`,l(y)),k.add(g.name),b.push(g),t&&T!==null&&u.push({kind:"PropertyMappingSyntax",property:g.name,source:J(T[2],{...l(y),column:y.indent+y.content.length-T[2].length+1},n),location:l(y)}),Fe(n,y,d.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(R(y.content)==="description")r=j(n,y,r,`Operation '${o}'`);else if(jn.test(y.content))s!==null?n.error(d.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",l(y)):(s=jn.exec(y.content)[1],c={...l(y),column:l(y).column+y.content.indexOf(s,4)}),Fe(n,y,d.InvalidSystemReference,"A system reference cannot have children.");else if(y.content==="execute"||y.content==="compensate"){let g=ir(n,y);y.content==="execute"?p!==null?n.error(d.InvalidOperationDeclaration,"An operation declares execute at most once.",l(y)):p=g:f!==null?n.error(d.InvalidOperationDeclaration,"An operation declares compensate at most once.",l(y)):f=g}else n.error(d.InvalidOperationDeclaration,`Unexpected '${y.content}' in operation - expected uses, an input, description, execute or compensate.`,l(y)),n.skipBlock(y.indent)}return s===null&&n.error(d.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",l(e)),{operation:{kind:"OperationSyntax",name:o,uses:s??"",usesLocation:c,inputs:b,description:r,execute:p,compensate:f,location:l(e)},mappings:u}}a(sn,"parseOperation");function ir(n,e){let t=null,i=null,o=null,r=null,s=!1;for(let c=n.peekChild(e.indent);c!==void 0;c=n.peekChild(e.indent)){if(n.reader.takeSignificant(),R(c.content)==="description"){t=j(n,c,t,`Operation phase '${e.content}'`);continue}if(R(c.content)==="implementation"){s&&n.error(d.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",l(c));let p=zn(n,c);s||(i=p.file,o=p.code,r=p.implementation),s=!0}else if(Q(c)||c.content.startsWith("```")){s&&n.error(d.ConflictingImplementationSources,"A phase has at most one file or inline payload.",l(c));let p=Q(c)?tn(n,c):null,f=p===null?Be(n,c):null;s||(i=p,o=f),s=!0,p!==null&&Fe(n,c,d.InvalidImplementationBlock,"A file directive cannot have children.")}else n.error(d.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",l(c)),n.skipBlock(c.indent)}return{kind:"OperationPhaseSyntax",description:t,file:i,code:o,implementation:r,location:l(e)}}a(ir,"parseOperationPhase");var or=v("^produces\\s+operation(?:\\s|$)"),rr=v("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),sr=v("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),ar=v("^produces\\s+when\\s+(.+)$"),cr=v("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),lr=v("^for\\s+(\\S.*)$"),dr=v("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),pr=v("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),ur=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function an(n,e,t=!1){if(or.test(e.content)){if(!t){n.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",l(e)),n.skipOpaqueBlock(e.indent);return}let y=sn(n,e,!0);return{kind:"ProducesSyntax",event:y.operation.name,targetLocation:{...l(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:y.operation,mappings:y.mappings,for:null,tags:[],location:l(e)}}let i=rr.exec(e.content),o=e,r,s;if(i!==null){if(!t){n.error(d.InlineEventOutsideCommand,"Inline events can only be declared inside commands",l(e)),n.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&n.error(d.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",l(e)),r=i[1],s=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(ar.test(e.content)){let y=n.peekChild(e.indent);if(y===void 0||!cr.test(y.content)){n.error(d.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",l(e)),n.skipOpaqueBlock(e.indent);return}n.reader.takeSignificant(),o=y,r=y.content,s=y.indent+1}else{let y=sr.exec(e.content);if(y===null){n.error(d.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,l(e)),n.skipOpaqueBlock(e.indent);return}r=y[1],s=e.indent+e.content.match(/^produces\s+/)[0].length+1}let c=[],p=new Set,f=[],b=[],u=new Ee(r),k=null;for(let y=n.peekChild(o.indent);y!==void 0;y=n.peekChild(o.indent)){n.reader.takeSignificant();let T=R(y.content),D=l(y);if(ur.has(T)){n.error(d.ReservedProductionMetadata,`'${T}' is system-assigned production metadata and cannot be supplied here`,D),n.skipOpaqueBlock(y.indent);continue}if(i!==null&&(T==="generation"||T==="origin")){n.error(T==="generation"?d.InlineEventGeneration:d.ReservedProductionMetadata,T==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",D),n.skipOpaqueBlock(y.indent);continue}if(T==="tag"){let A=Wn(n,y,!1);A!==void 0&&b.push(A);continue}let g=lr.exec(y.content);if(g!==null){k!==null?n.error(d.DuplicateProducesTarget,`'${o.content}' already declares where it lands - an event is appended to one event source`,D):k=J(g[1],D,n);continue}let m=(i===null?dr:pr).exec(y.content),w=m===null||i===null?void 0:ce(n,{...y,content:m[1].trimEnd()});if(m!==null&&(i===null||w!==void 0)){if(w!==void 0){w.isIdentifier&&(n.error(d.IdentifierOnEventProperty,`Property '${w.name}' of event '${r}' cannot be marked identifier - an event never carries its event source id`,D),w={...w,isIdentifier:!1});let A=w.name;p.has(A)&&n.error(d.DuplicateDeclaration,`Event '${r}' already declares property '${w.name}'`,D),p.add(A),c.push(w)}f.push({kind:"PropertyMappingSyntax",property:w?.name??V(m[1]),source:J(m[2],{...D,column:y.indent+y.content.length-m[2].length+1},n),location:D})}else(i===null||!u.tryParse(n,y))&&n.error(d.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${y.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,D)}return o!==e&&n.skipBlock(e.indent),{kind:"ProducesSyntax",event:r,targetLocation:{...l(o),column:s},inlineOperation:null,mappings:f,for:k,tags:i===null?b:[],location:l(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:r,properties:c,tags:b,generation:1,hasGenerationMarker:!1,...u.value,location:l(e)}}}a(an,"parseProduces");var fr=v("^command\\s+([A-Za-z_]\\w*)$"),mr=ue("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),hr=v("\\bseverity\\s+(\\S+)$"),vr=v(`\\bmessage\\s+(?:"(${H})"|(\\$strings\\.\\S*))$`),gr=v("^([\\w.]+)\\s+(.+)$"),yr=v("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),kr=v("^[A-Za-z_]\\w*$"),Sr=v("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),wr={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},br={information:"Information",warning:"Warning",error:"Error"},Pr=new Set(["reads","concurrency"]),Cr=new Set(["description","handler","concurrency"]);function ti(n,e){let t=new Set,i=new de(n.reader.fork(),n.path);return i.streamCandidates=n.streamCandidates,ni(i,e,void 0,t),ni(n,e,t)}a(ti,"parseCommand");function ni(n,e,t,i){let o=fr.exec(e.content)?.[1]??"";o===""&&n.error(d.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,l(e));let r=[],s=[],c,p=[],f=[],b=[],u=null,k=null,y=null,T=null,D=[];for(let h=n.peekChild(e.indent);h!==void 0;h=n.peekChild(e.indent)){n.reader.takeSignificant();let S=R(h.content),C=we(h);if(C!==void 0&&(Cr.has(S)||S==="validate"&&h.content!=="validate csharp"))c=cn(n,r,C,o,h,c);else if(S==="returns"){let $=Bn.exec(h.content);$!==null&&!$[1].startsWith("@")&&C!==void 0?t===void 0?(r.push(C),s.push({line:h,candidate:C,response:null})):t.has(C.type.name)?s.push({line:h,candidate:null,response:qn(n,h)}):c=cn(n,r,C,o,h,c):C!==void 0?c=cn(n,r,C,o,h,c):en(n,h)?n.skipBlock(h.indent):s.push({line:h,candidate:null,response:qn(n,h)})}else if(S==="stream"&&mr.test(h.content)&&C!==void 0&&n.streamCandidates?.hasSource(C.type.name.split(".")[0])===!0){let[$,E]=C.type.name.split("."),B=n.streamCandidates.hasPropertyType(C.type.name)&&n.streamCandidates.hasUniqueStream($,E),q=jt(n,h,C,B);(T!==null||D.length>0)&&n.error(d.InvalidCommandStream,"A command declares at most one stream route.",l(h)),B||T!==null?D.push(q):T=q}else if(S==="description")u=j(n,h,u,`Command '${o}'`);else if(S==="authorize")k=ae(k,he(n,h));else if(S==="validate"){let $=Ir(n,h);$!==void 0&&p.push($)}else if(S==="produces"){let $=an(n,h,!0);$!==void 0&&f.push($)}else if(S==="handler")y=_t(n,h);else if(Pr.has(S)){let $=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(h.content);$!==null&&b.push({readModel:$[1],alias:$[2]??null}),Sr.test(h.content)&&n.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",l(h)),n.skipOpaqueBlock(h.indent)}else C!==void 0?c=cn(n,r,C,o,h,c):(en(n,h),n.error(d.UnknownCommandDirective,`Unexpected '${h.content}' in command body`,l(h)),n.skipBlock(h.indent))}let g=new Set(s.flatMap(h=>h.candidate===null?[]:[h.candidate])),m=new Set(r.filter(h=>!g.has(h)).map(h=>h.name));s.some(h=>h.candidate!==null&&!m.has(h.candidate.type.name)&&h.candidate.type.name!=="returns")&&m.add("returns");for(let h of m)i?.add(h);let w=null,A=new Set;for(let h of s){let S=h.response;if(h.candidate!==null){if(!m.has(h.candidate.type.name))continue;A.add(h.candidate),S={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:h.candidate.type.name,location:h.candidate.type.location},location:l(h.line)}}S!==null&&(w!==null?n.error(d.InvalidCommandResponse,"A command declares at most one unconditional response.",l(h.line)):w=S)}y!==null&&f.length>0&&n.error(d.CommandWithProducesAndHandler,`Command '${o}' cannot declare both 'produces' and 'handler'`,l(e));let I={kind:"CommandSyntax",name:o,description:u,authorize:k,properties:r.filter(h=>!A.has(h)),validations:p,produces:f,handler:y,response:w,stream:T,streamCandidates:D,location:l(e)};return on.set(I,b),I}a(ni,"parseCommandBody");function cn(n,e,t,i,o,r){return le(n,t.type,o),t.isIdentifier&&r!==void 0&&(n.error(d.DuplicateCommandIdentifier,`Command '${i}' already marks '${r.name}' as identifier - only one property can be the identifier`,t.location),t={...t,isIdentifier:!1}),e.push(t),r??(t.isIdentifier?t:void 0)}a(cn,"addProperty");function Ir(n,e){if(e.content==="validate"){let t=n.peekChild(e.indent);if(t!==void 0&&t.content.startsWith("```"))return n.reader.takeSignificant(),n.skipFencedBody(),{kind:"CodeValidateSyntax",location:l(e)};let i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){if(n.reader.takeSignificant(),R(o.content)==="require"){n.skipOpaqueBlock(o.indent);continue}let r=$r(n,o);r!==void 0&&i.push(r)}return{kind:"DeclarativeValidateSyntax",rules:i,location:l(e)}}if(e.content==="validate csharp")return n.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",location:l(e)};n.error(d.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,l(e)),n.skipBlock(e.indent)}a(Ir,"parseValidate");function $r(n,e){let{content:t,message:i}=Er(e.content),o=Ar(n,e,t);if(o===void 0)return;let r=gr.exec(o.content);if(r===null){n.error(d.InvalidValidationRule,`Invalid validation rule '${e.content}'`,l(e));return}let s=Dr(n,r[2],e);if(s!==void 0)return s.kind==="Rule"&&n.skipOpaqueBlock(e.indent),{kind:"ValidationRuleSyntax",property:r[1],rule:s.kind,value:s.value,message:i,severity:o.severity,location:l(e)}}a($r,"parseValidationRule");function Er(n){let e=vr.exec(n);if(e===null)return{content:n,message:null};let t=e[1]!==void 0?G(e[1]):e[2];return{content:n.substring(0,e.index).trimEnd(),message:t}}a(Er,"splitMessage");function Ar(n,e,t){let i=hr.exec(t);if(i===null)return{content:t,severity:"Error"};let o=br[i[1]];if(o===void 0){n.error(d.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,l(e));return}return{content:t.substring(0,i.index).trimEnd(),severity:o}}a(Ar,"splitSeverity");function Dr(n,e,t){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=yr.exec(e);if(i===null){n.error(d.InvalidValidationRule,`Invalid validation rule '${t.content}'`,l(t));return}if(i[1]==="rule"){let o=i[2].trim();if(!kr.test(o)){n.error(d.InvalidRuleName,`Invalid rule name '${o}' in '${t.content}' - expected 'rule <Name>' with an identifier`,l(t));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:o,location:l(t)}}}return{kind:wr[i[1]],value:J(i[2],l(t),n)}}a(Dr,"parseRule");var Or=v("^constraint\\s+([A-Za-z_]\\w*)$"),Rr=v("^unique\\s+event\\s+([A-Z]\\w*)$"),Tr=v("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Lr=v("^released\\s+by\\s+([A-Z]\\w*)$"),Mr=v(`^message\\s+"(${H})"$`),xr=a(n=>n.kind==="FileConstraintSyntax"?void 0:n.event,"targetOf");function ii(n,e){let t=Or.exec(e.content);t===null&&n.error(d.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,l(e));let i=t?.[1]??R(e.content),o=[],r=[],s=new Set,c=new Set,p=null,f=!1;for(let b=n.peekChild(e.indent);b!==void 0;b=n.peekChild(e.indent)){n.reader.takeSignificant();let u=Lr.exec(b.content),k=Mr.exec(b.content);u!==null?s.has(u[1])?n.error(d.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${u[1]}'`,l(b)):(r.push(u[1]),s.add(u[1])):k!==null?p!==null?n.error(d.DuplicateConstraintBody,`Constraint '${i}' already has a message`,l(b)):p=G(k[1]):b.content==="ignore casing"?(f&&n.error(d.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,l(b)),f=!0):Nr(n,i,b,o,c)}for(let b of r.filter(u=>c.has(u)))n.error(d.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${b}'`,l(e));return o.length===0&&(n.error(d.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,l(e)),o.push(ln(i,l(e),{kind:"UniqueEventConstraintSyntax",event:""}))),o[0].kind==="FileConstraintSyntax"&&(r.length>0||p!==null||f)&&n.error(d.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,l(e)),{...o[0],additionalRules:o.slice(1),releasedBy:r,message:p,ignoreCasing:f}}a(ii,"parseConstraint");function Nr(n,e,t,i,o){let r=Yr(n,e,t);if(r===void 0)return;if(i.length>0&&(r.kind==="FileConstraintSyntax"||i[0].kind==="FileConstraintSyntax"||r.kind==="UniqueEventConstraintSyntax"!=(i[0].kind==="UniqueEventConstraintSyntax"))){n.error(d.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,l(t));return}let s=xr(r);if(s!==void 0&&o.has(s)){n.error(d.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,l(t));return}s!==void 0&&o.add(s),i.push(r)}a(Nr,"addRule");function Yr(n,e,t){let i=l(t),o=Rr.exec(t.content);if(o!==null)return ln(e,i,{kind:"UniqueEventConstraintSyntax",event:o[1]});let r=Tr.exec(t.content);if(r!==null){let s=r[1].split(",").map(c=>c.trim());if(new Set(s).size!==s.length){n.error(d.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return ln(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:r[2]})}if(Q(t)){n.warning(d.FileConstraintOnlySupportsUniqueness,"A file constraint can only declare unique constraints in Chronicle - declare them with 'unique ...' so they are portable; a rule that is not uniqueness belongs in command validation or a 'require' condition",i);let s=t.content.substring(4).trim();return ln(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}n.error(d.InvalidConstraintBody,`Invalid constraint body '${t.content}'`,i)}a(Yr,"parseRule");function ln(n,e,t){return{...t,name:n,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}a(ln,"rule");var Br=v("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),qr=v("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Fr=v("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),zr=v("^with\\s+(@?[\\w.]+)$"),Ur=v("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),Wr=v("^nested\\s+(@?[\\w.]+)$"),jr=v("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Vr=v("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Zr=v("^clear\\s+with\\s+(@?[\\w.]+)$"),_r=v("^variant\\s+(@?[\\w.]+)\\s*$"),Gr=v("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Hr=v("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),Qr=v("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),Jr=v("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),Kr=v("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),Xr={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function oi(n,e){let t=Br.exec(e.content);if(t===null)return n.error(d.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,l(e)),n.skipBlock(e.indent),{kind:"ProjectionSyntax",name:R(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:l(e)};let i=t[1],o=null,r="Inherit",s=[];for(let c=n.peekChild(e.indent);c!==void 0;c=n.peekChild(e.indent)){if(n.reader.takeSignificant(),Q(c))continue;let p=R(c.content);if(p==="sequence")o=c.content.substring(8).trim();else if(p==="automap")r="Enabled";else if(c.content==="no automap")r="Disabled";else if(p==="key")si(n,c);else if(p==="variant")s.push(as(n,c));else{let f=Zn(n,c,!1);f!==void 0&&s.push(f)}}return es(n,s,i),s.length===0&&n.error(d.EmptyProjection,`Projection '${i}' must contain at least one directive`,l(e)),{kind:"ProjectionSyntax",name:i,readModel:t[2]??null,sequence:o,autoMap:r,blocks:s,location:l(e)}}a(oi,"parseProjection");function es(n,e,t){let i=e.filter(s=>s.kind==="ProjectionVariantSyntax"),o=new Map;i.forEach(s=>o.set(s.name,[...o.get(s.name)??[],s]));for(let s of[...o.values()].flatMap(c=>c.slice(1)))n.error(d.DuplicateProjectionVariant,`Duplicate variant '${s.name}' - a variant name is declared once`,s.location);let r=new Set;for(let s of e.flatMap(c=>c.kind==="ProjectionVariantSyntax"?c.entersOn:[]))s.event.length>0&&r.has(s.event)&&n.error(d.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${t}'`,s.location),r.add(s.event)}a(es,"reportVariantConflicts");function Zn(n,e,t){let i=l(e);switch(R(e.content)){case"from":return ns(n,e);case"every":{let o=!0,{autoMap:r,mappings:s}=Vn(n,e,c=>c.content!=="exclude children"?!1:(o=!1,!0));return{kind:"EverySyntax",includeChildren:o,autoMap:r,mappings:s,location:i}}case"all":{let{autoMap:o,mappings:r}=Vn(n,e);return{kind:"AllSyntax",autoMap:o,mappings:r,location:i}}case"join":return ts(n,e);case"children":return is(n,e);case"nested":return os(n,e);case"remove":return rs(n,e);case"clear":return t||n.error(d.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),ss(n,e);default:n.error(d.UnknownProjectionDirective,`Unexpected '${R(e.content)}' in projection body`,i),n.skipBlock(e.indent);return}}a(Zn,"parseBlock");function ns(n,e){let t=[];for(let o of Tt(e.content.substring(4),",")){let r=o.trim();if(r.length===0){n.error(d.FromWithoutEvent,"Expected an event type after 'from'",l(e));continue}let s=qr.exec(r);if(s===null){n.error(d.InvalidEventReference,`Invalid event reference '${r}'`,l(e));continue}t.push({kind:"EventSpecSyntax",event:V(s[1]),location:l(e)})}let i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){n.reader.takeSignificant();let r=R(o.content);r==="key"?si(n,o):r!=="parent"&&ai(o,i)}return{kind:"FromSyntax",events:t,mappings:i,location:l(e)}}a(ns,"parseFrom");function ts(n,e){let t=Fr.exec(e.content);if(t===null)return n.error(d.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,l(e)),n.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:l(e)};let i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){n.reader.takeSignificant();let r=zr.exec(o.content);if(r===null){n.error(d.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${o.content}'`,l(o)),n.skipBlock(o.indent);continue}let{autoMap:s,mappings:c}=Vn(n,o);i.push({kind:"JoinEventSyntax",event:V(r[1]),autoMap:s,mappings:c,location:l(o)})}return{kind:"JoinSyntax",property:V(t[1]),on:V(t[2]),events:i,location:l(e)}}a(ts,"parseJoin");function is(n,e){let t=Ur.exec(e.content);if(t===null)return n.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,l(e)),n.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:l(e)};let{autoMap:i,blocks:o}=ri(n,e);return{kind:"ChildrenSyntax",property:V(t[1]),autoMap:i,blocks:o,location:l(e)}}a(is,"parseChildren");function os(n,e){let t=Wr.exec(e.content);if(t===null)return n.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,l(e)),n.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:l(e)};let i=V(t[1]),{autoMap:o,blocks:r}=ri(n,e);return r.some(s=>s.kind==="FromSyntax")||n.error(d.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,l(e)),{kind:"NestedSyntax",property:i,autoMap:o,blocks:r,location:l(e)}}a(os,"parseNested");function ri(n,e){let t=[],i="Inherit";for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){if(n.reader.takeSignificant(),o.content==="automap"){i="Enabled";continue}if(o.content==="no automap"){i="Disabled";continue}let r=Zn(n,o,!0);r!==void 0&&t.push(r)}return{autoMap:i,blocks:t}}a(ri,"parseChildBlocks");function rs(n,e){let t=Vr.exec(e.content);if(t!==null)return{kind:"RemoveViaJoinSyntax",event:V(t[1]),location:l(e)};let i=jr.exec(e.content);if(i===null){n.error(d.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,l(e)),n.skipBlock(e.indent);return}for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent))n.reader.takeSignificant(),R(o.content)!=="parent"&&n.error(d.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,l(o));return{kind:"RemoveWithSyntax",event:V(i[1]),location:l(e)}}a(rs,"parseRemove");function ss(n,e){let t=Zr.exec(e.content);return t===null?(n.error(d.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,l(e)),{kind:"ClearWithSyntax",event:"",location:l(e)}):{kind:"ClearWithSyntax",event:V(t[1]),location:l(e)}}a(ss,"parseClearWith");function as(n,e){let t=_r.exec(e.content);if(t===null)return n.error(d.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,l(e)),n.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:R(e.content),entersOn:[],blocks:[],location:l(e)};let i=V(t[1]),o=[],r=[];for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent)){n.reader.takeSignificant();let c=R(s.content);if(c==="enters")o.push(cs(n,s));else if(c==="variant")n.error(d.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",l(s)),n.skipBlock(s.indent);else{let p=Zn(n,s,!1);p!==void 0&&r.push(p)}}return o.length===0&&n.error(d.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,l(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:o,blocks:r,location:l(e)}}a(as,"parseVariant");function cs(n,e){let t=Gr.exec(e.content);return t===null?(n.error(d.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,l(e)),n.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",location:l(e)}):{kind:"ProjectionEntersOnSyntax",event:V(t[1]),location:l(e)}}a(cs,"parseEntersOn");function si(n,e){if(n.peekChild(e.indent)===void 0)return;n.skipBlock(e.indent);let t=n.reader.peekSignificant();t!==void 0&&t.indent===e.indent&&t.content==="}"&&n.reader.takeSignificant()}a(si,"skipKey");function Vn(n,e,t=()=>!1){let i="Inherit",o=[];for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent))n.reader.takeSignificant(),r.content==="automap"?i="Enabled":r.content==="no automap"?i="Disabled":t(r)||ai(r,o);return{autoMap:i,mappings:o}}a(Vn,"parseMappingBlock");function ai(n,e){let t=l(n),i=Hr.exec(n.content);if(i!==null){(i[1]!=="clear"||i[2]!=="with")&&e.push({kind:Xr[i[1]],property:V(i[2]),location:t});return}let o=Qr.exec(n.content);if(o!==null){e.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:V(o[2]),location:t});return}let r=Jr.exec(n.content)??Kr.exec(n.content);r!==null&&e.push({kind:"SetMappingSyntax",property:V(r[1]),location:t})}a(ai,"pushMapping");var ls=v("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),ds=v("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),ps=v("^scoped\\s+to\\s+([a-z_]\\w*)$"),us=new Set(["performer"]);function li(n,e){let t=ls.exec(e.content);if(t===null)return n.error(d.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,l(e)),n.skipBlock(e.indent),{kind:"QuerySyntax",name:R(e.content),returnType:ie("",l(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:l(e)};let i=t[1],o=ie(t[3],{...l(e),column:e.indent+1+t[0].length-t[3].length});t[2]===void 0&&o.name==="observable"&&o.isOptional&&!o.isCollection||le(n,o,e);let r=null,s=[],c=null,p=null,f=null;for(let b=n.peekChild(e.indent);b!==void 0;b=n.peekChild(e.indent)){n.reader.takeSignificant();let u=R(b.content);if(u==="description")c=j(n,b,c,`Query '${i}'`);else if(u==="by"){let k=ci(n,b,"by");k!==void 0&&(r!==null&&n.error(d.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,l(b)),r=k)}else if(u==="filter"){let k=ci(n,b,"filter");k!==void 0&&s.push(k)}else u==="authorize"?f=ae(f,he(n,b)):u==="scoped"?p=fs(n,b,p,i)??p:us.has(u)?n.skipOpaqueBlock(b.indent):(n.error(d.UnknownQueryDirective,`Unexpected '${b.content}' in query body - expected description, by, filter, authorize, scoped or performer`,l(b)),n.skipBlock(b.indent))}return{kind:"QuerySyntax",name:i,returnType:o,by:r,filters:s,description:c,isObservable:t[2]!==void 0,scope:p,authorize:f,location:l(e)}}a(li,"parseQuery");function ci(n,e,t){let i=ds.exec(e.content.substring(t.length).trim());if(i===null){n.error(d.InvalidQueryParameter,`Invalid '${t}' parameter '${e.content}' - expected '${t} <name> <Type> [from <source>]'`,l(e));return}let o=e.content.indexOf(i[1],t.length),r=ie(i[2],{...l(e),column:e.indent+1+e.content.indexOf(i[2],o+i[1].length)});return le(n,r,e),{kind:"QueryParameterSyntax",name:i[1],type:r,location:l(e)}}a(ci,"parseParameter");function fs(n,e,t,i){let o=ps.exec(e.content);if(o===null){n.error(d.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,l(e));return}if(t!==null){n.error(d.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,l(e));return}return o[1]}a(fs,"parseScope");var ms=v("^@?[a-z_]\\w*\\s+[\\w.]+");function _n(n,e){let t=ce(n,e);if(t!==void 0){t.isGenerated&&n.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",t.location),n.triggerData.push(t);return}ms.test(e.content)&&/\?|\boptional\b/.test(e.content)&&n.error(d.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,l(e)),n.skipOpaqueBlock(e.indent)}a(_n,"parseTriggerData");function di(n,e){for(let t=n.peekChild(e.indent);t!==void 0;t=n.peekChild(e.indent))n.reader.takeSignificant(),R(t.content)==="description"?j(n,t,null,`Trigger '${e.content}'`):Q(t)||_n(n,t)}a(di,"parseTriggerDeclaration");var hs=v("^reaction\\s+([A-Za-z_]\\w*)$"),vs=v("^when\\s+([A-Za-z_]\\w*)$"),gs=v("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),ys=v("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),ks=new Set(["when","every","at"]),Ss=v("^invokes\\s+([A-Z]\\w*)$"),ws=v("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function pi(n,e){let t=hs.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,l(e));let i=null,o=[],r=new Set,s=!1;for(let c=n.peekChild(e.indent);c!==void 0;c=n.peekChild(e.indent)){n.reader.takeSignificant();let p=R(c.content);if(p==="description"){i=j(n,c,i,`Reaction '${t}'`);continue}if(p==="where")continue;if(!ks.has(p)){n.error(d.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${c.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,l(c)),n.skipBlock(c.indent),s=!0;continue}let f=Cs(n,c);if(f===void 0){s=!0;continue}let b=Ps(f);if(r.has(b)){n.error(d.DuplicateReactionTrigger,`Reaction '${t}' already declares '${c.content}' - a second says nothing the first did not`,l(c)),n.skipBlock(c.indent);continue}r.add(b),o.push(bs(n,c,f))}return o.length===0&&!s&&n.error(d.ReactionWithoutTrigger,`Reaction '${t}' must declare at least one trigger - nothing sets it off`,l(e)),{kind:"ReactionSyntax",name:t,description:i,triggers:o,location:l(e)}}a(pi,"parseReaction");function bs(n,e,t){let i=null,o=[],r=[];for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent)){n.reader.takeSignificant();let c=R(s.content);if(c==="description")i=j(n,s,i,`Trigger '${s.content}'`);else if(c==="produces"){let p=an(n,s);p!==void 0&&o.push(p)}else if(c==="invokes"){let p=Ss.exec(s.content);p===null?(n.error(d.InvalidInvokesDeclaration,`Invalid invokes declaration '${s.content}' - expected 'invokes <Command>'`,l(s)),n.skipBlock(s.indent)):(r.push({kind:"InvokesSyntax",command:p[1],location:l(s)}),te(n,s))}else c==="reads"||c==="file"||s.content==="csharp"||s.content.startsWith("```")?(ws.test(s.content)&&n.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",l(s)),s.content.startsWith("```")&&n.skipFencedBody(),n.skipOpaqueBlock(s.indent)):_n(n,s)}return{kind:"ReactionTriggerSyntax",source:t,description:i,produces:o,invokes:r,location:l(e)}}a(bs,"parseTrigger");function Ps(n){switch(n.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([n.kind,n.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([n.kind,n.amount,n.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([n.kind,n.time,n.dayOfWeek,n.dayOfMonth])}}a(Ps,"sourceKey");function Cs(n,e){let t=l(e);switch(R(e.content)){case"when":{let i=vs.exec(e.content);if(i===null){n.error(d.InvalidReactionTrigger,`Invalid trigger '${e.content}' - expected 'when <Name>'`,t),n.skipBlock(e.indent);return}return{kind:"NamedTriggerSourceSyntax",name:i[1],location:t}}case"every":{let i=gs.exec(e.content),o=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(o)||o<1||o>2147483647){n.error(d.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,t),n.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:o,unit:Es(i[2]),location:t}}default:return Is(n,e)}}a(Cs,"parseTriggerSource");function Is(n,e){let t=l(e),i=ys.exec(e.content),o=i===null?void 0:$s(i[1]);if(i===null||o===void 0){n.error(d.InvalidScheduleTrigger,`Invalid schedule '${e.content}' - expected 'at <HH:mm>', optionally followed by 'on <Weekday>' or 'on day <n>'`,t),n.skipBlock(e.indent);return}if(i[3]!==void 0){let r=Number(i[3]);if(r<1||r>31){n.error(d.InvalidScheduleTrigger,`Invalid day of month '${r}' in '${e.content}' - a day of the month is between 1 and 31`,t),n.skipBlock(e.indent);return}return{kind:"ScheduleTriggerSourceSyntax",time:o,dayOfWeek:null,dayOfMonth:r,location:t}}return{kind:"ScheduleTriggerSourceSyntax",time:o,dayOfWeek:i[2]??null,dayOfMonth:null,location:t}}a(Is,"parseSchedule");function $s(n){let[e,t]=n.split(":").map(Number);if(e>=0&&e<=23&&t>=0&&t<=59)return`${n}:00.0000000`}a($s,"timeOf");function Es(n){switch(n.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}a(Es,"unitOf");var dn=`(?:"(${H})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,As=v("^screen\\s+([A-Za-z_]\\w*)$"),Ds=v("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Os=v("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Rs=v(`^label\\s+${dn}$`),Ts=v("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Ls=v("^[a-z_]\\w*$"),Ms=v(`^title\\s+${dn}$`),xs=v(`^column\\s+([\\w.]+)(?:\\s+label\\s+${dn})?$`),Ns=v("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),Ys=v(`^field\\s+([\\w.]+)\\s+label\\s+${dn}$`),ui=new Set(["csharp","typescript","react","html","sql"]),pn=a((n,e)=>n[e]!==void 0?G(n[e]):n[e+1],"operandText"),Bs=a(n=>["on","uses"].includes(R(n.content)),"isInteraction"),qs=a(n=>n.content.startsWith("```")||ui.has(n.content),"isCodeLine");function fi(n,e){let t=As.exec(e.content);t===null&&n.error(d.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,l(e));let i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent))n.reader.takeSignificant(),Q(o)||mi(n,o,i);return{kind:"ScreenSyntax",name:t?.[1]??"",directives:i,location:l(e)}}a(fi,"parseScreen");function mi(n,e,t){let i=Fs(n,e);i!==void 0&&t.push(i)}a(mi,"pushDirective");function hi(n,e){let t=[];for(let i=n.peekChild(e.indent);i!==void 0;i=n.peekChild(e.indent))n.reader.takeSignificant(),mi(n,i,t);return t}a(hi,"parseDirectives");function Fs(n,e){switch(R(e.content)){case"data":return zs(n,e);case"action":return Us(n,e);case"template":return Ws(n,e);case"section":return js(n,e);case"title":return Vs(n,e);case"table":return Zs(n,e);case"summary":return _s(n,e);case"navigate":return Gn(n,e.content,e);case"on":return te(n,e),{kind:"ScreenBehaviorSyntax",location:l(e)};case"uses":return n.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:l(e)};default:if(qs(e))return Gs(n,e);n.error(d.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,l(e)),n.skipBlock(e.indent);return}}a(Fs,"parseDirective");function zs(n,e){let t=Ds.exec(e.content);if(t===null){n.error(d.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,l(e));return}return{kind:"ScreenDataSyntax",type:ie(t[1],l(e)),query:t[2],by:t[3]??null,location:l(e)}}a(zs,"parseData");function Us(n,e){let t=Os.exec(e.content);if(t===null){n.error(d.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,l(e)),n.skipBlock(e.indent);return}let i=null,o=null;for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent)){n.reader.takeSignificant();let s=Rs.exec(r.content);s!==null?i=pn(s,1):R(r.content)==="navigate"?o=Gn(n,r.content,r)??null:n.error(d.UnknownActionDirective,`Unexpected '${r.content}' in action - expected 'label "..."' or 'navigate to ...'`,l(r))}return{kind:"ScreenActionSyntax",command:t[1],label:i,navigate:o,location:l(e)}}a(Us,"parseAction");function Gn(n,e,t){let i=Ts.exec(e);if(i===null){n.error(d.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,l(t));return}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,location:l(t)}}a(Gn,"parseNavigate");function Ws(n,e){let t=e.content.substring(8).trim(),i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){if(n.reader.takeSignificant(),!Ls.test(o.content)){n.error(d.InvalidScreenLayoutSlot,`Expected a slot name in template '${t}', got '${o.content}'`,l(o)),n.skipBlock(o.indent);continue}i.push({kind:"ScreenSlotSyntax",name:o.content,directives:hi(n,o),location:l(o)})}return{kind:"ScreenTemplateReferenceSyntax",name:t,slots:i,location:l(e)}}a(Ws,"parseTemplateReference");function js(n,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:hi(n,e),location:l(e)}}a(js,"parseSection");function Vs(n,e){let t=Ms.exec(e.content);return t===null?(n.error(d.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,l(e)),{kind:"ScreenTitleSyntax",text:"",location:l(e)}):{kind:"ScreenTitleSyntax",text:pn(t,1),location:l(e)}}a(Vs,"parseTitle");function Zs(n,e){let t=e.content.substring(5).trim(),i=[],o=null;for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent)){n.reader.takeSignificant();let s=xs.exec(r.content),c=Ns.exec(r.content);if(s!==null){let p=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:p?pn(s,2):null,location:l(r)})}else c!==null?o=Gn(n,c[1],r)??null:R(r.content)==="on"?te(n,r):Bs(r)?n.skipOpaqueBlock(r.indent):n.error(d.UnknownTableDirective,`Unexpected '${r.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,l(r))}return{kind:"ScreenTableSyntax",target:t,columns:i,rowClick:o,location:l(e)}}a(Zs,"parseTable");function _s(n,e){let t=e.content.substring(7).trim(),i=[];for(let o=n.peekChild(e.indent);o!==void 0;o=n.peekChild(e.indent)){n.reader.takeSignificant();let r=Ys.exec(o.content);if(r===null){n.error(d.UnknownSummaryDirective,`Unexpected '${o.content}' in summary - expected 'field <property> label "..."'`,l(o));continue}i.push({kind:"ScreenFieldSyntax",property:r[1],label:pn(r,2),location:l(o)})}return{kind:"ScreenSummarySyntax",target:t,fields:i,location:l(e)}}a(_s,"parseSummary");function Gs(n,e){let t=e.content.startsWith("```")?e.content.substring(3):e.content;if(!ui.has(t)){n.error(d.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,l(e));return}e.content.startsWith("```")||n.warning(d.LegacyInlineCodeFence,`'${t}' on its own line is deprecated - use '\`\`\`${t}' instead`,l(e));let i=Ce(n,t,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:t,code:i,location:l(e)},location:l(e)}}a(Gs,"parseCode");var Hn=v("^then\\s+returns\\b"),vi=v("^generated\\s+(?=\\S)(?![=])"),gi=v("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Hs=v("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Qs=v(`^(?:"${H}"|'(?:[^'\\\\]|\\\\.)*')$`);function yi(n,e,t,i){if((e.startsWith('"')||e.startsWith("'"))&&!Qs.test(e))return n.error(i,"Expected exactly one concrete value.",t),null;let o=J(e,t,n);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(o.kind)||o.kind==="LiteralExpressionSyntax"&&typeof o.value=="number"&&!Number.isFinite(o.value)?(n.error(i,"Expected exactly one concrete literal or structured value, not an expression.",t),null):o}a(yi,"parseConcrete");function un(n,e,t,i){let o=t.exec(e.content);if(o===null)return n.error(i,"Expected a named fixture or assertion with exactly one concrete value.",l(e)),n.skipBlock(e.indent),null;let r=l(e),s=yi(n,o[2],{...r,column:r.column+e.content.indexOf(o[2],e.content.indexOf("=")+1)},i),c=n.peekChild(e.indent);return c!==void 0&&(n.error(i,"A fixture or return field cannot have child directives.",l(c)),n.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:o[1],source:s,location:r}}a(un,"parseConcreteMapping");function ki(n,e){let t=Hn.exec(e.content)[0].length,i=e.content.substring(t).trim(),o=l(e);if(i.length>0){let s=yi(n,i,{...o,column:o.column+e.content.indexOf(i,t)},d.InvalidReturnExpectation),c=n.peekChild(e.indent);return c!==void 0&&(n.error(d.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",l(c)),n.skipBlock(e.indent)),s===null?null:{kind:"ScalarSpecificationReturnSyntax",value:s,location:o}}let r=[];for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent)){n.reader.takeSignificant();let c=un(n,s,Hs,d.InvalidReturnExpectation);c!==null&&r.push(c)}return{kind:"RecordSpecificationReturnSyntax",fields:r,location:o}}a(ki,"parseReturn");var Js=v("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),Ks=v("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),Xs=v("^specification\\s+([A-Za-z_]\\w*)$"),ea=v("^given\\s+([A-Z]\\w*)$"),na=v("^when\\s+append\\s+([A-Z]\\w*)$"),ta=v("^when\\s+([A-Z]\\w*)$"),ia=v("^then\\s+([A-Z]\\w*)$"),oa=v("^then\\s+query\\b"),Si=v("^(?:given|then)\\s+readmodel\\b"),ra=v("^given\\s+readmodel\\s+([A-Z]\\w*)$"),sa=v("^then\\s+readmodel\\s+([A-Z]\\w*)(\\s+exactly)?$"),wi=v("^then\\s+no\\b"),aa=v(`^then\\s+error\\s+"(${H})"$`),Jn=v("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),ca=v("^given\\s+clock\\b"),la=v("^given\\s+capture\\b"),da=v("^when\\s+clock\\b"),pa=v("^when\\s+trigger\\b"),ua=v("^when\\s+capture\\b"),fa=v("^when\\s+query\\b"),ma=v("^then\\s+result\\b"),ha=v("^then\\s+no\\s+result\\b"),va=v('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),ga=v("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),ya=v("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),ka=v("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Sa=v("^then\\s+result(\\s+exactly)?$");function bi(n,e){let t=Xs.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,l(e));let i={givenOperationFailures:[],thenOperations:[],thenCompensated:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenReadModels:[],thenErrors:[],givenClock:null,givenCaptures:[],whenClock:null,whenTrigger:null,whenCapture:null,whenQuery:null,thenResults:[],thenNoResult:null,thenDenied:null,thenReturns:null};for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent)){if(n.reader.takeSignificant(),Q(s)||wa(n,s,i))continue;let c=wi.test(s.content)?"then":R(s.content);c==="given"?ba(n,s,i):c==="when"?Pa(n,s,i,t):c==="then"?Ca(n,s,i):(n.error(d.UnknownSpecificationDirective,`Unexpected '${R(s.content)}' in specification body`,l(s)),n.skipBlock(s.indent))}let{whenDeclared:o,...r}=i;return{kind:"SpecificationSyntax",name:t,...r,location:l(e)}}a(bi,"parseSpecification");function wa(n,e,t){if(!Js.test(e.content))return!1;let i=Ks.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))n.error(d.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",l(e)),n.skipBlock(e.indent);else if(i[1]==="then operation"){let o=[];for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent)){n.reader.takeSignificant();let s=un(n,r,Jn,d.InvalidOperationSpecification);s!==null&&o.push(s)}t.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:o,location:l(e)})}else Fe(n,e,d.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?t.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:l(e)}):t.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:l(e)});return!0}a(wa,"parseOperationStep");function ba(n,e,t){if(ca.test(e.content))t.givenClock!==null?(n.error(d.InvalidSpecificationClock,"A specification states its clock at most once.",l(e)),n.skipBlock(e.indent)):t.givenClock=Pi(n,e,"given");else if(la.test(e.content)){let i=Ci(n,e,"given");i!==null&&t.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))n.skipOpaqueBlock(e.indent);else if(Si.test(e.content)){let i=Ii(n,e,ra,"given");i!==void 0&&t.givenReadModels.push(i)}else{let i=Kn(n,e,ea,"given");i!==void 0&&t.given.push(i)}}a(ba,"parseGiven");function Pa(n,e,t,i){let o=e.content.startsWith("when append");if(t.whenDeclared){let p=t.whenAppended!==null||o?d.ConflictingSpecificationActions:d.DuplicateSpecificationWhen;n.error(p,`Specification '${i}' already declares a 'when' - a specification can have at most one`,l(e)),n.skipBlock(e.indent);return}if(t.whenDeclared=!0,o){t.whenAppended=Kn(n,e,na,"when append")??null;return}if(da.test(e.content)){t.whenClock=Pi(n,e,"when");return}if(pa.test(e.content)){t.whenTrigger=Qn(n,e,ga,d.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(p,f)=>({kind:"SpecificationTriggerSyntax",trigger:p,values:f,location:l(e)}));return}if(ua.test(e.content)){t.whenCapture=Ci(n,e,"when");return}if(fa.test(e.content)){t.whenQuery=Qn(n,e,ka,d.InvalidSpecificationQueryAction,"when query","when query <Query>",(p,f)=>({kind:"SpecificationWhenQuerySyntax",query:p,arguments:f,location:l(e)}));return}let r=ta.exec(e.content);if(r===null){n.error(d.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,l(e)),n.skipBlock(e.indent);return}let s=[],c=$i(n,e,s);t.when={kind:"SpecificationCommandSyntax",commandType:r[1],...c,generatedValues:s,location:l(e)}}a(Pa,"parseWhen");function Ca(n,e,t){if(Hn.test(e.content)){let r=ki(n,e);t.thenReturns!==null?n.error(d.InvalidReturnExpectation,"A specification declares at most one return expectation.",l(e)):t.thenReturns=r;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||t.thenEventsInAnyOrder?n.error(d.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",l(e)):t.thenEventsInAnyOrder=!0,n.skipBlock(e.indent);return}if(ma.test(e.content)){Ia(n,e,t);return}if(ha.test(e.content)){e.content!=="then no result"||t.thenNoResult!==null?n.error(d.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",l(e)):t.thenNoResult={kind:"SpecificationNoResultSyntax",location:l(e)},n.skipBlock(e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(n.error(d.InvalidSpecificationDenied,"Expected exactly 'then denied'.",l(e)),n.skipBlock(e.indent)):t.thenDenied!==null?n.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",l(e)):t.thenDenied={kind:"SpecificationDeniedSyntax",location:l(e)};return}if(e.content==="then error"){t.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:l(e)});return}let i=aa.exec(e.content);if(i!==null){t.thenErrors.push({kind:"SpecificationErrorSyntax",name:G(i[1]),location:l(e)});return}if(R(e.content.substring(4).trim())==="error"){n.error(d.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,l(e)),n.skipBlock(e.indent);return}if(wi.test(e.content)||oa.test(e.content)){n.skipOpaqueBlock(e.indent);return}if(Si.test(e.content)){let r=Ii(n,e,sa,"then");r!==void 0&&t.thenReadModels.push(r);return}let o=Kn(n,e,ia,"then");o!==void 0&&t.thenEvents.push(o)}a(Ca,"parseThen");function Pi(n,e,t){let i=va.exec(e.content);return n.skipBlock(e.indent),i===null||i[1]!==t?(n.error(d.InvalidSpecificationClock,`Invalid '${t} clock' - expected '${t} clock "<ISO 8601 instant>"', such as '${t} clock "2026-10-05T08:00:00Z"'`,l(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:l(e)}}a(Pi,"parseClock");function Ci(n,e,t){return Qn(n,e,ya,d.InvalidSpecificationCapture,`${t} capture`,`${t} capture <Capture>`,(i,o)=>({kind:"SpecificationCaptureSyntax",capture:i,record:o,location:l(e)}))}a(Ci,"parseCapture");function Qn(n,e,t,i,o,r,s){let c=t.exec(e.content);return c===null?(n.error(i,`Invalid '${o}' declaration '${e.content}' - expected '${r}'`,l(e)),n.skipBlock(e.indent),null):s(c[1],Xn(n,e))}a(Qn,"parseNamedStep");function Ia(n,e,t){let i=Sa.exec(e.content);if(i===null){n.error(d.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,l(e)),n.skipBlock(e.indent);return}t.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:Xn(n,e),exactly:i[1]!==void 0,location:l(e)})}a(Ia,"parseResult");function Ii(n,e,t,i){let o=t.exec(e.content);if(o===null){n.error(d.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,l(e)),n.skipBlock(e.indent);return}return{kind:"SpecificationReadModelSyntax",name:o[1],properties:Xn(n,e),exactly:i==="then"&&o[2]!==void 0,location:l(e)}}a(Ii,"parseReadModelStep");function Kn(n,e,t,i){let o=t.exec(e.content);if(o===null){n.error(d.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,l(e)),n.skipBlock(e.indent);return}return{kind:"SpecificationEventSyntax",eventType:o[1],...$i(n,e),location:l(e)}}a(Kn,"parseEventStep");function $i(n,e,t){let i=[],o=null;for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent)){if(n.reader.takeSignificant(),t!==void 0&&vi.test(r.content)){let c=un(n,r,gi,d.InvalidGeneratedFixture);c!==null&&t.push(c);continue}let s=Jn.exec(r.content);if(s!==null)i.push(Ei(n,r,s));else if(R(r.content)==="for"){let c=r.content.substring(3).trim();c.length===0?n.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",l(r)):o!==null?n.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",l(r)):o=J(c,l(r),n)}else n.error(d.InvalidSpecificationValue,`Invalid property mapping '${r.content}' - expected '<property> = <value>'`,l(r))}return{values:i,for:o}}a($i,"parseValuesWithEventSource");function Xn(n,e){let t=[];for(let i=n.peekChild(e.indent);i!==void 0;i=n.peekChild(e.indent)){n.reader.takeSignificant();let o=Jn.exec(i.content);if(o===null){n.error(d.InvalidSpecificationValue,`Invalid property mapping '${i.content}' - expected '<property> = <value>'`,l(i));continue}t.push(Ei(n,i,o))}return t}a(Xn,"parseValues");function Ei(n,e,t){return{kind:"PropertyMappingSyntax",property:t[1],source:J(t[2],l(e),n),location:l(e)}}a(Ei,"mappingOf");var $a=v("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),Ea=new Set(["reducer"]);function Ai(n,e){let t=$a.exec(e.content),i="StateChange",o="";t===null?n.error(d.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,l(e)):(o=t[2],Lt.includes(t[1])?i=t[1]:n.error(d.UnknownSliceType,`Unknown slice type '${t[1]}' - expected StateChange, StateView, Automation or Translate`,l(e)));let r=n.scope;n.scope=[...r,o];let s=null,c=[],p=[],f=[],b=[],u=[],k=[],y=[],T=[],D=[],g=[],m=[];for(let w=n.peekChild(e.indent);w!==void 0;w=n.peekChild(e.indent)){if(n.reader.takeSignificant(),Q(w))continue;let A=R(w.content);A==="description"?s=j(n,w,s,`Slice '${o}'`):A==="operation"?p.push(sn(n,w).operation):A==="event"?c.push(Kt(n,w)):A==="command"?f.push(ti(n,w)):A==="query"?b.push(li(n,w)):A==="projection"?u.push(oi(n,w)):A==="capture"?y.push(xt(n,w)):A==="reaction"?k.push(pi(n,w)):A==="constraint"?T.push(ii(n,w)):A==="specification"?D.push(bi(n,w)):A==="readmodel"?g.push(Xt(n,w)):A==="screen"?m.push(fi(n,w)):Ea.has(A)?n.skipOpaqueBlock(w.indent):(n.warning(d.UnknownSliceDirective,`Unknown construct '${A}' in slice '${o}'`,l(w)),n.skipBlock(w.indent))}return n.scope=r,{kind:"SliceSyntax",type:i,name:o,description:s,events:c,operations:p,commands:f,queries:b,projections:u,captures:y,reactions:k,constraints:T,specifications:D,readModels:g,screens:m,location:l(e)}}a(Ai,"parseSlice");var Aa=v("^feature\\s+([A-Za-z_]\\w*)$"),Da=new Set(["on","uses","contribute"]),et="description, authorize, import, feature, slice, contribute, 'on <trigger>' or 'uses <Behavior>'",ze=class{static{a(this,"FeatureBody")}name;#e=[];#n=[];#i=[];#t=null;#o=null;constructor(e){this.name=e}tryParse(e,t){let i=R(t.content);switch(i){case"description":return this.#t=j(e,t,this.#t,`Feature '${this.name}'`),!0;case"authorize":return this.#o=ae(this.#o,he(e,t)),!0;case"import":return Ie(e,t,this.#i),!0;case"feature":return this.#e.push(fn(e,t)),!0;case"slice":return this.#n.push(Ai(e,t)),!0;default:return Da.has(i)?(te(e,t),!0):!1}}build(e,t=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#t,authorize:this.#o,features:this.#e,slices:this.#n,fileImports:this.#i,isPlacement:t,location:e}}};function fn(n,e){let t=Aa.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,l(e));let i=new ze(t),o=n.scope;n.scope=[...o,t];for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent))n.reader.takeSignificant(),i.tryParse(n,r)||(n.error(d.UnknownFeatureDirective,`Unexpected '${R(r.content)}' in feature body - expected ${et}`,l(r)),n.skipBlock(r.indent));return n.scope=o,i.build(l(e))}a(fn,"parseFeature");var nt=v("^module\\s+([A-Za-z_]\\w*)$"),Oa=new Set(["on","uses","screen","dialog","form","contribute"]),tt="description, authorize, import, screen template, dialog template, form, contribute, feature, 'on <trigger>' or 'uses <Behavior>'",Ue=class{static{a(this,"ModuleBody")}name;#e=[];#n=[];#i=null;#t=null;constructor(e){this.name=e}tryParse(e,t){let i=R(t.content);switch(i){case"description":return this.#i=j(e,t,this.#i,`Module '${this.name}'`),!0;case"authorize":return this.#t=ae(this.#t,he(e,t)),!0;case"import":return Ie(e,t,this.#n),!0;case"feature":return this.#e.push(fn(e,t)),!0;default:return Oa.has(i)?(te(e,t),!0):!1}}parseChildren(e,t){for(let i=e.peekChild(t.indent);i!==void 0;i=e.peekChild(t.indent))e.reader.takeSignificant(),this.tryParse(e,i)||(e.error(d.UnknownModuleDirective,`Unexpected '${R(i.content)}' in module body - expected ${tt}`,l(i)),e.skipBlock(i.indent))}build(e,t=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#i,authorize:this.#t,features:this.#e,fileImports:this.#n,isPlacement:t,location:e}}};function it(n,e){let t=nt.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,l(e));let i=new Ue(t),o=n.scope;return n.scope=[t],i.parseChildren(n,e),n.scope=o,i.build(l(e))}a(it,"parseModule");var Ra=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,Ta=/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.[0-9]{1,7})?(?:Z|[+-]([0-9]{2}):([0-9]{2}))$/;function ot(n,e){let t=(e?Ta:Ra).exec(n);if(t===null||t[0].length!==n.length)return!1;let i=Number(t[1]),o=Number(t[2]),r=Number(t[3]),c=[31,i%4===0&&(i%100!==0||i%400===0)?29:28,31,30,31,30,31,31,30,31,30,31];if(i<1||o<1||o>12||r<1||r>c[o-1])return!1;if(!e)return!0;if(Number(t[4])>23||Number(t[5])>59||Number(t[6])>59)return!1;if(t[7]===void 0)return!0;let p=Number(t[7]),f=Number(t[8]);return p<=14&&f<=59&&(p!==14||f===0)}a(ot,"responseDateValue");var mn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function hn(n,e,t=e.inputUses){let i=[],o=a((I,h)=>{let S=[...h,I.name];I.slices.forEach(C=>i.push({slice:C,scope:[...S,C.name]})),I.features.forEach(C=>o(C,S))},"collect");n.modules.forEach(I=>I.features.forEach(h=>o(h,[I.name])));let r=new Map,s=new Map,c=new Map;for(let{slice:I,scope:h}of i)for(let S of I.commands){let C=r.get(S.name)??[];C.push({command:S,scope:h}),r.set(S.name,C),s.set(S,ee(S.properties)),S.response?.kind==="RecordCommandResponseSyntax"&&c.set(S,ee(S.response.fields))}let p=new Map;for(let I of n.imports){let h=I.qualifiedName.split(".").at(-1);p.set(h,[...p.get(h)??[],I.qualifiedName])}let f=new Map,b=a((I,h)=>{let S=`${h.join(".")}|${I}`;if(f.has(S))return f.get(S);let C=p.get(I)??[],B=((r.get(I.split(".").at(-1))??[]).length===0&&C.length===1?C[0]:I).split("."),q=r.get(B.at(-1))??[];if(B.length>1){let x=B.slice(0,-1);q=q.filter(Y=>x.length<=Y.scope.length&&x.every((F,W)=>Y.scope[Y.scope.length-x.length+W]===F))}else for(let x=h.length;x>=0;x--){let Y=q.filter(F=>x<=F.scope.length&&h.slice(0,x).every((W,_)=>F.scope[_]===W));if(Y.length>0){q=Y;break}}let L=q.length===1?q[0].command:null;return f.set(S,L),L},"resolve"),u=ee(n.concepts),k=new Set(n.concepts.map(I=>I.name)),y=new Map([...ee(n.types)].map(([I,h])=>[I,ee(h.properties)])),T=new Set(i.flatMap(I=>I.slice.readModels.map(h=>h.name))),D=new Set([...s.keys()].flatMap(I=>[...I.properties])),g=a(I=>{for(let h of I)h.isGenerated&&!D.has(h)&&e.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",h.location)},"checkDeclarations"),m=a(I=>{I.features.forEach(m);for(let h of I.slices){for(let S of h.commands)for(let C of S.produces)C.inlineEvent!==null&&g(C.inlineEvent.properties);h.events.forEach(S=>g(S.properties)),h.readModels.forEach(S=>g(S.properties));for(let S of h.reactions)for(let C of S.triggers)for(let $ of C.produces)$.inlineEvent!==null&&g($.inlineEvent.properties)}},"checkFeature");n.types.forEach(I=>g(I.properties)),n.modules.forEach(I=>I.features.forEach(m));let w=a((I,h,S)=>{let C=s.get(S).get(I.property);if(C===void 0){e.error(d.InvalidResponseSource,`Response source '${I.property}' must reference one direct command property.`,I.location);return}let $=C.type;($.isCollection||T.has($.name))&&e.error(d.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",I.location),h!==null&&(h.name!==$.name||h.isCollection!==$.isCollection||h.isOptional!==$.isOptional)&&e.error(d.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",h.location)},"validateSource");for(let I of s.keys()){for(let S of I.properties){if(!S.isGenerated)continue;let C=u.get(S.type.name);(S.type.isOptional||S.type.isCollection||(C===void 0?mn.has(S.type.name)||y.has(S.type.name)||k.has(S.type.name)||T.has(S.type.name):C.type!=="Uuid"))&&e.error(d.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",S.location)}let h=I.response;if(h?.kind==="ScalarCommandResponseSyntax")w(h.source,null,I);else if(h?.kind==="RecordCommandResponseSyntax"){h.fields.length===0&&e.error(d.InvalidCommandResponse,"A response block requires at least one field.",h.location);let S=new Set;for(let C of h.fields)S.has(C.name)&&e.error(d.DuplicateResponseField,`Duplicate response field '${C.name}'.`,C.location),S.add(C.name),w(C.source,C.type,I)}}let A=a((I,h)=>{let S=I.when,C=S===null?null:b(S.commandType,h);if(S!==null&&C!==null){let q=s.get(C);for(let Y of S.values)q.get(Y.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${Y.property}' cannot be supplied as request or form input.`,Y.location);let L=[...q.values()].filter(Y=>Y.isIdentifier);if(S.for!==null&&L.length===1&&L[0].isGenerated){let Y=L[0].type;(mn.has(Y.name)||u.has(Y.name)||y.has(Y.name))&&(Y.isOptional||Y.isCollection||u.get(Y.name)?.type!=="Uuid"||S.for.kind!=="LiteralExpressionSyntax"||typeof S.for.value!="string"||!Di(S.for.value))&&e.error(d.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",S.for.location)}let x=new Set;for(let Y of S.generatedValues??[]){let F=q.get(Y.property);(x.has(Y.property)||F===void 0||!F.isGenerated||F.isIdentifier||!fe(Y.source,F.type,u,y))&&e.error(d.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",Y.location),x.add(Y.property)}}let $=I.thenReturns;if($==null||((S===null||I.thenErrors.length>0||I.thenDenied!=null)&&e.error(d.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",$.location),C===null))return;let E=C.response,B=s.get(C);if($.kind==="ScalarSpecificationReturnSyntax"&&E?.kind==="ScalarCommandResponseSyntax"&&B.has(E.source.property))fe($.value,B.get(E.source.property).type,u,y)||e.error(d.InvalidReturnExpectation,"The expected return value must match the response source's type.",$.location);else if($.kind==="RecordSpecificationReturnSyntax"&&E?.kind==="RecordCommandResponseSyntax"){$.fields.length===0&&e.error(d.InvalidReturnExpectation,"A record return expectation requires at least one field.",$.location);let q=c.get(C),L=new Set;for(let x of $.fields){let Y=q.get(x.property),F=Y===void 0?void 0:B.get(Y.source.property);(L.has(x.property)||F===void 0||!fe(x.source,F.type,u,y))&&e.error(d.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",x.location),L.add(x.property)}}else e.error(d.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",$.location)},"validateSpecification");for(let{slice:I,scope:h}of i)I.specifications.forEach(S=>A(S,h));for(let I of t){if(I.isParameter===!0)continue;let h=b(I.command,I.scope);h!==null&&s.get(h).get(I.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${I.property}' cannot be supplied as request or form input.`,I.location)}}a(hn,"validateResponses");function ee(n){let e=new Map,t=new Set;for(let i of n)e.has(i.name)&&t.add(i.name),e.set(i.name,i);return t.forEach(i=>e.delete(i)),e}a(ee,"uniqueByName");function fe(n,e,t,i){if(n.kind==="LiteralExpressionSyntax"&&n.value===null)return e.isOptional;if(e.isCollection)return n.kind==="ListExpressionSyntax"&&n.items.every(c=>fe(c,{...e,isCollection:!1,isOptional:!1},t,i));let o=i.get(e.name);if(o!==void 0)return n.kind==="ObjectExpressionSyntax"&&n.members.every(c=>{let p=o.get(c.name);return p!==void 0&&fe(c.value,p.type,t,i)});let r=t.get(e.name),s=r?.type??e.name;if(r?.type==="Enum")return n.kind==="LiteralExpressionSyntax"&&typeof n.value=="string"&&r.values.includes(n.value);if(n.kind==="LiteralExpressionSyntax")switch(s){case"Uuid":return typeof n.value=="string"&&Di(n.value);case"String":return typeof n.value=="string";case"Bool":return typeof n.value=="boolean";case"Int":return typeof n.value=="number"&&Number.isFinite(n.value)&&Number.isInteger(n.value);case"Decimal":return typeof n.value=="number"&&Number.isFinite(n.value);case"Date":return typeof n.value=="string"&&ot(n.value,!1);case"DateTime":return typeof n.value=="string"&&ot(n.value,!0);default:return!mn.has(s)}return!mn.has(s)&&r===void 0}a(fe,"compatibleValue");var La=/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|\{[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\}|\([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\))(?![\s\S])/i;function Di(n){return La.test(n)}a(Di,"uuidValue");var ve=class n{static{a(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}fork(){let e=new n(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&$t(this.lines[this.#e]);)this.#e++;return this.#e<this.lines.length?this.lines[this.#e]:void 0}takeSignificant(){let e=this.peekSignificant();if(e===void 0)throw new Error("There is no significant line left to take");return this.#e++,e}takeRaw(){return this.#e<this.lines.length?this.lines[this.#e++]:void 0}};function Ae(n){return[...n.events,...n.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}a(Ae,"eventDeclarations");function vn(n){return[...n.operations??[],...n.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}a(vn,"operationDeclarations");var Z;(function(n){n.Event="event",n.Operation="operation",n.Unresolved="unresolved",n.Ambiguous="ambiguous"})(Z||(Z={}));var pe=class{static{a(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e){let t=a((i,o)=>{for(let r of i){let s=[...o,r.name];for(let c of r.slices)this.slices.push({slice:c,scope:[...s,c.name]});t(r.features,s)}},"collect");e.modules.forEach(i=>t(i.features,[i.name]));for(let{slice:i,scope:o}of this.slices){this.scopes.set(i,o);let r=new Map;for(let c of Ae(i)){let p=r.get(c.name)??[];p.push(c),r.set(c.name,p)}let s=[...r.values()].flatMap(c=>new Set(c.map(p=>p.generation)).size!==c.length?c:[c.reduce((p,f)=>p.generation>=f.generation?p:f)]);this.declarations.push(...s.map(c=>({kind:Z.Event,name:c.name,node:c,scope:o})),...vn(i).map(c=>({kind:Z.Operation,name:c.name,node:c,scope:o})))}for(let i of this.declarations){let o=this.byName.get(i.name)??[];o.push(i),this.byName.set(i.name,o)}}resolve(e,t){let i=this.scopes.get(t);if(i===void 0)return{kind:Z.Unresolved,declaration:null,candidates:[]};let o=this.resolutions.get(t)??new Map,r=o.get(e);if(r!==void 0)return r;let s=this.candidates(e,i),c=s.length===1?{kind:s[0].kind,declaration:s[0],candidates:[]}:{kind:s.length===0?Z.Unresolved:Z.Ambiguous,declaration:null,candidates:s};return o.set(e,c),this.resolutions.set(t,o),c}isOperation(e,t){return e.inlineOperation!=null||this.resolve(e.event,t).kind===Z.Operation}isEventProduction(e,t){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,t);return i.kind!==Z.Operation&&!(i.kind===Z.Ambiguous&&i.candidates.some(o=>o.kind===Z.Operation))}candidates(e,t){let i=e.split("."),o=this.byName.get(i.at(-1))??[],r=i.slice(0,-1);if(r.length>0)return o.filter(s=>r.length<=s.scope.length&&r.every((c,p)=>s.scope[s.scope.length-r.length+p]===c));for(let s=t.length;s>=0;s--){let c=o.filter(p=>s<=p.scope.length&&t.slice(0,s).every((f,b)=>p.scope[b]===f));if(c.length>0)return c}return[]}};function Ma(n,e){return n.produces.filter(t=>t.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(t,e.slice)))}a(Ma,"eventProductions");function Oi(n,e){let t=Ma(n,e),i=n.properties.find(o=>o.isIdentifier)?.name;return t.some(o=>o.for!==null&&(o.for.kind!=="PathExpressionSyntax"||o.for.path!==i))||t.some(o=>o.inlineEvent!==null&&o.for===null)&&t.some(o=>o.inlineEvent===null&&o.for===null)}a(Oi,"requiresExplicitDestinations");function gn(n,e){let t=[],i=a(c=>{t.push(...c.slices),c.features.forEach(i)},"inFeature");n.modules.forEach(c=>c.features.forEach(i));let o=new Map;for(let c of t.flatMap(Ae))o.set(c.name,(o.get(c.name)??0)+1);let r=new Set(n.imports.map(c=>c.qualifiedName.split(".").at(-1))),s=new pe(n);for(let{slice:c,command:p}of t.flatMap(f=>f.commands.map(b=>({slice:f,command:b})))){let f=p.produces.filter(k=>s.isEventProduction(k,c)),b=p.properties.find(k=>k.isIdentifier)?.name,u=Oi(p,{resolver:s,slice:c});for(let k of f){let y=k.inlineEvent;y!==null&&((o.get(y.name)??0)>1||r.has(y.name))&&e.error(d.InlineEventCollision,`Inline event '${y.name}' collides with another event declaration or import`,k.location),u&&k.for===null&&e.error(d.ExplicitProducesTargetsRequired,`Production '${k.event}' in command '${p.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,k.location);let T=k.for?.kind==="PathExpressionSyntax"?k.for.path:k.for===null&&y!==null?b:void 0;if(!(b===void 0||T!==b))for(let D of k.mappings.filter(g=>g.source.kind==="PathExpressionSyntax"&&g.source.path===b)){let g=`Event '${k.event}' copies command identifier '${b}' into payload property '${D.property}' although it already identifies the event source`;y===null?e.information(d.EventSourceIdInPayload,g,D.location):e.warning(d.EventSourceIdInPayload,g,D.location)}}}}a(gn,"validateInlineEvents");function yn(n,e){let t=new pe(n),i=ee(n.concepts),o=new Map([...ee(n.types)].map(([m,w])=>[m,ee(w.properties)])),r=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...i.keys(),...o.keys()]),s=new Set(n.imports.map(m=>m.qualifiedName.split(".").at(-1))),c=new Map;for(let m of n.imports){let w=m.qualifiedName.split(".").at(-1);c.set(w,[...c.get(w)??[],m.qualifiedName])}let p=a(m=>{let w=new Map,A=new Map;for(let I of m){let h=w.get(I.name)??[];h.push(I),w.set(I.name,h)}return(I,h)=>{let S=JSON.stringify([I,h]);if(A.has(S))return A.get(S);let C=a(q=>{let L=q.split("."),x=w.get(L.at(-1))??[],Y=L.slice(0,-1);if(Y.length>0)return x.filter(F=>Y.length<=F.scope.length&&Y.every((W,_)=>F.scope[F.scope.length-Y.length+_]===W));for(let F=h.length;F>=0;F--){let W=x.filter(_=>F<=_.scope.length&&h.slice(0,F).every((se,me)=>_.scope[me]===se));if(W.length>0)return W}return[]},"candidates"),$=C(I),E=c.get(I)??[];$.length===0&&E.length===1&&($=C(E[0]));let B=$.length===1?$[0].node:null;return A.set(S,B),B}},"scoped"),f=p(t.slices.flatMap(({slice:m,scope:w})=>m.readModels.map(A=>({name:A.name,scope:w,node:A})))),b=p(t.slices.flatMap(({slice:m,scope:w})=>m.commands.map(A=>({name:A.name,scope:w,node:{command:A,slice:m}})))),u=new Map;for(let m of n.systems??[])u.has(m.name)&&e.error(d.InvalidSystemDeclaration,`System '${m.name}' is declared more than once.`,m.location),u.set(m.name,(u.get(m.name)??0)+1);let k=a((m,w,A=!0)=>{let[I,...h]=w.split("."),S=m.filter(B=>B.name===I);if(S.length!==1)return{type:null,missing:S.length===0};let C=S[0].type;if(h.length===0)return{type:C,missing:!1};let $=o.get(C.name);if($===void 0)return{type:null,missing:r.has(C.name)};let E=k([...$.values()],h.join("."),A);return E.type===null?E:{type:{...E.type,isOptional:A&&C.isOptional||E.type.isOptional,isCollection:C.isCollection||E.type.isCollection},missing:!1}},"pathType"),y=a((m,w,A,I,h=new Set)=>{if(A.has(w)||m.isOptional&&!I.has(w))return!0;if(m.isCollection||h.has(m.name))return!1;let S=o.get(m.name);return S===void 0?I.has(w)&&!r.has(m.name):[...S.values()].every(C=>y(C.type,`${w}.${C.name}`,A,I,new Set([...h,m.name])))},"covered"),T=a((m,w)=>{if(m.kind==="ListExpressionSyntax"&&w.isCollection)return m.items.every(I=>T(I,{...w,isCollection:!1,isOptional:!1}));let A=o.get(w.name);return m.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every(I=>(I.type.isOptional||m.members.some(h=>h.name===I.name))&&m.members.filter(h=>h.name===I.name).every(h=>T(h.value,I.type)))},"completeValue"),D=a(m=>m.kind==="LiteralExpressionSyntax"?typeof m.value!="number"||Number.isFinite(m.value):m.kind==="ObjectExpressionSyntax"?m.members.every(w=>D(w.value)):m.kind==="ListExpressionSyntax"&&m.items.every(D),"concrete"),g=a((m,w,A,I,h)=>{let S=new Set,C=new Set(m.map(E=>E.property)),$=new Set;for(let E of m){let B=E.property.split(".");for(let q=1;q<=B.length;q++)$.add(B.slice(0,q).join("."))}for(let E of m){S.has(E.property)&&e.error(d.InvalidOperationMapping,`Duplicate operation input mapping '${E.property}'.`,E.location),S.add(E.property);let B=k(w.inputs,E.property,!1);if(B.missing&&e.error(d.InvalidOperationMapping,`Operation '${w.name}' declares no input '${E.property}'.`,E.location),B.type===null)continue;let q=E.property.split(".");for(let L=1;L<q.length;L++)C.has(q.slice(0,L).join("."))&&e.error(d.InvalidOperationMapping,`Operation input mapping '${E.property}' overlaps a whole input mapping.`,E.location);if(A!==null&&E.source.kind==="PathExpressionSyntax"){let L=k(A.properties,E.source.path),x=E.source.path.split("."),Y=(on.get(A)??[]).filter(_=>(_.alias??_.readModel)===x[0]);if(L.missing&&Y.length>0){L={type:null,missing:!1};let _=Y.length===1?f(Y[0].readModel,h):null;x.length>1&&_!==null&&(L=k(_.properties,x.slice(1).join(".")))}L.missing&&e.error(d.InvalidOperationMapping,`Command '${A.name}' declares no source '${E.source.path}'.`,E.source.location);let F=L.type,W=B.type;F!==null&&r.has(F.name)&&r.has(W.name)&&(F.name!==W.name||F.isCollection!==W.isCollection||F.isOptional&&!W.isOptional)&&e.error(d.InvalidOperationMapping,`Source '${E.source.path}' is incompatible with input '${E.property}' of operation '${w.name}'.`,E.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(E.source.kind)&&(!fe(E.source,B.type,i,o)||I&&!T(E.source,B.type))&&e.error(d.InvalidOperationMapping,`Value is incompatible with input '${E.property}' of operation '${w.name}'.`,E.source.location)}if(I)for(let E of w.inputs)y(E.type,E.name,S,$)||e.error(d.InvalidOperationMapping,`Production of operation '${w.name}' supplies no value for required input '${E.name}'.`,w.location)},"validateMappings");for(let{slice:m,scope:w}of t.slices){let A=vn(m),I=new Set(Ae(m).map(h=>h.name));for(let h of A){I.has(h.name)&&e.error(d.ProductionDeclarationCollision,`Operation '${h.name}' collides with another event or operation in slice '${m.name}'.`,h.location),I.add(h.name),h.uses.length>0&&u.get(h.uses)!==1&&e.error(d.InvalidSystemReference,`Operation '${h.name}' must use one declared system; '${h.uses}' does not resolve uniquely.`,h.usesLocation??h.location);for(let S of h.inputs)!r.has(S.type.name)&&!s.has(S.type.name)&&e.warning(d.UnknownType,`Unknown type '${S.type.name}' on input '${S.name}' of operation '${h.name}'.`,S.type.location)}for(let h of m.commands)for(let S of h.produces){let C=t.resolve(S.event,m);C.kind===Z.Ambiguous&&C.candidates.some($=>$.kind===Z.Operation)&&e.error(d.InvalidProductionReference,`Production '${S.event}' is ambiguous.`,S.location),S.event.includes(".")&&C.kind!==Z.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",S.location),C.declaration?.node.kind==="OperationSyntax"&&((S.for!==null||S.tags.length>0)&&e.error(d.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",S.location),g(S.mappings,C.declaration.node,h,!0,w))}for(let h of m.reactions.flatMap(S=>S.triggers).flatMap(S=>S.produces)){let S=t.resolve(h.event,m);S.kind===Z.Ambiguous&&S.candidates.some(C=>C.kind===Z.Operation)&&e.error(d.InvalidProductionReference,`Production '${h.event}' is ambiguous.`,h.location),h.event.includes(".")&&t.resolve(h.event,m).kind!==Z.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",h.location),t.isOperation(h,m)&&e.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",h.location)}for(let h of m.specifications){let S=[...h.givenOperationFailures??[],...h.thenOperations??[],...h.thenCompensated??[]];if(S.length===0)continue;let C=b(h.when?.commandType??"",w);(C===null||h.whenAppended!==null||h.whenQuery!==null||h.whenTrigger!==null||h.whenClock!==null||h.whenCapture!==null)&&e.error(d.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",h.location);let $=new Map;for(let E of S){if(E.kind==="SpecificationOperationSyntax")for(let L of E.values)D(L.source)||e.error(d.InvalidOperationSpecification,"Operation assertions require concrete input values.",L.source.location);let B=t.resolve(E.operation,m).declaration?.node;if(B?.kind!=="OperationSyntax"){e.error(d.InvalidOperationSpecification,`'${E.operation}' does not resolve uniquely to a declared operation.`,E.location);continue}let q=$.get(B)??new Set;if(q.has(E.kind)&&e.error(d.InvalidOperationSpecification,`Duplicate operation step '${E.operation}'.`,E.location),q.add(E.kind),$.set(B,q),E.kind==="SpecificationCompensatedSyntax"&&B.compensate===null&&e.error(d.InvalidOperationSpecification,`Operation '${E.operation}' declares no compensation.`,E.location),C!==null&&C.command.handler==null){let L=C.command.produces.map(x=>t.resolve(x.event,C.slice));L.every(x=>x.kind===Z.Event||x.kind===Z.Operation)&&!L.some(x=>x.declaration?.node===B)&&e.error(d.InvalidOperationSpecification,`Command '${C.command.name}' does not produce operation '${E.operation}'.`,E.location)}E.kind==="SpecificationOperationSyntax"&&g(E.values,B,null,!1,w)}}}}a(yn,"validateOperations");var xa=v("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Ti=v("^import\\s+([\\w.]+)$"),Na=v("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@\\w+)*)$"),Ya=v("^@?[a-z_]\\w*$"),Ba=v(`^([a-z_]\\w*)\\s+reason\\s+"(${H})"$`),qa=v("^persona\\s+([A-Za-z_]\\w*)$"),Fa=v("^policy\\s+([A-Za-z_]\\w*)$"),za=/^[ ]*\t/,Ri=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Li=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Ua=new Set(["slice","feature","description","authorize","screen","dialog","form","contribute","on","uses"]);function kn(n,e,t=Se){Ga(n,e);let i=t.length===1?new Ue(t[0]):void 0,o=t.length>1?new ze(t[t.length-1]):void 0,r=i??o,s=null,c=[],p=[],f=[],b=[],u=[],k=[],y=[],T=[],D=!1;for(let g=n.reader.peekSignificant();g!==void 0;g=n.reader.peekSignificant()){n.reader.takeSignificant();let m=R(g.content);if(m==="domain"){s=_a(n,g,s,D);continue}if(D||=Wa(m,g,t),m==="import"&&Ot(g.content))r!==void 0?r.tryParse(n,g):Ie(n,g,p);else if(m==="import"){let w=Ti.exec(g.content);w===null?n.error(d.InvalidImportDeclaration,`Invalid import '${g.content}' - expected 'import <Qualified.Name>'`,l(g)):c.push({kind:"ImportSyntax",qualifiedName:w[1],location:l(g)})}else m==="eventsource"?k.push(zt(n,g)):m==="system"?u.push(ei(n,g)):m==="concept"?f.push(Ha(n,g)):m==="type"?b.push(Jt(n,g)):m==="module"&&!Ne(t)?ja(n,g,t,i):m==="module"?y.push(it(n,g)):m==="persona"?T.push(Ja(n,g)):m==="trigger"?di(n,g):Li.has(m)?m==="behavior"||m==="layout"?te(n,g):n.skipOpaqueBlock(g.indent):r?.tryParse(n,g)!==!0&&Va(n,g,t)}return i!==void 0?y.unshift(i.build(n.start,!0)):o!==void 0&&y.unshift(Za(t,o.build(n.start,!0),n.start)),{kind:"ApplicationSyntax",domain:s,imports:c,concepts:f,types:b,systems:u,eventSources:k,modules:y,personas:T,fileImports:p,location:n.start}}a(kn,"parseApplication");function Wa(n,e,t){return n==="import"?Ti.test(e.content):n==="module"?Ne(t):n==="eventsource"||n==="system"||n==="concept"||n==="type"||n==="persona"||Li.has(n)}a(Wa,"declaresConstruct");function ja(n,e,t,i){let o=nt.exec(e.content)?.[1]??"";if(i!==void 0&&o===t[0]){i.parseChildren(n,e);return}n.error(d.ModuleInPlacedFile,`This file is imported into ${Ke(t)}, so it cannot declare module '${o}' - import it at the top level of a document instead`,l(e)),n.skipBlock(e.indent)}a(ja,"parseModuleInPlacedFile");function Va(n,e,t){let i=R(e.content);if(Ne(t)){let o=Ua.has(i)?` - '${i}' belongs in a module or feature; wrap it in one, or import this file from inside one`:" - expected domain, import, concept, type, policy, persona, authentication, module, seed, trigger, behavior, ui profile, theme or layout";n.error(d.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${o}`,l(e))}else{let o=t.length===1?tt:et;n.error(d.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${Ke(t)} - expected an application declaration or ${o}`,l(e))}n.skipBlock(e.indent)}a(Va,"reportUnexpectedTopLevel");function Za(n,e,t){let i=e;for(let o=n.length-2;o>=1;o--)i={kind:"FeatureSyntax",name:n[o],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:t};return{kind:"ModuleSyntax",name:n[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:t}}a(Za,"place");function _a(n,e,t,i){let o=xa.exec(e.content);return o===null?(n.error(d.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,l(e)),t):t!==null?(n.error(d.DuplicateDomain,"The document already declares a domain - a document can have at most one",l(e)),t):(i&&n.error(d.DomainNotFirst,"'domain' must be declared before any other construct",l(e)),{kind:"DomainSyntax",name:o[1],location:l(e)})}a(_a,"parseDomain");function Ga(n,e){let t=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){t=!t;continue}!t&&za.test(i.raw)&&n.warning(d.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",Et(i))}}a(Ga,"warnOnTabIndentation");function Ha(n,e){let t=Na.exec(e.content);if(t===null)return n.error(d.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,l(e)),n.skipBlock(e.indent),{kind:"ConceptSyntax",name:R(e.content),type:"",attributes:[],values:[],location:l(e)};let[,i,o,r]=t,s=r.split(" ").filter(f=>f.length>0).map(f=>({kind:"ConceptAttributeSyntax",name:f.replace(/^@+/,""),reason:null,location:l(e)}));o!=="Enum"&&!Ri.includes(o)&&n.error(d.UnknownPrimitiveType,`Unknown primitive type '${o}' - expected ${Ri.join(", ")} or Enum`,l(e));let c=new Map;s.forEach((f,b)=>{c.has(f.name)||c.set(f.name,b)});let p=[];for(let f=n.peekChild(e.indent);f!==void 0;f=n.peekChild(e.indent)){n.reader.takeSignificant();let b=Ba.exec(f.content);Q(f)||(R(f.content)==="validate"?(o==="Enum"&&f.content==="validate"&&n.peekChild(f.indent)===void 0&&n.warning(d.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,l(f)),n.skipOpaqueBlock(f.indent)):b!==null?Qa(n,f,i,s,c,b[1],G(b[2])):o==="Enum"&&Ya.test(f.content)?p.push(V(f.content)):o==="Enum"?n.error(d.InvalidEnumerationValue,`Invalid enum value '${f.content}' - expected an identifier`,l(f)):(n.error(d.UnknownConceptDirective,`Unexpected '${f.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,l(f)),n.skipBlock(f.indent)))}return{kind:"ConceptSyntax",name:i,type:o,attributes:s,values:p,location:l(e)}}a(Ha,"parseConcept");function Qa(n,e,t,i,o,r,s){let c=o.get(r);c===void 0?n.error(d.AttributeReasonWithoutAttribute,`Concept '${t}' declares a reason for '${r}' without the attribute - write 'concept ${t} : <Type> @${r}'`,l(e)):i[c].reason!==null?n.error(d.DuplicateAttributeReason,`Concept '${t}' already declares a reason for '${r}' - at most one is allowed`,l(e)):i[c]={...i[c],reason:s}}a(Qa,"applyAttributeReason");function Ja(n,e){let t=qa.exec(e.content)?.[1]??"";t===""&&n.error(d.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,l(e));let i=null,o=[];for(let r=n.peekChild(e.indent);r!==void 0;r=n.peekChild(e.indent)){n.reader.takeSignificant();let s=R(r.content);if(s==="description")i=j(n,r,i,`Persona '${t}'`);else if(s==="policy"){let c=Fa.exec(r.content);c===null?n.error(d.InvalidPersonaPolicyReference,`Invalid policy reference '${r.content}' - expected 'policy <Name>'`,l(r)):o.push(c[1])}else n.error(d.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,l(r)),n.skipBlock(r.indent)}return{kind:"PersonaSyntax",name:t,description:i,policies:o,location:l(e)}}a(Ja,"parsePersona");var De=class n{static{a(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,t){this.sources=e,this.qualifiedTypes=t}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,t){let i=this.sources.get(e);return i?.length===1&&i[0].filter(o=>o===t).length===1}static capture(e,t=Se){return this.capturePlaced([...e].map(i=>({lines:i,placement:t})))}static capturePlaced(e){let t=new Map,i=new Set,o=new Set;for(let{lines:s,placement:c}of e){let p=new de(new ve(s));p.scope=c;let f=kn(p,s,c);for(let b of f.types)i.add(b.name);for(let b of f.concepts)i.add(b.name);for(let b of f.imports)o.add(b.qualifiedName);for(let b of f.eventSources??[])t.set(b.name,[...t.get(b.name)??[],b.streams.map(u=>u.name)])}let r=new Set([...o].filter(s=>i.has(s.substring(s.lastIndexOf(".")+1))));return new n(t,r)}};var oe;(function(n){n.Unique="unique",n.Ambiguous="ambiguous",n.NotFound="notFound",n.WrongKind="wrongKind"})(oe||(oe={}));var Sn=class{static{a(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let t of e.eventSources??[])this.sources.set(t.name,[...this.sources.get(t.name)??[],t]);this.otherNames=new Set([...e.concepts,...e.types].map(t=>t.name))}resolve(e,t){let i=this.sources.get(e)??[],o=i.flatMap(s=>s.streams).filter(s=>s.name===t),r;return i.length===0?r=this.otherNames.has(e)?oe.WrongKind:oe.NotFound:i.length>1||o.length>1?r=oe.Ambiguous:r=o.length===1?oe.Unique:oe.NotFound,{kind:r,sources:i,streams:o}}};var rt=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function wn(n,e){let t=ee(n.concepts),i=ee(n.types),o=new Set([...rt,...t.keys(),...i.keys()]),r=new Map([...i].map(([u,k])=>[u,ee(k.properties)])),s=a((u,k)=>o.has(u.name)&&o.has(k.name)?u.name===k.name&&u.isCollection===k.isCollection&&(!u.isOptional||k.isOptional):null,"compatible"),c=a((u,k)=>{if(u===null)return;if(u.isOptional||u.isCollection||n.types.some(D=>D.name===u.name)){e.error(d.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",u.location);return}let y=n.concepts.filter(D=>D.name===u.name),T=y.length===1?y[0].type:y.length===0&&rt.has(u.name)?u.name:null;k&&T!==null&&(!["String","Uuid","Int"].includes(T)||T==="Int"&&y.length===0||y.some(D=>D.values.length>0))&&e.error(d.UnsupportedStreamIdType,"Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.",u.location),T===null&&!n.imports.some(D=>D.qualifiedName===u.name||D.qualifiedName.split(".").at(-1)===u.name)&&e.warning(d.UnknownType,`Unknown type '${u.name}' in event source declaration.`,u.location)},"validateType"),p=new Set;for(let u of n.eventSources??[]){p.has(u.name)&&e.error(d.InvalidEventSourceDeclaration,`Event source '${u.name}' has multiple physical declarations.`,u.location),p.add(u.name),c(u.identifier,!1);let k=new Set;for(let y of u.streams)k.has(y.name)&&e.error(d.InvalidEventSourceDeclaration,`Stream '${u.name}.${y.name}' has multiple declarations under this source.`,y.location),k.add(y.name),c(y.streamId,!0)}let f=a((u,k)=>{let[y,...T]=k.split(".");if(u===null)return{property:null,missing:!1};let D=u.filter(w=>w.name===y);if(D.length!==1)return{property:null,missing:D.length===0};let g=D[0];if(T.length===0)return{property:g,missing:!1};if(rt.has(g.type.name)||t.has(g.type.name)&&!i.has(g.type.name))return{property:null,missing:!0};let m=f(i.get(g.type.name)?.properties??null,T.join("."));return m.property===null?m:{property:{...m.property,type:{...m.property.type,isCollection:g.type.isCollection||m.property.type.isCollection,isOptional:g.type.isOptional||m.property.type.isOptional}},missing:!1}},"pathProperty"),b=new Sn(n);for(let{slice:u}of new pe(n).slices)for(let k of u.commands){let y=k.stream;if(y==null||y.propertyCandidate!==null)continue;let T=b.resolve(y.eventSource,y.stream);if(T.kind!==oe.Unique){let A={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[T.kind];e.error(d.InvalidCommandStream,`Stream '${y.eventSource}.${y.stream}' is ${A}; routing requires one physical source and stream.`,y.location);continue}let D=T.sources[0],g=T.streams[0],m=k.properties.filter(A=>A.isIdentifier);if(D.identifier!==null&&m.length===1&&s(m[0].type,D.identifier)===!1&&e.warning(d.InvalidCommandStream,`Command identifier '${m[0].name}' does not have the source's nominal identifier type '${D.identifier.name}'. The stream does not supply a destination.`,m[0].location),(g.streamId===null&&y.streamId!==null||g.streamId!==null&&y.streamId===null)&&e.error(d.InvalidCommandStream,g.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",y.location),g.streamId===null||y.streamId===null)continue;let w=y.streamId.source;if(w.kind==="PathExpressionSyntax"){let A=f(k.properties,w.path);(A.missing||A.property!==null&&s(A.property.type,g.streamId)===!1)&&e.error(d.InvalidCommandStream,`Stream id source '${w.path}' is absent or incompatible with nominal type '${g.streamId.name}'.`,w.location)}else w.kind==="LiteralExpressionSyntax"&&!fe(w,g.streamId,t,r)?e.error(d.InvalidCommandStream,`Stream id value is incompatible with nominal type '${g.streamId.name}'.`,w.location):(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(w.kind)||w.kind==="LiteralExpressionSyntax"&&w.value===null)&&e.error(d.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",w.location)}}a(wn,"validateEventSources");function Oe(n,e,t=Se,i=!0,o){let r=Pe(n,!1,e),s=new de(new ve(r),e);s.scope=t,s.streamCandidates=o??De.capture([r],t);let c=kn(s,r,t);return i&&(gn(c,s),yn(c,s),hn(c,s),wn(c,s)),{value:c,diagnostics:s.diagnostics,triggerData:s.triggerData,inputUses:s.inputUses,success:!s.diagnostics.some(p=>p.severity==="error")}}a(Oe,"parseForAuthoring");var bn=class{static{a(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(t=>this.visitImport(t)),e.fileImports.forEach(t=>this.visitFileImport(t)),e.systems?.forEach(t=>this.visitSystem(t)),e.eventSources?.forEach(t=>this.visitEventSource(t)),e.concepts.forEach(t=>this.visitConcept(t)),e.types.forEach(t=>this.visitType(t)),e.personas.forEach(t=>this.visitPersona(t)),e.modules.forEach(t=>this.visitModule(t))}visitPersona(e){this.visitNode(e)}visitAuthorize(e){this.visitNode(e),this.visitPolicyRequirement(e.requirement)}visitPolicyRequirement(e){this.visitNode(e),e.kind==="LogicalPolicyRequirementSyntax"&&(this.visitPolicyRequirement(e.left),this.visitPolicyRequirement(e.right))}visitDomain(e){this.visitNode(e)}visitImport(e){this.visitNode(e)}visitFileImport(e){this.visitNode(e)}visitConcept(e){this.visitNode(e),e.attributes.forEach(t=>this.visitNode(t))}visitType(e){this.visitNode(e),e.properties.forEach(t=>this.visitProperty(t))}visitModule(e){this.visitNode(e),e.fileImports.forEach(t=>this.visitFileImport(t)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(t=>this.visitFeature(t))}visitFeature(e){this.visitNode(e),e.fileImports.forEach(t=>this.visitFileImport(t)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(t=>this.visitFeature(t)),e.slices.forEach(t=>this.visitSlice(t))}visitSlice(e){this.visitNode(e),e.commands.forEach(t=>this.visitCommand(t)),e.operations?.forEach(t=>this.visitOperation(t)),e.events.forEach(t=>this.visitEvent(t)),e.constraints.forEach(t=>this.visitConstraint(t)),e.queries.forEach(t=>this.visitQuery(t)),e.projections.forEach(t=>this.visitProjection(t)),e.readModels.forEach(t=>this.visitReadModel(t)),e.captures.forEach(t=>this.visitCapture(t)),e.reactions.forEach(t=>this.visitReaction(t)),e.screens.forEach(t=>this.visitScreen(t)),e.specifications.forEach(t=>this.visitSpecification(t))}visitCommand(e){this.visitNode(e),e.properties.forEach(t=>this.visitProperty(t)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.stream!=null&&this.visitCommandStream(e.stream),e.streamCandidates?.forEach(t=>this.visitCommandStream(t)),e.validations.forEach(t=>this.visitValidate(t)),e.produces.forEach(t=>this.visitProduces(t)),e.handler!=null&&this.visitHandler(e.handler),e.response!=null&&this.visitCommandResponse(e.response)}visitEventSource(e){this.visitNode(e),e.identifier!==null&&this.visitTypeRef(e.identifier),e.streams.forEach(t=>this.visitEventStream(t))}visitEventStream(e){this.visitNode(e),e.streamId!==null&&this.visitTypeRef(e.streamId)}visitCommandStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.propertyCandidate!==null&&this.visitProperty(e.propertyCandidate)}visitSystem(e){this.visitNode(e)}visitOperation(e){this.visitNode(e),e.inputs.forEach(t=>this.visitProperty(t)),e.execute!==null&&this.visitOperationPhase(e.execute),e.compensate!==null&&this.visitOperationPhase(e.compensate)}visitOperationPhase(e){this.visitNode(e),e.implementation!==null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitSpecificationOperationFailure(e){this.visitNode(e)}visitSpecificationCompensated(e){this.visitNode(e)}visitSpecificationOperation(e){this.visitNode(e),e.values.forEach(t=>this.visitPropertyMapping(t))}visitHandler(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitImplementation(e){this.visitNode(e),e.hints.forEach(t=>this.visitImplementationHint(t))}visitImplementationHint(e){this.visitNode(e)}visitFileReference(e){this.visitNode(e)}visitCodeBlock(e){this.visitNode(e)}visitCommandResponse(e){e.kind==="ScalarCommandResponseSyntax"?this.visitScalarCommandResponse(e):this.visitRecordCommandResponse(e)}visitScalarCommandResponse(e){this.visitNode(e),this.visitPropertyResponseSource(e.source)}visitRecordCommandResponse(e){this.visitNode(e),e.fields.forEach(t=>this.visitResponseField(t))}visitResponseField(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type),this.visitPropertyResponseSource(e.source)}visitPropertyResponseSource(e){this.visitNode(e)}visitSpecificationReturn(e){e.kind==="ScalarSpecificationReturnSyntax"?this.visitScalarSpecificationReturn(e):this.visitRecordSpecificationReturn(e)}visitScalarSpecificationReturn(e){this.visitNode(e),this.visitExpression(e.value)}visitRecordSpecificationReturn(e){this.visitNode(e),e.fields.forEach(t=>this.visitPropertyMapping(t))}visitValidate(e){this.visitNode(e),e.kind==="DeclarativeValidateSyntax"&&e.rules.forEach(t=>this.visitValidationRule(t))}visitValidationRule(e){this.visitNode(e),e.value!==null&&this.visitExpression(e.value)}visitEvent(e){this.visitNode(e),e.properties.forEach(t=>this.visitProperty(t)),e.tags.forEach(t=>this.visitTag(t))}visitTag(e){this.visitNode(e),this.visitExpression(e.value)}visitReadModel(e){this.visitNode(e),e.properties.forEach(t=>this.visitProperty(t))}visitConstraint(e){this.visitNode(e),e.kind==="FileConstraintSyntax"&&this.visitNode(e.file),e.additionalRules.forEach(t=>this.visitConstraint(t))}visitQuery(e){this.visitNode(e),this.visitTypeRef(e.returnType),e.by!==null&&this.visitQueryParameter(e.by),e.filters.forEach(t=>this.visitQueryParameter(t)),e.authorize!==null&&this.visitAuthorize(e.authorize)}visitQueryParameter(e){this.visitNode(e),this.visitTypeRef(e.type)}visitProjection(e){this.visitNode(e),e.blocks.forEach(t=>this.visitProjectionBlock(t))}visitProjectionBlock(e){switch(this.visitNode(e),e.kind){case"FromSyntax":e.events.forEach(t=>this.visitNode(t)),e.mappings.forEach(t=>this.visitMapping(t));break;case"EverySyntax":case"AllSyntax":e.mappings.forEach(t=>this.visitMapping(t));break;case"JoinSyntax":e.events.forEach(t=>this.visitJoinEvent(t));break;case"ProjectionVariantSyntax":e.entersOn.forEach(t=>this.visitNode(t)),e.blocks.forEach(t=>this.visitProjectionBlock(t));break;case"ChildrenSyntax":case"NestedSyntax":e.blocks.forEach(t=>this.visitProjectionBlock(t));break}}visitJoinEvent(e){this.visitNode(e),e.mappings.forEach(t=>this.visitMapping(t))}visitMapping(e){this.visitNode(e)}visitReaction(e){this.visitNode(e),e.triggers.forEach(t=>this.visitReactionTrigger(t))}visitReactionTrigger(e){this.visitNode(e),this.visitTriggerSource(e.source),e.produces.forEach(t=>this.visitProduces(t)),e.invokes.forEach(t=>this.visitInvokes(t))}visitProduces(e){this.visitNode(e),e.inlineEvent!==null&&this.visitEvent(e.inlineEvent),e.inlineOperation!=null&&this.visitOperation(e.inlineOperation),e.for!==null&&this.visitExpression(e.for),e.mappings.forEach(t=>this.visitPropertyMapping(t)),e.tags.forEach(t=>this.visitTag(t))}visitInvokes(e){this.visitNode(e)}visitCapture(e){this.visitNode(e),e.source!==null&&this.visitCaptureSource(e.source),e.appends.forEach(t=>this.visitCaptureAppend(t)),e.children.forEach(t=>this.visitCaptureChildren(t)),e.nested.forEach(t=>this.visitCaptureNested(t))}visitCaptureSource(e){this.visitNode(e),e.settings.forEach(t=>this.visitCaptureSourceSetting(t))}visitCaptureSourceSetting(e){this.visitNode(e)}visitCaptureAppend(e){this.visitNode(e)}visitCaptureChildren(e){this.visitNode(e),e.appends.forEach(t=>this.visitCaptureAppend(t))}visitCaptureNested(e){this.visitNode(e),e.appends.forEach(t=>this.visitCaptureAppend(t))}visitTriggerSource(e){this.visitNode(e)}visitScreen(e){this.visitNode(e),e.directives.forEach(t=>this.visitScreenDirective(t))}visitScreenDirective(e){switch(this.visitNode(e),e.kind){case"ScreenDataSyntax":this.visitTypeRef(e.type);break;case"ScreenActionSyntax":e.navigate!==null&&this.visitScreenDirective(e.navigate);break;case"ScreenTemplateReferenceSyntax":e.slots.forEach(t=>{this.visitNode(t),t.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenSectionSyntax":e.directives.forEach(t=>this.visitScreenDirective(t));break;case"ScreenTableSyntax":e.columns.forEach(t=>this.visitNode(t)),e.rowClick!==null&&this.visitScreenDirective(e.rowClick);break;case"ScreenSummarySyntax":e.fields.forEach(t=>this.visitNode(t));break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitSpecification(e){this.visitNode(e),e.givenClock!==null&&this.visitSpecificationClock(e.givenClock),e.givenOperationFailures?.forEach(t=>this.visitSpecificationOperationFailure(t)),e.thenOperations?.forEach(t=>this.visitSpecificationOperation(t)),e.thenCompensated?.forEach(t=>this.visitSpecificationCompensated(t)),e.given.forEach(t=>this.visitSpecificationEvent(t)),e.givenReadModels.forEach(t=>this.visitSpecificationReadModel(t)),e.when!==null&&this.visitSpecificationCommand(e.when),e.givenCaptures.forEach(t=>this.visitSpecificationCapture(t)),e.whenAppended!==null&&this.visitSpecificationEvent(e.whenAppended),e.whenClock!==null&&this.visitSpecificationClock(e.whenClock),e.whenTrigger!==null&&this.visitSpecificationTrigger(e.whenTrigger),e.whenCapture!==null&&this.visitSpecificationCapture(e.whenCapture),e.whenQuery!==null&&this.visitSpecificationWhenQuery(e.whenQuery),e.thenEvents.forEach(t=>this.visitSpecificationEvent(t)),e.thenReadModels.forEach(t=>this.visitSpecificationReadModel(t)),e.thenResults.forEach(t=>this.visitSpecificationQueryResult(t)),e.thenNoResult!==null&&this.visitNode(e.thenNoResult),e.thenDenied!=null&&this.visitNode(e.thenDenied),e.thenReturns!=null&&this.visitSpecificationReturn(e.thenReturns),e.thenErrors.forEach(t=>this.visitNode(t))}visitSpecificationClock(e){this.visitNode(e)}visitSpecificationTrigger(e){this.visitNode(e),e.values.forEach(t=>this.visitPropertyMapping(t))}visitSpecificationCapture(e){this.visitNode(e),e.record.forEach(t=>this.visitPropertyMapping(t))}visitSpecificationWhenQuery(e){this.visitNode(e),e.arguments.forEach(t=>this.visitPropertyMapping(t))}visitSpecificationQueryResult(e){this.visitNode(e),e.properties.forEach(t=>this.visitPropertyMapping(t))}visitSpecificationEvent(e){this.visitNode(e),e.values.forEach(t=>this.visitPropertyMapping(t)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationCommand(e){this.visitNode(e),(e.generatedValues??[]).forEach(t=>this.visitPropertyMapping(t)),e.values.forEach(t=>this.visitPropertyMapping(t)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationReadModel(e){this.visitNode(e),e.properties.forEach(t=>this.visitPropertyMapping(t))}visitPropertyMapping(e){this.visitNode(e),this.visitExpression(e.source)}visitProperty(e){this.visitNode(e),this.visitTypeRef(e.type)}visitTypeRef(e){this.visitNode(e)}visitExpression(e){this.visitNode(e),e.kind==="ListExpressionSyntax"?e.items.forEach(t=>this.visitExpression(t)):e.kind==="ObjectExpressionSyntax"&&e.members.forEach(t=>this.visitObjectMember(t))}visitObjectMember(e){this.visitNode(e),this.visitExpression(e.value)}};function _h(n){return n===d.LegacyOptionalSuffix||n===d.RedundantEventId}a(_h,"isQuickFixDiagnostic");function st(n,e){return e.code!==d.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(n.slice(e.location.column-1))?.[0].length??0}a(st,"legacyOptionalTypeLength");function Gh(n,e={}){let t=Oe(n,void 0,e.placement);if(!t.success)return()=>[];let i=Pe(n),o=new Map;new class extends bn{visitEvent(m){o.set(m.location.line,m)}}().visitApplication(t.value);let s=new Map,c=new Map,p=new Map,f;for(let m of i)f=o.get(m.number)??f,f!==void 0&&p.set(m.number,f);for(let m of t.diagnostics){s.set(m.code,(s.get(m.code)??0)+1);let w=i[m.location.line-1],A=st(w.raw,m);if(A>0)c.set(w.number,{line:w.number,fix:{diagnosticCode:m.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:w.startOffset+m.location.column+A-2,length:1,text:" optional"}]}});else if(m.code===d.RedundantEventId&&Ln(w.raw)<0){let I=p.get(w.number);if(I?.id!==I?.name||I===void 0)continue;c.set(w.number,{line:w.number,fix:{diagnosticCode:m.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:w.startOffset,length:(i[w.number]?.startOffset??n.length)-w.startOffset,text:""}]},change:{node:I,replacement:{...I,id:null}}})}}let b=[...c.values()].filter(m=>m.fix.diagnosticCode===d.LegacyOptionalSuffix),u=We(t),k=new Map,y,T=!1,D,g=a((m,w)=>{let A=Mi(n,m.edits);if(A===void 0)return;let I=Oe(A,void 0,e.placement);if(!(!I.success||We(I)!==(w===void 0?u:We(t,[w]))))return I.diagnostics.filter(h=>h.code===m.diagnosticCode).length===(s.get(m.diagnosticCode)??0)-m.edits.length?m:void 0},"verify");return(m,w)=>{let A=typeof m=="number"||m===void 0?void 0:m,I=A===void 0?w===void 0||w===d.LegacyOptionalSuffix:A.some($=>$.diagnosticCode===d.LegacyOptionalSuffix);if(I&&!T&&(b.length>0&&(D=g({diagnosticCode:d.LegacyOptionalSuffix,title:"Use 'optional' throughout this document",scope:"document",edits:b.flatMap($=>$.fix.edits)})),T=!0),A!==void 0){if(y===void 0){y=new Map;let E=i.flatMap(L=>c.has(L.number)?[c.get(L.number)]:[]),B=E.flatMap(L=>L.fix.edits),q=Mi(n,B);if(B.length>0&&q!==void 0){let L=Oe(q,void 0,e.placement),x=E.flatMap(Y=>Y.change===void 0?[]:[Y.change]);if(L.success&&We(L)===We(t,x)){let Y=new Map,F=new Map;for(let W of L.diagnostics)Y.set(W.code,(Y.get(W.code)??0)+1);for(let W of E)F.set(W.fix.diagnosticCode,(F.get(W.fix.diagnosticCode)??0)+W.fix.edits.length);if([...F].every(([W,_])=>(Y.get(W)??0)===(s.get(W)??0)-_))for(let W of E)y.set(W.line,W.fix)}}}let $=new Map;for(let E of A){let B=y.get(E.line);B?.diagnosticCode===E.diagnosticCode&&$.set(E.line,B)}return[...$.values(),...I&&D!==void 0?[D]:[]]}let h=typeof m=="number"?m:void 0,S=h===void 0?void 0:c.get(h),C;return S!==void 0&&h!==void 0&&(w===void 0||S.fix.diagnosticCode===w)&&(k.has(h)||(k.size===32&&k.delete(k.keys().next().value),k.set(h,g(S.fix,S.change))),C=k.get(h)),[C,I?D:void 0].filter($=>$!==void 0)}}a(Gh,"prepareQuickFixes");function We(n,e=[]){let t=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([n.value,n.triggerData],(i,o)=>["location","usesLocation","targetLocation"].includes(i)?void 0:t.get(o)??o)}a(We,"verificationShape");function Mi(n,e){let t=[],i=0;for(let o of e){if(o.start<i||o.start<0||o.length<0||o.start+o.length>n.length)return;t.push(n.slice(i,o.start),o.text),i=o.start+o.length}return t.push(n.slice(i)),t.join("")}a(Mi,"applyQuickFixEdits");var Re=class{static{a(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,t){this.complete=t;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(t=>t.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(t.code))}resolve(e,t){let i=this.sources.get(e)??[],o=t===void 0?[]:i.flatMap(f=>f.source.streams).filter(f=>f.name===t),r=i.length>1||o.length>1,s=!this.complete||i.some(f=>!f.placementResolved),c=r?"ambiguous":s?"incomplete":i.length===1&&(t===void 0||o.length===1)?"unique":"notFound",p=[];return i.length>1&&p.push("Multiple physical parent sources claim the exact name."),o.length>1&&p.push("Multiple physical streams claim the exact parent and local name."),i.some(f=>!f.placementResolved)&&p.push("A physical parent has unresolved import placement."),this.complete||p.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:c,sources:i.map(f=>f.source),streams:o,reasons:p}}};var xi=a(n=>typeof n=="object"&&n!==null&&typeof n.kind=="string","isNode");function ct(n){return at(n)}a(ct,"toSyntaxJson");function at(n){if(Array.isArray(n))return n.map(at);if(xi(n)){Ka(n),Ni(n);let e={kind:n.kind},t={...n};n.kind==="ApplicationSyntax"&&t.eventSources===void 0&&(t.eventSources=[]),n.kind==="CommandSyntax"&&t.stream===void 0&&(t.stream=null),n.kind==="CommandSyntax"&&t.streamCandidates===void 0&&(t.streamCandidates=[]);let i=Object.keys(t).filter(o=>o!=="kind"&&o!=="location"&&o!=="targetLocation"&&o!=="referenceLocation"&&o!=="referenceLength"&&o!=="nameWasEscaped"&&!(n.kind==="OperationSyntax"&&o==="usesLocation")).sort(Xa);for(let o of i)e[o]=at(t[o]);return e}return n===void 0?null:n}a(at,"write");function Ka(n){if(n.kind==="ProducesSyntax"){let e=n,t=e.inlineOperation;if(t!=null){if(e.inlineEvent!==null)throw new Error("A production cannot declare both an event and an operation.");if(e.event!==t.name||e.for!==null||e.tags.length>0)throw new Error("An inline operation requires a matching target without event metadata.");if(t.inputs.length!==e.mappings.length||t.inputs.some((i,o)=>i.name!==e.mappings[o].property))throw new Error("Inline operation inputs and mappings must correspond in order.")}}if(n.kind==="OperationPhaseSyntax"){let e=n;if(e.file!==null&&e.code!==null)throw new Error("An operation phase has at most one file or inline payload.");if(e.implementation!==null&&(!Array.isArray(e.implementation.hints)||e.implementation.hints.some(t=>t==null||nn(t.text))))throw new Error("Implementation hints must be a collection of nonblank hints.")}}a(Ka,"validateOperation");function Ni(n){let e=a(o=>{if(!xn(o))throw new Error("Event source and stream names must be identifiers.")},"name"),t=a((o,r)=>xi(o)&&o.kind===r,"hasKind"),i=a((o,r,s)=>{if(!Array.isArray(o)||[...o].some(c=>!t(c,r)))throw new Error(s)},"collection");if(n.kind==="ApplicationSyntax"){let o=n.eventSources;o!==void 0&&i(o,"EventSourceSyntax","Event sources must be a collection of event source nodes without null elements.")}if(n.kind==="EventSourceSyntax"||n.kind==="EventStreamSyntax"){let o=n;if(e(o.name),o.id!==null&&(typeof o.id!="string"||o.id.trim()===""))throw new Error("A rename pin must be nonempty.");let r=o.kind==="EventSourceSyntax"?o.identifier:o.streamId;if(r!==null&&!t(r,"TypeRefSyntax"))throw new Error("Source identifiers and stream ids require type reference nodes.");if(r!==null&&(r.isCollection||r.isOptional))throw new Error("Source identifiers and stream ids require nonoptional scalar type references.");if(r!==null&&!Nn(r.name))throw new Error("Source identifiers and stream ids require an exact type reference name.");if(o.kind==="EventSourceSyntax"){if(!Array.isArray(o.streams)||[...o.streams].some(s=>s==null))throw new Error("Event streams must be a collection without null elements.");i(o.streams,"EventStreamSyntax","Event streams must contain event stream nodes.")}}if(n.kind==="CommandSyntax"){let o=n;if(o.stream?.propertyCandidate!=null)throw new Error("The authoritative command stream cannot contain an ambiguous property candidate.");if(o.stream!=null&&!t(o.stream,"CommandStreamSyntax"))throw new Error("The authoritative command stream must be a command stream node.");if(o.streamCandidates!==void 0&&!Array.isArray(o.streamCandidates))throw new Error("Command stream candidates must be a collection.");for(let r of o.streamCandidates??[]){if(r==null)throw new Error("Command stream candidates cannot contain null.");if(!t(r,"CommandStreamSyntax"))throw new Error("Command stream candidates must contain command stream nodes.");if(Ni(r),r.propertyCandidate===null&&o.stream==null)throw new Error("A duplicate route candidate requires an authoritative route.");if(r.propertyCandidate!==null&&o.properties.some(s=>s===r.propertyCandidate))throw new Error("An ambiguous property is owned only by its stream candidate.")}}if(n.kind==="CommandStreamSyntax"){let o=n;if(e(o.eventSource),e(o.stream),o.streamId!==null&&o.streamId.property!=="streamId")throw new Error("A command stream maps only streamId.");let r=o.propertyCandidate;if(r!==null&&(r.name!=="stream"||r.type.name!==`${o.eventSource}.${o.stream}`||r.type.isCollection||r.type.isOptional||r.isGenerated||r.isIdentifier||o.streamId!==null))throw new Error("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}a(Ni,"validateSourceStream");function Xa(n,e){return n<e?-1:n>e?1:0}a(Xa,"ordinal");function Yi(n){let e=[],t=n.map(u=>u.value),i=new Map,o=Pn(t.flatMap(u=>u.concepts),"declaration of",e,void 0,i),r=Pn(t.flatMap(u=>u.types),"declaration of",e,void 0,i),s=t.map(u=>u.domain).filter(u=>u!==null);for(let u of s.slice(1))e.push(Wi(d.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${Cn(s[0].location.path)}' - a folder compiles to one application, which can have at most one`,u.location));let c=ec(t.flatMap(u=>u.modules),e),p=Pn(t.flatMap(u=>u.personas),"persona",e),f={kind:"ApplicationSyntax",domain:s[0]??null,imports:nc(t.flatMap(u=>u.imports),u=>u.qualifiedName),concepts:o,types:r,systems:t.flatMap(u=>u.systems??[]),eventSources:t.flatMap(u=>u.eventSources??[]),modules:c,personas:p,fileImports:t.flatMap(u=>u.fileImports),location:t[0]?.location??{line:1,column:1}},b=[...n.flatMap(u=>u.diagnostics),...e];return{value:f,diagnostics:b,success:!b.some(u=>u.severity==="error")}}a(Yi,"mergeDocuments");function ec(n,e){return zi(n).map(qi).map(t=>t.length===1?{...t[0],isPlacement:!1,features:t[0].features.map(lt)}:{...t[0],isPlacement:!1,fileImports:t.flatMap(i=>i.fileImports),description:Ui(t,`module '${t[0].name}'`,e),authorize:Fi(t.map(i=>i.authorize),`module '${t[0].name}'`,e),features:Bi(t.flatMap(i=>i.features),e)})}a(ec,"mergeModules");function Bi(n,e){return zi(n).map(qi).map(t=>t.length===1?lt(t[0]):{...t[0],isPlacement:!1,fileImports:t.flatMap(i=>i.fileImports),description:Ui(t,`feature '${t[0].name}'`,e),authorize:Fi(t.map(i=>i.authorize),`feature '${t[0].name}'`,e),features:Bi(t.flatMap(i=>i.features),e),slices:Pn(t.flatMap(i=>i.slices),"slice",e,`feature '${t[0].name}'`)})}a(Bi,"mergeFeatures");function qi(n){return[...n.filter(e=>!e.isPlacement),...n.filter(e=>e.isPlacement)]}a(qi,"placedLast");function lt(n){return{...n,isPlacement:!1,features:n.features.map(lt)}}a(lt,"unplaced");function Fi(n,e,t){let i=[];for(let o of n.filter(r=>r!==null)){let r=i.find(s=>s.location.path!==o.location.path&&JSON.stringify(ct(s))===JSON.stringify(ct(o)));if(r!==void 0){t.push(ji(d.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${Cn(r.location.path)}' - this repeated gate is ignored`,o.location));continue}i.push(o)}return i.reduce((o,r)=>ae(o,r),null)}a(Fi,"combineAuthorization");function nc(n,e){let t=new Set;return n.filter(i=>!t.has(e(i))&&t.add(e(i))!==void 0)}a(nc,"firstOfEach");function zi(n){let e=new Map;for(let t of n)e.set(t.name,[...e.get(t.name)??[],t]);return[...e.values()]}a(zi,"groupByName");function Ui(n,e,t){let i=n.filter(o=>o.description!==null);for(let o of i.slice(1).filter(r=>r.description!==i[0].description))t.push(ji(d.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${Cn(i[0].location.path)}' - keeping that description`,o.location));return i[0]?.description??null}a(Ui,"firstDescription");function Pn(n,e,t,i,o=new Map){let r=[];for(let s of n){let c=o.get(s.name);if(c!==void 0&&c.path!==s.location.path){t.push(Wi(d.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${Cn(c.path)}'`,s.location));continue}c===void 0&&o.set(s.name,s.location),r.push(s)}return r}a(Pn,"declaredInOneFile");var Cn=a(n=>n??"another file","describe"),Wi=a((n,e,t)=>({severity:"error",code:n,message:e,location:t}),"error"),ji=a((n,e,t)=>({severity:"warning",code:n,message:e,location:t}),"warning");function Zi(n){let e=De.capturePlaced(n.filter(u=>u.isPlacementResolved!==!1).map(u=>({lines:Pe(u.source,!1,u.path),placement:u.placement}))),t=n.map(u=>Oe(u.source,u.path,u.isPlacementResolved===!1?[]:u.placement,!1,e)),i=t.flatMap((u,k)=>(u.value.eventSources??[]).map(y=>({source:y,placementResolved:n[k].isPlacementResolved!==!1}))),o=n.every(u=>u.isPlacementResolved!==!1)&&t.every(u=>!Re.hasUnknownExtent(u.diagnostics)),r=t.map((u,k)=>n[k].isPlacementResolved===!1?{...u,value:{...u.value,eventSources:[]}}:u),s=Yi(r),c=new de(new ve([]));wn(s.value,c),yn(s.value,c),gn(s.value,c),hn(s.value,c,r.flatMap(u=>u.inputUses));let p=s.diagnostics,f=new Set(p.map(Vi)),b=[...p,...c.diagnostics.filter(u=>!f.has(Vi(u)))];return{...s,diagnostics:b,success:!b.some(u=>u.severity==="error"),physicalEventSources:i,sourceInventoryComplete:o}}a(Zi,"parsePlacedDocuments");function Vi(n){return JSON.stringify([n.code,n.location.path,n.location.line,n.location.column])}a(Vi,"diagnosticKey");var Ve="Syntax-only; execution unavailable until ESM v8 (PLAY0268). No response type is emitted.",je=new Map;function ic(n,e){let t=X(n),i=n.flatMap((u,k)=>!t[k]&&U(u)===0&&/^\w/.test(u)?[u.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(u=>["feature","slice","command","event","operation","reaction","specification"].includes(u)))return{source:n.join(`
7
+ `),locations:n.map((u,k)=>({line:k+1,column:0}))};let o=[],r=[],s=!1;n.forEach((u,k)=>{!t[k]&&U(u)===0&&/^\w/.test(u)&&(s=/^(?:concept|type|import|domain|system|eventsource)\b/.test(u)),(s?o:r).push(k)});let c=i.includes("feature")?1:i.includes("slice")?2:3,p=e.slice(0,c),f=[...o.map(u=>n[u]),...p,...r.map(u=>" ".repeat(c*2)+n[u])].join(`
8
+ `),b=[...o.map(u=>({line:u+1,column:0})),...p.map(()=>({line:0,column:0})),...r.map(u=>({line:u+1,column:c*2}))];return{source:f,locations:b}}a(ic,"authoringSource");function oc(n,e,t,i="current.play",o=!0){let r=e.map((P,O)=>typeof P=="string"?{path:`other-${O}.play`,source:P}:P).filter(P=>P.path!==i),s=[{path:i,source:n.join(`
9
+ `),placement:t,isPlacementResolved:o},...r],c=new Set(s.flatMap(P=>[...P.source.matchAll(/\w+/g)].map(O=>O[0]).concat(P.placement??[]))),p=a(P=>{let O=P;for(let M=1;c.has(O);M++)O=`${P}${M}`;return c.add(O),O},"fresh"),f=p("EditorAuthoring"),b=p("FragmentFeature"),u=new Set([f,b]),k=s.map((P,O)=>{let M=O===0?n:P.source.split(`
10
+ `),N=p(`Fragment${O}`);u.add(N);let Me=P.placement?.length?{source:P.source,locations:M.map((En,Qe)=>({line:Qe+1,column:0}))}:ic(M,[`module ${f}`,` feature ${b}`,` slice StateChange ${N}`]);return{...P,...Me,placement:P.placement??[]}}),y=k[0],T=new Map(k.map(P=>[P.path,P.locations])),D=Zi([...k.slice(1),y]),g=new Map,m=new Map,w=new WeakSet,A=a(P=>{if(P===null||typeof P!="object"||w.has(P))return;if(w.add(P),Array.isArray(P)){P.forEach(A);return}let O=P;if(typeof O.path=="string"&&typeof O.line=="number"&&typeof O.column=="number"){let M=T.get(O.path)?.[O.line-1];M&&(O.line=M.line,O.column=Math.max(1,O.column-M.column));return}for(let M of Object.values(O))A(M);O.location?.path===i&&(O.kind==="CommandSyntax"&&g.set(O.location.line-1,P),O.kind==="SpecificationSyntax"&&m.set(O.location.line-1,P))},"walk");A(D.value),A(D.physicalEventSources);for(let P of D.diagnostics)A(P.location);let I=D.diagnostics.some(P=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(P.code))return!1;let O=k.find(N=>N.path===P.location.path),M=s.find(N=>N.path===P.location.path)?.source.split(`
11
+ `)[P.location.line-1];return O?.locations.some(N=>N.line===0)&&M!==void 0&&U(M)===0}),h=D.diagnostics.filter(P=>P.location.path===i).flatMap(P=>(A(P.location),P.location.line>0?[P]:[])),S=new pe(D.value),C=new Set(S.slices.flatMap(({slice:P})=>[...P.commands.flatMap(O=>O.produces),...P.reactions.flatMap(O=>O.triggers).flatMap(O=>O.produces)].filter(O=>O.location.path===i&&!S.isEventProduction(O,P)).map(O=>O.location.line-1)));for(let P of h)P.code==="PLAY0499"&&C.add(P.location.line-1);let $=S.declarations.filter(P=>P.kind===Z.Operation).map(P=>({...P.node,scope:P.scope.filter(O=>!u.has(O))})),E=new Map,B=X(n),q=a(P=>{let O=[],M=U(n[P]);for(let N=P;N<n.length&&!(N>P&&!B[N]&&ke(n[N]).trim()&&U(n[N])<=M);N++)O.push(N);return O},"range");for(let{slice:P,scope:O}of S.slices){if(P.location.path===i&&P.location.line>0)for(let M of q(P.location.line-1))E.set(M,{scope:O});for(let M of P.specifications.filter(N=>N.location.path===i&&N.location.line>0))for(let N of q(M.location.line-1))E.set(N,{scope:O});for(let M of P.commands.filter(N=>N.location.path===i&&N.location.line>0))for(let N of q(M.location.line-1))E.set(N,{scope:O,commandLine:M.location.line-1})}let L=new Map(S.declarations.map(P=>[P.node.location,P.scope]));for(let P of $.filter(O=>O.location.path===i)){let O=L.get(P.location);for(let M of q(P.location.line-1))E.set(M,{...E.get(M),scope:O,operation:P})}let x=new Map($.map(P=>[P.location,P])),Y=a((P,O)=>{let M=ke(n[P.line-1]??""),N=M.slice(P.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return N&&M.slice(P.column-1+N.length,P.column-1+N.length+O.length)===O?{...P,column:P.column+N.length}:P},"referenceLocation"),F=[];for(let{slice:P}of S.slices){for(let O of P.commands)for(let M of O.produces){if(M.location.path!==i)continue;let N=S.resolve(M.event,P),Me=N.declaration?x.get(N.declaration.node.location)??null:null,En={name:M.event,location:M.location,targetLocation:M.targetLocation??M.location,kind:N.kind,declaration:Me,mappings:M.mappings};if(F.push(En),N.kind===Z.Operation)for(let Qe of q(M.location.line-1)){let bt=E.get(Qe);bt&&E.set(Qe,{...bt,production:En})}}for(let O of P.specifications)for(let M of[...O.givenOperationFailures??[],...O.thenOperations??[],...O.thenCompensated??[]]){if(M.location.path!==i)continue;let N=S.resolve(M.operation,P);F.push({name:M.operation,location:M.location,targetLocation:Y(M.location,M.operation),kind:N.kind,declaration:N.declaration?x.get(N.declaration.node.location)??null:null,mappings:[]})}}let W={declarations:$,systems:D.value.systems??[],references:F,contexts:E,types:D.value.types,concepts:D.value.concepts,targets:a(P=>{let O=S.slices.find(M=>M.scope.length===P.length&&M.scope.every((N,Me)=>N===P[Me]))?.slice;return O?$.flatMap(M=>{let N=S.resolve(M.name,O).declaration?.node.location===M.location?M.name:[...M.scope,M.name].join(".");return S.resolve(N,O).kind===Z.Operation&&S.resolve(N,O).declaration?.node.location===M.location?[{name:N,declaration:M}]:[]}):[]},"targets")},_=D.physicalEventSources.map(P=>P.source),se=new Re(D.physicalEventSources,D.sourceInventoryComplete&&!I),me=new Map,St=a((P,O)=>{let M=JSON.stringify([P,O]),N=me.get(M);return N||(N=se.resolve(P,O),me.set(M,N)),{...N,source:N.state==="unique"?N.sources[0]:void 0,stream:N.state==="unique"?N.streams[0]:void 0}},"resolve"),Xi=new Set(D.value.imports.map(P=>P.qualifiedName)),eo=_.flatMap(P=>P.streams.filter(O=>St(P.name,O.name).state==="unique"&&!Xi.has(`${P.name}.${O.name}`)).map(O=>({name:`${P.name}.${O.name}`,source:P,stream:O}))),be=new Map,wt=[];for(let P of g.values()){for(let O of q(P.location.line-1))be.set(O,{command:P});for(let O of[...P.produces,...P.validations,...P.handler?[P.handler]:[]])for(let M of q(O.location.line-1))be.delete(M);if(P.stream){wt.push(P.stream);for(let O of q(P.stream.location.line-1))be.set(O,{command:P,route:P.stream})}}for(let P of _.filter(O=>O.location.path===i)){for(let O of q(P.location.line-1))be.set(O,{source:P});for(let O of P.streams)for(let M of q(O.location.line-1))be.set(M,{source:P,stream:O})}let no=[...g.values()].flatMap(P=>P.streamCandidates??[]).filter(P=>P.propertyCandidate!==null);return{commands:g,specifications:m,diagnostics:h,operationProductionLines:C,operations:W,eventSources:{declarations:_,routes:wt,ambiguousCandidates:no,contexts:be,targets:eo,resolve:St}}}a(oc,"analyze");function Te(n,e=[],t,i="current.play",o=!0){let r=JSON.stringify([n,e,t,i,o]),s=je.get(r);return s===void 0&&(s=oc(n,e,t,i,o),je.size>=16&&je.delete(je.keys().next().value),je.set(r,s)),s}a(Te,"responseAnalysis");var dt="file",rc=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,sc=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function Vg(n){return sc.test(n)}a(Vg,"isAbsoluteFileReferencePath");function ac(n){let e=!1,t=!1;for(let i=0;i<n.length;i++){let o=n[i];if(o==="\\"&&e&&i+1<n.length)i++;else if(o==='"'&&!t)e=!e;else if(o==="`"&&!e)t=!t;else if(!e&&!t&&o==="/"&&n[i+1]==="/")return n.slice(0,i)}return n}a(ac,"withoutComment");function pt(n,e){let t=U(n),i=ac(n.slice(t)).trimEnd();if(Tn(i)!==dt)return;let o=i.slice(dt.length),r=o.trim();if(r.length===0||rc.test(r))return;let s=o.length-o.trimStart().length,c=t+dt.length+s+1;return{path:r,line:e,startColumn:c,endColumn:c+r.length}}a(pt,"fileReferenceOn");function Zg(n){let e=X(n),t=[];for(let i=0;i<n.length;i++){if(e[i])continue;let o=pt(n[i],i);o&&t.push(o)}return t}a(Zg,"fileReferences");function ge(n){let e=!1;return n.map(t=>{if(e)return t.trim()==="```"&&(e=!1),t;let i=ke(t);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}a(ge,"eventAnalysisSource");var cc=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,lc=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?\s*$/,_i=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,dc=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,pc=["authorize","produces","reads"],uc=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,fc=qe,mc=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],hc=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function ye(n){return n.typeReference??xe(n.type)}a(ye,"propertyTypeReference");function ut(n,e){let t=n.slice(e-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??"";return{text:t,startColumn:e,endColumn:e+t.length}}a(ut,"sourceTypeAt");function ft(n,e,t){return e.map(i=>({index:i,match:n[i].match(lc)})).filter(i=>i.match!==null).filter(({match:i})=>i[1].startsWith("@")||i[1]==="as"||!t.includes(i[1])).map(({index:i,match:o})=>({name:o[1].replace(/^@/,""),type:o[2],typeReference:xe(o[2]),sourceType:ut(n[i],n[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:o[4]!==void 0,...o[3]!==void 0?{isGenerated:!0}:{},line:i}))}a(ft,"propertiesIn");function _e(n,e,t,i){let o=[];for(let r=t+1;r<n.length;r++){if(e[r])continue;let s=n[r];if(s.trim().length!==0){if(U(s)<=i)break;o.push(r)}}return o}a(_e,"collectBody");function Le(n,e,t,i){let o=_e(n,e,t,i).filter(c=>!e[c]&&!/^\s*(?:\/\/|#)/.test(n[c]));if(!/^\s*command\b/.test(n[t]))return o;let r,s=!1;return o.filter(c=>{let p=U(n[c]),f=n[c].trim();return r!==void 0&&p>r&&(!s||uc.test(f))?!1:(r=f!=="validate csharp"&&ft(n,[c],pc).length>0||/^description(?:\s|$)/.test(f)?void 0:p,s=/^authorize(?:\s|$)/.test(f),!0)})}a(Le,"directBody");var Ze=new Map;function Ge(n){let e=n.join(`
12
+ `),t=Ze.get(e);if(t)return t;let i=Te(n),o={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};n=ge(n);let r=X(n),s=n,c=r,p=n.map(f=>f.replace(/\s*=(?!=|>).*/,""));for(let f=0;f<n.length;f++){if(r[f])continue;let b=n[f],u=b.trim(),k=U(b),y=s[f].trim().match(/^import\s+([\w.]+)\s*$/);if(y&&k===0){let S=y[1],C=S.split(".").pop()??S;o.imports.push({qualifiedName:S,shortName:C,line:f});continue}let T=u.match(cc);if(T){let S=_e(n,r,f,k).map(E=>n[E].trim()),C={};for(let E of S){let B=E.match(_i);B&&C[B[1]]===void 0&&(C[B[1]]=B[2])}let $=T[2]==="Enum"?S.filter(E=>!_i.test(E)):[];o.concepts.push({name:T[1],primitive:T[2],attributes:T[3].trim().split(/\s+/).filter(Boolean),attributeReasons:C,enumValues:$,line:f});continue}let D=u.match(/^type\s+(\w+)\s*$/);if(D){o.types.push({name:D[1],properties:ft(n,_e(n,r,f,k),Pt),line:f});continue}let g=u.match(/^policy\s+(\w+)\s*$/);if(g){let S=_e(n,r,f,k).filter(C=>!r[C]).map(C=>n[C].trim());o.policies.push({name:g[1],requires:S,line:f});continue}let m=s[f].trim().match(/^(?:produces\s+)?event\s+(\w+)(?:\s+generation\s+(\d+))?\s*$/);if(m){let S=u.startsWith("produces "),C=Le(s,c,f,k),$=S?C:C.filter(E=>pt(s[E],E)===void 0);o.events.push({name:m[1],...m[2]?{generation:Number(m[2])}:{},inline:S,properties:ft(S?p:s,$,S?mc:fc),line:f});continue}let w=i.commands.get(f);if(w){let S=Le(n,r,f,k),C=S.filter($=>/^\s*produces\b/.test(n[$])&&!i.operationProductionLines?.has($));o.commands.push({name:w.name,properties:w.properties.map($=>({name:$.name,type:`${$.type.name}${$.type.isCollection?"[]":""}${$.type.isOptional?" optional":""}`,typeReference:{name:$.type.name,isCollection:$.type.isCollection,isOptional:$.type.isOptional},sourceType:ut(n[$.type.location.line-1],$.type.location.column),isIdentifier:$.isIdentifier||/\sidentifier\s*$/.test(n[$.location.line-1]),...$.isGenerated?{isGenerated:!0}:{},line:$.location.line-1})),response:w.response,productionHeaders:C,produces:C.flatMap($=>{let E=s[$].trim(),B=/^produces\s+event\b/.test(E),q=/^produces\s+when\b/.test(E),L=q?Le(s,c,$,U(s[$]))[0]:$;if(L===void 0)return[];let x=q?s[L].trim():E.match(B?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(x===void 0||!/^[A-Za-z_]\w*$/.test(x))return[];let Y=Le(s,c,L,U(s[L])),F=Y.map(se=>s[se].trim().match(/^for(?:\s+(.*))?$/)).filter(se=>se!==null),W=F.length===0?void 0:F.length===1?F[0][1]??"":"",_=Y.flatMap(se=>{let me=s[se].trim().match(B?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return me===null?[]:[{name:me[1].replace(/^@/,""),source:me[2],line:se}]});return[{name:x,inline:B,conditional:q,line:$,target:W,mappings:_}]}),reads:S.filter($=>!r[$]).map($=>({line:$,match:n[$].match(dc)})).filter($=>$.match!==null).map(({line:$,match:E})=>({view:E[1],...E[2]?{alias:E[2]}:{},...E[3]?{by:E[3]}:{},line:$})),line:f});continue}let A=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(A){let S=_e(n,r,f,k).map(C=>({index:C,match:n[C].match(hc)})).filter(C=>C.match!==null).map(({index:C,match:$})=>({name:$[1],type:$[2],typeReference:xe($[2]),sourceType:ut(n[C],n[C].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:C}));o.queries.push({name:A[1],returnType:A[2],returnTypeReference:xe(A[2]),parameters:S,line:f});continue}let I=u.match(/^screen\s+(\w+)\s*$/);if(I){o.screens.push({name:I[1],line:f});continue}let h=u.match(/^trigger\s+(\w+)\s*$/);h&&k===0&&o.triggers.push({name:h[1],line:f})}return Ze.size>=16&&Ze.delete(Ze.keys().next().value),Ze.set(e,o),o}a(Ge,"scanDocument");function In(...n){return{authoringSources:n.flatMap(e=>e.authoringSources??[]),...n.some(e=>e.authoringDocuments)?{authoringDocuments:n.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:n.flatMap(e=>e.eventSources??[]),imports:n.flatMap(e=>e.imports),concepts:n.flatMap(e=>e.concepts),types:n.flatMap(e=>e.types),policies:n.flatMap(e=>e.policies),events:n.flatMap(e=>e.events),commands:n.flatMap(e=>e.commands),queries:n.flatMap(e=>e.queries),screens:n.flatMap(e=>e.screens),triggers:n.flatMap(e=>e.triggers)}}a(In,"mergeSymbols");function Gi(n,e){let t=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(o=>o.path===t);return{...In(Ge(n),e??In()),authoringDocuments:e?.authoringDocuments,authoringPath:t,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}a(Gi,"symbolsForBuffer");function $n(n){return[...n.events.map(e=>e.name),...n.imports.map(e=>e.shortName)]}a($n,"knownEventNames");var vc=["Startup","Shutdown"];function ay(n){return[...$n(n),...n.triggers.map(e=>e.name),...vc]}a(ay,"knownTriggerNames");function mt(n,e){return[...e,...n.concepts.map(t=>t.name),...n.types.map(t=>t.name),...n.imports.map(t=>t.shortName)]}a(mt,"knownTypeNames");var Hi="EventContext",He={EventContext:[{name:"eventType",type:"EventType",kind:"composite",description:"The type of the event - its identifier, generation and whether it is a tombstone."},{name:"eventSourceType",type:"EventSourceType",kind:"value",description:"The type of the event source the event was appended to."},{name:"eventSourceId",type:"EventSourceId",kind:"value",description:"The identifier of the event source the event was appended to - the value $eventSourceId resolves."},{name:"eventStreamType",type:"EventStreamType",kind:"value",description:"The type of the event stream the event belongs to."},{name:"eventStreamId",type:"EventStreamId",kind:"value",description:"The identifier of the event stream the event belongs to."},{name:"sequenceNumber",type:"EventSequenceNumber",kind:"value",description:"The position of the event in its event sequence."},{name:"occurred",type:"DateTimeOffset",kind:"value",description:"When the event occurred - the time it was appended unless one was given."},{name:"eventStore",type:"EventStoreName",kind:"value",description:"The name of the event store the event belongs to."},{name:"namespace",type:"EventStoreNamespaceName",kind:"value",description:"The namespace within the event store the event belongs to."},{name:"correlationId",type:"CorrelationId",kind:"value",description:"The correlation identifier the event was appended with."},{name:"causation",type:"IEnumerable<Causation>",kind:"collection",description:"The chain of causes that led to the event - a collection, not addressable below."},{name:"causedBy",type:"Identity",kind:"composite",description:"The identity that caused the event."},{name:"tags",type:"IEnumerable<Tag>",kind:"collection",description:"The tags the event was appended with - a collection, not addressable below."},{name:"hash",type:"EventHash",kind:"value",description:"The hash of the event content."},{name:"observationState",type:"EventObservationState",kind:"value",description:"Whether the observer sees the event for the first time or again on replay - differs between live processing and replay."},{name:"subject",type:"Subject",kind:"value",description:"The compliance subject the event is about - the event source identifier unless one was given."},{name:"subjectIsEventSourceId",type:"bool",kind:"value",description:"Whether the subject is the event source identifier."}],EventType:[{name:"id",type:"EventTypeId",kind:"value",description:"The identifier of the event type."},{name:"generation",type:"EventTypeGeneration",kind:"value",description:"The generation of the event type."},{name:"tombstone",type:"bool",kind:"value",description:"Whether the event is a tombstone event."}],EventSourceType:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventSourceId:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventStreamType:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventStreamId:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventSequenceNumber:[{name:"value",type:"ulong",kind:"value",description:"The underlying ulong value."}],DateTimeOffset:[{name:"Week",type:"int",kind:"function",description:"The ISO 8601 week of the year the value falls in."}],EventStoreName:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventStoreNamespaceName:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],CorrelationId:[{name:"value",type:"Guid",kind:"value",description:"The underlying Guid value."}],Identity:[{name:"subject",type:"string",kind:"value",description:"The subject identifier of the identity."},{name:"name",type:"string",kind:"value",description:"The display name of the identity."},{name:"userName",type:"string",kind:"value",description:"The user name of the identity."},{name:"onBehalfOf",type:"Identity",kind:"composite",description:"The identity this identity acted on behalf of, if any - an identity with the same members."}],EventHash:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],Subject:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventTypeId:[{name:"value",type:"string",kind:"value",description:"The underlying string value."}],EventTypeGeneration:[{name:"value",type:"uint",kind:"value",description:"The underlying uint value."}]},gc=[{path:"eventType",name:"eventType",type:"EventType",kind:"composite",description:"The type of the event - its identifier, generation and whether it is a tombstone."},{path:"eventType.id",name:"id",type:"EventTypeId",kind:"value",description:"The identifier of the event type."},{path:"eventType.id.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventType.generation",name:"generation",type:"EventTypeGeneration",kind:"value",description:"The generation of the event type."},{path:"eventType.generation.value",name:"value",type:"uint",kind:"value",description:"The underlying uint value."},{path:"eventType.tombstone",name:"tombstone",type:"bool",kind:"value",description:"Whether the event is a tombstone event."},{path:"eventSourceType",name:"eventSourceType",type:"EventSourceType",kind:"value",description:"The type of the event source the event was appended to."},{path:"eventSourceType.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventSourceId",name:"eventSourceId",type:"EventSourceId",kind:"value",description:"The identifier of the event source the event was appended to - the value $eventSourceId resolves."},{path:"eventSourceId.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventStreamType",name:"eventStreamType",type:"EventStreamType",kind:"value",description:"The type of the event stream the event belongs to."},{path:"eventStreamType.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"eventStreamId",name:"eventStreamId",type:"EventStreamId",kind:"value",description:"The identifier of the event stream the event belongs to."},{path:"eventStreamId.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"sequenceNumber",name:"sequenceNumber",type:"EventSequenceNumber",kind:"value",description:"The position of the event in its event sequence."},{path:"sequenceNumber.value",name:"value",type:"ulong",kind:"value",description:"The underlying ulong value."},{path:"occurred",name:"occurred",type:"DateTimeOffset",kind:"value",description:"When the event occurred - the time it was appended unless one was given."},{path:"occurred.Week",name:"Week",type:"int",kind:"function",description:"The ISO 8601 week of the year the value falls in."},{path:"eventStore",name:"eventStore",type:"EventStoreName",kind:"value",description:"The name of the event store the event belongs to."},{path:"eventStore.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"namespace",name:"namespace",type:"EventStoreNamespaceName",kind:"value",description:"The namespace within the event store the event belongs to."},{path:"namespace.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"correlationId",name:"correlationId",type:"CorrelationId",kind:"value",description:"The correlation identifier the event was appended with."},{path:"correlationId.value",name:"value",type:"Guid",kind:"value",description:"The underlying Guid value."},{path:"causation",name:"causation",type:"IEnumerable<Causation>",kind:"collection",description:"The chain of causes that led to the event - a collection, not addressable below."},{path:"causedBy",name:"causedBy",type:"Identity",kind:"composite",description:"The identity that caused the event."},{path:"causedBy.subject",name:"subject",type:"string",kind:"value",description:"The subject identifier of the identity."},{path:"causedBy.name",name:"name",type:"string",kind:"value",description:"The display name of the identity."},{path:"causedBy.userName",name:"userName",type:"string",kind:"value",description:"The user name of the identity."},{path:"causedBy.onBehalfOf",name:"onBehalfOf",type:"Identity",kind:"composite",description:"The identity this identity acted on behalf of, if any - an identity with the same members."},{path:"tags",name:"tags",type:"IEnumerable<Tag>",kind:"collection",description:"The tags the event was appended with - a collection, not addressable below."},{path:"hash",name:"hash",type:"EventHash",kind:"value",description:"The hash of the event content."},{path:"hash.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"observationState",name:"observationState",type:"EventObservationState",kind:"value",description:"Whether the observer sees the event for the first time or again on replay - differs between live processing and replay."},{path:"subject",name:"subject",type:"Subject",kind:"value",description:"The compliance subject the event is about - the event source identifier unless one was given."},{path:"subject.value",name:"value",type:"string",kind:"value",description:"The underlying string value."},{path:"subjectIsEventSourceId",name:"subjectIsEventSourceId",type:"bool",kind:"value",description:"Whether the subject is the event source identifier."}];function ht(n,e){if(n.kind==="function")return e===n.name||e===`${n.name}()`;let t=n.name[0].toUpperCase()+n.name.slice(1);return e===t||e.length>0&&e[0].toUpperCase()+e.slice(1)===t}a(ht,"namesEventContextMember");var vt=He[Hi];function yc(n){let e=vt;for(let t of n){let i=e.find(o=>ht(o,t));if(!i||i.kind==="collection"||i.kind==="function")return;e=He[i.type]??[]}return e}a(yc,"eventContextMembersAfter");function uy(n){return n.length===0?void 0:yc(n.slice(0,-1))?.find(t=>ht(t,n[n.length-1]))}a(uy,"eventContextMemberAt");function gt(n){let e,t=vt;for(let i of n.split(".")){if(i.length===0)return{status:"missing",member:e,expected:t};if(e?.kind==="collection")return{status:"belowCollection",member:e,segment:i,expected:[]};let o=t.find(r=>ht(r,i));if(!o)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:t};e=o,t=o.kind==="function"?[]:He[o.type]??[]}return{status:"known",member:e,expected:[]}}a(gt,"resolveEventContextPath");function fy(){return["**$eventContext**","","Metadata about the event being projected. Paths are checked against the event-context catalog; `causation` and `tags` are collections and cannot be addressed below.","","**Members:**",...vt.map(n=>`- \`${n.name}\` (${n.type}) - ${n.description}`)].join(`
13
+ `)}a(fy,"describeEventContext");function my(n,e){let t=e.kind==="collection"||e.kind==="function"?[]:He[e.type]??[],i=[`**$eventContext.${n}**: \`${e.type}\``,"",e.description];return t.length>0&&i.push("",`**Members:** ${t.map(o=>`\`${o.name}\``).join(", ")}`),i.join(`
14
+ `)}a(my,"describeEventContextMember");function yt(n){let e=n.properties.filter(r=>r.isIdentifier&&!ye(r).isOptional&&!ye(r).isCollection),t=e.length===1?e[0].name:void 0,i=n.produces??[],o=i.some(r=>r.target!==void 0&&r.target!==t)||i.some(r=>r.inline&&r.target===void 0)&&i.some(r=>!r.inline&&r.target===void 0);return{identifier:t,mixed:o}}a(yt,"productionDestinations");function by(n,e){let t=Te(n,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=ge(n);return Ge(i).commands.map(o=>({...o,produces:o.produces?.filter(r=>!t.operationProductionLines?.has(r.line)&&t.operations.references.some(s=>s.location.line-1===r.line&&s.kind==="event")),productionHeaders:o.productionHeaders?.filter(r=>!t.operationProductionLines?.has(r))})).flatMap(o=>{let{identifier:r,mixed:s}=yt(o);if(s||o.productionHeaders?.length!==o.produces?.length)return[];let c=o.produces?.some(p=>p.target!==void 0||p.inline);return(o.produces??[]).flatMap(p=>p.target!==void 0||p.inline&&(r===void 0||/\bgeneration\b/.test(i[p.line]))?[]:!p.inline&&c?[]:[{line:p.line,column:i[p.line].length+1,label:p.inline?`for ${r}`:"for <new event source>"}])})}a(by,"destinationHints");var z={invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",invalidImplementationBlock:"PLAY0492",invalidImplementationHint:"PLAY0493",conflictingImplementationSources:"PLAY0494",eventSourceIdInPayload:"PLAY0469",explicitProducesTargetsRequired:"PLAY0470",redundantEventId:"PLAY0471",invalidEventId:"PLAY0472",inlineEventCollision:"PLAY0473",inlineEventOutsideCommand:"PLAY0474",inlineEventGeneration:"PLAY0475",reservedProductionMetadata:"PLAY0476",invalidEventDocumentation:"PLAY0477",tabIndentation:"PLAY0006",unknownPrimitiveType:"PLAY0008",unknownSliceType:"PLAY0028",duplicateCommandIdentifier:"PLAY0036",unknownContextPath:"PLAY0153",unknownContextCausedByProperty:"PLAY0154",unknownContextIdentityProperty:"PLAY0155",unclosedCodeBlock:"PLAY0164",unknownType:"PLAY0165",unknownEvent:"PLAY0166",unknownPolicy:"PLAY0167",duplicateDeclaration:"PLAY0168",unknownEventContextMember:"PLAY0295",unknownEventContextPath:"PLAY0296",eventContextPathBelowCollection:"PLAY0297",missingEventContextPath:"PLAY0298",unresolvedDynamicKeySource:"PLAY0299",invalidFileImport:"PLAY0454",omittedProductionDestination:"PLAY0478",legacyOptionalSuffix:"PLAY0479",invalidOptionalModifierOrder:"PLAY0480",optionalReadsNotSupported:"PLAY0481",unavailableResponseExecution:"PLAY0268",generatedPropertyOutsideCommand:"PLAY0482",invalidGeneratedType:"PLAY0483",invalidGeneratedModifierOrder:"PLAY0484",generatedPropertyInput:"PLAY0485",invalidCommandResponse:"PLAY0486",invalidResponseSource:"PLAY0487",duplicateResponseField:"PLAY0488",invalidResponseShape:"PLAY0489",invalidGeneratedFixture:"PLAY0490",invalidReturnExpectation:"PLAY0491"};var kc=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,Sc=/^import\s+"/;function Ji(n){return Sc.test(n.trim())}a(Ji,"isFileImportLine");function kt(n,e){let t=U(n),i=n.slice(t).match(kc);if(!i)return;let o=t+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:o,endColumn:o+i[2].length}}a(kt,"fileImportOn");function Ey(n){let e=X(n),t=[];for(let i=0;i<n.length;i++){if(e[i])continue;let o=kt(n[i],i);o&&t.push(o)}return t}a(Ey,"fileImports");var Qi=a(n=>n.split("/").slice(0,-1),"folderOf");function wc(n,e){let t=e.split("/"),i=0;for(;i<n.length&&i<t.length-1&&n[i]===t[i];)i++;return[...n.slice(i).map(()=>".."),...t.slice(i)].join("/")}a(wc,"relativeTo");function Ay(n,e){let t=Qi(n),i=new Set;for(let o of e.filter(r=>r!==n&&r.toLowerCase().endsWith(".play"))){let r=wc(t,o),s=Qi(r);i.add(r),i.add([...s,"*.play"].join("/"));for(let c=0;c<=s.length;c++)i.add([...s.slice(0,c),"**","*.play"].join("/"))}return[...i].sort()}a(Ay,"importablePaths");var bc=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),Pc=/^id\s+"((?:[^"\\]|\\.)*)"$/;function Ki(n,e,t,i=new Set){n=ge(n);let o=[],r=X(n),s=Cc(n,r),c=new Set(e.commands.flatMap(k=>k.productionHeaders??[])),p=new Map,f=new Set;for(let k of[e,t]){for(let y of k.events)p.set(y.name,(p.get(y.name)??0)+1);for(let y of k.imports)f.add(y.shortName)}let b=a((k,y,T,D="error")=>{o.push({line:k,startColumn:U(n[k])+1,endColumn:n[k].length+1,code:y,message:T,severity:D})},"report");for(let k of e.events){let y=Le(n,r,k.line,U(n[k.line]));if(k.inline){let g=new Set;for(let m of k.properties)g.has(m.name)&&b(m.line,z.duplicateDeclaration,`Event '${k.name}' already declares property '${m.name}'.`),g.add(m.name);c.has(k.line)||b(k.line,z.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),k.generation!==void 0&&b(k.line,z.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((p.get(k.name)??0)>1||f.has(k.name))&&b(k.line,z.inlineEventCollision,`Inline event '${k.name}' collides with another declaration or import.`)}let T=!1,D=!1;for(let g of y){let m=n[g].trim(),w=m.split(/\s+/)[0];if(k.inline&&w==="generation"&&b(g,z.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),k.inline&&w==="origin"&&b(g,z.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(m)){if(w==="id"){let A=m.match(Pc);T||A===null||A[1].trim().length===0?b(g,z.invalidEventId,'Expected one nonempty id "<old-name>".'):A[1]===k.name&&b(g,z.redundantEventId,"This id repeats the event name; remove it.","information"),T=!0}if(w==="documentation"){let A=g+1;for(;A<n.length&&n[A].trim().length===0;)A++;(D||m!=="documentation"||n[A]?.trim()!=="```markdown"||U(n[A])<=U(n[g])||!s.has(A))&&b(g,z.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),D=!0}}}}let u=[];for(let k=0;k<n.length;k++){if(r[k]||n[k].trim().length===0)continue;let y=U(n[k]);for(;u.length>0&&u[u.length-1].indent>=y;)u.pop();let T=n[k].trim().split(/\s+/)[0];bc.has(T)&&u.at(-1)?.event&&b(k,z.reservedProductionMetadata,`'${T}' is system-assigned production metadata.`),T==="produces"&&u.push({indent:y,event:!i.has(k)&&!/^\s*produces\s+operation\b/.test(n[k])})}for(let k of e.commands){let{identifier:y,mixed:T}=yt(k);for(let D of k.produces??[]){T&&D.target===void 0&&b(D.line,z.explicitProducesTargetsRequired,`Production '${D.name}' must state for explicitly when destinations differ.`);let g=D.target??(D.inline?y:void 0);if(!(y===void 0||g!==y))for(let m of D.mappings.filter(w=>w.source===y))b(m.line,z.eventSourceIdInPayload,`The payload copies '${y}', which already identifies the event source.`,D.inline?"warning":"information")}}return o}a(Ki,"validateInlineEvents");function Cc(n,e){let t=new Set,i,o=!1;for(let r=0;r<n.length;r++){if(!e[r])continue;let s=n[r].trim();i===void 0?(i=r,o=!1):s==="```"?(o&&n[i].trim()==="```markdown"&&t.add(i),i=void 0):s.length>0&&(o=!0)}return t}a(Cc,"nonemptyMarkdownBlocks");function K(n,e,t,i,o,r){return{severity:n,message:o,line:e,startColumn:t,endColumn:t+i,code:r}}a(K,"issue");function re(n,e,t,i,o,r){let s=t.indexOf(i)+1;return K(n,e,s,i.length,o,r)}a(re,"tokenIssue");function Ic(n,e,t){let i=[],o=new Set([...mt(e,Je),...mt(t,[])]),r=a((c,p)=>{for(let f of c.filter(b=>!o.has(ye(b).name))){let b=ye(f).name;i.push(K("warning",f.line,f.sourceType.startColumn,f.sourceType.text.length,b==="optional"?`Unknown type 'optional' on '${f.name}' of ${p} \u2014 did you forget the type before 'optional'?`:`Unknown type '${b}' on '${f.name}' of ${p} \u2014 declare it with 'concept ${b} : <Primitive>' or 'type ${b}'.`,z.unknownType))}},"checkProperties");for(let c of e.types)r(c.properties,`type '${c.name}'`);for(let c of e.events)r(c.properties,`event '${c.name}'`);for(let c of e.queries)r(c.parameters,`query '${c.name}'`);for(let c of e.commands){r(c.properties,`command '${c.name}'`);let p=c.properties.filter(f=>f.isIdentifier);for(let f of p.slice(1))i.push(re("error",f.line,n[f.line],"identifier",`Command '${c.name}' already marks '${p[0].name}' as identifier \u2014 only one property can be the identifier.`,z.duplicateCommandIdentifier))}let s=new Map;for(let c of[...e.concepts,...e.types]){if(s.get(c.name)===void 0){s.set(c.name,c.line);continue}i.push(re("error",c.line,n[c.line],c.name,`Duplicate declaration of '${c.name}' \u2014 concept and type names must be unique.`,z.duplicateDeclaration))}return i}a(Ic,"validateDeclarations");function ek(n,e={}){let t=X(n),i=Ge(n),o=e.application??In(),r=Gi(n,{...o,authoringPath:e.path??o.authoringPath,authoringPlacement:e.placement??o.authoringPlacement}),s=Te(n,r.authoringDocuments??r.authoringSources?.filter(g=>g!==n.join(`
15
+ `)),r.authoringPlacement,r.authoringPath,r.authoringPlacementResolved),c=new Set(s.eventSources.routes.map(g=>g.location.line-1)),p={...i,commands:i.commands.map(g=>({...g,properties:g.properties.filter(m=>!c.has(m.line)),produces:g.produces?.filter(m=>!s.operationProductionLines?.has(m.line)),productionHeaders:g.productionHeaders?.filter(m=>!s.operationProductionLines?.has(m))}))},f=new Set([...$n(p),...$n(o)]),b=new Set([...p.policies,...o.policies].map(g=>g.name)),u=Ic(n,p,o);u.push(...$c(n,p));let k=new Set([d.LegacyOptionalSuffix,d.InvalidOptionalModifierOrder,d.OptionalReadsNotSupported]);for(let g of e.compilerDiagnostics??s.diagnostics){if(!k.has(g.code)&&g.code!==d.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY048[2-9]$|^PLAY004[56]$/.test(g.code))continue;let m=g.location.line-1,w=st(n[m],g)||n[m].length-g.location.column+1;u.push(K(g.severity,m,g.location.column,w,g.message,g.code))}for(let g of s.commands.values()){for(let m of g.properties.filter(w=>w.isGenerated))u.push(K("information",m.location.line-1,m.location.column,m.name.length,`Generated value '${m.name}' is not a request or form input. ${Ve}`,z.unavailableResponseExecution));g.response&&u.push(K("information",g.response.location.line-1,g.response.location.column,7,Ve,z.unavailableResponseExecution))}for(let g of s.specifications.values()){for(let m of g.when?.generatedValues??[])u.push(K("information",m.location.line-1,m.location.column,9,Ve,z.unavailableResponseExecution));g.thenReturns&&u.push(K("information",g.thenReturns.location.line-1,g.thenReturns.location.column,12,Ve,z.unavailableResponseExecution))}let y=a((g,m,w)=>{f.has(w)||u.push(re("warning",g,m,w,`Unknown event type '${w}' \u2014 declare it in a slice or import it.`,z.unknownEvent))},"checkEvent"),T=-1;for(let g=0;g<n.length;g++){let m=n[g],w=m.trim();if(t[g]||w.length===0)continue;let A=m.match(/^[ ]*(\t+)/);if(A&&u.push(K("warning",g,A[0].length-A[1].length+1,A[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",z.tabIndentation)),T>=0){if(U(m)>T&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(w)){for(let L of w.split(/\s+/).filter(x=>x!=="or"))b.has(L)||u.push(re("warning",g,m,L,`Unknown policy '${L}' \u2014 declare it with 'policy ${L}'.`,z.unknownPolicy));continue}T=-1}let I=Ec(n,t,g);I&&u.push(I);let h=w.match(/^slice\s+(\w+)/);h&&!Rn.includes(h[1])&&u.push(re("error",g,m,h[1],`Unknown slice type '${h[1]}' \u2014 expected ${Rn.join(", ")}.`,z.unknownSliceType));let S=w.match(/^concept\s+\w+\s*:\s*(\w+)/);S&&S[1]!=="Enum"&&!Je.includes(S[1])&&u.push(re("error",g,m,S[1],`Unknown primitive type '${S[1]}' \u2014 expected ${Je.join(", ")} or Enum.`,z.unknownPrimitiveType));let C=w.match(/^authorize\s+(.*)$/);if(C){T=U(m);for(let L of C[1].split(/\s+/).filter(x=>x!=="or"&&x.length>0))b.has(L)||u.push(re("warning",g,m,L,`Unknown policy '${L}' \u2014 declare it with 'policy ${L}'.`,z.unknownPolicy))}let $=w.match(/^on\s+([A-Z]\w*)\s*$/);$&&y(g,m,$[1]);let E=w.match(/^produces\s+([A-Z]\w*)\s*$/);if(E&&!s.operationProductionLines?.has(g)&&y(g,m,E[1]),/^produces\s+when\b/.test(w)&&!s.operationProductionLines?.has(g))for(let L=g+1;L<n.length;L++){let x=n[L];if(!(t[L]||x.trim().length===0)){if(U(x)>U(m)){let Y=x.trim().match(/^([A-Z]\w*)\s*$/);Y&&y(L,x,Y[1])}break}}let B=w.match(/^unique\s+event\s+([A-Z]\w*)/);B&&y(g,m,B[1]);let q=w.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);q&&y(g,m,q[1]);for(let L of m.match(/\$context\.[\w.]+/g)??[]){let x=L.substring(9).split(".");An.includes(x[0])?x[0]==="causedBy"&&x.length>1&&!Dn.includes(x[1])?u.push(re("warning",g,m,L,`Unknown $context.causedBy property '${x[1]}' \u2014 expected ${Dn.join(", ")}.`,z.unknownContextCausedByProperty)):x[0]==="identity"&&x.length>1&&!On.includes(x[1])&&u.push(re("warning",g,m,L,`Unknown $context.identity property '${x[1]}' \u2014 expected ${On.join(", ")}.`,z.unknownContextIdentityProperty)):u.push(re("warning",g,m,L,`Unknown $context path '${x.join(".")}' \u2014 expected one of ${An.join(", ")}.`,z.unknownContextPath))}}u.push(...Dc(n,t)),u.push(...Ki(n,p,o,s.operationProductionLines));let D=n.map((g,m)=>({line:g,index:m})).filter(({line:g})=>/^\s*```(?:[a-z]+)?\s*$/.test(g));if(D.length%2===1){let g=D[D.length-1];u.push(K("error",g.index,1,g.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",z.unclosedCodeBlock))}return u}a(ek,"validateLines");function $c(n,e){let t=[];n=ge(n);for(let i of e.commands){let o=i.properties.filter(r=>r.isIdentifier&&!ye(r).isOptional&&!ye(r).isCollection);if(o.length===1)for(let r of i.produces??[]){if(r.inline||r.conditional||r.target!==void 0)continue;let s=r.line;t.push(K("information",s,U(n[s])+1,n[s].trim().length,`Plain 'produces ${r.name}' omits its destination \u2014 use 'for ${o[0].name}' to explicitly select the command's identifier.`,z.omittedProductionDestination))}}return t}a($c,"validateProductionDestinations");function Ec(n,e,t){let i=n[t],o=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(o)||kt(i,t))return;let r=U(i);if(!(!(r>0&&["module","feature"].includes(Ct(n,e,t,r)[0]))&&!Ji(i)))return K("error",t,r+1,o.length,`Invalid import '${o}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,z.invalidFileImport)}a(Ec,"validateImport");var Ac=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Dc(n,e){let t=[],i=a(o=>o.map(r=>r.name).join(", "),"names");for(let o=0;o<n.length;o++){let r=n[o];if(e[o])continue;for(let p of r.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let f=p[0].substring(p[1]?.length??0),b=p[2];if(b.length===0){p[1]&&t.push(K("error",o,(p.index??0)+2,f.length,`'$eventContext' names no member - expected one of ${i(gt("").expected)}.`,z.missingEventContextPath));continue}let u=b.substring(1),k=gt(u),y=(p.index??0)+(p[1]?.length??0)+1;switch(k.status){case"missing":t.push(K("error",o,y,f.length,`'$eventContext.${u}' names no member - expected one of ${i(k.expected)}.`,z.missingEventContextPath));break;case"unknownMember":t.push(K("warning",o,y,f.length,`Unknown event context member '${k.segment}' in '$eventContext.${u}' - expected one of ${i(k.expected)}.`,z.unknownEventContextMember));break;case"unknownSubPath":{let T=k.expected.length===0?"no members to address":`members ${i(k.expected)}`;t.push(K("warning",o,y,f.length,`Unknown event context path '$eventContext.${u}' - '${k.member?.name}' (${k.member?.type}) has ${T}.`,z.unknownEventContextPath));break}case"belowCollection":t.push(K("error",o,y,f.length,`'$eventContext.${u}' cannot resolve - '${k.member?.name}' is a collection (${k.member?.type}) and cannot be addressed below.`,z.eventContextPathBelowCollection));break}}let s=r.trim().match(Ac)?.[1],c=s?.match(/\.\$(\w+)/)?.[1];s&&c&&c!=="eventContext"&&t.push(re("warning",o,r,s,`Dynamic dictionary key '$${c}' in '${s}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${c}' becomes the key.`,z.unresolvedDynamicKeySource))}return t}a(Dc,"validateEventContextPaths");export{to as a,Rc as b,Tc as c,Pt as d,Lc as e,An as f,Dn as g,Rn as h,Je as i,Mc as j,xc as k,xe as l,Yc as m,d as n,ue as o,xn as p,Nn as q,_h as r,Gh as s,ke as t,U as u,Tn as v,X as w,Ct as x,Fc as y,ge as z,Ve as A,Te as B,dt as C,Vg as D,pt as E,Zg as F,ye as G,Le as H,Ge as I,In as J,Gi as K,$n as L,vc as M,ay as N,mt as O,gc as P,ht as Q,vt as R,yc as S,uy as T,fy as U,my as V,yt as W,by as X,z as Y,Ji as Z,kt as _,Ey as $,Ay as aa,ek as ba,Dc as ca};
16
+ //# sourceMappingURL=chunk-ZWIZSFH3.js.map