@cratis/screenplay-language 4.76.1 → 4.78.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.
- package/dist/bundles/chunk-2E5TT2R2.js +16 -0
- package/dist/bundles/chunk-2E5TT2R2.js.map +7 -0
- package/dist/bundles/index.js +1 -1
- package/dist/bundles/sub-languages/projection/index.js +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-X5DNGVII.js +0 -16
- package/dist/bundles/chunk-X5DNGVII.js.map +0 -7
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-AYDF3IFZ.js";var Po="screenplay",Td={id:Po,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Md=["domain","import","concept","type","policy","persona","authentication","module","layout","theme","ui","feature","slice","event","system","eventsource","operation","command","query","projection","capture","reaction","reducer","readmodel","trigger","screen","dialog","form","contribute","constraint","specification","seed","behavior"];var Oi=["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"],Dd=["csharp","typescript","react","html","sql"],hn=["command","arguments","tenant","causedBy","causation","occurred","identity"],gn=["subject","name","userName"],xn=["id","name","userName","isAuthenticated","roles","claims"],$n=["StateChange","StateView","Automation","Translate"],Ct=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],jd=["@pii","@sensitive"],Oo=/^\s*(?:module|feature|slice\s+\w+|type|command|event|readmodel|reducer|projection|capture|reaction|screen|dialog|form|contribute|specification|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|validate|handler|on)\b[^=]*$/,Nd={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Oo,action:{indentAction:1}}],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 nt(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}c(nt,"typeReferenceSymbol");function qd(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}c(qd,"typeReferenceText");function Oe(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(Oe,"withoutComment");function z(t){return t.length-t.trimStart().length}c(z,"indentOf");function vn(t){return t.trim().split(/\s+/)[0]??""}c(vn,"firstWord");function ae(t){let e=new Array(t.length).fill(!1),n=!1;for(let i=0;i<t.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(t[i])&&(!n||/^\s*```\s*$/.test(t[i]))){e[i]=!0,n=!n;continue}e[i]=n}return e}c(ae,"fenceMap");function Ai(t,e,n,i){let r=[],o=i;for(let a=n-1;a>=0&&o>0;a--){if(e[a])continue;let s=Oe(t[a]);if(s.trim().length===0)continue;let p=z(s);p<o&&(r.push(vn(s)),o=p)}return r}c(Ai,"enclosingChain");function Yd(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=Oe(t[r]);if(o.trim().length!==0&&z(o)<i)return o.trim()}}c(Yd,"nearestEnclosingLine");function Wd(t,e,n,i){let r=[],o=i;for(let a=n-1;a>=0&&o>0;a--){if(e[a])continue;let s=Oe(t[a]);if(s.trim().length===0)continue;let p=z(s);p<o&&(r.push(s.trim()),o=p)}return r}c(Wd,"enclosingHeaders");var l={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",UnknownRuleImplementationDirective:"PLAY0144",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",InvalidSpecificationQuery:"PLAY0265",UnknownSpecificationQueryDirective:"PLAY0266",DuplicateSpecificationQueryArguments:"PLAY0267",InvalidAbsentReadModelStep:"PLAY0453",LegacyOptionalSuffix:"PLAY0479",InvalidOptionalModifierOrder:"PLAY0480",OptionalReadsNotSupported:"PLAY0481",InvalidSpecificationCaller:"PLAY0386",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",InvalidCaptureDeclaration:"PLAY0078",UnknownCaptureDirective:"PLAY0079",InvalidMapEntry:"PLAY0080",InvalidTranslation:"PLAY0081",InvalidSplitDeclaration:"PLAY0082",InvalidSplitTarget:"PLAY0083",InvalidAppendDeclaration:"PLAY0084",UnknownAppendDirective:"PLAY0085",WhenWithoutTrigger:"PLAY0086",InvalidWhenClause:"PLAY0087",InvalidWhenTransitionClause:"PLAY0088",MixedWhenCombinators:"PLAY0089",WhenCombinatorWithoutProperty:"PLAY0090",UnknownCaptureBlockDirective:"PLAY0091",InvalidCompositeKeyPart:"PLAY0072",TemplateInCompositeKey:"PLAY0073",EmptyCompositeKey:"PLAY0074",InvalidProjectionMapping:"PLAY0075",ExpectedLiteralValue:"PLAY0150",InvalidExpression:"PLAY0152",UnterminatedInterpolation:"PLAY0157",UnterminatedTemplateExpression:"PLAY0156",ProjectionDocumentWithoutProjection:"PLAY0055",CaptureDocumentWithoutCapture:"PLAY0077",SpecificationDocumentWithoutSpecification:"PLAY0093",InvalidSeedDeclaration:"PLAY0128",InvalidSeedGroup:"PLAY0129",InvalidSeedEvent:"PLAY0130",InvalidSeedPropertyAssignment:"PLAY0131",InvalidPolicyDeclaration:"PLAY0112",UnknownPolicyDirective:"PLAY0113",PolicyWithoutRequirement:"PLAY0114",ExpectedRoleName:"PLAY0118",ExpectedClaimName:"PLAY0119",ExpectedClaimMatches:"PLAY0120",ExpectedClaimMatchTarget:"PLAY0121",MixedPolicyImplementation:"PLAY0440",RepeatedPolicyRequirement:"PLAY0441",UnexpectedTokenInPolicyCondition:"PLAY0115",ExpectedPolicyCondition:"PLAY0116",UnclosedPolicyConditionGroup:"PLAY0117",UnexpectedTokenInCondition:"PLAY0158",ExpectedCondition:"PLAY0159",UnclosedConditionGroup:"PLAY0160",InvalidNumericDirective:"PLAY0508",DuplicateNumericDirective:"PLAY0509",LateNumericDirective:"PLAY0510",InexactNumericLiteral:"PLAY0511",MixedNumericModes:"PLAY0512",IncompatibleNumericSource:"PLAY0513",EventFromLaterSlice:"PLAY0516",TimelineCycleGroup:"PLAY0517",AmbiguousReference:"PLAY0198",InvalidDependencyTarget:"PLAY0554",RepeatedDependencyDeclaration:"PLAY0555",InvalidEventSourceDeclaration:"PLAY0503",InvalidCommandStream:"PLAY0504",AmbiguousCommandStream:"PLAY0505",UnsupportedStreamIdType:"PLAY0506",RedundantSourceStreamId:"PLAY0507",UnknownEvent:"PLAY0166",UnknownReadModelProperty:"PLAY0514",PiiNotSupportedOnIdentifier:"PLAY0515",HandlerWithoutImplementation:"PLAY0045",UnknownHandlerDirective:"PLAY0046",CommandWithProducesAndHandler:"PLAY0035",AbsoluteFileReference:"PLAY0264",InvalidTriggerData:"PLAY0246"};function Be(t,e=!1,n){let i=[],r=0,o=0;for(let a of t.split(`
|
|
2
|
-
`)){r++;let s=a.endsWith("\r")?a.replace(/\r+$/,""):a,p=s.length-s.trimStart().length,f=Ao(s.substring(p),e).trimEnd();i.push(n===void 0?{number:r,raw:s,indent:p,content:f,startOffset:o}:{number:r,raw:s,indent:p,content:f,path:n,startOffset:o}),o+=a.length+1}return i}c(Be,"splitLines");function it(t,e=!1){let n=!1,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"&&n&&r+1<t.length)r++;else if(o==='"'&&!i)n=!n;else if(o==="`"&&!n)i=!i;else if(!n&&!i&&(o==="/"&&r+1<t.length&&t[r+1]==="/"||e&&o==="#"))return r}return-1}c(it,"commentStart");function Ao(t,e){let n=it(t,e);return n<0?t:t.substring(0,n)}c(Ao,"stripComment");var wi=c((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),kn=c(t=>[...t.scope,t.name].join("."),"addressOf"),bn=class{static{c(this,"DeclaredDependencyTargets")}static resolve(e,n,i){let r=e.split(".");if(r.length>1){let o=i.filter(a=>wi([...a.scope,a.name].slice(-r.length),r));return o.length===1?{resolved:o[0],ambiguous:[]}:{ambiguous:o}}for(let o=n.length-1;o>=0;o--){let a=i.filter(s=>s.name===e&&wi(s.scope,n.slice(0,o)));if(a.length>0)return a.length===1?{resolved:a[0],ambiguous:[]}:{ambiguous:a}}return{ambiguous:[]}}};function Et(t,e){let n=[],i=!1,r=c((s,p)=>{n.push({name:s.name,scope:p}),i||=(s.dependsOn?.length??0)>0,s.features.forEach(f=>r(f,[...p,s.name]))},"inventory");for(let s of t.modules)n.push({name:s.name,scope:[]}),i||=(s.dependsOn?.length??0)>0,s.features.forEach(p=>r(p,[s.name]));if(!i)return t;n=[...new Map(n.map(s=>[kn(s),s])).values()];let o=c((s,p)=>{let f=new Set,y=[],u=p.join(".");for(let m of s){let S=bn.resolve(m.target,p,n),v=S.resolved===void 0?void 0:kn(S.resolved),g=v===void 0?`text:${m.target}`:`resolved:${v}`;if(f.has(g)){e.warning(l.RepeatedDependencyDeclaration,`Dependency '${m.target}' is already declared on this container - this repeated declaration is ignored`,m.location);continue}f.add(g),y.push(m),S.ambiguous.length>0?e.warning(l.AmbiguousReference,`Ambiguous dependency target '${m.target}' - candidates: ${S.ambiguous.map(kn).join(", ")}`,m.location):(v===void 0||v===u||v.startsWith(u+".")||u.startsWith(v+"."))&&e.warning(l.InvalidDependencyTarget,`Invalid dependency target '${m.target}' on '${u}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,m.location)}return y},"keep"),a=c((s,p)=>{let f=[...p,s.name];return{...s,dependsOn:o(s.dependsOn??[],f),features:s.features.map(y=>a(y,f))}},"normalize");return{...t,modules:t.modules.map(s=>({...s,dependsOn:o(s.dependsOn??[],[s.name]),features:s.features.map(p=>a(p,[s.name]))}))}}c(Et,"validateDependencyDeclarations");var Te=[],rt=c(t=>t.length===0,"isDocumentPlacement");function Pt(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}c(Pt,"describePlacement");var Cn="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",X="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function G(t){let e=`(?=[\\u0000-\\uFFFF])[${Cn}]`,n=t.replace(/\[([^\]]*\\w[^\]]*)\]/g,(i,r)=>{let o=r.replaceAll("\\w","");return o===""?`(?:${e})`:`(?:${e}|[${o}])`});return new RegExp(n.replaceAll("\\w",`(?:${e})`),"u")}c(G,"nativePattern");function C(t){let e="",n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&i+1<t.length){let o=t[i+1];i++,o==="w"?e+=n?Cn:`[${Cn}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}c(C,"pattern");var Fe=c((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var En=c(t=>t.content.length===0,"isBlank"),d=c(t=>Fe(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),Ii=c(t=>Fe(t.number,1,t.path),"startOf");var wo=C("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),Io=new RegExp(C("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),Ro=C("^[A-Z]\\w*$");function Ae(t,e){let n=e.content.substring(9);for(let s=t.peekChild(e.indent);s!==void 0&&wo.test(s.content);s=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${s.content}`;let i=To(n),r=d(e);if(i.length===0)return t.error(l.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let a=new Pn(t,i,r).parse();return a===null?null:{kind:"AuthorizeSyntax",requirement:a,location:r}}c(Ae,"parseAuthorize");function $e(t,e){return t===null?e:e===null?t:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:t.requirement,operator:"And",right:e.requirement,location:t.location},location:t.location}}c($e,"combineAuthorize");function To(t){let e=[];for(let n of t.match(Io)??[])e.length>0&&Mo(e[e.length-1])&&Do(n)&&e.push("and"),e.push(n);return e}c(To,"tokenize");var Ri=c(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),Mo=c(t=>t===")"||Ri(t),"isOperandEnd"),Do=c(t=>t==="("||Ri(t),"isOperandStart"),Pn=class{static{c(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,n,i){this.context=e,this.tokens=n,this.location=i}parse(){let e=this.#t();return e!==null&&this.#e<this.tokens.length&&this.context.error(l.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#i("or","Or",()=>this.#r())}#r(){return this.#i("and","And",()=>this.#n())}#i(e,n,i){let r=i();for(;r!==null&&this.tokens[this.#e]===e;){this.#e++;let o=i();if(o===null)return null;r={kind:"LogicalPolicyRequirementSyntax",left:r,operator:n,right:o,location:this.location}}return r}#n(){if(this.tokens[this.#e]!=="(")return this.#a();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(l.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#a(){if(this.#e>=this.tokens.length)return this.context.error(l.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return Ro.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(l.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};var U='(?:[^"\\\\]|\\\\.)*',jo={"\\":"\\",'"':'"',n:`
|
|
3
|
-
`,r:"\r",t:" "};function V(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?jo[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}c(V,"unescapeString");function Ye(t,e,n,i=!1){let o=n.content.startsWith("```")?n:t.reader.peekSignificant(),a=e==="description"?"```text":`\`\`\`${e}`;if(o===void 0||o!==n&&o.indent<=n.indent||o.content!==a&&!(i&&e==="description"&&o.content==="```markdown")&&!(o.content==="```"&&o!==n))return t.error(l.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,d(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(l.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",d(o));let s=[];for(;;){let p=t.reader.takeRaw();if(p===void 0){t.error(l.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",d(o));break}if(p.raw.trim()==="```")break;let f=0;for(;f<o.indent&&f<p.raw.length&&p.raw[f]===" ";)f++;s.push(p.raw.substring(f))}return s.join(`
|
|
4
|
-
`)}c(Ye,"parseFencedText");var No=C(`^description\\s+"(${U})"$`);function Q(t,e,n,i,r=!1){if(e.content==="description"){let a=Ye(t,"description",e,r);return a===null?n:a.trim().length===0?(t.error(l.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,d(e)),n):Ti(t,e,n,i,a)}let o=No.exec(e.content);return o===null?(t.error(l.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,d(e)),n):Ti(t,e,n,i,V(o[1]))}c(Q,"parseDescription");function Ti(t,e,n,i,r){return n!==null?(t.error(l.DuplicateDescription,`${i} already declares a description - at most one is allowed`,d(e)),n):r}c(Ti,"keep");var Lo=G(`^depends${X}+on${X}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function Ot(t,e,n,i){let r=Lo.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,d(e)),t.skipBlock(e.indent);return}if(n.some(o=>o.target===r)){t.warning(l.RepeatedDependencyDeclaration,`Dependency '${r}' is already declared on this container - this repeated declaration is ignored`,d(e));return}n.push({kind:"DependsOnSyntax",target:r,location:d(e)})}c(Ot,"parseDependsOn");var qo=C('^import\\s+"([^"\\\\]+)"$'),Bo=C('^import\\s+"'),Mi=c(t=>Bo.test(t),"isFileImport");function Di(t){let e=qo.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:d(t)}}c(Di,"tryParseFileImport");function We(t,e,n){let i=Di(e);if(i!==void 0){n.push(i);return}t.error(l.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,d(e)),t.skipBlock(e.indent)}c(We,"parseFileImport");var R=c(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),Z=c(t=>t.replaceAll("@",""),"unescapeIdentifier");function ji(t,e){let n=[],i=0,r=!1,o=!1;for(let a=0;a<t.length;a++){let s=t[a];s==="\\"&&r&&a+1<t.length?a++:s==='"'&&!o?r=!r:s==="`"&&!r?o=!o:s===e&&!r&&!o&&(n.push(t.substring(i,a)),i=a+1)}return n.push(t.substring(i)),n}c(ji,"splitTopLevel");var Fo=C("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Yo=C("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Wo=C("^field\\s+([\\w.]+)(?:\\s|$)"),Uo=C("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),zo=C("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),Vo=C("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),Qo=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on"]);function ye(t,e){let n=[],i=new Set,r=[],o=R(e.content)==="behavior",a=c(s=>{for(;n.length>0&&n[n.length-1].indent>=s.indent;)n.pop();let p=o&&n.length===0?Vo.exec(s.content):null;p!==null&&i.add(p[1]);let f=Fo.exec(s.content),y=Yo.exec(s.content);if(f!==null)n.push({command:f[1],kind:"form",indent:s.indent});else if(y!==null)n.push({command:y[2],kind:y[1],indent:s.indent});else if(Qo.has(R(s.content)))n.push({command:"",kind:"other",indent:s.indent});else{let u=n.at(-1);if(u===void 0||u.kind==="other")return;let m=(u.kind==="form"?Wo:u.kind==="execute"?Uo:zo).exec(s.content);m!==null&&r.push({command:u.command,property:Z(m[1]),scope:t.scope,location:d(s)})}},"recognize");a(e);for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))t.reader.takeSignificant(),s.content.startsWith("```")?t.skipFencedBody():a(s);for(let s of r)t.inputUses.push(i.has(s.command)?{...s,isParameter:!0}:s)}c(ye,"collectInputUses");var Ni=["StateChange","StateView","Automation","Translate"];var ot=["tag"];var Zo=C(`^id\\s+"(${U})"$`),Ue=class{static{c(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=d(n);switch(R(n.content)){case"id":{let r=Zo.exec(n.content),o=r===null?"":V(r[1]);return o.trim().length===0||this.value.id!==null?e.error(l.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(l.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=Q(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":{if(n.content!=="documentation"||e.peekChild(n.indent)?.content!=="```markdown")return e.error(l.InvalidEventDocumentation,`Event '${this.name}' documentation requires a fenced markdown block`,i),e.skipOpaqueBlock(n.indent),!0;let r=Ye(e,"markdown",n);return r===null||r.trim().length===0||this.value.documentation!==null?e.error(l.InvalidEventDocumentation,`Event '${this.name}' accepts one nonempty documentation block`,i):this.value.documentation=r,!0}default:return!1}}};var On="79228162514264337593543950335";function be(t){let e=Li(t);if(e===void 0)return;let n=e.integer+e.fraction,i=0;for(;i<n.length&&n[i]==="0";)i++;if(i===n.length)return Object.freeze({literalType:"ExactNumber",value:"0"});let r=n.length;for(;n[r-1]==="0";)r--;let o=e.fraction.length-e.exponent-(n.length-r),a=o<0?-o:0;if(o>28||r-i+a>On.length)return;let s=n.substring(i,r)+"0".repeat(a);if(s.length===On.length&&s>On)return;let p=Math.max(0,o),f=p===0?s:s.length>p?`${s.substring(0,s.length-p)}.${s.substring(s.length-p)}`:`0.${"0".repeat(p-s.length)}${s}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+f})}c(be,"parseExactNumber");function at(t){return Li(t)!==void 0}c(at,"isExactNumberToken");function Li(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&An(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let s=++i;for(;i<t.length&&An(t[i]);)i++;if(i===s)return;o=t.substring(s,i)}let a=0;if(t[i]==="e"||t[i]==="E"){i++;let s=t[i]==="-";(t[i]==="+"||t[i]==="-")&&i++;let p=i,f=t.length+29;for(;i<t.length&&An(t[i]);)a=Math.min(f,a*10+t.charCodeAt(i++)-48);if(i===p)return;s&&(a=-a)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:a}:void 0}c(Li,"scan");function An(t){return t>="0"&&t<="9"}c(An,"isDigit");var qi=64,ce=class extends Error{static{c(this,"InvalidStructuredValue")}},At=class{static{c(this,"StructuredValueParser")}text;start;context;#e=0;constructor(e,n,i){this.text=e,this.start=n,this.context=i}parse(){let e=this.#t(0);if(this.#o(),this.#e<this.text.length)throw new ce(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#o();let n=this.#l(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=qi)throw new ce(`The value nests deeper than ${qi} levels.`);return i==="["?this.#r(e,n):this.#i(e,n)}if(i==='"')return{kind:"LiteralExpressionSyntax",value:this.#n(),location:n};for(let[r,o]of[["true",!0],["false",!1],["null",null]])if(this.text.startsWith(r,this.#e))return this.#e+=r.length,{kind:"LiteralExpressionSyntax",value:o,location:n};return this.#d(n)}#r(e,n){this.#e++;let i=[];if(this.#o(),this.#s("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#o(),this.#s("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#c(",")}}#i(e,n){this.#e++;let i=[],r=new Set;if(this.#o(),this.#s("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#o();let o=this.#l();if(this.text[this.#e]!=='"')throw new ce("Expected a property name in double quotes.");let a=this.#n();this.#o(),this.#c(":");let s=this.#t(e+1);if(r.has(a)?this.context?.error(l.DuplicateStructuredValueMember,`Duplicate property '${a}' in structured value`,o):(r.add(a),i.push({kind:"ObjectMemberSyntax",name:a,value:s,location:o})),this.#o(),this.#s("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#c(",")}}#n(){let e=this.#a(this.#e),n=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(n)}catch{throw new ce(`${n} is not a valid JSON string.`)}}#a(e){for(let n=e+1;n<this.text.length;n++)if(this.text[n]==="\\")n++;else if(this.text[n]==='"')return n+1;throw new ce("A string is not closed.")}#d(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new ce(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=be(n[0]);return r===void 0?(this.context.error(l.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:n[0],location:e}):{kind:"LiteralExpressionSyntax",value:r,location:e}}let i=Number(n[0]);if(!Number.isFinite(i))throw new ce("JSON number is outside the finite Double range.");return{kind:"LiteralExpressionSyntax",value:i,location:e}}#l(){return{...this.start,column:this.start.column+this.#e}}#o(){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 ce(`Expected '${e}' at position ${this.#e}.`)}};var Go=C("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Ko=G("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),_o=C("^-?\\d+(\\.\\d+)?$"),Bi=["command","arguments","tenant","causedBy","causation","occurred","identity"],Fi=["subject","name","userName"],Yi=["id","name","userName","isAuthenticated","roles","claims"];function le(t,e,n){return ee(t,e,n,!0)}c(le,"parseModeledMappingSource");function ee(t,e,n,i=!1){if(t=t.trim(),t.startsWith("$context.")){let o=t.substring(9);return Jo(o,e,n),{kind:"ContextExpressionSyntax",path:o,location:e}}if(t.startsWith("$env."))return{kind:"EnvironmentExpressionSyntax",name:t.substring(5),location:e};if(t.startsWith("$strings."))return{kind:"StringsExpressionSyntax",key:t.substring(9),location:e};if(t.startsWith("$."))return{kind:"SourceItemExpressionSyntax",path:t.substring(2),location:e};if(t.startsWith("{")||t.startsWith("["))try{return new At(t,e,n).parse()}catch(o){if(!(o instanceof ce))throw o;return n?.error(l.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?st(t,e):st(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?Ko:Go).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}c(ee,"parseMappingSource");function Jo(t,e,n){let[i,r]=t.split(".");Bi.includes(i)?r!==void 0&&i==="causedBy"&&!Fi.includes(r)?n?.warning(l.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Fi.join(", ")}`,e):r!==void 0&&i==="identity"&&!Yi.includes(r)&&n?.warning(l.UnknownContextIdentityProperty,`Unknown $context.identity property '${r}' - expected ${Yi.join(", ")}`,e):n?.warning(l.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${Bi.join(", ")}`,e)}c(Jo,"warnOnUnknownContextPath");function st(t,e,n){let i=c(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(t){case"true":return i(!0);case"false":return i(!1);case"null":return i(null)}if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return i(V(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!at(t))return;let o=be(t);return o!==void 0?i(o):(n.error(l.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(_o.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}c(st,"parseLiteral");var Ho=C("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Wi=c(t=>R(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),te=c(t=>Wi(t).length>0,"isFileDirective"),wt=c(t=>te(t)&&!Ho.test(Wi(t)),"isFileDirectiveAmongProperties");var Xo=C("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?$"),ea=C("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier)(?:\\s+(?:optional|generated|identifier))*)$"),ta=C("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function Me(t){let e=Xo.exec(t.content);if(e===null)return;let n=d(t);return{kind:"PropertySyntax",name:Z(e[1]),type:me(e[2],{...n,column:n.column+t.content.indexOf(e[2],e[1].length)}),isGenerated:e[3]!==void 0,nameWasEscaped:e[1].startsWith("@"),isIdentifier:e[4]!==void 0,location:n}}c(Me,"tryParseProperty");function me(t,e){let n=t.endsWith("?"),i=/\soptional$/.test(t),r=n||i;r&&(t=t.substring(0,t.length-(n?1:8)).trimEnd());let o=t.endsWith("[]");return o&&(t=t.substring(0,t.length-2)),{kind:"TypeRefSyntax",name:t,isCollection:o,isOptional:r,location:e}}c(me,"parseTypeRef");function ve(t,e){let n=Me(e);return n!==void 0?ke(t,n.type,e):It(t,e),n}c(ve,"parseProperty");function ke(t,e,n){t.claimField(n);let i=e.name.length+(e.isCollection?2:0),r=e.location.column-n.indent-1+i;if(e.isOptional&&n.content[r]==="?"){let o=e.name+(e.isCollection?"[]":"");t.information(l.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}c(ke,"reportLegacyOptionalSuffix");function It(t,e){if(ta.test(e.content))return t.error(l.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",d(e)),!0;{let n=ea.exec(e.content);if(n!==null&&n[1].split(/\s+/).some(i=>i==="generated"||i==="identifier"))return t.error(l.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",d(e)),!0}return!1}c(It,"reportInvalidModifierOrder");var na=C("^type\\s+([A-Za-z_]\\w*)$"),ia=C("^event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+([0-9]+))?$"),ra=C("^readmodel\\s+([A-Za-z_]\\w*)$"),Ui=4294967295,oa=C("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),aa=C("^[A-Za-z_]\\w*$"),zi=c(t=>R(t.content)==="description"&&Me(t)===void 0,"isDescription");function wn(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,d(n)),{...e,isIdentifier:!1}):e}c(wn,"withoutIdentifier");function Vi(t,e){let n=na.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,d(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),zi(o)){r=Q(t,o,r,`Type '${n}'`);continue}if(wt(o))continue;let a=ve(t,o);if(a===void 0){t.error(l.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,d(o));continue}i.push(wn(t,a,o,l.IdentifierOutsideCommand,`Property '${a.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(l.TypeWithoutProperties,`Type '${n}' must declare at least one property`,d(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:d(e)}}c(Vi,"parseType");function Qi(t,e){let n=ia.exec(e.content),i=n?.[1]??"";n===null&&t.error(l.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected 'event <Name> [generation <N>]'`,d(e));let r=n?.[2]!==void 0,o=1;if(r){let f=Number(n[2]);!Number.isSafeInteger(f)||f===0||f>=Ui?t.error(l.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Ui-1}`,d(e)):o=f}let a=[],s=[],p=new Ue(i);for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){if(t.reader.takeSignificant(),wt(f))continue;if(ot.includes(R(f.content))){let u=ct(t,f);u!==void 0&&s.push(u);continue}let y=ve(t,f);if(y===void 0){p.tryParse(t,f)||t.error(l.InvalidPropertyDeclaration,`Invalid property '${f.content}' - expected '<name> <Type>'`,d(f));continue}a.push(wn(t,y,f,l.IdentifierOnEventProperty,`Property '${y.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:a,tags:s,generation:o,hasGenerationMarker:r,...p.value,location:d(e)}}c(Qi,"parseEvent");function ct(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&oa.test(i)&&t.warning(l.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`,d(e)),i.length===0){t.error(l.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",d(e));return}if(aa.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:d(e)},location:d(e)};let r=ee(i,d(e),t);if(r.kind==="RawExpressionSyntax"){t.error(l.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,d(e));return}return{kind:"TagSyntax",value:r,location:d(e)}}c(ct,"parseTag");function Zi(t,e){let n=ra.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,d(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))if(t.reader.takeSignificant(),zi(o))r=Q(t,o,r,`Read model '${n}'`);else{if(wt(o))continue;{let a=ve(t,o);if(a===void 0){t.error(l.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,d(o));continue}i.push(wn(t,a,o,l.IdentifierOutsideCommand,`Property '${a.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,location:d(e)}}c(Zi,"parseReadModel");var sa=G("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function ie(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(l.UnterminatedTemplateExpression,"Unterminated template expression - expected a closing backtick",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};let a=t.substring(1,t.length-1),s=0;for(let p=0;p<a.length;p++){if(a[p]!=="$"||a[p+1]!=="{")continue;p>s&&o.push({kind:"TemplateTextSyntax",text:a.substring(s,p),location:e});let f=a.indexOf("}",p);if(f<0)return n.error(l.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:ie(a.substring(p+2,f),e,n),location:e}),p=f,s=f+1}return s<a.length&&o.push({kind:"TemplateTextSyntax",text:a.substring(s),location:e}),{kind:"TemplateExpressionSyntax",parts:o,location:e}}let i=t.startsWith("literal ")?t.substring(8).trim():t;if(n.sourceOptions.numericMode==="exact"&&(i.startsWith("{")||i.startsWith("[")))return le(i,e,n);if(t.startsWith("literal ")){let o=st(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(l.ExpectedLiteralValue,`Expected a literal value after 'literal', got '${t.substring(8).trim()}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}if(t==="$eventSourceId")return{kind:"EventSourceIdExpressionSyntax",location:e};if(t.startsWith("$eventContext."))return{kind:"EventContextExpressionSyntax",path:t.substring(14),location:e};if(t==="$causedBy")return{kind:"CausedByExpressionSyntax",property:null,location:e};if(t.startsWith("$causedBy."))return{kind:"CausedByExpressionSyntax",property:t.substring(10),location:e};let r=st(t,e,n);return r!==void 0?r:sa.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(l.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}c(ie,"parseProjectionExpression");var Tt=c(t=>({legacy:C(t),native:G(t)}),"grammar"),ca=Tt("^capture\\s+([A-Za-z_]\\w*)$"),la=Tt("^append\\s+([A-Z]\\w*)$"),da=Tt("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),pa=Tt("^nested\\s+([\\w.]+)$"),Rt=c((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),fa=G("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),ua=G("^([a-z_]\\w*)\\s*=\\s*(.+)$"),ya=G(`^"(${U})"\\s*=>\\s*(\\w+)$`),ma=G(`^split\\s+(\\S+)\\s+by\\s+"(${U})"$`),Sa=new RegExp(G(`"${U}"|[\\w.]+`).source,"gu"),ha=G("^[\\w.]+$");function In(t,e){t=t.valueContext;let n=Rt(t,ca).exec(e.content)?.[1]??"";n===""&&t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,d(e));let i=null,r=null,o=[],a=[],s=[],p=[];for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent))switch(t.reader.takeSignificant(),R(f.content)){case"source":i=ga(t,f);break;case"key":r=f.content.substring(3).trim();break;case"map":o.push(...Ki(t,f));break;case"append":_i(t,f,a);break;case"children":{let y=Rt(t,da).exec(f.content);if(y===null){t.error(l.InvalidChildrenDeclaration,`Invalid children declaration '${f.content}' - expected 'children <collection> identified by <key>'`,d(f)),t.skipOpaqueBlock(f.indent);break}let u=Gi(t,f);y!==null&&s.push({kind:"CaptureChildrenSyntax",property:y[1],identifiedBy:y[2],...u,location:d(f)});break}case"nested":{let y=Rt(t,pa).exec(f.content);if(y===null){t.error(l.InvalidNestedDeclaration,`Invalid nested declaration '${f.content}' - expected 'nested <Property>'`,d(f)),t.skipOpaqueBlock(f.indent);break}let u=Gi(t,f);y!==null&&p.push({kind:"CaptureNestedSyntax",property:y[1],...u,location:d(f)});break}default:t.error(l.UnknownCaptureDirective,`Unexpected '${f.content}' in capture body`,d(f)),t.skipOpaqueBlock(f.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:n,source:i,key:r,map:o,appends:a,children:s,nested:p,location:d(e)}}c(In,"parseCapture");function ga(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=R(i.content);n.push({kind:"CaptureSourceSettingSyntax",name:r,value:i.content.substring(r.length).trim(),location:d(i)})}return{kind:"CaptureSourceSyntax",syntaxKind:e.content.substring(6).trim(),settings:n,location:d(e)}}c(ga,"parseSource");function Ki(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=d(i);if(R(i.content)==="split"){let u=ma.exec(i.content);if(u===null){t.error(l.InvalidSplitDeclaration,`Invalid split operation '${i.content}' - expected 'split <property> by "<separator>"'`,r),t.skipOpaqueBlock(i.indent);continue}let m=[];for(let S=t.peekChild(i.indent);S!==void 0;S=t.peekChild(i.indent))t.reader.takeSignificant(),ha.test(S.content)?m.push(S.content):t.error(l.InvalidSplitTarget,`Invalid split target '${S.content}' - expected a property path`,d(S));u!==null&&n.push({kind:"CaptureSplitSyntax",source:ie(u[1],r,t),separator:V(u[2]),targets:m,location:r});continue}let o=ua.exec(i.content);if(o===null){t.error(l.InvalidMapEntry,`Invalid map entry '${i.content}' - expected '<property> = <source> [translate]'`,r),t.skipOpaqueBlock(i.indent);continue}let a=o[2].trim(),s=a.startsWith("`")?a.indexOf("`",1):-1,p=a.startsWith("`")?s>=0&&a.substring(s+1).trim()==="translate":a.endsWith(" translate"),f=a.startsWith("`")&&s>=0&&(t.sourceOptions.numericMode!=="exact"||p||a.substring(s+1).trim()==="")?a.substring(0,s+1):p?a.substring(0,a.length-10).trimEnd():a,y=[];if(p)for(let u=t.peekChild(i.indent);u!==void 0;u=t.peekChild(i.indent)){t.reader.takeSignificant();let m=ya.exec(u.content);m!==null?y.push({kind:"CaptureTranslationSyntax",from:V(m[1]),to:m[2],location:d(u)}):t.error(l.InvalidTranslation,`Invalid translation '${u.content}' - expected '"<source>" => <target>'`,d(u))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:ie(f,r,t),translations:y,location:r})}return n}c(Ki,"parseMap");function Gi(t,e){let n=[],i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),R(r.content)==="map"?n=Ki(t,r):R(r.content)==="append"?_i(t,r,i):(t.error(l.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${R(e.content)} block - expected 'map' or 'append <EventType>'`,d(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}c(Gi,"mapAndAppends");function _i(t,e,n){let i=Rt(t,la).exec(e.content);if(i===null){t.error(l.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,d(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],a=null,s=c((p,f=!1)=>{let y=d(p);if(R(p.content)==="tag"){let m=ct(t.valueContext,p,!1);m!==void 0&&o.push(m);return}let u=fa.exec(p.content);u!==null?r.push({kind:"PropertyMappingSyntax",property:Z(u[1]),source:le(u[2],y,t.valueContext),location:y}):t.error(f?l.InvalidPropertyMapping:l.UnknownAppendDirective,`Unexpected '${p.content}' in append body`,y)},"mapping");for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))if(t.reader.takeSignificant(),R(p.content)==="when"){a=xa(t,p);for(let f=t.peekChild(p.indent);f!==void 0;f=t.peekChild(p.indent))t.reader.takeSignificant(),s(f,!0)}else s(p);n.push({kind:"CaptureAppendSyntax",event:i[1],when:a,mappings:r,tags:o,location:d(e)})}c(_i,"pushAppend");function xa(t,e){let n=e.content.substring(4).trim(),i=d(e),r=c((p,f=[],y=null,u=null,m=null)=>({kind:"CaptureWhenSyntax",syntaxKind:p,properties:f,fromValue:y,toValue:u,expression:m,location:i}),"value");if(n==="added")return r("Added");if(n==="removed")return r("Removed");if(n.startsWith("`"))return(!n.endsWith("`")||n.length<2)&&t.error(l.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(l.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${U}"|[^\\s]+`,"gu"):Sa)??[]],a=c(p=>p.startsWith('"')&&p.endsWith('"')?V(p.substring(1,p.length-1)):p,"unquote");if(o.length===0)return t.error(l.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length===1)return r("PropertyChanged",[a(o[0])]);if(o[1]==="from")return o.length===5&&o[3]==="to"?r("ValueTransition",[a(o[0])],a(o[2]),a(o[4])):(t.error(l.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(l.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(l.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let s=[a(o[0])];for(let p=1;p<o.length-1;p+=2){if(o[p]!==o[1])return t.error(l.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;s.push(a(o[p+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",s)}c(xa,"parseWhen");var Ji={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function ze(t,e,n){t=t.valueContext;let i=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|":"",r=t.sourceOptions.numericMode==="exact"?"[\\w.$-]+|[^\\s]":"[\\w.$-]+",o=e.match(new RegExp(G(`"${U}"|==|!=|>=|<=|>|<|\\(|\\)|${i}${r}`).source,"gu"))??[],a=0,s=c(()=>{if(o[a]==="("){a++;let v=f();return o[a]===")"?a++:t.sourceOptions.numericMode==="exact"&&t.error(l.UnclosedConditionGroup,"Expected ')' in condition",n),v}let u=o[a++],m=o[a++];m==="starts"&&o[a]==="with"&&(m+=" with",a++);let S=o[a++];return u===void 0||S===void 0||Ji[m]===void 0?null:{kind:"ComparisonConditionSyntax",left:u,operator:Ji[m],right:le(S,n,t),location:n}},"group"),p=c(()=>{let u=s();for(;u!==null&&o[a]==="and";){a++;let m=s();if(m===null)return null;u={kind:"LogicalConditionSyntax",left:u,operator:"And",right:m,location:n}}return u},"and"),f=c(()=>{let u=p();for(;u!==null&&o[a]==="or";){a++;let m=p();if(m===null)return null;u={kind:"LogicalConditionSyntax",left:u,operator:"Or",right:m,location:n}}return u},"or"),y=f();return t.sourceOptions.numericMode==="exact"&&(y===null?t.error(l.ExpectedCondition,"Expected a condition",n):a<o.length&&t.error(l.UnexpectedTokenInCondition,`Unexpected '${o[a]}' in condition`,n)),y}c(ze,"parseCondition");function de(t){return C(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}c(de,"sourceStreamPattern");var $a=de("^[A-Za-z_]\\w*(?![\\s\\S])"),va=de("^[\\w.]+(?![\\s\\S])");function Rn(t){return typeof t=="string"&&$a.test(t)}c(Rn,"isSourceStreamName");function Tn(t){return typeof t=="string"&&va.test(t)}c(Tn,"isSourceStreamTypeName");var ka=C(`^id\\s+"(${U})"$`),ba=de("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Ca=de("^eventsource\\s+([A-Za-z_]\\w*)$"),Ea=de("^stream\\s+([A-Za-z_]\\w*)$");function Hi(t,e){let n=Ca.exec(e.content)?.[1]??"";n===""&&Ve(t,e,"Expected 'eventsource <Name>'.");let i=[],r=null,o=null,a=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))switch(t.reader.takeSignificant(),R(s.content)){case"stream":i.push(Pa(t,s));break;case"identifier":r=Xi(t,s,"identifier",r);break;case"description":o=Q(t,s,o,`Event source '${n}'`,!0);break;case"id":a=er(t,s,n,a);break;default:Ve(t,s,"An event source accepts description, id, identifier and stream declarations."),t.skipBlock(s.indent);break}return{kind:"EventSourceSyntax",name:n,streams:i,identifier:r,description:o,id:a,location:d(e)}}c(Hi,"parseEventSource");function Pa(t,e){let n=Ea.exec(e.content)?.[1]??"";n===""&&Ve(t,e,"Expected 'stream <Name>'.");let i=null,r=null,o=null;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent))switch(t.reader.takeSignificant(),R(a.content)){case"streamId":i=Xi(t,a,"streamId",i);break;case"description":r=Q(t,a,r,`Stream '${n}'`,!0);break;case"id":o=er(t,a,n,o);break;default:Ve(t,a,"A stream accepts description, id and streamId declarations."),t.skipBlock(a.indent);break}return{kind:"EventStreamSyntax",name:n,streamId:i,description:r,id:o,location:d(e)}}c(Pa,"parseEventStream");function Xi(t,e,n,i){let r=ba.exec(e.content);return r===null||i!==null?Ve(t,e,`Declare at most one '${n} <Type>'.`):(i=me(r[2],{...d(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),ke(t,i,e)),Mn(t,e,l.InvalidEventSourceDeclaration),i}c(Xi,"parseType");function er(t,e,n,i){let r=ka.exec(e.content),o=r===null?null:V(r[1]);return o===null||o.trim()===""||i!==null?Ve(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(l.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",d(e))),Mn(t,e,l.InvalidEventSourceDeclaration),i}c(er,"parsePin");function tr(t,e,n,i){let[r,o]=n.type.name.split("."),a={kind:"CommandStreamSyntax",eventSource:r,stream:o,streamId:null,propertyCandidate:null,referenceLocation:n.type.location,referenceLength:n.type.name.length,location:d(e)};if(i)return t.error(l.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,d(e)),{...a,propertyCandidate:n};let s=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let f=/^streamId\s*=\s*(.+)$/.exec(p.content);if(f===null||s!==null)t.error(l.InvalidCommandStream,"A command stream accepts at most one 'streamId = <source>' mapping.",d(p)),t.skipBlock(p.indent);else{let y={...d(p),column:p.indent+1+p.content.indexOf(f[1],p.content.indexOf("=")+1)};s={kind:"PropertyMappingSyntax",property:"streamId",source:ee(f[1],y,t),location:d(p)},Mn(t,p,l.InvalidCommandStream)}}return{...a,streamId:s}}c(tr,"parseCommandStream");function Mn(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",d(i)),t.skipBlock(e.indent))}c(Mn,"rejectChildren");function Ve(t,e,n){t.error(l.InvalidEventSourceDeclaration,n,d(e))}c(Ve,"invalid");var Dn=C("^returns\\s+(@?[A-Za-z_]\\w*)$"),Oa=C("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function jn(t,e){let n=d(e);if(e.content!=="returns"){let r=Dn.exec(e.content);if(r===null)return t.error(l.InvalidCommandResponse,"Expected 'returns <property>' or an unconditional 'returns' block.",n),t.skipBlock(e.indent),null;let o=t.peekChild(e.indent);o!==void 0&&(t.error(l.InvalidCommandResponse,"A scalar response cannot have child directives.",d(o)),t.skipBlock(e.indent));let a=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:Z(r[1]),location:{...n,column:n.column+a}},location:n}}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Oa.exec(r.content);if(o===null){t.error(l.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",d(r)),t.skipBlock(r.indent);continue}let a=d(r),s=o[2]===void 0?null:me(o[2],{...a,column:a.column+r.content.indexOf(o[2],o[1].length)});s!==null&&ke(t,s,r),i.push({kind:"ResponseFieldSyntax",name:Z(o[1]),type:s,source:{kind:"PropertyResponseSourceSyntax",property:Z(o[3]),location:{...a,column:a.column+r.content.lastIndexOf(o[3])}},location:a});let p=t.peekChild(r.indent);p!==void 0&&(t.error(l.InvalidCommandResponse,"A response field cannot have child directives.",d(p)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}c(jn,"parseCommandResponse");var Aa=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function Mt(t){if(t===null)return!0;for(let e of t){let n=e.charCodeAt(0);if(!(n>=9&&n<=13||n>=8192&&n<=8202||Aa.has(n)))return!1}return!0}c(Mt,"isBlankImplementationHint");var nr=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),Qe=c(t=>R(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),lt=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function we(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(l.AbsoluteFileReference,`'${n}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,d(e)),{kind:"FileReferenceSyntax",path:n,location:d(e)}}c(we,"parseFile");var Nn=c(t=>t.raw.trim()==="```","isClosingCodeFence");function pe(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(l.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,d(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(l.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,d(e));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=e.indent||o.content!=="```"&&o.content!==`\`\`\`${n}`)return t.error(l.ExpectedCodeFence,`Expected an opening \`\`\`${n} fence after '${n}'`,d(e)),null;i=t.reader.takeSignificant()}let r=[];for(;;){let o=t.reader.takeRaw();if(o===void 0){t.error(l.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",d(i));break}if(Nn(o))break;let a=0;for(;a<i.indent&&o.raw[a]===" ";)a++;r.push(o.raw.substring(a))}return{kind:"CodeBlockSyntax",language:n,code:r.join(`
|
|
6
|
-
`),location:d(e)}}c(pe,"parseCode");function ir(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(l.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",d(e)),null;if(t.reader.takeSignificant(),R(n.content)==="implementation")return wa(t,e,n);let i=Qe(n)?we(t,n):null,r=i===null&<(t,n)?pe(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&R(o.content)==="implementation"&&(t.error(l.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",d(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:d(e)}}return t.error(l.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,d(n)),t.skipBlock(e.indent),null}c(ir,"parseHandler");function wa(t,e,n){let i=dt(t,n);for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(R(r.content)==="implementation"?l.InvalidImplementationBlock:l.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",d(r)),lt(t,r)?pe(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:d(e)}}c(wa,"parseImplementation");function dt(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(l.InvalidImplementationBlock,"Expected 'implementation' with no operand.",d(e));for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent))if(t.reader.takeSignificant(),R(a.content)==="hint"||nr.test(a.content)){let s=nr.exec(a.content),p=s===null?null:V(s[1]);Mt(p)?t.error(l.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",d(a)):n.push({kind:"ImplementationHintSyntax",text:p,location:d(a)});let f=t.peekChild(a.indent);f!==void 0&&(t.error(l.InvalidImplementationHint,"A hint cannot have children.",d(f)),t.skipBlock(a.indent))}else if(Qe(a)||a.content.startsWith("```")){o&&t.error(l.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",d(a));let s=Qe(a)?we(t,a):null,p=s===null?pe(t,a):null;o||(i=s,r=p),o=!0;let f=t.peekChild(a.indent);s!==null&&f!==void 0&&(t.error(l.InvalidImplementationBlock,"A file directive cannot have children.",d(f)),t.skipBlock(a.indent))}else t.error(l.InvalidImplementationBlock,`Unexpected '${a.content}' in implementation - expected hint, file or a tagged fence.`,d(a)),t.skipBlock(a.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:d(e)}}}c(dt,"parseImplementationWrapper");var H=class extends Error{static{c(this,"InvalidSyntaxJson")}};var fe=Object.freeze({numericMode:"legacy"}),Dt=Object.freeze({numericMode:"exact"}),rr=Object.freeze({numericMode:"invalid"});function Ze(t){if(typeof t!="object"||t===null||Object.getPrototypeOf(t)!==Object.prototype&&Object.getPrototypeOf(t)!==null||Reflect.ownKeys(t).length!==1||!Object.hasOwn(t,"numericMode"))throw new H("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new H("Malformed source numeric options.");return e==="exact"?Dt:fe}c(Ze,"validatedSourceOptions");var or=new WeakSet;function ar(t){or.add(t)}c(ar,"recordAuthoredDocument");function sr(t){return or.has(t)}c(sr,"isAuthoredDocument");var se=class t{static{c(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=fe;authoredDeclarations=!1;streamCandidates;get valueContext(){if(this.sourceOptions.numericMode==="exact")return this;let e=new t(this.reader,this.path,this.languages);return e.sourceOptions=this.sourceOptions,e}constructor(e,n,i=new Set(["csharp","typescript","react","html","sql"])){this.reader=e,this.path=n,this.languages=i}get start(){return Fe(1,1,this.path)}get diagnostics(){return this.nestedNumericDirectives.size>0&&this.sourceOptions.numericMode!=="legacy"&&this.reader.atEnd&&(this.#e.push(...[...this.nestedNumericDirectives].sort((e,n)=>e[0]-n[0]).map(e=>e[1])),this.nestedNumericDirectives.clear()),this.#e}nestedNumericDirectives=new Map;claimField(e){this.nestedNumericDirectives.delete(e.number)}information(e,n,i){this.#e.push({severity:"information",code:e,message:n,location:i})}error(e,n,i){this.#e.push({severity:"error",code:e,message:n,location:i})}warning(e,n,i){this.#e.push({severity:"warning",code:e,message:n,location:i})}peekChild(e){let n=this.reader.peekSignificant();return n!==void 0&&n.indent>e?n:void 0}skipBlock(e){for(;this.peekChild(e)!==void 0;)this.reader.takeSignificant()}skipOpaqueBlock(e){let n=this.peekChild(e);for(;n!==void 0;)this.reader.takeSignificant(),n.content.startsWith("```")&&this.skipFencedBody(),n=this.peekChild(e)}skipFencedBody(){for(let e=this.reader.takeRaw();e!==void 0;e=this.reader.takeRaw())if(e.raw.trim()==="```")return}};var jt=new WeakMap;var De=new WeakMap,pt=c(t=>De.get(t)??{},"dependencySourcesOf");function Nt(t){let e=C(`^reads${X}+([A-Z]\\w*)(?:${X}+as${X}+([a-z_]\\w*))?(?:${X}+by${X}+([a-z_]\\w*))?$`).exec(t.content);if(!(e===null||["as","by","reads"].includes(e[2])))return{kind:"ReadsSyntax",readModel:e[1],alias:e[2]??null,by:e[3]??null,location:d(t)}}c(Nt,"captureReads");function cr(t){return new se(t.reader.fork(),t.path,t.languages)}c(cr,"fork");function lr(t,e){if(e.content!=="concurrency")return;let n=cr(t),i=!1,r={},o;for(let a=n.peekChild(e.indent);a!==void 0;a=n.peekChild(e.indent))switch(n.reader.takeSignificant(),R(a.content)){case"eventSource":a.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let s=C(`^(sourceType|streamType|streamId)${X}+([A-Za-z_]\\w*)$`).exec(a.content);s!==null&&(r[s[1]]??=s[2]);break}case"events":{if(o!==void 0)break;let s=a.content.slice(6).split(",").map(p=>p.replace(new RegExp(`^${X}+|${X}+$`,"gu"),"")).filter(Boolean);s.length>0&&s.every(p=>C("^[A-Z]\\w*$").test(p))&&(o=s);break}default:n.skipBlock(a.indent);break}return{kind:"ConcurrencySyntax",eventSource:i,eventSourceType:r.sourceType??null,eventStreamType:r.streamType??null,eventStreamId:r.streamId??null,eventTypes:o??[],location:d(e)}}c(lr,"captureConcurrency");function dr(t,e){let n=C(`^reducer${X}+([A-Za-z_]\\w*)${X}*=>${X}*([A-Za-z_]\\w*)$`).exec(e.content),i=cr(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),R(o.content)==="description"){Q(i,o,null,"Reducer");continue}let a=C(`^on${X}+([A-Z]\\w*)$`).exec(o.content);a!==null&&r.push({kind:"ReducerRuleSyntax",event:a[1],file:null,code:null,description:null,location:d(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:d(e)}}c(dr,"captureReducer");var Ia=C("^system\\s+([A-Za-z_]\\w*)$"),Ra=C("^operation\\s+([A-Za-z_]\\w*)$"),Ta=C("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),Ln=C("^uses\\s+([A-Za-z_]\\w*)$"),Ma=C("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Da=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function ft(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,d(r)),t.skipBlock(e.indent))}c(ft,"rejectOperationChildren");function pr(t,e){let n=Ia.exec(e.content);n===null&&t.error(l.InvalidSystemDeclaration,"Expected 'system <Name>'.",d(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),R(r.content)==="description"?i=Q(t,r,i,`System '${n?.[1]??""}'`):(t.error(l.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",d(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:d(e)}}c(pr,"parseSystem");function Lt(t,e,n=!1){let i=(n?Ta:Ra).exec(e.content),r=i?.[1]??"";i===null&&t.error(l.InvalidOperationDeclaration,"Expected an operation declaration with one name.",d(e));let o=null,a=null,s=d(e),p=null,f=null,y=[],u=[],m=new Set;for(let S=t.peekChild(e.indent);S!==void 0;S=t.peekChild(e.indent)){t.reader.takeSignificant();let v=Ma.exec(S.content),g=n&&v!==null?{...S,content:v[1].trimEnd()}:S;if(v===null&&Da.has(R(S.content))){t.error(l.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",d(S)),t.skipBlock(S.indent);continue}if(!Ln.test(S.content)&&Me(g)!==void 0){let P=ve(t,g);n&&v===null&&t.error(l.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",d(S)),(P.isIdentifier||P.isGenerated)&&t.error(l.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",d(S)),m.has(P.name)&&t.error(l.DuplicateDeclaration,`Operation '${r}' already declares input '${P.name}'.`,d(S)),m.add(P.name),y.push(P),n&&v!==null&&u.push({kind:"PropertyMappingSyntax",property:P.name,source:ee(v[2],{...d(S),column:S.indent+S.content.length-v[2].length+1},t),location:d(S)}),ft(t,S,l.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(R(S.content)==="description")o=Q(t,S,o,`Operation '${r}'`);else if(Ln.test(S.content))a!==null?t.error(l.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",d(S)):(a=Ln.exec(S.content)[1],s={...d(S),column:d(S).column+S.content.indexOf(a,4)}),ft(t,S,l.InvalidSystemReference,"A system reference cannot have children.");else if(S.content==="execute"||S.content==="compensate"){let P=ja(t,S);S.content==="execute"?p!==null?t.error(l.InvalidOperationDeclaration,"An operation declares execute at most once.",d(S)):p=P:f!==null?t.error(l.InvalidOperationDeclaration,"An operation declares compensate at most once.",d(S)):f=P}else t.error(l.InvalidOperationDeclaration,`Unexpected '${S.content}' in operation - expected uses, an input, description, execute or compensate.`,d(S)),t.skipBlock(S.indent)}return a===null&&t.error(l.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",d(e)),{operation:{kind:"OperationSyntax",name:r,uses:a??"",usesLocation:s,inputs:y,description:o,execute:p,compensate:f,location:d(e)},mappings:u}}c(Lt,"parseOperation");function ja(t,e){let n=null,i=null,r=null,o=null,a=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){if(t.reader.takeSignificant(),R(s.content)==="description"){n=Q(t,s,n,`Operation phase '${e.content}'`);continue}if(R(s.content)==="implementation"){a&&t.error(l.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",d(s));let p=dt(t,s);a||(i=p.file,r=p.code,o=p.implementation),a=!0}else if(te(s)||s.content.startsWith("```")){a&&t.error(l.ConflictingImplementationSources,"A phase has at most one file or inline payload.",d(s));let p=te(s)?we(t,s):null,f=p===null?pe(t,s):null;a||(i=p,r=f),a=!0,p!==null&&ft(t,s,l.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(l.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",d(s)),t.skipBlock(s.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:d(e)}}c(ja,"parseOperationPhase");var Na=C("^produces\\s+operation(?:\\s|$)"),La=C("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),qa=C("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),fr=C("^produces\\s+when\\s+(.+)$"),Ba=C("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Fa=C("^for\\s+(\\S.*)$"),Ya=C("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Wa=C("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Ua=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function qt(t,e,n=!1){if(Na.test(e.content)){if(!n){t.error(l.OperationOutsideCommand,"Operations can only be produced by commands.",d(e)),t.skipOpaqueBlock(e.indent);return}let v=Lt(t,e,!0);return{kind:"ProducesSyntax",when:null,event:v.operation.name,targetLocation:{...d(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:v.operation,mappings:v.mappings,for:null,tags:[],location:d(e)}}let i=La.exec(e.content),r=e,o=null,a,s;if(i!==null){if(!n){t.error(l.InlineEventOutsideCommand,"Inline events can only be declared inside commands",d(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(l.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",d(e)),a=i[1],s=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(fr.test(e.content)){o=ze(t,fr.exec(e.content)[1],d(e));let v=t.peekChild(e.indent);if(v===void 0||!Ba.test(v.content)){t.error(l.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",d(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=v,a=v.content,s=v.indent+1}else{let v=qa.exec(e.content);if(v===null){t.error(l.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,d(e)),t.skipOpaqueBlock(e.indent);return}a=v[1],s=e.indent+e.content.match(/^produces\s+/)[0].length+1}let p=[],f=new Set,y=[],u=[],m=new Ue(a),S=null;for(let v=t.peekChild(r.indent);v!==void 0;v=t.peekChild(r.indent)){t.reader.takeSignificant();let g=R(v.content),P=d(v);if(Ua.has(g)){t.error(l.ReservedProductionMetadata,`'${g}' is system-assigned production metadata and cannot be supplied here`,P),t.skipOpaqueBlock(v.indent);continue}if(i!==null&&(g==="generation"||g==="origin")){t.error(g==="generation"?l.InlineEventGeneration:l.ReservedProductionMetadata,g==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",P),t.skipOpaqueBlock(v.indent);continue}if(g==="tag"){let h=ct(t,v,!1);h!==void 0&&u.push(h);continue}let b=Fa.exec(v.content);if(b!==null){S!==null?t.error(l.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,P):S=ee(b[1],P,t);continue}let O=(i===null?Ya:Wa).exec(v.content),k=O===null||i===null?void 0:ve(t,{...v,content:O[1].trimEnd()});if(O!==null&&(i===null||k!==void 0)){if(k!==void 0){k.isIdentifier&&(t.error(l.IdentifierOnEventProperty,`Property '${k.name}' of event '${a}' cannot be marked identifier - an event never carries its event source id`,P),k={...k,isIdentifier:!1});let h=k.name;f.has(h)&&t.error(l.DuplicateDeclaration,`Event '${a}' already declares property '${k.name}'`,P),f.add(h),p.push(k)}y.push({kind:"PropertyMappingSyntax",property:k?.name??Z(O[1]),source:ee(O[2],{...P,column:v.indent+v.content.length-O[2].length+1},t),location:P})}else(i===null||!m.tryParse(t,v))&&t.error(l.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${v.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,P)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:a,targetLocation:{...d(r),column:s},inlineOperation:null,mappings:y,for:S,tags:i===null?u:[],location:d(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:a,properties:p,tags:u,generation:1,hasGenerationMarker:!1,...m.value,location:d(e)}}}c(qt,"parseProduces");var za=C("^command\\s+([A-Za-z_]\\w*)$"),Va=de("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Qa=C("\\bseverity\\s+(\\S+)$"),yr=C(`\\bmessage\\s+(?:"(${U})"|(\\$strings\\.\\S*))$`),Za=C("^([\\w.]+)\\s+(.+)$"),Ga=C("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),Ka=de("^[A-Za-z_]\\w*$"),_a=C("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),Ja={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},mr={information:"Information",warning:"Warning",error:"Error"},Ha=new Set(["reads","concurrency"]),Xa=new Set(["description","handler","concurrency"]);function Sr(t,e){let n=new Set,i=new se(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,ur(i,e,void 0,n),ur(t,e,n)}c(Sr,"parseCommand");function ur(t,e,n,i){let r=za.exec(e.content)?.[1]??"";r===""&&t.error(l.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,d(e));let o=[],a=[],s,p=[],f=[],y=[],u=[],m,S=null,v=null,g=null,P=null,b=[];for(let $=t.peekChild(e.indent);$!==void 0;$=t.peekChild(e.indent)){t.reader.takeSignificant();let w=R($.content),A=Me($);if(A!==void 0&&(Xa.has(w)||w==="validate"&&$.content!=="validate csharp"))s=Bt(t,o,A,r,$,s);else if(w==="returns"){let M=Dn.exec($.content);M!==null&&!M[1].startsWith("@")&&A!==void 0?n===void 0?(o.push(A),a.push({line:$,candidate:A,response:null})):n.has(A.type.name)?a.push({line:$,candidate:null,response:jn(t,$)}):s=Bt(t,o,A,r,$,s):A!==void 0?s=Bt(t,o,A,r,$,s):It(t,$)?t.skipBlock($.indent):a.push({line:$,candidate:null,response:jn(t,$)})}else if(w==="stream"&&Va.test($.content)&&A!==void 0&&t.streamCandidates?.hasSource(A.type.name.split(".")[0])===!0){let[M,L]=A.type.name.split("."),q=t.streamCandidates.hasPropertyType(A.type.name)&&t.streamCandidates.hasUniqueStream(M,L),Y=tr(t,$,A,q);(P!==null||b.length>0)&&t.error(l.InvalidCommandStream,"A command declares at most one stream route.",d($)),q||P!==null?b.push(Y):P=Y}else if(w==="description")S=Q(t,$,S,`Command '${r}'`);else if(w==="authorize")v=$e(v,Ae(t,$));else if(w==="validate"){let M=qn(t,$,"command");M!==void 0&&p.push(M)}else if(w==="produces"){let M=qt(t,$,!0);M!==void 0&&f.push(M)}else if(w==="handler")g=ir(t,$);else if(Ha.has(w)){let M=Nt($);M!==void 0&&u.push(M),w==="concurrency"&&m===void 0&&(m=lr(t,$));let L=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec($.content);L!==null&&y.push({readModel:L[1],alias:L[2]??null}),_a.test($.content)&&t.error(l.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",d($)),t.skipOpaqueBlock($.indent)}else A!==void 0?s=Bt(t,o,A,r,$,s):(It(t,$),t.error(l.UnknownCommandDirective,`Unexpected '${$.content}' in command body`,d($)),t.skipBlock($.indent))}let O=new Set(a.flatMap($=>$.candidate===null?[]:[$.candidate])),k=new Set(o.filter($=>!O.has($)).map($=>$.name));a.some($=>$.candidate!==null&&!k.has($.candidate.type.name)&&$.candidate.type.name!=="returns")&&k.add("returns");for(let $ of k)i?.add($);let h=null,x=new Set;for(let $ of a){let w=$.response;if($.candidate!==null){if(!k.has($.candidate.type.name))continue;x.add($.candidate),w={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:$.candidate.type.name,location:$.candidate.type.location},location:d($.line)}}w!==null&&(h!==null?t.error(l.InvalidCommandResponse,"A command declares at most one unconditional response.",d($.line)):h=w)}g!==null&&f.length>0&&t.error(l.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,d(e));let E={kind:"CommandSyntax",name:r,description:S,authorize:v,properties:o.filter($=>!x.has($)),validations:p,produces:f,handler:g,response:h,stream:P,streamCandidates:b,location:d(e)};return jt.set(E,y),De.set(E,{reads:u,concurrency:m}),E}c(ur,"parseCommandBody");function Bt(t,e,n,i,r,o){return ke(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(l.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,n.location),n={...n,isIdentifier:!1}),e.push(n),o??(n.isIdentifier?n:void 0)}c(Bt,"addProperty");function qn(t,e,n){if(e.content==="validate"){let i=t.peekChild(e.indent);if(i!==void 0&&i.content.startsWith("```")){t.reader.takeSignificant();let s=pe(t.valueContext,i);return s===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:s,location:d(e)}}let r=[],o=[],a;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&s.content.startsWith("```")){t.skipFencedBody();continue}if(a!==void 0&&s.indent<=a&&(a=void 0),a!==void 0||R(s.content)==="implementation"){t.error(l.InvalidValidationRule,`Invalid validation rule '${s.content}'`,d(s)),a??=s.indent;continue}}if(R(s.content)==="require"){let f=ze(n==="concept"?t.valueContext:t,s.content.substring(7).trim(),d(s)),y=null,u="Error",m=!1;for(let S=t.peekChild(s.indent);S!==void 0;S=t.peekChild(s.indent)){t.reader.takeSignificant();let v=yr.exec(S.content);v!==null&&v.index===0?y=v[1]!==void 0?V(v[1]):v[2]:R(S.content)==="severity"?(m||(u=mr[S.content.substring(8).trim()]??"Error"),m=!0):t.skipOpaqueBlock(S.indent)}f!==null&&o.push({kind:"RequirementSyntax",condition:f,message:y,severity:u,location:d(s)});continue}let p=es(t,n==="concept"?{...s,content:`value ${s.content}`}:s,n);p!==void 0&&r.push(p)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:d(e)}}if(e.content==="validate csharp"){let i=pe(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:d(e)}}t.error(l.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,d(e)),t.skipBlock(e.indent)}c(qn,"parseValidate");function es(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=ns(e.content),a=is(i,e,r);if(a===void 0)return;let s=Za.exec(a.content);if(s===null){i.error(l.InvalidValidationRule,`Invalid validation rule '${e.content}'`,d(e));return}let p=rs(i,s[2],e);if(p===void 0)return;let f=p.kind==="Rule"?ts(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:s[1],rule:p.kind,value:p.value,message:o,severity:a.severity,...f,location:d(e)}}c(es,"parseValidationRule");function ts(t,e,n){let i=t.peekChild(e.indent);if(i===void 0)return{file:null,code:null,implementation:null};t.reader.takeSignificant();let r=n&&R(i.content)==="implementation",o=r?dt(t,i):{file:Qe(i)?we(t,i):null,code:!Qe(i)&<(t,i)?pe(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(l.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,d(i)),t.skipBlock(i.indent));for(let a=t.peekChild(e.indent);a!==void 0&&(r||n&&R(a.content)==="implementation");a=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&R(a.content)==="implementation"?l.InvalidImplementationBlock:l.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",d(a)),lt(t,a)?pe(t,a):t.skipBlock(a.indent);return o}c(ts,"parseRuleImplementation");function ns(t){let e=yr.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?V(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}c(ns,"splitMessage");function is(t,e,n){let i=Qa.exec(n);if(i===null)return{content:n,severity:"Error"};let r=mr[i[1]];if(r===void 0){t.error(l.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,d(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}c(is,"splitSeverity");function rs(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Ga.exec(e);if(i===null){t.error(l.InvalidValidationRule,`Invalid validation rule '${n.content}'`,d(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!Ka.test(r)){t.error(l.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,d(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:d(n)}}}return{kind:Ja[i[1]],value:ee(i[2],d(n),t)}}c(rs,"parseRule");var os=C("^constraint\\s+([A-Za-z_]\\w*)$"),as=C("^unique\\s+event\\s+([A-Z]\\w*)$"),ss=C("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),cs=C("^released\\s+by\\s+([A-Z]\\w*)$"),ls=C(`^message\\s+"(${U})"$`),ds=c(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function hr(t,e){let n=os.exec(e.content);n===null&&t.error(l.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,d(e));let i=n?.[1]??R(e.content),r=[],o=[],a=new Set,s=new Set,p=null,f=!1;for(let y=t.peekChild(e.indent);y!==void 0;y=t.peekChild(e.indent)){t.reader.takeSignificant();let u=cs.exec(y.content),m=ls.exec(y.content);u!==null?a.has(u[1])?t.error(l.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${u[1]}'`,d(y)):(o.push(u[1]),a.add(u[1])):m!==null?p!==null?t.error(l.DuplicateConstraintBody,`Constraint '${i}' already has a message`,d(y)):p=V(m[1]):y.content==="ignore casing"?(f&&t.error(l.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,d(y)),f=!0):ps(t,i,y,r,s)}for(let y of o.filter(u=>s.has(u)))t.error(l.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${y}'`,d(e));return r.length===0&&(t.error(l.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,d(e)),r.push(Ft(i,d(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||p!==null||f)&&t.error(l.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,d(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:p,ignoreCasing:f}}c(hr,"parseConstraint");function ps(t,e,n,i,r){let o=fs(t,e,n);if(o===void 0)return;if(i.length>0&&(o.kind==="FileConstraintSyntax"||i[0].kind==="FileConstraintSyntax"||o.kind==="UniqueEventConstraintSyntax"!=(i[0].kind==="UniqueEventConstraintSyntax"))){t.error(l.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,d(n));return}let a=ds(o);if(a!==void 0&&r.has(a)){t.error(l.DuplicateConstraintBody,`Constraint '${e}' already targets event '${a}'`,d(n));return}a!==void 0&&r.add(a),i.push(o)}c(ps,"addRule");function fs(t,e,n){let i=d(n),r=as.exec(n.content);if(r!==null)return Ft(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=ss.exec(n.content);if(o!==null){let a=o[1].split(",").map(s=>s.trim());if(new Set(a).size!==a.length){t.error(l.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return Ft(e,i,{kind:"UniquePropertyConstraintSyntax",property:a[0],additionalProperties:a.slice(1),event:o[2]})}if(te(n)){t.warning(l.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 a=n.content.substring(4).trim();return Ft(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:a,location:i}})}t.error(l.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}c(fs,"parseRule");function Ft(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}c(Ft,"rule");var us=C("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),ys=C("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),ms=C("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),Ss=C("^with\\s+(@?[\\w.]+)$"),hs=C("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),gs=C("^nested\\s+(@?[\\w.]+)$"),xs=C("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),$s=C("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),vs=C("^clear\\s+with\\s+(@?[\\w.]+)$"),ks=C("^variant\\s+(@?[\\w.]+)\\s*$"),bs=C("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Cs=C("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),Es=C("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),Ps=C("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),gr=C("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),Os={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function Fn(t,e){let n=us.exec(e.content);if(n===null)return t.error(l.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,d(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:R(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:d(e)};let i=n[1],r=null,o="Inherit",a=null,s=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),te(p))continue;let f=R(p.content);if(f==="sequence")r=p.content.substring(8).trim();else if(f==="automap")o="Enabled";else if(p.content==="no automap")o="Disabled";else if(f==="key")a=$r(t,p);else if(f==="variant")s.push(js(t,p));else{let y=Yn(t,p,!1);y!==void 0&&s.push(y)}}return As(t,s,i),s.length===0&&t.error(l.EmptyProjection,`Projection '${i}' must contain at least one directive`,d(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:o,key:a,blocks:s,location:d(e)}}c(Fn,"parseProjection");function As(t,e,n){let i=e.filter(a=>a.kind==="ProjectionVariantSyntax"),r=new Map;i.forEach(a=>r.set(a.name,[...r.get(a.name)??[],a]));for(let a of[...r.values()].flatMap(s=>s.slice(1)))t.error(l.DuplicateProjectionVariant,`Duplicate variant '${a.name}' - a variant name is declared once`,a.location);let o=new Set;for(let a of e.flatMap(s=>s.kind==="ProjectionVariantSyntax"?s.entersOn:[]))a.event.length>0&&o.has(a.event)&&t.error(l.DuplicateVariantEnteringEvent,`Entering event '${a.event}' is claimed more than once in projection '${n}'`,a.location),o.add(a.event)}c(As,"reportVariantConflicts");function Yn(t,e,n){let i=d(e);switch(R(e.content)){case"from":return ws(t,e);case"every":{let r=!0,{autoMap:o,mappings:a}=Bn(t,e,s=>s.content!=="exclude children"?!1:(r=!1,!0));return{kind:"EverySyntax",includeChildren:r,autoMap:o,mappings:a,location:i}}case"all":{let{autoMap:r,mappings:o}=Bn(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return Is(t,e);case"children":return Rs(t,e);case"nested":return Ts(t,e);case"remove":return Ms(t,e);case"clear":return n||t.error(l.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),Ds(t,e);default:t.error(l.UnknownProjectionDirective,`Unexpected '${R(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}c(Yn,"parseBlock");function ws(t,e){let n=[];for(let a of ji(e.content.substring(4),",")){let s=a.trim();if(s.length===0){t.error(l.FromWithoutEvent,"Expected an event type after 'from'",d(e));continue}let p=ys.exec(s);if(p===null){t.error(l.InvalidEventReference,`Invalid event reference '${s}'`,d(e));continue}n.push({kind:"EventSpecSyntax",event:Z(p[1]),key:p[2]===void 0?null:ie(p[2],d(e),t),location:d(e)})}let i=[],r=null,o=null;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let s=R(a.content);s==="key"?r=$r(t,a):s==="parent"?o=ie(a.content.substring(6),d(a),t):vr(t,a,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:d(e)}}c(ws,"parseFrom");function Is(t,e){let n=ms.exec(e.content);if(n===null)return t.error(l.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,d(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:d(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Ss.exec(r.content);if(o===null){t.error(l.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,d(r)),t.skipBlock(r.indent);continue}let{autoMap:a,mappings:s}=Bn(t,r);i.push({kind:"JoinEventSyntax",event:Z(o[1]),autoMap:a,mappings:s,location:d(r)})}return{kind:"JoinSyntax",property:Z(n[1]),on:Z(n[2]),events:i,location:d(e)}}c(Is,"parseJoin");function Rs(t,e){let n=hs.exec(e.content);if(n===null)return t.error(l.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,d(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:d(e)};let{autoMap:i,blocks:r}=xr(t,e);return{kind:"ChildrenSyntax",property:Z(n[1]),identifiedBy:ie(n[2],d(e),t),autoMap:i,blocks:r,location:d(e)}}c(Rs,"parseChildren");function Ts(t,e){let n=gs.exec(e.content);if(n===null)return t.error(l.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,d(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:d(e)};let i=Z(n[1]),{autoMap:r,blocks:o}=xr(t,e);return o.some(a=>a.kind==="FromSyntax")||t.error(l.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,d(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:d(e)}}c(Ts,"parseNested");function xr(t,e){let n=[],i="Inherit";for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r.content==="automap"){i="Enabled";continue}if(r.content==="no automap"){i="Disabled";continue}let o=Yn(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}c(xr,"parseChildBlocks");function Ms(t,e){let n=$s.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:Z(n[1]),key:n[2]===void 0?null:ie(n[2],d(e),t),location:d(e)};let i=xs.exec(e.content);if(i===null){t.error(l.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,d(e)),t.skipBlock(e.indent);return}let r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),R(o.content)==="parent"?r=ie(o.content.substring(6),d(o),t):t.error(l.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,d(o));return{kind:"RemoveWithSyntax",event:Z(i[1]),key:i[2]===void 0?null:ie(i[2],d(e),t),parentKey:r,location:d(e)}}c(Ms,"parseRemove");function Ds(t,e){let n=vs.exec(e.content);return n===null?(t.error(l.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,d(e)),{kind:"ClearWithSyntax",event:"",location:d(e)}):{kind:"ClearWithSyntax",event:Z(n[1]),location:d(e)}}c(Ds,"parseClearWith");function js(t,e){let n=ks.exec(e.content);if(n===null)return t.error(l.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,d(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:R(e.content),entersOn:[],blocks:[],location:d(e)};let i=Z(n[1]),r=[],o=[];for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let s=R(a.content);if(s==="enters")r.push(Ns(t,a));else if(s==="variant")t.error(l.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",d(a)),t.skipBlock(a.indent);else{let p=Yn(t,a,!1);p!==void 0&&o.push(p)}}return r.length===0&&t.error(l.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,d(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:d(e)}}c(js,"parseVariant");function Ns(t,e){let n=bs.exec(e.content);return n===null?(t.error(l.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,d(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:d(e)}):{kind:"ProjectionEntersOnSyntax",event:Z(n[1]),key:n[2]===void 0?null:ie(n[2],d(e),t),location:d(e)}}c(Ns,"parseEntersOn");function $r(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:ie(n,d(e),t),location:d(e)};let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),o.content==="}")continue;let a=gr.exec(o.content);if(a===null){t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,d(o));continue}let s=ie(a[2],d(o),t);t.sourceOptions.numericMode==="exact"&&s.kind==="TemplateExpressionSyntax"&&t.error(l.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",d(o)),i.push({kind:"KeyPartSyntax",property:Z(a[1]),expression:s,location:d(o)})}let r=t.reader.peekSignificant();return r!==void 0&&r.indent===e.indent&&r.content==="}"&&t.reader.takeSignificant(),t.sourceOptions.numericMode==="exact"&&i.length===0&&t.error(l.EmptyCompositeKey,"Composite keys must contain at least one part",d(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:d(e)}}c($r,"parseKey");function Bn(t,e,n=()=>!1){let i="Inherit",r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),o.content==="automap"?i="Enabled":o.content==="no automap"?i="Disabled":n(o)||vr(t,o,r);return{autoMap:i,mappings:r}}c(Bn,"parseMappingBlock");function vr(t,e,n){let i=d(e),r=Cs.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:Os[r[1]],property:Z(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidProjectionMapping,`Invalid mapping '${e.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,i);return}let o=Es.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:Z(o[2]),value:ie(o[3],i,t),location:i});return}let a=Ps.exec(e.content)??gr.exec(e.content);a!==null?n.push({kind:"SetMappingSyntax",property:Z(a[1]),source:ie(a[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}c(vr,"pushMapping");var Ls=C("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),qs=C("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),Bs=C("^scoped\\s+to\\s+([a-z_]\\w*)$"),Fs=new Set(["performer"]);function br(t,e){let n=Ls.exec(e.content);if(n===null)return t.error(l.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,d(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:R(e.content),returnType:me("",d(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:d(e)};let i=n[1],r=me(n[3],{...d(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||ke(t,r,e);let o=null,a=[],s=null,p=null,f=null;for(let y=t.peekChild(e.indent);y!==void 0;y=t.peekChild(e.indent)){t.reader.takeSignificant();let u=R(y.content);if(u==="description")s=Q(t,y,s,`Query '${i}'`);else if(u==="by"){let m=kr(t,y,"by");m!==void 0&&(o!==null&&t.error(l.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,d(y)),o=m)}else if(u==="filter"){let m=kr(t,y,"filter");m!==void 0&&a.push(m)}else u==="authorize"?f=$e(f,Ae(t,y)):u==="scoped"?p=Ys(t,y,p,i)??p:Fs.has(u)?t.skipOpaqueBlock(y.indent):(t.error(l.UnknownQueryDirective,`Unexpected '${y.content}' in query body - expected description, by, filter, authorize, scoped or performer`,d(y)),t.skipBlock(y.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:a,description:s,isObservable:n[2]!==void 0,scope:p,authorize:f,location:d(e)}}c(br,"parseQuery");function kr(t,e,n){let i=qs.exec(e.content.substring(n.length).trim());if(i===null){t.error(l.InvalidQueryParameter,`Invalid '${n}' parameter '${e.content}' - expected '${n} <name> <Type> [from <source>]'`,d(e));return}let r=e.content.indexOf(i[1],n.length),o=me(i[2],{...d(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return ke(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ee(i[3],d(e),t.valueContext),location:d(e)}}c(kr,"parseParameter");function Ys(t,e,n,i){let r=Bs.exec(e.content);if(r===null){t.error(l.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,d(e));return}if(n!==null){t.error(l.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,d(e));return}return r[1]}c(Ys,"parseScope");var Ws=C("^@?[a-z_]\\w*\\s+[\\w.]+");function Wn(t,e){let n=ve(t,e);if(n!==void 0){n.isGenerated&&t.error(l.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),t.triggerData.push(n);return}Ws.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(l.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,d(e)),t.skipOpaqueBlock(e.indent)}c(Wn,"parseTriggerData");function Cr(t,e){let n=t.triggerData.length;for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),R(i.content)==="description"?Q(t,i,null,`Trigger '${e.content}'`):te(i)||Wn(t,i);return t.triggerData.slice(n)}c(Cr,"parseTriggerDeclaration");var Us=C("^reaction\\s+([A-Za-z_]\\w*)$"),zs=C("^when\\s+([A-Za-z_]\\w*)$"),Vs=C("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Qs=C("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),Zs=new Set(["when","every","at"]),Gs=C("^invokes\\s+([A-Z]\\w*)$"),Ks=G("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),_s=C("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function Er(t,e){let n=Us.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,d(e));let i=null,r=null,o=[],a=new Set,s=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let f=R(p.content);if(f==="description"){i=Q(t,p,i,`Reaction '${n}'`);continue}if(f==="where"){r=ze(t,p.content.substring(5).trim(),d(p));continue}if(!Zs.has(f)){t.error(l.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${p.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,d(p)),t.skipBlock(p.indent),s=!0;continue}let y=Xs(t,p);if(y===void 0){s=!0;continue}let u=Hs(y);if(a.has(u)){t.error(l.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,d(p)),t.skipBlock(p.indent);continue}a.add(u),o.push(Js(t,p,y))}return o.length===0&&!s&&t.error(l.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,d(e)),{kind:"ReactionSyntax",name:n,description:i,where:r,triggers:o,location:d(e)}}c(Er,"parseReaction");function Js(t,e,n){let i=null,r=[],o=[],a=[],s=[];for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){t.reader.takeSignificant();let y=R(f.content);if(y==="description")i=Q(t,f,i,`Trigger '${f.content}'`);else if(y==="produces"){let u=qt(t,f);u!==void 0&&r.push(u)}else if(y==="invokes"){let u=Gs.exec(f.content);if(u===null)t.error(l.InvalidInvokesDeclaration,`Invalid invokes declaration '${f.content}' - expected 'invokes <Command>'`,d(f)),t.skipBlock(f.indent);else{let m=new se(t.reader.fork(),t.path,t.languages);m.scope=t.scope,m.sourceOptions=t.sourceOptions,ye(m,f),t.inputUses.push(...m.inputUses);let S=[];for(let v=t.peekChild(f.indent);v!==void 0;v=t.peekChild(f.indent)){t.reader.takeSignificant();let g=Ks.exec(v.content);g!==null?S.push({kind:"PropertyMappingSyntax",property:g[1].replaceAll("@",""),source:le(g[2],d(v),t.valueContext),location:d(v)}):t.skipOpaqueBlock(v.indent)}o.push({kind:"InvokesSyntax",command:u[1],mappings:S,location:d(f)})}}else if(y==="reads"||y==="file"||f.content==="csharp"||f.content.startsWith("```")){let u=Nt(f);u!==void 0&&a.push(u),_s.test(f.content)&&t.error(l.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",d(f)),f.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(f.indent)}else{let u=t.triggerData.length;Wn(t,f);for(let m of t.triggerData.slice(u))s.push({kind:"TriggerDataSyntax",name:m.name,type:m.type,location:m.location})}}let p={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:d(e)};return De.set(p,{reads:a,data:s}),p}c(Js,"parseTrigger");function Hs(t){switch(t.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([t.kind,t.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([t.kind,t.amount,t.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([t.kind,t.time,t.dayOfWeek,t.dayOfMonth])}}c(Hs,"sourceKey");function Xs(t,e){let n=d(e);switch(R(e.content)){case"when":{let i=zs.exec(e.content);if(i===null){t.error(l.InvalidReactionTrigger,`Invalid trigger '${e.content}' - expected 'when <Name>'`,n),t.skipBlock(e.indent);return}return{kind:"NamedTriggerSourceSyntax",name:i[1],location:n}}case"every":{let i=Vs.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(l.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:nc(i[2]),location:n}}default:return ec(t,e)}}c(Xs,"parseTriggerSource");function ec(t,e){let n=d(e),i=Qs.exec(e.content),r=i===null?void 0:tc(i[1]);if(i===null||r===void 0){t.error(l.InvalidScheduleTrigger,`Invalid schedule '${e.content}' - expected 'at <HH:mm>', optionally followed by 'on <Weekday>' or 'on day <n>'`,n),t.skipBlock(e.indent);return}if(i[3]!==void 0){let o=Number(i[3]);if(o<1||o>31){t.error(l.InvalidScheduleTrigger,`Invalid day of month '${o}' in '${e.content}' - a day of the month is between 1 and 31`,n),t.skipBlock(e.indent);return}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:null,dayOfMonth:o,location:n}}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:i[2]??null,dayOfMonth:null,location:n}}c(ec,"parseSchedule");function tc(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}c(tc,"timeOf");function nc(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}c(nc,"unitOf");var Yt=`(?:"(${U})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,ic=C("^screen\\s+([A-Za-z_]\\w*)$"),rc=C("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),oc=C("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),ac=C(`^label\\s+${Yt}$`),sc=C("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),cc=C("^[a-z_]\\w*$"),lc=C(`^title\\s+${Yt}$`),dc=C(`^column\\s+([\\w.]+)(?:\\s+label\\s+${Yt})?$`),pc=C("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),fc=C(`^field\\s+([\\w.]+)\\s+label\\s+${Yt}$`),Wt=c((t,e)=>t[e]!==void 0?V(t[e]):t[e+1],"operandText"),uc=c(t=>["on","uses"].includes(R(t.content)),"isInteraction"),yc=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function Pr(t,e){let n=ic.exec(e.content);n===null&&t.error(l.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,d(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),te(r)||Or(t,r,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,location:d(e)}}c(Pr,"parseScreen");function Or(t,e,n){let i=mc(t,e);i!==void 0&&n.push(i)}c(Or,"pushDirective");function Ar(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),Or(t,i,n);return n}c(Ar,"parseDirectives");function mc(t,e){switch(R(e.content)){case"data":return Sc(t,e);case"action":return hc(t,e);case"template":return gc(t,e);case"section":return xc(t,e);case"title":return $c(t,e);case"table":return vc(t,e);case"summary":return kc(t,e);case"navigate":return Un(t,e.content,e);case"on":return ye(t,e),{kind:"ScreenBehaviorSyntax",location:d(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:d(e)};default:if(yc(t,e))return bc(t,e);t.error(l.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,d(e)),t.skipBlock(e.indent);return}}c(mc,"parseDirective");function Sc(t,e){let n=rc.exec(e.content);if(n===null){t.error(l.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,d(e));return}return{kind:"ScreenDataSyntax",type:me(n[1],d(e)),query:n[2],by:n[3]??null,location:d(e)}}c(Sc,"parseData");function hc(t,e){let n=oc.exec(e.content);if(n===null){t.error(l.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,d(e)),t.skipBlock(e.indent);return}let i=null,r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let a=ac.exec(o.content);a!==null?i=Wt(a,1):R(o.content)==="navigate"?r=Un(t,o.content,o)??null:t.error(l.UnknownActionDirective,`Unexpected '${o.content}' in action - expected 'label "..."' or 'navigate to ...'`,d(o))}return{kind:"ScreenActionSyntax",command:n[1],label:i,navigate:r,location:d(e)}}c(hc,"parseAction");function Un(t,e,n){let i=sc.exec(e);if(i===null){t.error(l.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,d(n));return}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,location:d(n)}}c(Un,"parseNavigate");function gc(t,e){let n=e.content.substring(8).trim(),i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){if(t.reader.takeSignificant(),!cc.test(r.content)){t.error(l.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,d(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:Ar(t,r),location:d(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:d(e)}}c(gc,"parseTemplateReference");function xc(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:Ar(t,e),location:d(e)}}c(xc,"parseSection");function $c(t,e){let n=lc.exec(e.content);return n===null?(t.error(l.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,d(e)),{kind:"ScreenTitleSyntax",text:"",location:d(e)}):{kind:"ScreenTitleSyntax",text:Wt(n,1),location:d(e)}}c($c,"parseTitle");function vc(t,e){let n=e.content.substring(5).trim(),i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let a=dc.exec(o.content),s=pc.exec(o.content);if(a!==null){let p=a[2]!==void 0||a[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:a[1],label:p?Wt(a,2):null,location:d(o)})}else s!==null?r=Un(t,s[1],o)??null:R(o.content)==="on"?ye(t,o):uc(o)?t.skipOpaqueBlock(o.indent):t.error(l.UnknownTableDirective,`Unexpected '${o.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,d(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:d(e)}}c(vc,"parseTable");function kc(t,e){let n=e.content.substring(7).trim(),i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=fc.exec(r.content);if(o===null){t.error(l.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,d(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:Wt(o,2),location:d(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:d(e)}}c(kc,"parseSummary");function bc(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(l.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,d(e));return}e.content.startsWith("```")||t.warning(l.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,d(e));let i=Ye(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:d(e)},location:d(e)}}c(bc,"parseCode");var zn=C("^then\\s+returns\\b"),wr=C("^generated\\s+(?=\\S)(?![=])"),Ir=C("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Cc=C("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Ec=C(`^(?:"${U}"|'(?:[^'\\\\]|\\\\.)*')$`);function Rr(t,e,n,i){if((e.startsWith('"')||e.startsWith("'"))&&!Ec.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ee(e,n,t);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(r.kind)||r.kind==="LiteralExpressionSyntax"&&typeof r.value=="number"&&!Number.isFinite(r.value)?(t.error(i,"Expected exactly one concrete literal or structured value, not an expression.",n),null):r}c(Rr,"parseConcrete");function Ut(t,e,n,i){let r=n.exec(e.content);if(r===null)return t.error(i,"Expected a named fixture or assertion with exactly one concrete value.",d(e)),t.skipBlock(e.indent),null;let o=d(e),a=Rr(t,r[2],{...o,column:o.column+e.content.indexOf(r[2],e.content.indexOf("=")+1)},i),s=t.peekChild(e.indent);return s!==void 0&&(t.error(i,"A fixture or return field cannot have child directives.",d(s)),t.skipBlock(e.indent)),a===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:a,location:o}}c(Ut,"parseConcreteMapping");function Tr(t,e){let n=zn.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=d(e);if(i.length>0){let a=Rr(t,i,{...r,column:r.column+e.content.indexOf(i,n)},l.InvalidReturnExpectation),s=t.peekChild(e.indent);return s!==void 0&&(t.error(l.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",d(s)),t.skipBlock(e.indent)),a===null?null:{kind:"ScalarSpecificationReturnSyntax",value:a,location:r}}let o=[];for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Ut(t,a,Cc,l.InvalidReturnExpectation);s!==null&&o.push(s)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}c(Tr,"parseReturn");var Pc=C("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),Oc=C("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),Ac=C("^specification\\s+([A-Za-z_]\\w*)$"),wc=C("^given\\s+([A-Z]\\w*)$"),Ic=C("^when\\s+append\\s+([A-Z]\\w*)$"),Rc=C("^when\\s+([A-Z]\\w*)$"),Tc=C("^then\\s+([A-Z]\\w*)$"),Mc=C("^then\\s+query\\b"),Mr=C("^(?:given|then)\\s+readmodel\\b"),Dc=C("^given\\s+readmodel\\s+([A-Z]\\w*)$"),jc=C("^then\\s+readmodel\\s+([A-Z]\\w*)(\\s+exactly)?$"),Dr=C("^then\\s+no\\b"),Nc=C(`^then\\s+error\\s+"(${U})"$`),Qn=C("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Lc=G("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),qc=C("^given\\s+clock\\b"),Bc=C("^given\\s+capture\\b"),Fc=C("^when\\s+clock\\b"),Yc=C("^when\\s+trigger\\b"),Wc=C("^when\\s+capture\\b"),Uc=C("^when\\s+query\\b"),zc=C("^then\\s+result\\b"),Vc=C("^then\\s+no\\s+result\\b"),Qc=C('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),Zc=C("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),Gc=C("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),Kc=C("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),_c=C("^then\\s+result(\\s+exactly)?$"),jr=G("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Jc=G(`^(?:"${U}"|'(?:[^'\\\\]|\\\\.)*')$`),Hc=G("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function Zn(t,e){let n=Ac.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,d(e));let i={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],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,givenCaller:null,thenReturns:null};for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),te(a)||Xc(t,a,i))continue;let s=Dr.test(a.content)?"then":R(a.content);s==="given"?el(t,a,i):s==="when"?rl(t,a,i,n):s==="then"?ol(t,a,i):(t.error(l.UnknownSpecificationDirective,`Unexpected '${R(a.content)}' in specification body`,d(a)),t.skipBlock(a.indent))}let{whenDeclared:r,...o}=i;return{kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,...o,location:d(e)}}c(Zn,"parseSpecification");function Xc(t,e,n){if(!Pc.test(e.content))return!1;let i=Oc.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(l.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",d(e)),re(t,e.indent);else if(i[1]==="then operation"){let r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let a=Ut(t,o,Qn,l.InvalidOperationSpecification);a!==null&&r.push(a)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:d(e)})}else ft(t,e,l.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:d(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:d(e)});return!0}c(Xc,"parseOperationStep");function el(t,e,n){if(qc.test(e.content))n.givenClock!==null?(t.error(l.InvalidSpecificationClock,"A specification states its clock at most once.",d(e)),re(t,e.indent)):n.givenClock=Nr(t,e,"given");else if(Bc.test(e.content)){let i=Lr(t,e,"given");i!==null&&n.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))n.givenCaller!==null?(t.error(l.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",d(e)),t.skipBlock(e.indent)):n.givenCaller=il(t,e);else if(Mr.test(e.content)){let i=qr(t,e,Dc,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=Gn(t,e,wc,"given");i!==void 0&&n.given.push(i)}}c(el,"parseGiven");var tl=C(`^role${X}+"(${U})"$`),nl=C(`^claim${X}+"(${U})"${X}*=${X}*"(${U})"$`);function il(t,e){if(e.content!=="given caller")return t.error(l.InvalidSpecificationCaller,"Expected exactly 'given caller'.",d(e)),t.skipBlock(e.indent),null;let n=!1,i=[],r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let a=tl.exec(o.content),s=nl.exec(o.content);o.content==="authenticated"&&!n?n=!0:a!==null?i.push(V(a[1])):s!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:V(s[1]),value:V(s[2]),location:d(o)}):t.error(l.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,d(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:d(e)}}c(il,"parseCaller");function rl(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let p=n.whenAppended!==null||r?l.ConflictingSpecificationActions:l.DuplicateSpecificationWhen;t.error(p,`Specification '${i}' already declares a 'when' - a specification can have at most one`,d(e)),re(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=Gn(t,e,Ic,"when append")??null;return}if(Fc.test(e.content)){n.whenClock=Nr(t,e,"when");return}if(Yc.test(e.content)){n.whenTrigger=Vn(t,e,Zc,l.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(p,f)=>({kind:"SpecificationTriggerSyntax",trigger:p,values:f,location:d(e)}));return}if(Wc.test(e.content)){n.whenCapture=Lr(t,e,"when");return}if(Uc.test(e.content)){n.whenQuery=Vn(t,e,Kc,l.InvalidSpecificationQueryAction,"when query","when query <Query>",(p,f)=>({kind:"SpecificationWhenQuerySyntax",query:p,arguments:f,location:d(e)}));return}let o=Rc.exec(e.content);if(o===null){t.error(l.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,d(e)),re(t,e.indent);return}let a=[],s=Br(t,e,a);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...s,generatedValues:a,location:d(e)}}c(rl,"parseWhen");function ol(t,e,n){if(zn.test(e.content)){let o=Tr(t,e);n.thenReturns!==null?t.error(l.InvalidReturnExpectation,"A specification declares at most one return expectation.",d(e)):n.thenReturns=o;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||n.thenEventsInAnyOrder?t.error(l.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",d(e)):n.thenEventsInAnyOrder=!0,re(t,e.indent);return}if(zc.test(e.content)){sl(t,e,n);return}if(Vc.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(l.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",d(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:d(e)},re(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(l.InvalidSpecificationDenied,"Expected exactly 'then denied'.",d(e)),re(t,e.indent)):n.thenDenied!==null?t.error(l.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",d(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:d(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:d(e)});return}let i=Nc.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:V(i[1]),location:d(e)});return}if(R(e.content.substring(4).trim())==="error"){t.error(l.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,d(e)),re(t,e.indent);return}if(Dr.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let a=al(t,e);a!==null&&n.thenAbsentReadModels.push(a);return}let o=jr.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let a=ee(o[2].trim(),d(e),t.valueContext);(a.kind==="LiteralExpressionSyntax"||a.kind==="ObjectExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:a,location:d(e)})}t.skipOpaqueBlock(e.indent);return}if(Mc.test(e.content)){let o=t.sourceOptions.numericMode==="exact",a=c((u,m,S)=>{if(!o)return t.skipOpaqueBlock(S.indent);t.error(u,m,d(S)),t.skipBlock(S.indent)},"reject"),s=Hc.exec(e.content);if(s===null)return a(l.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let p=[],f=[],y=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))t.reader.takeSignificant(),u.content==="arguments"&&!y?p.push(...ut(t.valueContext,u,!0)):u.content==="arguments"?a(l.DuplicateSpecificationQueryArguments,`Query assertion '${s[1]}' already declares arguments`,u):u.content==="result"?f.push({kind:"SpecificationQueryResultSyntax",properties:ut(t.valueContext,u,!0),exactly:!1,location:d(u)}):a(l.UnknownSpecificationQueryDirective,`Unexpected '${R(u.content)}' in 'then query' body - expected arguments or result`,u),y||=u.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:s[1],arguments:p,results:f,exactly:s[2]!==void 0,location:d(e)});return}if(Mr.test(e.content)){let o=qr(t,e,jc,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=Gn(t,e,Tc,"then");r!==void 0&&n.thenEvents.push(r)}c(ol,"parseThen");function al(t,e){let n=jr.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(l.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,d(e)),re(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Jc.test(i)?ee(i,d(e),t.valueContext):null,a=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax");a||t.error(l.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,d(e));let s=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(l.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",d(p)),s=!0;return s||!a?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:d(e)}}c(al,"parseAbsentReadModel");function re(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}c(re,"skipBody");function Nr(t,e,n){let i=Qc.exec(e.content);return re(t,e.indent),i===null||i[1]!==n?(t.error(l.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,d(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:d(e)}}c(Nr,"parseClock");function Lr(t,e,n){return Vn(t,e,Gc,l.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:d(e)}))}c(Lr,"parseCapture");function Vn(t,e,n,i,r,o,a){let s=n.exec(e.content);return s===null?(t.error(i,`Invalid '${r}' declaration '${e.content}' - expected '${o}'`,d(e)),re(t,e.indent),null):a(s[1],ut(t,e))}c(Vn,"parseNamedStep");function sl(t,e,n){let i=_c.exec(e.content);if(i===null){t.error(l.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,d(e)),re(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:ut(t,e),exactly:i[1]!==void 0,location:d(e)})}c(sl,"parseResult");function qr(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(l.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,d(e)),re(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:ut(t,e),exactly:i==="then"&&r[2]!==void 0,location:d(e)}}c(qr,"parseReadModelStep");function Gn(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(l.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,d(e)),re(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...Br(t,e),location:d(e)}}c(Gn,"parseEventStep");function Br(t,e,n){let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&wr.test(o.content)){let s=Ut(t,o,Ir,l.InvalidGeneratedFixture);s!==null&&n.push(s);continue}let a=Qn.exec(o.content);if(a!==null)i.push(Fr(t,o,a));else if(R(o.content)==="for"){let s=o.content.substring(3).trim();s.length===0?t.error(l.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",d(o)):r!==null?t.error(l.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",d(o)):r=ee(s,d(o),t)}else t.error(l.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,d(o))}return{values:i,for:r}}c(Br,"parseValuesWithEventSource");function ut(t,e,n=!1){let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=(n||t.sourceOptions.numericMode==="exact"?Lc:Qn).exec(r.content);if(o===null){t.error(l.InvalidSpecificationValue,`Invalid property mapping '${r.content}' - expected '<property> = <value>'`,d(r));continue}i.push(Fr(t,r,o,n))}return i}c(ut,"parseValues");function Fr(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:ee(n[2],d(e),t,i),location:d(e)}}c(Fr,"mappingOf");var cl=C("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),ll=new Set(["reducer"]);function Yr(t,e){let n=cl.exec(e.content),i="StateChange",r="";n===null?t.error(l.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,d(e)):(r=n[2],Ni.includes(n[1])?i=n[1]:t.error(l.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,d(e)));let o=t.scope;t.scope=[...o,r];let a=null,s=[],p=[],f=[],y=[],u=[],m=[],S=[],v=[],g=[],P=[],b=[],O=[];for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){if(t.reader.takeSignificant(),te(h))continue;let x=R(h.content);x==="description"?a=Q(t,h,a,`Slice '${r}'`):x==="operation"?p.push(Lt(t,h).operation):x==="event"?s.push(Qi(t,h)):x==="command"?f.push(Sr(t,h)):x==="query"?y.push(br(t,h)):x==="projection"?u.push(Fn(t,h)):x==="capture"?S.push(In(t,h)):x==="reaction"?m.push(Er(t,h)):x==="constraint"?v.push(hr(t,h)):x==="specification"?g.push(Zn(t,h)):x==="readmodel"?P.push(Zi(t,h)):x==="screen"?b.push(Pr(t,h)):ll.has(x)?(O.push(dr(t,h)),t.skipOpaqueBlock(h.indent)):(t.warning(l.UnknownSliceDirective,`Unknown construct '${x}' in slice '${r}'`,d(h)),t.skipBlock(h.indent))}t.scope=o;let k={kind:"SliceSyntax",type:i,name:r,description:a,events:s,operations:p,commands:f,queries:y,projections:u,captures:S,reactions:m,constraints:v,specifications:g,readModels:P,screens:b,location:d(e)};return De.set(k,{reducers:O}),k}c(Yr,"parseSlice");var dl=C("^feature\\s+([A-Za-z_]\\w*)$"),pl=new Set(["on","uses","contribute"]),Kn="description, authorize, import, feature, slice, contribute, 'on <trigger>' or 'uses <Behavior>'",yt=class{static{c(this,"FeatureBody")}name;#e=[];#t=[];#r=[];#i=[];#n=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=R(n.content);switch(i){case"description":return this.#n=Q(e,n,this.#n,`Feature '${this.name}'`),!0;case"depends":return Ot(e,n,this.#i,l.UnknownFeatureDirective),!0;case"authorize":return this.#a=$e(this.#a,Ae(e,n)),!0;case"import":return We(e,n,this.#r),!0;case"feature":return this.#e.push(zt(e,n)),!0;case"slice":return this.#t.push(Yr(e,n)),!0;default:return pl.has(i)?(ye(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#n,authorize:this.#a,dependsOn:this.#i,features:this.#e,slices:this.#t,fileImports:this.#r,isPlacement:n,location:e}}};function zt(t,e){let n=dl.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,d(e));let i=new yt(n),r=t.scope;t.scope=[...r,n];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),i.tryParse(t,o)||(t.error(l.UnknownFeatureDirective,`Unexpected '${R(o.content)}' in feature body - expected ${Kn}`,d(o)),t.skipBlock(o.indent));return t.scope=r,i.build(d(e))}c(zt,"parseFeature");var _n=C("^module\\s+([A-Za-z_]\\w*)$"),fl=new Set(["on","uses","screen","dialog","form","contribute"]),Jn="description, authorize, import, screen template, dialog template, form, contribute, feature, 'on <trigger>' or 'uses <Behavior>'",mt=class{static{c(this,"ModuleBody")}name;#e=[];#t=[];#r=[];#i=null;#n=null;constructor(e){this.name=e}tryParse(e,n){let i=R(n.content);switch(i){case"description":return this.#i=Q(e,n,this.#i,`Module '${this.name}'`),!0;case"depends":return Ot(e,n,this.#r,l.UnknownModuleDirective),!0;case"authorize":return this.#n=$e(this.#n,Ae(e,n)),!0;case"import":return We(e,n,this.#t),!0;case"feature":return this.#e.push(zt(e,n)),!0;default:return fl.has(i)?(ye(e,n),!0):!1}}parseChildren(e,n){for(let i=e.peekChild(n.indent);i!==void 0;i=e.peekChild(n.indent))e.reader.takeSignificant(),this.tryParse(e,i)||(e.error(l.UnknownModuleDirective,`Unexpected '${R(i.content)}' in module body - expected ${Jn}`,d(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#i,authorize:this.#n,dependsOn:this.#r,features:this.#e,fileImports:this.#t,isPlacement:n,location:e}}};function Hn(t,e){let n=_n.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,d(e));let i=new mt(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(d(e))}c(Hn,"parseModule");var Xn=class extends Error{static{c(this,"InvalidExactNumber")}};function ul(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||be(t.value)?.value!==t.value)throw new Xn("Expected a canonical, bounded ExactNumber value.");return t.value}c(ul,"canonicalExactText");function Wr(t){return!ul(t).includes(".")}c(Wr,"exactIsIntegral");var yl=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,ml=/^([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 ei(t,e){let n=(e?ml:yl).exec(t);if(n===null||n[0].length!==t.length)return!1;let i=Number(n[1]),r=Number(n[2]),o=Number(n[3]),s=[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||r<1||r>12||o<1||o>s[r-1])return!1;if(!e)return!0;if(Number(n[4])>23||Number(n[5])>59||Number(n[6])>59)return!1;if(n[7]===void 0)return!0;let p=Number(n[7]),f=Number(n[8]);return p<=14&&f<=59&&(p!==14||f===0)}c(ei,"responseDateValue");var Vt=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Qt(t,e,n=e.inputUses){let i=[],r=c((h,x)=>{let E=[...x,h.name];h.slices.forEach($=>i.push({slice:$,scope:[...E,$.name]})),h.features.forEach($=>r($,E))},"collect");t.modules.forEach(h=>h.features.forEach(x=>r(x,[h.name])));let o=new Map,a=new Map,s=new Map;for(let{slice:h,scope:x}of i)for(let E of h.commands){let $=o.get(E.name)??[];$.push({command:E,scope:x}),o.set(E.name,$),a.set(E,ne(E.properties)),E.response?.kind==="RecordCommandResponseSyntax"&&s.set(E,ne(E.response.fields))}let p=new Map;for(let h of t.imports){let x=h.qualifiedName.split(".").at(-1);p.set(x,[...p.get(x)??[],h.qualifiedName])}let f=new Map,y=c((h,x)=>{let E=`${x.join(".")}|${h}`;if(f.has(E))return f.get(E);let $=p.get(h)??[],M=((o.get(h.split(".").at(-1))??[]).length===0&&$.length===1?$[0]:h).split("."),L=o.get(M.at(-1))??[];if(M.length>1){let Y=M.slice(0,-1);L=L.filter(B=>Y.length<=B.scope.length&&Y.every((j,F)=>B.scope[B.scope.length-Y.length+F]===j))}else for(let Y=x.length;Y>=0;Y--){let B=L.filter(j=>Y<=j.scope.length&&x.slice(0,Y).every((F,J)=>j.scope[J]===F));if(B.length>0){L=B;break}}let q=L.length===1?L[0].command:null;return f.set(E,q),q},"resolve"),u=ne(t.concepts),m=new Set(t.concepts.map(h=>h.name)),S=new Map([...ne(t.types)].map(([h,x])=>[h,ne(x.properties)])),v=new Set(i.flatMap(h=>h.slice.readModels.map(x=>x.name))),g=new Set([...a.keys()].flatMap(h=>[...h.properties])),P=c(h=>{for(let x of h)x.isGenerated&&!g.has(x)&&e.error(l.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",x.location)},"checkDeclarations"),b=c(h=>{h.features.forEach(b);for(let x of h.slices){for(let E of x.commands)for(let $ of E.produces)$.inlineEvent!==null&&P($.inlineEvent.properties);x.events.forEach(E=>P(E.properties)),x.readModels.forEach(E=>P(E.properties));for(let E of x.reactions)for(let $ of E.triggers)for(let w of $.produces)w.inlineEvent!==null&&P(w.inlineEvent.properties)}},"checkFeature");t.types.forEach(h=>P(h.properties)),t.modules.forEach(h=>h.features.forEach(b));let O=c((h,x,E)=>{let $=a.get(E).get(h.property);if($===void 0){e.error(l.InvalidResponseSource,`Response source '${h.property}' must reference one direct command property.`,h.location);return}let w=$.type;(w.isCollection||v.has(w.name))&&e.error(l.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",h.location),x!==null&&(x.name!==w.name||x.isCollection!==w.isCollection||x.isOptional!==w.isOptional)&&e.error(l.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",x.location)},"validateSource");for(let h of a.keys()){for(let E of h.properties){if(!E.isGenerated)continue;let $=u.get(E.type.name);(E.type.isOptional||E.type.isCollection||($===void 0?Vt.has(E.type.name)||S.has(E.type.name)||m.has(E.type.name)||v.has(E.type.name):$.type!=="Uuid"))&&e.error(l.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",E.location)}let x=h.response;if(x?.kind==="ScalarCommandResponseSyntax")O(x.source,null,h);else if(x?.kind==="RecordCommandResponseSyntax"){x.fields.length===0&&e.error(l.InvalidCommandResponse,"A response block requires at least one field.",x.location);let E=new Set;for(let $ of x.fields)E.has($.name)&&e.error(l.DuplicateResponseField,`Duplicate response field '${$.name}'.`,$.location),E.add($.name),O($.source,$.type,h)}}let k=c((h,x)=>{let E=h.when,$=E===null?null:y(E.commandType,x);if(E!==null&&$!==null){let L=a.get($);for(let B of E.values)L.get(B.property.split(".")[0])?.isGenerated&&e.error(l.GeneratedPropertySuppliedAsInput,`Generated property '${B.property}' cannot be supplied as request or form input.`,B.location);let q=[...L.values()].filter(B=>B.isIdentifier);if(E.for!==null&&q.length===1&&q[0].isGenerated){let B=q[0].type;(Vt.has(B.name)||u.has(B.name)||S.has(B.name))&&(B.isOptional||B.isCollection||u.get(B.name)?.type!=="Uuid"||E.for.kind!=="LiteralExpressionSyntax"||typeof E.for.value!="string"||!Ur(E.for.value))&&e.error(l.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",E.for.location)}let Y=new Set;for(let B of E.generatedValues??[]){let j=L.get(B.property);(Y.has(B.property)||j===void 0||!j.isGenerated||j.isIdentifier||!Ce(B.source,j.type,u,S))&&e.error(l.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",B.location),Y.add(B.property)}}let w=h.thenReturns;if(w==null||((E===null||h.thenErrors.length>0||h.thenDenied!=null)&&e.error(l.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",w.location),$===null))return;let A=$.response,M=a.get($);if(w.kind==="ScalarSpecificationReturnSyntax"&&A?.kind==="ScalarCommandResponseSyntax"&&M.has(A.source.property))Ce(w.value,M.get(A.source.property).type,u,S)||e.error(l.InvalidReturnExpectation,"The expected return value must match the response source's type.",w.location);else if(w.kind==="RecordSpecificationReturnSyntax"&&A?.kind==="RecordCommandResponseSyntax"){w.fields.length===0&&e.error(l.InvalidReturnExpectation,"A record return expectation requires at least one field.",w.location);let L=s.get($),q=new Set;for(let Y of w.fields){let B=L.get(Y.property),j=B===void 0?void 0:M.get(B.source.property);(q.has(Y.property)||j===void 0||!Ce(Y.source,j.type,u,S))&&e.error(l.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",Y.location),q.add(Y.property)}}else e.error(l.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",w.location)},"validateSpecification");for(let{slice:h,scope:x}of i)h.specifications.forEach(E=>k(E,x));for(let h of n){if(h.isParameter===!0)continue;let x=y(h.command,h.scope);x!==null&&a.get(x).get(h.property.split(".")[0])?.isGenerated&&e.error(l.GeneratedPropertySuppliedAsInput,`Generated property '${h.property}' cannot be supplied as request or form input.`,h.location)}}c(Qt,"validateResponses");function ne(t){let e=new Map,n=new Set;for(let i of t)e.has(i.name)&&n.add(i.name),e.set(i.name,i);return n.forEach(i=>e.delete(i)),e}c(ne,"uniqueByName");function Ce(t,e,n,i){if(t.kind==="LiteralExpressionSyntax"&&t.value===null)return e.isOptional;if(e.isCollection)return t.kind==="ListExpressionSyntax"&&t.items.every(s=>Ce(s,{...e,isCollection:!1,isOptional:!1},n,i));let r=i.get(e.name);if(r!==void 0)return t.kind==="ObjectExpressionSyntax"&&t.members.every(s=>{let p=r.get(s.name);return p!==void 0&&Ce(s.value,p.type,n,i)});let o=n.get(e.name),a=o?.type??e.name;if(o?.type==="Enum")return t.kind==="LiteralExpressionSyntax"&&typeof t.value=="string"&&o.values.includes(t.value);if(t.kind==="LiteralExpressionSyntax")switch(a){case"Uuid":return typeof t.value=="string"&&Ur(t.value);case"String":return typeof t.value=="string";case"Bool":return typeof t.value=="boolean";case"Int":return typeof t.value=="number"?Number.isFinite(t.value)&&Number.isInteger(t.value):typeof t.value=="object"&&t.value!==null&&Wr(t.value);case"Decimal":return typeof t.value=="number"?Number.isFinite(t.value):typeof t.value=="object"&&t.value!==null&&t.value.literalType==="ExactNumber";case"Date":return typeof t.value=="string"&&ei(t.value,!1);case"DateTime":return typeof t.value=="string"&&ei(t.value,!0);default:return!Vt.has(a)}return!Vt.has(a)&&o===void 0}c(Ce,"compatibleValue");var Sl=/^(?:[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 Ur(t){return Sl.test(t)}c(Ur,"uuidValue");var je=class t{static{c(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(En)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&En(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 Zt(t,e,n,i=!1){let r=[],o=[],a=fe,s=!1,p=!1,f=!1,y=new Map,u=new se(new je([]),e,n).languages;for(let S of t){let v=S;if(v.number===1&&v.raw.startsWith("\uFEFF")){let g=v.raw.substring(1),P=g.length-g.trimStart().length,b=it(g.substring(P),i);v={...v,indent:P,contentOffset:1,content:(b<0?g.substring(P):g.substring(P,P+b)).trimEnd()}}if(f){Nn(v)&&(f=!1),r.push(v);continue}if(v.content.startsWith("```")&&(["```","```text","```markdown"].includes(v.content)||u.has(v.content.substring(3)))&&(f=!0),!f&&v.indent===0&&R(v.content)==="numbers"){let g=v.content!=="numbers exact"?l.InvalidNumericDirective:s?l.DuplicateNumericDirective:p?l.LateNumericDirective:void 0;g!==void 0?(o.push({severity:"error",code:g,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:d(v)}),a=Object.freeze({numericMode:"invalid"})):a=Dt,s=!0,r.push({...v,content:""});continue}!f&&v.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(v.content)&&y.set(v.number,{severity:"error",code:l.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:d(v)}),p||=v.content.trim().length>0,r.push(v)}let m=new se(new je(s?r:t),e,n);return m.sourceOptions=a,m.nestedNumericDirectives=y,o.forEach(S=>m.error(S.code,S.message,S.location)),m}c(Zt,"sourceContext");function Se(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}c(Se,"eventDeclarations");function Gt(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}c(Gt,"operationDeclarations");var K;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(K||(K={}));var oe=class{static{c(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e){let n=c((i,r)=>{for(let o of i){let a=[...r,o.name];for(let s of o.slices)this.slices.push({slice:s,scope:[...a,s.name]});n(o.features,a)}},"collect");e.modules.forEach(i=>n(i.features,[i.name]));for(let{slice:i,scope:r}of this.slices){this.scopes.set(i,r);let o=new Map;for(let s of Se(i)){let p=o.get(s.name)??[];p.push(s),o.set(s.name,p)}let a=[...o.values()].flatMap(s=>new Set(s.map(p=>p.generation)).size!==s.length?s:[s.reduce((p,f)=>p.generation>=f.generation?p:f)]);this.declarations.push(...a.map(s=>({kind:K.Event,name:s.name,node:s,scope:r})),...Gt(i).map(s=>({kind:K.Operation,name:s.name,node:s,scope:r})))}for(let i of this.declarations){let r=this.byName.get(i.name)??[];r.push(i),this.byName.set(i.name,r)}}resolve(e,n){let i=this.scopes.get(n);if(i===void 0)return{kind:K.Unresolved,declaration:null,candidates:[]};let r=this.resolutions.get(n)??new Map,o=r.get(e);if(o!==void 0)return o;let a=this.candidates(e,i),s=a.length===1?{kind:a[0].kind,declaration:a[0],candidates:[]}:{kind:a.length===0?K.Unresolved:K.Ambiguous,declaration:null,candidates:a};return r.set(e,s),this.resolutions.set(n,r),s}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===K.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==K.Operation&&!(i.kind===K.Ambiguous&&i.candidates.some(r=>r.kind===K.Operation))}candidates(e,n){let i=e.split("."),r=this.byName.get(i.at(-1))??[],o=i.slice(0,-1);if(o.length>0)return r.filter(a=>o.length<=a.scope.length&&o.every((s,p)=>a.scope[a.scope.length-o.length+p]===s));for(let a=n.length;a>=0;a--){let s=r.filter(p=>a<=p.scope.length&&n.slice(0,a).every((f,y)=>p.scope[y]===f));if(s.length>0)return s}return[]}};function hl(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}c(hl,"eventProductions");function zr(t,e){let n=hl(t,e),i=t.properties.find(r=>r.isIdentifier)?.name;return n.some(r=>r.for!==null&&(r.for.kind!=="PathExpressionSyntax"||r.for.path!==i))||n.some(r=>r.inlineEvent!==null&&r.for===null)&&n.some(r=>r.inlineEvent===null&&r.for===null)}c(zr,"requiresExplicitDestinations");function Kt(t,e){let n=[],i=c(s=>{n.push(...s.slices),s.features.forEach(i)},"inFeature");t.modules.forEach(s=>s.features.forEach(i));let r=new Map;for(let s of n.flatMap(Se))r.set(s.name,(r.get(s.name)??0)+1);let o=new Set(t.imports.map(s=>s.qualifiedName.split(".").at(-1))),a=new oe(t);for(let{slice:s,command:p}of n.flatMap(f=>f.commands.map(y=>({slice:f,command:y})))){let f=p.produces.filter(m=>a.isEventProduction(m,s)),y=p.properties.find(m=>m.isIdentifier)?.name,u=zr(p,{resolver:a,slice:s});for(let m of f){let S=m.inlineEvent;S!==null&&((r.get(S.name)??0)>1||o.has(S.name))&&e.error(l.InlineEventCollision,`Inline event '${S.name}' collides with another event declaration or import`,m.location),u&&m.for===null&&e.error(l.ExplicitProducesTargetsRequired,`Production '${m.event}' in command '${p.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,m.location);let v=m.for?.kind==="PathExpressionSyntax"?m.for.path:m.for===null&&S!==null?y:void 0;if(!(y===void 0||v!==y))for(let g of m.mappings.filter(P=>P.source.kind==="PathExpressionSyntax"&&P.source.path===y)){let P=`Event '${m.event}' copies command identifier '${y}' into payload property '${g.property}' although it already identifies the event source`;S===null?e.information(l.EventSourceIdInPayload,P,g.location):e.warning(l.EventSourceIdInPayload,P,g.location)}}}}c(Kt,"validateInlineEvents");function _t(t,e){let n=new oe(t),i=ne(t.concepts),r=new Map([...ne(t.types)].map(([b,O])=>[b,ne(O.properties)])),o=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...i.keys(),...r.keys()]),a=new Set(t.imports.map(b=>b.qualifiedName.split(".").at(-1))),s=new Map;for(let b of t.imports){let O=b.qualifiedName.split(".").at(-1);s.set(O,[...s.get(O)??[],b.qualifiedName])}let p=c(b=>{let O=new Map,k=new Map;for(let h of b){let x=O.get(h.name)??[];x.push(h),O.set(h.name,x)}return(h,x)=>{let E=JSON.stringify([h,x]);if(k.has(E))return k.get(E);let $=c(L=>{let q=L.split("."),Y=O.get(q.at(-1))??[],B=q.slice(0,-1);if(B.length>0)return Y.filter(j=>B.length<=j.scope.length&&B.every((F,J)=>j.scope[j.scope.length-B.length+J]===F));for(let j=x.length;j>=0;j--){let F=Y.filter(J=>j<=J.scope.length&&x.slice(0,j).every((xe,Pe)=>J.scope[Pe]===xe));if(F.length>0)return F}return[]},"candidates"),w=$(h),A=s.get(h)??[];w.length===0&&A.length===1&&(w=$(A[0]));let M=w.length===1?w[0].node:null;return k.set(E,M),M}},"scoped"),f=p(n.slices.flatMap(({slice:b,scope:O})=>b.readModels.map(k=>({name:k.name,scope:O,node:k})))),y=p(n.slices.flatMap(({slice:b,scope:O})=>b.commands.map(k=>({name:k.name,scope:O,node:{command:k,slice:b}})))),u=new Map;for(let b of t.systems??[])u.has(b.name)&&e.error(l.InvalidSystemDeclaration,`System '${b.name}' is declared more than once.`,b.location),u.set(b.name,(u.get(b.name)??0)+1);let m=c((b,O,k=!0)=>{let[h,...x]=O.split("."),E=b.filter(M=>M.name===h);if(E.length!==1)return{type:null,missing:E.length===0};let $=E[0].type;if(x.length===0)return{type:$,missing:!1};let w=r.get($.name);if(w===void 0)return{type:null,missing:o.has($.name)};let A=m([...w.values()],x.join("."),k);return A.type===null?A:{type:{...A.type,isOptional:k&&$.isOptional||A.type.isOptional,isCollection:$.isCollection||A.type.isCollection},missing:!1}},"pathType"),S=c((b,O,k,h,x=new Set)=>{if(k.has(O)||b.isOptional&&!h.has(O))return!0;if(b.isCollection||x.has(b.name))return!1;let E=r.get(b.name);return E===void 0?h.has(O)&&!o.has(b.name):[...E.values()].every($=>S($.type,`${O}.${$.name}`,k,h,new Set([...x,b.name])))},"covered"),v=c((b,O)=>{if(b.kind==="ListExpressionSyntax"&&O.isCollection)return b.items.every(h=>v(h,{...O,isCollection:!1,isOptional:!1}));let k=r.get(O.name);return b.kind!=="ObjectExpressionSyntax"||k===void 0?!0:[...k.values()].every(h=>(h.type.isOptional||b.members.some(x=>x.name===h.name))&&b.members.filter(x=>x.name===h.name).every(x=>v(x.value,h.type)))},"completeValue"),g=c(b=>b.kind==="LiteralExpressionSyntax"?typeof b.value!="number"||Number.isFinite(b.value):b.kind==="ObjectExpressionSyntax"?b.members.every(O=>g(O.value)):b.kind==="ListExpressionSyntax"&&b.items.every(g),"concrete"),P=c((b,O,k,h,x)=>{let E=new Set,$=new Set(b.map(A=>A.property)),w=new Set;for(let A of b){let M=A.property.split(".");for(let L=1;L<=M.length;L++)w.add(M.slice(0,L).join("."))}for(let A of b){E.has(A.property)&&e.error(l.InvalidOperationMapping,`Duplicate operation input mapping '${A.property}'.`,A.location),E.add(A.property);let M=m(O.inputs,A.property,!1);if(M.missing&&e.error(l.InvalidOperationMapping,`Operation '${O.name}' declares no input '${A.property}'.`,A.location),M.type===null)continue;let L=A.property.split(".");for(let q=1;q<L.length;q++)$.has(L.slice(0,q).join("."))&&e.error(l.InvalidOperationMapping,`Operation input mapping '${A.property}' overlaps a whole input mapping.`,A.location);if(k!==null&&A.source.kind==="PathExpressionSyntax"){let q=m(k.properties,A.source.path),Y=A.source.path.split("."),B=(jt.get(k)??[]).filter(J=>(J.alias??J.readModel)===Y[0]);if(q.missing&&B.length>0){q={type:null,missing:!1};let J=B.length===1?f(B[0].readModel,x):null;Y.length>1&&J!==null&&(q=m(J.properties,Y.slice(1).join(".")))}q.missing&&e.error(l.InvalidOperationMapping,`Command '${k.name}' declares no source '${A.source.path}'.`,A.source.location);let j=q.type,F=M.type;j!==null&&o.has(j.name)&&o.has(F.name)&&(j.name!==F.name||j.isCollection!==F.isCollection||j.isOptional&&!F.isOptional)&&e.error(l.InvalidOperationMapping,`Source '${A.source.path}' is incompatible with input '${A.property}' of operation '${O.name}'.`,A.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(A.source.kind)&&(!Ce(A.source,M.type,i,r)||h&&!v(A.source,M.type))&&e.error(l.InvalidOperationMapping,`Value is incompatible with input '${A.property}' of operation '${O.name}'.`,A.source.location)}if(h)for(let A of O.inputs)S(A.type,A.name,E,w)||e.error(l.InvalidOperationMapping,`Production of operation '${O.name}' supplies no value for required input '${A.name}'.`,O.location)},"validateMappings");for(let{slice:b,scope:O}of n.slices){let k=Gt(b),h=new Set(Se(b).map(x=>x.name));for(let x of k){h.has(x.name)&&e.error(l.ProductionDeclarationCollision,`Operation '${x.name}' collides with another event or operation in slice '${b.name}'.`,x.location),h.add(x.name),x.uses.length>0&&u.get(x.uses)!==1&&e.error(l.InvalidSystemReference,`Operation '${x.name}' must use one declared system; '${x.uses}' does not resolve uniquely.`,x.usesLocation??x.location);for(let E of x.inputs)!o.has(E.type.name)&&!a.has(E.type.name)&&e.warning(l.UnknownType,`Unknown type '${E.type.name}' on input '${E.name}' of operation '${x.name}'.`,E.type.location)}for(let x of b.commands)for(let E of x.produces){let $=n.resolve(E.event,b);$.kind===K.Ambiguous&&$.candidates.some(w=>w.kind===K.Operation)&&e.error(l.InvalidProductionReference,`Production '${E.event}' is ambiguous.`,E.location),E.event.includes(".")&&$.kind!==K.Operation&&e.error(l.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",E.location),$.declaration?.node.kind==="OperationSyntax"&&((E.for!==null||E.tags.length>0)&&e.error(l.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",E.location),P(E.mappings,$.declaration.node,x,!0,O))}for(let x of b.reactions.flatMap(E=>E.triggers).flatMap(E=>E.produces)){let E=n.resolve(x.event,b);E.kind===K.Ambiguous&&E.candidates.some($=>$.kind===K.Operation)&&e.error(l.InvalidProductionReference,`Production '${x.event}' is ambiguous.`,x.location),x.event.includes(".")&&n.resolve(x.event,b).kind!==K.Operation&&e.error(l.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",x.location),n.isOperation(x,b)&&e.error(l.OperationOutsideCommand,"Operations can only be produced by commands.",x.location)}for(let x of b.specifications){let E=[...x.givenOperationFailures??[],...x.thenOperations??[],...x.thenCompensated??[]];if(E.length===0)continue;let $=y(x.when?.commandType??"",O);($===null||x.whenAppended!==null||x.whenQuery!==null||x.whenTrigger!==null||x.whenClock!==null||x.whenCapture!==null)&&e.error(l.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",x.location);let w=new Map;for(let A of E){if(A.kind==="SpecificationOperationSyntax")for(let q of A.values)g(q.source)||e.error(l.InvalidOperationSpecification,"Operation assertions require concrete input values.",q.source.location);let M=n.resolve(A.operation,b).declaration?.node;if(M?.kind!=="OperationSyntax"){e.error(l.InvalidOperationSpecification,`'${A.operation}' does not resolve uniquely to a declared operation.`,A.location);continue}let L=w.get(M)??new Set;if(L.has(A.kind)&&e.error(l.InvalidOperationSpecification,`Duplicate operation step '${A.operation}'.`,A.location),L.add(A.kind),w.set(M,L),A.kind==="SpecificationCompensatedSyntax"&&M.compensate===null&&e.error(l.InvalidOperationSpecification,`Operation '${A.operation}' declares no compensation.`,A.location),$!==null&&$.command.handler==null){let q=$.command.produces.map(Y=>n.resolve(Y.event,$.slice));q.every(Y=>Y.kind===K.Event||Y.kind===K.Operation)&&!q.some(Y=>Y.declaration?.node===M)&&e.error(l.InvalidOperationSpecification,`Command '${$.command.name}' does not produce operation '${A.operation}'.`,A.location)}A.kind==="SpecificationOperationSyntax"&&P(A.values,M,null,!1,O)}}}}c(_t,"validateOperations");var gl=G("^policy\\s+([A-Za-z_]\\w*)$");function Vr(t,e){t=t.valueContext;let n=gl.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,d(e));let i=null,r=null,o=null,a=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),R(s.content)==="require"){let p=s.content.substring(7).trim();for(let y=t.peekChild(s.indent);y!==void 0;y=t.peekChild(s.indent))t.reader.takeSignificant(),p+=` ${y.content}`;let f=xl(t,p,d(s));a?t.error(l.RepeatedPolicyRequirement,`Policy '${n}' has more than one require line; combine the conditions with and/or in one require`,d(s)):i=f,a=!0}else if(R(s.content)==="file"){let p=we(t,s);r===null&&o===null?o=p:t.error(l.UnknownPolicyDirective,`Policy '${n}' must have only one implementation - a file reference or an inline code block, not both`,d(s))}else if(s.content.startsWith("```")||t.languages.has(s.content)){let p=pe(t,s);r===null&&o===null?r=p:t.error(l.UnknownPolicyDirective,`Policy '${n}' must have only one implementation - a file reference or an inline code block, not both`,d(s))}else t.error(l.UnknownPolicyDirective,`Unexpected '${s.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,d(s)),t.skipOpaqueBlock(s.indent);return i!==null&&(r!==null||o!==null)&&t.error(l.MixedPolicyImplementation,`Policy '${n}' cannot combine 'require' with a file or inline code block`,d(e)),i===null&&r===null&&o===null&&t.error(l.PolicyWithoutRequirement,`Policy '${n}' must declare a 'require' condition, a file reference or an inline code block`,d(e)),{kind:"PolicySyntax",name:n,condition:i,code:r,file:o,location:d(e)}}c(Vr,"parsePolicy");function xl(t,e,n){let i=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+",r=[...e.match(new RegExp(G(`"${U}"|\\(|\\)|${i}`).source,"gu"))??[]],o=0,a=c(m=>m!==void 0&&m.startsWith('"')&&m.endsWith('"'),"quoted"),s=c(m=>V(m.substring(1,m.length-1)),"unquote"),p=c(()=>{if(r[o]==="("){o++;let g=y();return r[o]===")"?o++:t.sourceOptions.numericMode==="exact"&&t.error(l.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),g}let m=r[o++];if(m==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(m!=="role"&&m!=="claim")return t.error(m===void 0?l.ExpectedPolicyCondition:l.UnexpectedTokenInPolicyCondition,m===void 0?"Expected a policy condition":`Unexpected '${m}' in policy condition`,n),null;let S=r[o++];if(!a(S))return t.error(m==="role"?l.ExpectedRoleName:l.ExpectedClaimName,`Expected a quoted ${m} name after '${m}'`,n),null;if(m==="role")return{kind:"RoleConditionSyntax",role:s(S),location:n};if(r[o++]!=="matches")return t.error(l.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let v=r[o++];return v===void 0?(t.error(l.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(S),matchesSubject:v==="subject",matches:v==="subject"?null:le(v,n,t),location:n}},"group"),f=c(()=>{let m=p();for(;m!==null&&r[o]==="and";){o++;let S=p();if(S===null)return null;m={kind:"LogicalPolicyConditionSyntax",left:m,operator:"And",right:S,location:n}}return m},"and"),y=c(()=>{let m=f();for(;m!==null&&r[o]==="or";){o++;let S=f();if(S===null)return null;m={kind:"LogicalPolicyConditionSyntax",left:m,operator:"Or",right:S,location:n}}return m},"or"),u=y();return t.sourceOptions.numericMode==="exact"&&u!==null&&o<r.length&&t.error(l.UnexpectedTokenInPolicyCondition,`Unexpected '${r[o]}' in policy condition`,n),u}c(xl,"parsePolicyCondition");var $l=new RegExp(`^for\\s+"(${U})"$`,"u"),vl=G("^[A-Z]\\w*$"),kl=G("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Qr(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(l.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,d(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:d(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=$l.exec(i.content);if(r===null){t.error(l.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,d(i)),t.skipOpaqueBlock(i.indent);continue}let o=[];for(let a=t.peekChild(i.indent);a!==void 0;a=t.peekChild(i.indent)){if(t.reader.takeSignificant(),!vl.test(a.content)){t.error(l.InvalidSeedEvent,`Invalid seed event '${a.content}' - expected an event type name`,d(a)),t.skipOpaqueBlock(a.indent);continue}let s=[];for(let p=t.peekChild(a.indent);p!==void 0;p=t.peekChild(a.indent)){t.reader.takeSignificant();let f=kl.exec(p.content);f!==null?s.push({kind:"PropertyMappingSyntax",property:f[1],source:le(f[2],d(p),t),location:d(p)}):t.error(l.InvalidSeedPropertyAssignment,`Invalid property assignment '${p.content}' - expected '<property> = <value>'`,d(p))}o.push({kind:"SeedEventSyntax",event:a.content,properties:s,location:d(a)})}n.push({kind:"SeedGroupSyntax",eventSourceId:V(r[1]),events:o,location:d(i)})}return{kind:"SeedSyntax",groups:n,location:d(e)}}c(Qr,"parseSeed");var bl=C("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Kr=C("^import\\s+([\\w.]+)$"),Cl=C("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@\\w+)*)$"),El=C("^@?[a-z_]\\w*$"),Pl=C(`^([a-z_]\\w*)\\s+reason\\s+"(${U})"$`),Ol=C("^persona\\s+([A-Za-z_]\\w*)$"),Al=C("^policy\\s+([A-Za-z_]\\w*)$"),wl=/^[ ]*\t/,Zr=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],_r=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Il=new Set(["slice","feature","description","authorize","screen","dialog","form","contribute","on","uses"]);function Jt(t,e,n=Te){jl(t,e);let i=n.length===1?new mt(n[0]):void 0,r=n.length>1?new yt(n[n.length-1]):void 0,o=i??r,a=null,s=[],p=[],f=[],y=[],u=[],m=[],S=[],v=[],g=[],P=[],b=[],O=!1;for(let h=t.reader.peekSignificant();h!==void 0;h=t.reader.peekSignificant()){t.reader.takeSignificant();let x=R(h.content);if(x==="domain"){t.authoredDeclarations=!0,a=Dl(t,h,a,O);continue}if(O||=Gr(x,h,n),t.authoredDeclarations||=x!=="import"&&Gr(x,h,n),x==="import"&&Mi(h.content))o!==void 0?o.tryParse(t,h):We(t,h,p);else if(x==="import"){let E=Kr.exec(h.content);E===null?t.error(l.InvalidImportDeclaration,`Invalid import '${h.content}' - expected 'import <Qualified.Name>'`,d(h)):s.push({kind:"ImportSyntax",qualifiedName:E[1],location:d(h)})}else if(x==="eventsource")m.push(Hi(t,h));else if(x==="system")u.push(pr(t,h));else if(x==="concept")f.push(Nl(t,h));else if(x==="type")y.push(Vi(t,h));else if(x==="module"&&!rt(n))Rl(t,h,n,i);else if(x==="module")S.push(Hn(t,h));else if(x==="persona")v.push(ql(t,h));else if(x==="seed")P.push(Qr(t.valueContext,h));else if(x==="policy")g.push(Vr(t.valueContext,h));else if(x==="trigger"){let E=Cr(t,h),$=/^trigger\s+([A-Za-z_]\w*)$/.exec(h.content)?.[1];$!==void 0&&b.push({name:$,data:E})}else _r.has(x)?x==="behavior"||x==="layout"?ye(t,h):t.skipOpaqueBlock(h.indent):o?.tryParse(t,h)!==!0&&Tl(t,h,n)}i!==void 0?S.unshift(i.build(t.start,!0)):r!==void 0&&S.unshift(Ml(n,r.build(t.start,!0),t.start));let k={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:a,imports:s,concepts:f,types:y,systems:u,eventSources:m,modules:S,personas:v,policies:g,seeds:P,declaredTriggers:b,fileImports:p,location:t.start};return t.authoredDeclarations&&ar(k),k}c(Jt,"parseApplication");function Gr(t,e,n){return t==="import"?Kr.test(e.content):t==="module"?rt(n):t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||_r.has(t)}c(Gr,"declaresConstruct");function Rl(t,e,n,i){let r=_n.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(l.ModuleInPlacedFile,`This file is imported into ${Pt(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,d(e)),t.skipBlock(e.indent)}c(Rl,"parseModuleInPlacedFile");function Tl(t,e,n){let i=R(e.content);if(rt(n)){let r=Il.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";t.error(l.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,d(e))}else{let r=n.length===1?Jn:Kn;t.error(l.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${Pt(n)} - expected an application declaration or ${r}`,d(e))}t.skipBlock(e.indent)}c(Tl,"reportUnexpectedTopLevel");function Ml(t,e,n){let i=e;for(let r=t.length-2;r>=1;r--)i={kind:"FeatureSyntax",name:t[r],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:"ModuleSyntax",name:t[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:n}}c(Ml,"place");function Dl(t,e,n,i){let r=bl.exec(e.content);return r===null?(t.error(l.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,d(e)),n):n!==null?(t.error(l.DuplicateDomain,"The document already declares a domain - a document can have at most one",d(e)),n):(i&&t.error(l.DomainNotFirst,"'domain' must be declared before any other construct",d(e)),{kind:"DomainSyntax",name:r[1],location:d(e)})}c(Dl,"parseDomain");function jl(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&wl.test(i.raw)&&t.warning(l.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",Ii(i))}}c(jl,"warnOnTabIndentation");function Nl(t,e){let n=Cl.exec(e.content);if(n===null)return t.error(l.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,d(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:R(e.content),type:"",attributes:[],values:[],location:d(e)};let[,i,r,o]=n,a=o.split(" ").filter(y=>y.length>0).map(y=>({kind:"ConceptAttributeSyntax",name:y.replace(/^@+/,""),reason:null,location:d(e)}));r!=="Enum"&&!Zr.includes(r)&&t.error(l.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${Zr.join(", ")} or Enum`,d(e));let s=new Map;a.forEach((y,u)=>{s.has(y.name)||s.set(y.name,u)});let p=[],f=[];for(let y=t.peekChild(e.indent);y!==void 0;y=t.peekChild(e.indent)){t.reader.takeSignificant();let u=Pl.exec(y.content);if(!te(y))if(R(y.content)==="validate"){r==="Enum"&&y.content==="validate"&&t.peekChild(y.indent)===void 0&&t.warning(l.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,d(y));let m=qn(t,y,"concept");m!==void 0&&f.push(m)}else u!==null?Ll(t,y,i,a,s,u[1],V(u[2])):r==="Enum"&&El.test(y.content)?p.push(Z(y.content)):r==="Enum"?t.error(l.InvalidEnumerationValue,`Invalid enum value '${y.content}' - expected an identifier`,d(y)):(t.error(l.UnknownConceptDirective,`Unexpected '${y.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,d(y)),t.skipBlock(y.indent))}return{kind:"ConceptSyntax",name:i,type:r,attributes:a,values:p,validations:f,location:d(e)}}c(Nl,"parseConcept");function Ll(t,e,n,i,r,o,a){let s=r.get(o);s===void 0?t.error(l.AttributeReasonWithoutAttribute,`Concept '${n}' declares a reason for '${o}' without the attribute - write 'concept ${n} : <Type> @${o}'`,d(e)):i[s].reason!==null?t.error(l.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${o}' - at most one is allowed`,d(e)):i[s]={...i[s],reason:a}}c(Ll,"applyAttributeReason");function ql(t,e){let n=Ol.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,d(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let a=R(o.content);if(a==="description")i=Q(t,o,i,`Persona '${n}'`);else if(a==="policy"){let s=Al.exec(o.content);s===null?t.error(l.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,d(o)):r.push(s[1])}else t.error(l.UnknownPersonaDirective,`Unexpected '${a}' in persona body - expected description or policy`,d(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:d(e)}}c(ql,"parsePersona");var Ge=class t{static{c(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,n){this.sources=e,this.qualifiedTypes=n}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,n){let i=this.sources.get(e);return i?.length===1&&i[0].filter(r=>r===n).length===1}static capture(e,n=Te,i){return this.capturePlaced([...e].map(r=>({lines:r,placement:n})),i)}static capturePlaced(e,n){let i=new Map,r=new Set,o=new Set;for(let{lines:s,placement:p}of e){let f=Zt(s,s[0]?.path,n);f.scope=p;let y=Jt(f,s,p);for(let u of y.types)r.add(u.name);for(let u of y.concepts)r.add(u.name);for(let u of y.imports)o.add(u.qualifiedName);for(let u of y.eventSources??[])i.set(u.name,[...i.get(u.name)??[],u.streams.map(m=>m.name)])}let a=new Set([...o].filter(s=>r.has(s.substring(s.lastIndexOf(".")+1))));return new t(i,a)}};var he;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(he||(he={}));var Ht=class{static{c(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let n of e.eventSources??[])this.sources.set(n.name,[...this.sources.get(n.name)??[],n]);this.otherNames=new Set([...e.concepts,...e.types].map(n=>n.name))}resolve(e,n){let i=this.sources.get(e)??[],r=i.flatMap(a=>a.streams).filter(a=>a.name===n),o;return i.length===0?o=this.otherNames.has(e)?he.WrongKind:he.NotFound:i.length>1||r.length>1?o=he.Ambiguous:o=r.length===1?he.Unique:he.NotFound,{kind:o,sources:i,streams:r}}};var ti=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function Xt(t,e){let n=ne(t.concepts),i=ne(t.types),r=new Set([...ti,...n.keys(),...i.keys()]),o=new Map([...i].map(([u,m])=>[u,ne(m.properties)])),a=c((u,m)=>r.has(u.name)&&r.has(m.name)?u.name===m.name&&u.isCollection===m.isCollection&&(!u.isOptional||m.isOptional):null,"compatible"),s=c((u,m)=>{if(u===null)return;if(u.isOptional||u.isCollection||t.types.some(g=>g.name===u.name)){e.error(l.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",u.location);return}let S=t.concepts.filter(g=>g.name===u.name),v=S.length===1?S[0].type:S.length===0&&ti.has(u.name)?u.name:null;m&&v!==null&&(!["String","Uuid","Int"].includes(v)||v==="Int"&&S.length===0||S.some(g=>g.values.length>0))&&e.error(l.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),v===null&&!t.imports.some(g=>g.qualifiedName===u.name||g.qualifiedName.split(".").at(-1)===u.name)&&e.warning(l.UnknownType,`Unknown type '${u.name}' in event source declaration.`,u.location)},"validateType"),p=new Set;for(let u of t.eventSources??[]){p.has(u.name)&&e.error(l.InvalidEventSourceDeclaration,`Event source '${u.name}' has multiple physical declarations.`,u.location),p.add(u.name),s(u.identifier,!1);let m=new Set;for(let S of u.streams)m.has(S.name)&&e.error(l.InvalidEventSourceDeclaration,`Stream '${u.name}.${S.name}' has multiple declarations under this source.`,S.location),m.add(S.name),s(S.streamId,!0)}let f=c((u,m)=>{let[S,...v]=m.split(".");if(u===null)return{property:null,missing:!1};let g=u.filter(O=>O.name===S);if(g.length!==1)return{property:null,missing:g.length===0};let P=g[0];if(v.length===0)return{property:P,missing:!1};if(ti.has(P.type.name)||n.has(P.type.name)&&!i.has(P.type.name))return{property:null,missing:!0};let b=f(i.get(P.type.name)?.properties??null,v.join("."));return b.property===null?b:{property:{...b.property,type:{...b.property.type,isCollection:P.type.isCollection||b.property.type.isCollection,isOptional:P.type.isOptional||b.property.type.isOptional}},missing:!1}},"pathProperty"),y=new Ht(t);for(let{slice:u}of new oe(t).slices)for(let m of u.commands){let S=m.stream;if(S==null||S.propertyCandidate!==null)continue;let v=y.resolve(S.eventSource,S.stream);if(v.kind!==he.Unique){let k={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[v.kind];e.error(l.InvalidCommandStream,`Stream '${S.eventSource}.${S.stream}' is ${k}; routing requires one physical source and stream.`,S.location);continue}let g=v.sources[0],P=v.streams[0],b=m.properties.filter(k=>k.isIdentifier);if(g.identifier!==null&&b.length===1&&a(b[0].type,g.identifier)===!1&&e.warning(l.InvalidCommandStream,`Command identifier '${b[0].name}' does not have the source's nominal identifier type '${g.identifier.name}'. The stream does not supply a destination.`,b[0].location),(P.streamId===null&&S.streamId!==null||P.streamId!==null&&S.streamId===null)&&e.error(l.InvalidCommandStream,P.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",S.location),P.streamId===null||S.streamId===null)continue;let O=S.streamId.source;if(O.kind==="PathExpressionSyntax"){let k=f(m.properties,O.path);(k.missing||k.property!==null&&a(k.property.type,P.streamId)===!1)&&e.error(l.InvalidCommandStream,`Stream id source '${O.path}' is absent or incompatible with nominal type '${P.streamId.name}'.`,O.location)}else O.kind==="LiteralExpressionSyntax"&&!Ce(O,P.streamId,n,o)?e.error(l.InvalidCommandStream,`Stream id value is incompatible with nominal type '${P.streamId.name}'.`,O.location):(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(O.kind)||O.kind==="LiteralExpressionSyntax"&&O.value===null)&&e.error(l.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",O.location)}}c(Xt,"validateEventSources");function en(t,e){let n=new oe(t),i=n.slices,r=new Set(t.imports.map(g=>g.qualifiedName)),o=new Set([...i.flatMap(({slice:g})=>Se(g).map(P=>P.name)),...t.imports.map(g=>g.qualifiedName.split(".").at(-1))]),a=ne(t.types),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(g=>g.name)].filter(g=>!a.has(g))),p=c((g,P)=>{let[b,...O]=P.split(".");if(g===null)return{value:null,missing:!1};let k=g.filter(x=>x.name===b);if(k.length!==1)return{value:null,missing:k.length===0};let h=k[0];return O.length===0?{value:h,missing:!1}:s.has(h.type.name)?{value:null,missing:!0}:p(a.get(h.type.name)?.properties??null,O.join("."))},"property"),f=i.flatMap(({slice:g,scope:P})=>g.readModels.map(b=>({node:b,scope:P}))),y=c((g,P)=>{let b=c(h=>{let x=h.split("."),E=f.filter(w=>w.node.name===x.at(-1)),$=x.slice(0,-1);if($.length>0)return E.filter(w=>$.length<=w.scope.length&&$.every((A,M)=>w.scope[w.scope.length-$.length+M]===A));for(let w=P.length;w>=0;w--){let A=E.filter(M=>w<=M.scope.length&&P.slice(0,w).every((L,q)=>M.scope[q]===L));if(A.length>0)return A}return[]},"candidates"),O=b(g),k=t.imports.filter(h=>h.qualifiedName.split(".").at(-1)===g);return O.length===0&&k.length===1&&(O=b(k[0].qualifiedName)),O.length===1?O[0].node.properties:null},"viewProperties"),u=c((g,P,b)=>{let O=n.resolve(g,b);o.has(g)||r.has(g)||O.declaration?.kind===K.Event||O.candidates.some(h=>h.kind===K.Event)||e.warning(l.UnknownEvent,`Unknown event '${g}' - declare it with 'event ${g}'`,P)},"unknownEvent"),m=c((g,P)=>{for(let b of g)(b.kind==="RemoveWithSyntax"||b.kind==="RemoveViaJoinSyntax")&&u(b.event,b.location,P),"blocks"in b&&m(b.blocks,P)},"removals"),S=new Set,v=c((g,P,b=!1,O=!1)=>{let k=c((x,E)=>{let $=p(P,x),w=JSON.stringify([E.path,E.line,E.column]);return $.missing&&!S.has(w)&&(S.add(w),e.warning(l.UnknownReadModelProperty,`Projection target '${x}' is not a declared ${b?"element":"read-model"} property`,E)),$.value},"validate"),h=O||g.some(x=>x.kind==="FromSyntax"||x.kind==="JoinSyntax"||x.kind==="AllSyntax");for(let x of g){let E=x.kind==="EverySyntax"&&!h?[]:"mappings"in x?x.mappings:x.kind==="JoinSyntax"?x.events.flatMap($=>$.mappings):[];for(let $ of E)k($.property,$.location);if(x.kind==="ChildrenSyntax"||x.kind==="NestedSyntax"){let $=k(x.property,x.location);v(x.blocks,$===null?null:a.get($.type.name)?.properties??null,!0)}}},"walk");for(let{slice:g}of i){for(let P of g.projections)m(P.blocks,g);for(let P of g.captures)for(let b of[...P.appends,...P.children.flatMap(O=>O.appends),...P.nested.flatMap(O=>O.appends)])u(b.event,b.location,g)}for(let{slice:g,scope:P}of i)for(let b of g.projections){let O=b.blocks.filter(k=>k.kind==="ProjectionVariantSyntax");O.length===0&&v(b.blocks,y(b.readModel??b.name,P));for(let k of O){let h=y(k.name,P);v(b.blocks.filter(E=>E.kind==="ChildrenSyntax"||E.kind==="NestedSyntax"),h);let x=k.entersOn.length>0||b.blocks.some(E=>E.kind==="FromSyntax"||E.kind==="JoinSyntax"||E.kind==="AllSyntax");v(k.blocks,h,!1,x)}}}c(en,"validateProjectionTargets");function tn(t,e){let n=new Set(t.concepts.filter(p=>p.attributes.some(f=>f.name==="pii")).map(p=>p.name)),i=ne(t.types),r=new oe(t),o=new Map;for(let p of t.declaredTriggers??[]){let f=o.get(p.name)??[];f.push(p.data),o.set(p.name,f)}let a=c((p,f)=>{n.has(p.name)&&e.error(l.PiiNotSupportedOnIdentifier,`Concept '${p.name}' is @pii and cannot be an event source identifier - use a surrogate Uuid identifier and keep the @pii value as a property`,f)},"validate"),s=c((p,f)=>{let[y,...u]=f.split("."),m=p.filter(v=>v.name===y);if(m.length!==1)return null;let S=m[0];return u.length===0?S:s(i.get(S.type.name)?.properties??[],u.join("."))},"property");for(let p of t.eventSources??[])p.identifier!=null&&a(p.identifier,p.identifier.location);for(let{slice:p}of r.slices){for(let f of p.commands){for(let y of f.properties.filter(u=>u.isIdentifier))a(y.type,y.location);for(let y of f.produces.filter(u=>r.isEventProduction(u,p))){if(y.for?.kind!=="PathExpressionSyntax")continue;let u=s(f.properties,y.for.path);u!==null&&!u.isIdentifier&&a(u.type,y.for.location)}}for(let f of p.reactions.flatMap(y=>y.triggers)){if(f.source.kind!=="NamedTriggerSourceSyntax")continue;let u=r.resolve(f.source.name,p).declaration?.node,m=[u?.kind==="EventSyntax"?u.properties:[],...o.get(f.source.name)??[]];for(let S of f.produces.filter(v=>r.isEventProduction(v,p))){if(S.for?.kind!=="PathExpressionSyntax")continue;let v=S.for.path,g=m.map(P=>s(P,v)).find(P=>P!==null&&n.has(P.type.name));g!=null&&a(g.type,S.for.location)}}}}c(tn,"validateIdentifierCompliance");var Ke=class{static{c(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(n=>this.visitImport(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.systems?.forEach(n=>this.visitSystem(n)),e.eventSources?.forEach(n=>this.visitEventSource(n)),e.concepts.forEach(n=>this.visitConcept(n)),e.types.forEach(n=>this.visitType(n)),e.personas.forEach(n=>this.visitPersona(n)),e.policies?.forEach(n=>this.visitPolicy(n)),e.seeds?.forEach(n=>this.visitSeed(n)),e.modules.forEach(n=>this.visitModule(n))}visitPolicy(e){this.visitNode(e),e.condition!==null&&this.visitPolicyCondition(e.condition),e.code!==null&&this.visitCodeBlock(e.code),e.file!==null&&this.visitFileReference(e.file)}visitPolicyCondition(e){this.visitNode(e),e.kind==="ClaimConditionSyntax"&&e.matches!==null&&this.visitExpression(e.matches),e.kind==="LogicalPolicyConditionSyntax"&&(this.visitPolicyCondition(e.left),this.visitPolicyCondition(e.right))}visitSeed(e){this.visitNode(e),e.groups.forEach(n=>{this.visitNode(n),n.events.forEach(i=>{this.visitNode(i),i.properties.forEach(r=>this.visitPropertyMapping(r))})})}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(n=>this.visitNode(n)),e.validations?.forEach(n=>this.visitValidate(n))}visitType(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitDependsOn(e){this.visitNode(e)}visitModule(e){this.visitNode(e),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n))}visitFeature(e){this.visitNode(e),e.dependsOn?.forEach(n=>this.visitDependsOn(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.features.forEach(n=>this.visitFeature(n)),e.slices.forEach(n=>this.visitSlice(n))}visitSlice(e){this.visitNode(e),e.commands.forEach(n=>this.visitCommand(n)),e.operations?.forEach(n=>this.visitOperation(n)),e.events.forEach(n=>this.visitEvent(n)),e.constraints.forEach(n=>this.visitConstraint(n)),e.queries.forEach(n=>this.visitQuery(n)),e.projections.forEach(n=>this.visitProjection(n)),e.readModels.forEach(n=>this.visitReadModel(n)),e.captures.forEach(n=>this.visitCapture(n)),e.reactions.forEach(n=>this.visitReaction(n)),e.screens.forEach(n=>this.visitScreen(n)),e.specifications.forEach(n=>this.visitSpecification(n))}visitTriggerData(e){this.visitNode(e),e.type!==null&&this.visitTypeRef(e.type)}visitReads(e){this.visitNode(e)}visitConcurrency(e){this.visitNode(e)}visitReducer(e){this.visitNode(e),e.rules.forEach(n=>this.visitReducerRule(n))}visitReducerRule(e){this.visitNode(e),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitForm(e){this.visitNode(e),e.populate!==null&&this.visitNode(e.populate),e.fields.forEach(n=>this.visitNode(n)),e.onSubmit!==null&&this.visitScreenDirective(e.onSubmit)}visitCommand(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.authorize!==null&&this.visitAuthorize(e.authorize),e.stream!=null&&this.visitCommandStream(e.stream),e.streamCandidates?.forEach(n=>this.visitCommandStream(n)),e.validations.forEach(n=>this.visitValidate(n)),e.produces.forEach(n=>this.visitProduces(n)),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(n=>this.visitEventStream(n))}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(n=>this.visitProperty(n)),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(n=>this.visitPropertyMapping(n))}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(n=>this.visitImplementationHint(n))}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(n=>this.visitResponseField(n))}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(n=>this.visitPropertyMapping(n))}visitValidate(e){this.visitNode(e),e.kind==="DeclarativeValidateSyntax"?(e.rules.forEach(n=>this.visitValidationRule(n)),e.requirements?.forEach(n=>{this.visitNode(n),this.visitCondition(n.condition)})):e.code!=null&&this.visitCodeBlock(e.code)}visitValidationRule(e){this.visitNode(e),e.implementation!=null&&this.visitImplementation(e.implementation),e.value!==null&&this.visitExpression(e.value),e.file!==null&&this.visitFileReference(e.file),e.code!==null&&this.visitCodeBlock(e.code)}visitEvent(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n)),e.tags.forEach(n=>this.visitTag(n))}visitTag(e){this.visitNode(e),this.visitExpression(e.value)}visitReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitProperty(n))}visitConstraint(e){this.visitNode(e),e.kind==="FileConstraintSyntax"&&this.visitNode(e.file),e.additionalRules.forEach(n=>this.visitConstraint(n))}visitQuery(e){this.visitNode(e),this.visitTypeRef(e.returnType),e.by!==null&&this.visitQueryParameter(e.by),e.filters.forEach(n=>this.visitQueryParameter(n)),e.authorize!==null&&this.visitAuthorize(e.authorize)}visitQueryParameter(e){this.visitNode(e),this.visitTypeRef(e.type),e.source!=null&&this.visitExpression(e.source)}visitKey(e){this.visitNode(e),e.kind==="ExpressionKeySyntax"?this.visitExpression(e.expression):e.parts.forEach(n=>{this.visitNode(n),this.visitExpression(n.expression)})}visitProjection(e){this.visitNode(e),e.key!=null&&this.visitKey(e.key),e.blocks.forEach(n=>this.visitProjectionBlock(n))}visitProjectionBlock(e){switch(this.visitNode(e),e.kind){case"FromSyntax":e.events.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.key!=null&&this.visitKey(e.key),e.parentKey!=null&&this.visitExpression(e.parentKey),e.mappings.forEach(n=>this.visitMapping(n));break;case"EverySyntax":case"AllSyntax":e.mappings.forEach(n=>this.visitMapping(n));break;case"JoinSyntax":e.events.forEach(n=>this.visitJoinEvent(n));break;case"ProjectionVariantSyntax":e.entersOn.forEach(n=>{this.visitNode(n),n.key!=null&&this.visitExpression(n.key)}),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"ChildrenSyntax":e.identifiedBy!==void 0&&this.visitExpression(e.identifiedBy),e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"NestedSyntax":e.blocks.forEach(n=>this.visitProjectionBlock(n));break;case"RemoveWithSyntax":e.parentKey!=null&&this.visitExpression(e.parentKey),e.key!=null&&this.visitExpression(e.key);break;case"RemoveViaJoinSyntax":e.key!=null&&this.visitExpression(e.key);break}}visitJoinEvent(e){this.visitNode(e),e.mappings.forEach(n=>this.visitMapping(n))}visitMapping(e){this.visitNode(e),e.source!==void 0&&this.visitExpression(e.source),e.value!==void 0&&this.visitExpression(e.value)}visitCondition(e){this.visitNode(e),e.kind==="ComparisonConditionSyntax"?this.visitExpression(e.right):(this.visitCondition(e.left),this.visitCondition(e.right))}visitReaction(e){this.visitNode(e),e.where!=null&&this.visitCondition(e.where),e.triggers.forEach(n=>this.visitReactionTrigger(n))}visitReactionTrigger(e){this.visitNode(e),this.visitTriggerSource(e.source),e.produces.forEach(n=>this.visitProduces(n)),e.invokes.forEach(n=>this.visitInvokes(n))}visitProduces(e){this.visitNode(e),e.when!=null&&this.visitCondition(e.when),e.inlineEvent!==null&&this.visitEvent(e.inlineEvent),e.inlineOperation!=null&&this.visitOperation(e.inlineOperation),e.for!==null&&this.visitExpression(e.for),e.mappings.forEach(n=>this.visitPropertyMapping(n)),e.tags.forEach(n=>this.visitTag(n))}visitInvokes(e){this.visitNode(e),e.mappings?.forEach(n=>this.visitPropertyMapping(n))}visitCapture(e){this.visitNode(e),e.source!==null&&this.visitCaptureSource(e.source),e.map?.forEach(n=>this.visitCaptureMap(n)),e.appends.forEach(n=>this.visitCaptureAppend(n)),e.children.forEach(n=>this.visitCaptureChildren(n)),e.nested.forEach(n=>this.visitCaptureNested(n))}visitCaptureSource(e){this.visitNode(e),e.settings.forEach(n=>this.visitCaptureSourceSetting(n))}visitCaptureSourceSetting(e){this.visitNode(e)}visitCaptureMap(e){this.visitNode(e),this.visitExpression(e.source),e.kind==="CaptureMapEntrySyntax"&&e.translations.forEach(n=>this.visitNode(n))}visitCaptureAppend(e){this.visitNode(e),e.when!=null&&this.visitNode(e.when),e.mappings?.forEach(n=>this.visitPropertyMapping(n)),e.tags?.forEach(n=>this.visitTag(n))}visitCaptureChildren(e){this.visitNode(e),e.map?.forEach(n=>this.visitCaptureMap(n)),e.appends.forEach(n=>this.visitCaptureAppend(n))}visitCaptureNested(e){this.visitNode(e),e.map?.forEach(n=>this.visitCaptureMap(n)),e.appends.forEach(n=>this.visitCaptureAppend(n))}visitTriggerSource(e){this.visitNode(e)}visitScreen(e){this.visitNode(e),e.directives.forEach(n=>this.visitScreenDirective(n))}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(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenSectionSyntax":e.directives.forEach(n=>this.visitScreenDirective(n));break;case"ScreenTableSyntax":e.columns.forEach(n=>this.visitNode(n)),e.rowClick!==null&&this.visitScreenDirective(e.rowClick);break;case"ScreenSummarySyntax":e.fields.forEach(n=>this.visitNode(n));break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitSpecification(e){this.visitNode(e),e.givenClock!==null&&this.visitSpecificationClock(e.givenClock),e.givenOperationFailures?.forEach(n=>this.visitSpecificationOperationFailure(n)),e.thenOperations?.forEach(n=>this.visitSpecificationOperation(n)),e.thenCompensated?.forEach(n=>this.visitSpecificationCompensated(n)),e.givenCaller!=null&&(this.visitNode(e.givenCaller),e.givenCaller.claims.forEach(n=>this.visitNode(n))),e.given.forEach(n=>this.visitSpecificationEvent(n)),e.givenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.when!==null&&this.visitSpecificationCommand(e.when),e.givenCaptures.forEach(n=>this.visitSpecificationCapture(n)),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(n=>this.visitSpecificationEvent(n)),e.thenReadModels.forEach(n=>this.visitSpecificationReadModel(n)),e.thenAbsentReadModels?.forEach(n=>{this.visitNode(n),this.visitExpression(n.key)}),e.thenQueries?.forEach(n=>{this.visitNode(n),n.arguments.forEach(i=>this.visitPropertyMapping(i)),n.results.forEach(i=>this.visitSpecificationQueryResult(i))}),e.thenResults.forEach(n=>this.visitSpecificationQueryResult(n)),e.thenNoResult!==null&&this.visitNode(e.thenNoResult),e.thenDenied!=null&&this.visitNode(e.thenDenied),e.thenReturns!=null&&this.visitSpecificationReturn(e.thenReturns),e.thenErrors.forEach(n=>this.visitNode(n))}visitSpecificationClock(e){this.visitNode(e)}visitSpecificationTrigger(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationCapture(e){this.visitNode(e),e.record.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationWhenQuery(e){this.visitNode(e),e.arguments.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationQueryResult(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationEvent(e){this.visitNode(e),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationCommand(e){this.visitNode(e),(e.generatedValues??[]).forEach(n=>this.visitPropertyMapping(n)),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationReadModel(e){this.visitNode(e),e.properties.forEach(n=>this.visitPropertyMapping(n))}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(n=>this.visitExpression(n)):e.kind==="ObjectExpressionSyntax"?e.members.forEach(n=>this.visitObjectMember(n)):e.kind==="TemplateExpressionSyntax"&&e.parts.forEach(n=>{this.visitNode(n),n.kind==="TemplateInterpolationSyntax"&&this.visitExpression(n.expression)})}visitObjectMember(e){this.visitNode(e),this.visitExpression(e.value)}};var Bl={from:"usesFactsFrom",join:"usesFactsFrom",remove:"usesFactsFrom",removeViaJoin:"usesFactsFrom",clear:"usesFactsFrom",entersOn:"usesFactsFrom",reduces:"usesFactsFrom",uniqueEvent:"usesFactsFrom",uniqueProperty:"usesFactsFrom",concurrency:"usesFactsFrom",trigger:"reactsTo",reads:"decidesFrom",invokes:"asks",action:"asks",formCommand:"asks",dataQuery:"shows",populate:"shows",navigate:"shows",specificationEvent:"verifiedWith",givenEvent:"verifiedWith",whenAppendedEvent:"verifiedWith",thenEvent:"verifiedWith",whenCommand:"verifiedWith",declares:null,uses:null,commandEventSource:null,commandStream:null,thenOperation:null,givenOperationFailure:null,thenCompensated:null,produces:null,authorizes:null,queryResult:null,dataReadModel:null,type:null,contributes:null,template:null,specificationReadModel:null,thenAbsentReadModel:null,thenReadModel:null,givenReadModel:null,thenQuery:null,compositeKeyType:null,builds:null,buildsVariant:null,appends:null,seed:null};function ii(t){let e=new ni;return e.visitSlice(t),{references:e.references.sort((n,i)=>n.location.line-i.location.line||n.location.column-i.location.column),shared:e.shared}}c(ii,"sliceReferences");var ni=class extends Ke{static{c(this,"SliceReferenceCollector")}references=[];shared=[];specification;projection=!1;visitSlice(e){super.visitSlice(e),pt(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=pt(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=pt(e);n.data?.forEach(i=>this.visitTriggerData(i)),n.reads?.forEach(i=>this.visitReads(i)),super.visitReactionTrigger(e)}visitProjection(e){this.projection=!0,super.visitProjection(e),this.projection=!1}visitSpecification(e){this.specification=e,super.visitSpecification(e),this.specification=void 0}visitNode(e){let n=c((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:Bl[o],location:e.location,timeline:this.projection||o==="trigger"})},"add");switch(e.kind){case"TypeRefSyntax":{let i=e.name;["Uuid","String","Int","Decimal","Bool","Date","DateTime"].includes(i)||this.shared.push({kind:"type",name:i});break}case"PolicyReferenceSyntax":this.shared.push({kind:"policy",name:e.name});break;case"EventSpecSyntax":n(e.event,"Event","from");break;case"JoinEventSyntax":n(e.event,"Event","join");break;case"RemoveWithSyntax":n(e.event,"Event","remove");break;case"RemoveViaJoinSyntax":n(e.event,"Event","removeViaJoin");break;case"ClearWithSyntax":n(e.event,"Event","clear");break;case"ProjectionEntersOnSyntax":n(e.event,"Event","entersOn");break;case"ReducerRuleSyntax":n(e.event,"Event","reduces");break;case"UniqueEventConstraintSyntax":n(e.event,"Event","uniqueEvent");break;case"UniquePropertyConstraintSyntax":n(e.event,"Event","uniqueProperty");break;case"NamedTriggerSourceSyntax":n(e.name,"Event","trigger");break;case"ReadsSyntax":n(e.readModel,"ReadModel","reads");break;case"InvokesSyntax":n(e.command,"Command","invokes");break;case"ScreenActionSyntax":n(e.command,"Command","action");break;case"FormSyntax":n(e.for,"Command","formCommand");break;case"ScreenDataSyntax":n(e.query,"Query","dataQuery");break;case"FormPopulateViaQuerySyntax":n(e.query,"Query","populate");break;case"ScreenNavigateSyntax":n(e.screen,"Screen","navigate");break;case"SpecificationEventSyntax":n(e.eventType,"Event",this.specification?.given.includes(e)===!0?"givenEvent":this.specification?.whenAppended===e?"whenAppendedEvent":"thenEvent");break;case"SpecificationCommandSyntax":n(e.commandType,"Command","whenCommand");break;case"ConcurrencySyntax":e.eventTypes.forEach(i=>n(i,"Event","concurrency"));break}}};function ri(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],a=c(s=>{e.set(s,e.size),n.set(s,e.get(s)),i.push(s),r.add(s);for(let y of[...t.get(s)].sort())e.has(y)?r.has(y)&&n.set(s,Math.min(n.get(s),e.get(y))):(a(y),n.set(s,Math.min(n.get(s),n.get(y))));if(n.get(s)!==e.get(s))return;let p=[],f;do f=i.pop(),r.delete(f),p.push(f);while(f!==s);o.push(p.sort())},"visit");for(let s of[...t.keys()].sort())e.has(s)||a(s);return o}c(ri,"stronglyConnectedGroups");var Wl=new WeakMap,St=c(t=>JSON.stringify(t),"authoredOrderKey");function nn(t){return Wl.get(t)??new Map}c(nn,"authoredOrderOf");function si(t){let e=nn(t),n=c((y,u)=>y.map(m=>({syntax:m,rank:e.get(St([...u,m.name]))??Number.MAX_SAFE_INTEGER})).sort((m,S)=>m.rank-S.rank).map(m=>m.syntax),"ordered"),i=[],r=c((y,u)=>{let m=[...u,y.name];for(let S of n(y.slices,m))i.push({syntax:S,scope:[...m,S.name],identity:[...m.map(v=>`container:${v}`),`slice:${S.name}`],index:i.length});for(let S of n(y.features,m))r(S,m)},"feature");for(let y of n(t.modules,[]))for(let u of n(y.features,[y.name]))r(u,[y.name]);let o=new Map;for(let y of i)for(let u of Se(y.syntax))o.has(u.name.toLowerCase())||o.set(u.name.toLowerCase(),y);let a=[];for(let y of i){let u=new Set,m=ii(y.syntax).references.filter(S=>S.timeline).map(S=>({event:S.name,location:S.location}));for(let S of m){let v=S.event.toLowerCase();if(u.has(v))continue;u.add(v);let g=o.get(v);if(g===void 0||g===y)continue;let P=0;for(;P<y.scope.length&&P<g.scope.length&&y.identity[P]===g.identity[P];)P++;P===y.scope.length||P===g.scope.length||a.push({...S,consumer:y,producer:g,container:St(y.identity.slice(0,P)),left:y.identity[P],right:g.identity[P]})}}let s=c((y,u)=>y.consumer.index-u.consumer.index||y.location.line-u.location.line||y.location.column-u.location.column,"compare"),p=new Set,f=[];for(let y of new Set(a.map(u=>u.container))){let u=a.filter(S=>S.container===y),m=new Map;for(let S of u)m.has(S.left)||m.set(S.left,new Set),m.has(S.right)||m.set(S.right,new Set),m.get(S.left).add(S.right);for(let S of ri(m).filter(v=>v.length>1)){let v=new Set(S),g=u.filter(O=>v.has(O.left)&&v.has(O.right));g.forEach(O=>p.add(O));let P=g.filter(O=>O.consumer.index<O.producer.index).sort(s)[0];if(P===void 0)continue;let b=c(O=>Math.min(...g.flatMap(k=>[k.consumer,k.producer]).filter(k=>{let h=JSON.parse(y);return k.identity[h.length]===O}).map(k=>k.index)),"memberIndex");S.sort((O,k)=>b(O)-b(k)),f.push({edge:P,diagnostic:{severity:"information",code:l.TimelineCycleGroup,message:`Timeline group ${S.map(O=>`'${O.slice(O.indexOf(":")+1)}'`).join(", ")} uses each other's events; reordering these members cannot make every event flow left to right.`,location:P.location}})}}for(let y of a){if(y.consumer.index>=y.producer.index||p.has(y))continue;let u=y.consumer.scope.slice(0,-1),S=y.producer.scope.length>y.consumer.scope.length&&u.every((v,g)=>y.producer.scope[g]===v)?" The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.":" Consider drawing the producer before the consumer.";f.push({edge:y,diagnostic:{severity:"information",code:l.EventFromLaterSlice,message:`Slice '${y.consumer.syntax.name}' uses event '${y.event}' produced by slice '${y.producer.syntax.name}' drawn after it.${S}`,location:y.location}})}return f.sort((y,u)=>s(y.edge,u.edge)).map(y=>y.diagnostic)}c(si,"timelineOrderDiagnostics");function Ne(t,e,n=Te,i=!0,r,o){let a=Be(t,!1,e),s=Zt(a,e,o);s.scope=n,s.streamCandidates=r??Ge.capture([a],n,o);let p=Jt(s,a,n);if(i){Kt(p,s),_t(p,s),Qt(p,s),Xt(p,s),en(p,s),tn(p,s),p=Et(p,s);for(let f of si(p))s.information(f.code,f.message,f.location)}return{value:p,diagnostics:s.diagnostics,triggerData:s.triggerData,inputUses:s.inputUses,success:!s.diagnostics.some(f=>f.severity==="error")}}c(Ne,"parseForAuthoring");function g$(t){return t===l.LegacyOptionalSuffix||t===l.RedundantEventId}c(g$,"isQuickFixDiagnostic");function ci(t,e){return e.code!==l.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}c(ci,"legacyOptionalTypeLength");function x$(t,e={}){let n=Ne(t,void 0,e.placement);if(!n.success)return()=>[];let i=Be(t),r=new Map;new class extends Ke{visitEvent(b){r.set(b.location.line,b)}}().visitApplication(n.value);let a=new Map,s=new Map,p=new Map,f;for(let b of i)f=r.get(b.number)??f,f!==void 0&&p.set(b.number,f);for(let b of n.diagnostics){a.set(b.code,(a.get(b.code)??0)+1);let O=i[b.location.line-1],k=ci(O.raw,b);if(k>0)s.set(O.number,{line:O.number,fix:{diagnosticCode:b.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:O.startOffset+b.location.column+k-2,length:1,text:" optional"}]}});else if(b.code===l.RedundantEventId&&it(O.raw)<0){let h=p.get(O.number);if(h?.id!==h?.name||h===void 0)continue;s.set(O.number,{line:O.number,fix:{diagnosticCode:b.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:O.startOffset,length:(i[O.number]?.startOffset??t.length)-O.startOffset,text:""}]},change:{node:h,replacement:{...h,id:null}}})}}let y=[...s.values()].filter(b=>b.fix.diagnosticCode===l.LegacyOptionalSuffix),u=ht(n),m=new Map,S,v=!1,g,P=c((b,O)=>{let k=Xr(t,b.edits);if(k===void 0)return;let h=Ne(k,void 0,e.placement);if(!(!h.success||ht(h)!==(O===void 0?u:ht(n,[O]))))return h.diagnostics.filter(x=>x.code===b.diagnosticCode).length===(a.get(b.diagnosticCode)??0)-b.edits.length?b:void 0},"verify");return(b,O)=>{let k=typeof b=="number"||b===void 0?void 0:b,h=k===void 0?O===void 0||O===l.LegacyOptionalSuffix:k.some(w=>w.diagnosticCode===l.LegacyOptionalSuffix);if(h&&!v&&(y.length>0&&(g=P({diagnosticCode:l.LegacyOptionalSuffix,title:"Use 'optional' throughout this document",scope:"document",edits:y.flatMap(w=>w.fix.edits)})),v=!0),k!==void 0){if(S===void 0){S=new Map;let A=i.flatMap(q=>s.has(q.number)?[s.get(q.number)]:[]),M=A.flatMap(q=>q.fix.edits),L=Xr(t,M);if(M.length>0&&L!==void 0){let q=Ne(L,void 0,e.placement),Y=A.flatMap(B=>B.change===void 0?[]:[B.change]);if(q.success&&ht(q)===ht(n,Y)){let B=new Map,j=new Map;for(let F of q.diagnostics)B.set(F.code,(B.get(F.code)??0)+1);for(let F of A)j.set(F.fix.diagnosticCode,(j.get(F.fix.diagnosticCode)??0)+F.fix.edits.length);if([...j].every(([F,J])=>(B.get(F)??0)===(a.get(F)??0)-J))for(let F of A)S.set(F.line,F.fix)}}}let w=new Map;for(let A of k){let M=S.get(A.line);M?.diagnosticCode===A.diagnosticCode&&w.set(A.line,M)}return[...w.values(),...h&&g!==void 0?[g]:[]]}let x=typeof b=="number"?b:void 0,E=x===void 0?void 0:s.get(x),$;return E!==void 0&&x!==void 0&&(O===void 0||E.fix.diagnosticCode===O)&&(m.has(x)||(m.size===32&&m.delete(m.keys().next().value),m.set(x,P(E.fix,E.change))),$=m.get(x)),[$,h?g:void 0].filter(w=>w!==void 0)}}c(x$,"prepareQuickFixes");function ht(t,e=[]){let n=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([t.value,t.triggerData],(i,r)=>["location","usesLocation","targetLocation"].includes(i)?void 0:n.get(r)??r)}c(ht,"verificationShape");function Xr(t,e){let n=[],i=0;for(let r of e){if(r.start<i||r.start<0||r.length<0||r.start+r.length>t.length)return;n.push(t.slice(i,r.start),r.text),i=r.start+r.length}return n.push(t.slice(i)),n.join("")}c(Xr,"applyQuickFixEdits");var _e=class{static{c(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,n){this.complete=n;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(n=>n.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(n.code))}resolve(e,n){let i=this.sources.get(e)??[],r=n===void 0?[]:i.flatMap(f=>f.source.streams).filter(f=>f.name===n),o=i.length>1||r.length>1,a=!this.complete||i.some(f=>!f.placementResolved),s=o?"ambiguous":a?"incomplete":i.length===1&&(n===void 0||r.length===1)?"unique":"notFound",p=[];return i.length>1&&p.push("Multiple physical parent sources claim the exact name."),r.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:s,sources:i.map(f=>f.source),streams:r,reasons:p}}};var Ul=de("^[A-Za-z_]\\w*$"),Le=c((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),_=c(t=>{throw new H(t)},"refuse"),Je=c((t,e,n)=>{if(!Array.isArray(t))return _(n);for(let i=0;i<t.length;i++)Le(t[i],e)||_(n)},"collection");function He(t){if(t.kind==="ConceptSyntax"){let e=t;for(let n of e.validations??[])n.kind==="DeclarativeValidateSyntax"&&n.rules.some(i=>i.implementation!=null)&&_("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let e=t;e.implementation!=null&&(Le(e.implementation,"ImplementationSyntax")||_("A named rule requires an ImplementationSyntax wrapper."),(e.rule!=="Rule"||e.value?.kind!=="PathExpressionSyntax"||!Le(e.value,"PathExpressionSyntax")||typeof e.value.path!="string"||Ul.exec(e.value.path)?.[0]!==e.value.path)&&_("An implementation wrapper requires a valid named rule."),e.file!=null&&e.code!=null&&_("A named rule has at most one file or inline payload."),e.file!=null&&(!Le(e.file,"FileReferenceSyntax")||typeof e.file.path!="string")&&_("A named rule file requires a FileReferenceSyntax payload with a string path."),e.code!=null&&(!Le(e.code,"CodeBlockSyntax")||typeof e.code.language!="string"||typeof e.code.code!="string")&&_("A named rule inline payload requires a CodeBlockSyntax with string language and code."),He(e.implementation))}if(t.kind==="ProducesSyntax"){let e=t,n=e.inlineOperation;if(n!=null){e.inlineEvent!=null&&_("A production cannot declare both an event and an operation."),(e.when!=null||e.event!==n.name||e.for!=null||(e.tags??[]).length>0)&&_("An inline operation requires a matching unconditional target without event metadata."),Je(n.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),Je(e.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),n.inputs.length!==e.mappings.length&&_("Inline operation inputs and mappings must correspond in order.");for(let i=0;i<n.inputs.length;i++)n.inputs[i].name!==e.mappings[i].property&&_("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let e=t;e.file!=null&&e.code!=null&&_("An operation phase has at most one file or inline payload."),e.implementation!=null&&He(e.implementation)}if(t.kind==="HandlerSyntax"){let e=t;e.implementation!=null&&e.file!=null&&e.code!=null&&_("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let e=t;Je(e.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let n=0;n<e.hints.length;n++)He(e.hints[n])}if(t.kind==="ImplementationHintSyntax"){let e=t;(typeof e.text!="string"||Mt(e.text))&&_("An implementation hint must be nonblank.")}eo(t)}c(He,"validateSyntaxInvariants");function eo(t){let e=c(n=>{Rn(n)||_("Event source and stream names must be identifiers.")},"name");if(t.kind==="ApplicationSyntax"){let n=t.eventSources;n!==void 0&&Je(n,"EventSourceSyntax","Event sources must be a collection of event source nodes without null elements.")}if(t.kind==="EventSourceSyntax"||t.kind==="EventStreamSyntax"){let n=t;e(n.name),n.id!==null&&(typeof n.id!="string"||n.id.trim()==="")&&_("A rename pin must be nonempty.");let i=n.kind==="EventSourceSyntax"?n.identifier:n.streamId;i!==null&&!Le(i,"TypeRefSyntax")&&_("Source identifiers and stream ids require type reference nodes."),i!==null&&(i.isCollection||i.isOptional)&&_("Source identifiers and stream ids require nonoptional scalar type references."),i!==null&&!Tn(i.name)&&_("Source identifiers and stream ids require an exact type reference name."),n.kind==="EventSourceSyntax"&&Je(n.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements.")}if(t.kind==="CommandSyntax"){let n=t;n.stream?.propertyCandidate!=null&&_("The authoritative command stream cannot contain an ambiguous property candidate."),n.stream!=null&&!Le(n.stream,"CommandStreamSyntax")&&_("The authoritative command stream must be a command stream node."),n.streamCandidates!==void 0&&Je(n.streamCandidates,"CommandStreamSyntax","Command stream candidates must be a collection without null elements.");let i=n.streamCandidates??[];for(let r=0;r<i.length;r++){let o=i[r];if(eo(o),o.propertyCandidate===null&&n.stream==null&&_("A duplicate route candidate requires an authoritative route."),o.propertyCandidate!==null)for(let a=0;a<n.properties.length;a++)n.properties[a]===o.propertyCandidate&&_("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="CommandStreamSyntax"){let n=t;e(n.eventSource),e(n.stream),n.streamId!==null&&n.streamId.property!=="streamId"&&_("A command stream maps only streamId.");let i=n.propertyCandidate;i!==null&&(i.name!=="stream"||i.type.name!==`${n.eventSource}.${n.stream}`||i.type.isCollection||i.type.isOptional||i.isGenerated||i.isIdentifier||n.streamId!==null)&&_("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}c(eo,"validateSourceStream");var Ee={kinds:["AddMappingSyntax","AllSyntax","ApplicationSyntax","ApplicationTriggerInteractionTriggerSyntax","ArrangementContainerSyntax","ArrangementOverrideSyntax","ArrangementSlotSyntax","ArrangementSyntax","AuthenticatedConditionSyntax","AuthenticationProviderSyntax","AuthenticationSyntax","AuthorizeSyntax","BehaviorArgumentSyntax","BehaviorParameterSyntax","BehaviorSyntax","BuiltInInteractionTriggerSyntax","CaptureAppendSyntax","CaptureChildrenSyntax","CaptureMapEntrySyntax","CaptureNestedSyntax","CaptureSourceSettingSyntax","CaptureSourceSyntax","CaptureSplitSyntax","CaptureSyntax","CaptureTranslationSyntax","CaptureWhenSyntax","CausedByExpressionSyntax","ChildrenSyntax","ClaimConditionSyntax","ClearMappingSyntax","ClearWithSyntax","CloseDialogActionSyntax","CodeBlockSyntax","CodeValidateSyntax","CommandSyntax","CommandStreamSyntax","ComparisonConditionSyntax","CompositeKeySyntax","ConceptAttributeSyntax","ConceptSyntax","ConcurrencySyntax","ConfirmActionSyntax","ContextExpressionSyntax","ContributionSyntax","CountMappingSyntax","DeclarativeValidateSyntax","DecrementMappingSyntax","DialogTemplateSyntax","DomainSyntax","EnvironmentExpressionSyntax","EventContextExpressionSyntax","EventInteractionTriggerSyntax","EventSourceIdExpressionSyntax","EventSourceSyntax","EventStreamSyntax","EventSpecSyntax","EventSyntax","EverySyntax","ExecuteCommandActionSyntax","ExpressionKeySyntax","FeatureSyntax","FileConstraintSyntax","FileImportSyntax","FileReferenceSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","InteractionArgumentSyntax","InteractionBindingSyntax","IntervalInteractionTriggerSyntax","IntervalTriggerSourceSyntax","InvokesSyntax","JoinEventSyntax","JoinSyntax","KeyPartSyntax","LayoutSyntax","ListExpressionSyntax","LiteralExpressionSyntax","LogicalConditionSyntax","LogicalPolicyConditionSyntax","LogicalPolicyRequirementSyntax","ModuleSyntax","NamedTriggerSourceSyntax","NavigateActionSyntax","NavigateBackActionSyntax","NestedSyntax","NotifyActionSyntax","OpenDialogActionSyntax","ObjectExpressionSyntax","ObjectMemberSyntax","PathExpressionSyntax","PerformerSyntax","PersonaSyntax","PlaceSyntax","PolicyReferenceSyntax","PolicySyntax","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PropertyMappingSyntax","PropertySyntax","PropertyResponseSourceSyntax","ResponseFieldSyntax","ScalarCommandResponseSyntax","RecordCommandResponseSyntax","ScalarSpecificationReturnSyntax","RecordSpecificationReturnSyntax","QueryParameterSyntax","QuerySyntax","RaiseTriggerActionSyntax","RawExpressionSyntax","ReactionSyntax","ReactionTriggerSyntax","ReadModelSyntax","ReadsSyntax","ReducerRuleSyntax","ReducerSyntax","RefreshQueryActionSyntax","RemoveViaJoinSyntax","RemoveWithSyntax","RequirementSyntax","RoleConditionSyntax","ScheduleTriggerSourceSyntax","ScreenActionSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","fileImports","imports","layouts","modules","personas","policies","seeds","sourceOptions","numericMode","systems","themes","triggers","types","uiProfiles","triggerName","children","gap","syntaxKind","height","root","width","grow","name","span","mode","overrides","variants","alias","providers","requirement","type","bindings","description","file","order","parameters","event","tags","when","appends","identifiedBy","map","source","translations","settings","separator","targets","key","nested","from","to","expression","fromValue","properties","toValue","blocks","claim","matches","matchesSubject","arguments","onFailure","onResult","onSuccess","code","language","authorize","concurrency","handler","produces","reads","response","stream","streamCandidates","validations","eventSource","propertyCandidate","streamId","left","operator","right","parts","reason","attributes","values","eventSourceType","eventStreamId","eventStreamType","eventTypes","message","messageIsLiteral","path","contributionPoint","label","navigate","requirements","rules","arrangement","slots","usedBehaviors","eventName","id","identifier","streams","documentation","generation","hasGenerationMarker","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","composeUsing","by","query","fields","for","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","operation","qualifiedName","binding","actions","condition","trigger","amount","unit","on","items","literalType","dialogTemplates","forms","screenTemplates","screen","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","filters","isObservable","performer","returnType","scope","where","data","invokes","severity","role","dayOfMonth","dayOfWeek","time","behavior","directives","target","columns","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","operations","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","roles","capture","record","instant","commandType","generatedValues","eventType","exactly","results","given","givenCaller","givenCaptures","givenClock","givenOperationFailures","givenReadModels","thenAbsentReadModels","thenCompensated","thenDenied","thenErrors","thenEvents","thenEventsInAnyOrder","thenNoResult","thenOperations","thenQueries","thenReadModels","thenResults","thenReturns","whenAppended","whenCapture","whenClock","whenQuery","whenTrigger","compatibleWith","isCollection","isOptional","defaultSizeClass","layout","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,42,49,50,52,89,90,101,103,124,160,177,180],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,29,44,46,79,156,178],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",39],["array",12],["ref",48],["union",14,8],["ref",53],["array",16],["ref",62],["array",18],["ref",78],["array",20],["ref",88],["array",22],["union",23,8],["ref",94],["array",25],["ref",105],["array",27],["union",28,8],["ref",108],["array",30],["ref",155],["array",32],["union",33,8],["enum","legacy","exact"],["object",[[17,35,!0]]],["ref",72],["array",37],["ref",183],["array",39],["union",40,8],["ref",185],["array",42],["union",43,8],["ref",187],["array",45],["union",46,8],["ref",188],["array",48],["union",49,8],["object",[[4,9,!1],[5,11,!1],[6,13,!1],[7,15,!1],[8,17,!1],[9,19,!1],[10,21,!1],[11,24,!1],[12,26,!1],[13,29,!1],[14,31,!1],[15,34,!1],[16,36,!1],[18,38,!1],[19,41,!1],[20,44,!1],[21,47,!1],[22,50,!1]]],["object",[[23,0,!0]]],["ref",4,6],["array",53],["integer",-2147483648,2147483647],["union",55,8],["enum","Flat","Row","Column","Grid"],["object",[[24,54,!1],[25,56,!1],[26,57,!0]]],["union",0,8],["object",[[27,59,!1],[28,53,!0],[29,59,!1]]],["boolean"],["object",[[30,61,!1],[27,56,!1],[31,0,!0],[32,56,!1],[29,56,!1]]],["enum","Flow","Freeform"],["ref",5],["array",64],["union",65,8],["union",53,8],["ref",194],["array",68],["union",69,8],["object",[[33,63,!0],[34,66,!1],[28,67,!1],[35,70,!1]]],["object",[]],["object",[[36,59,!1],[31,0,!0]]],["ref",9],["array",74],["object",[[37,75,!1]]],["ref",93,107],["object",[[38,77,!0]]],["object",[[31,0,!0],[1,0,!0]]],["ref",186],["union",80,8],["object",[[31,0,!0],[39,81,!1]]],["ref",81],["array",83],["ref",63],["union",85,8],["ref",13],["array",87],["object",[[40,84,!1],[41,59,!1],[42,86,!1],[31,59,!1],[43,56,!1],[44,88,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[26,90,!0]]],["ref",113],["array",92],["ref",179],["array",94],["union",95,8],["ref",25],["union",97,8],["object",[[45,0,!0],[3,93,!1],[46,96,!1],[47,98,!1]]],["ref",16],["array",100],["ref",18,22],["array",102],["object",[[48,101,!1],[49,0,!0],[50,103,!1],[0,0,!0]]],["ref",24],["array",105],["object",[[0,0,!0],[51,1,!0],[52,106,!1]]],["object",[[48,101,!1],[50,103,!1],[0,0,!0]]],["ref",20],["array",109],["object",[[53,110,!1],[26,0,!0]]],["array",0],["object",[[54,0,!0],[51,1,!0],[55,112,!1]]],["ref",17],["array",114],["ref",19],["array",116],["ref",21],["union",118,8],["object",[[48,101,!1],[24,115,!1],[56,59,!1],[50,103,!1],[31,0,!0],[57,117,!1],[51,119,!1],[16,36,!1]]],["object",[[58,0,!0],[59,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[60,59,!1],[61,59,!1],[62,112,!1],[26,122,!0],[63,59,!1]]],["object",[[0,59,!1]]],["ref",1,27,30,57,68,86,98,112,132,133],["array",125],["object",[[2,3,!0],[64,126,!1],[49,1,!0],[0,0,!0]]],["union",1,8],["object",[[65,0,!0],[66,128,!1],[67,61,!0]]],["object",[[0,0,!0]]],["object",[[45,0,!0]]],["ref",80],["array",132],["ref",31,41,58,96,97,99,100,123,131,157],["array",134],["object",[[68,133,!1],[69,135,!1],[70,135,!1],[71,135,!1]]],["object",[[72,0,!0],[73,0,!0]]],["ref",32],["object",[[72,138,!0]]],["ref",11],["union",140,8],["ref",40],["union",142,8],["ref",69],["union",144,8],["ref",109],["array",146],["ref",114],["array",148],["ref",128],["array",150],["union",151,8],["ref",117,118],["union",153,8],["ref",35],["union",155,8],["array",155],["ref",33,45],["array",158],["object",[[74,141,!1],[75,143,!1],[41,59,!1],[76,145,!1],[31,0,!0],[77,147,!1],[62,149,!1],[78,152,!1],[79,154,!1],[80,156,!1],[81,157,!1],[82,159,!1]]],["union",148,8],["union",92,8],["object",[[83,0,!0],[84,161,!1],[80,0,!0],[85,162,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[86,0,!0],[87,164,!0],[88,1,!0]]],["ref",87],["array",166],["object",[[89,167,!1],[39,0,!0]]],["object",[[31,0,!0],[90,59,!1]]],["ref",38],["array",170],["union",159,8],["object",[[91,171,!1],[42,86,!1],[31,0,!0],[39,0,!0],[82,172,!1],[92,112,!1]]],["object",[[83,61,!0],[93,59,!1],[94,59,!1],[95,59,!1],[96,112,!1]]],["object",[[68,133,!1],[97,0,!0],[98,61,!0],[69,135,!1],[70,135,!1],[71,135,!1]]],["object",[[99,0,!0]]],["ref",143],["union",177,8],["object",[[100,0,!0],[101,59,!1],[102,178,!1],[43,56,!1]]],["ref",134],["array",180],["union",181,8],["ref",193],["array",183],["object",[[103,182,!1],[104,184,!1]]],["ref",7],["union",186,8],["ref",159],["array",188],["ref",192],["array",190],["object",[[105,187,!1],[5,11,!1],[31,0,!0],[106,189,!1],[107,191,!1]]],["object",[[31,0,!0]]],["object",[[108,0,!0]]],["ref",54],["array",195],["object",[[41,59,!1],[109,59,!1],[110,81,!1],[31,0,!0],[111,196,!1]]],["object",[[41,59,!1],[109,59,!1],[31,0,!0],[85,81,!1]]],["object",[[45,0,!0],[56,128,!1]]],["integer",0,4294967295],["object",[[41,59,!1],[112,59,!1],[42,86,!1],[113,200,!1],[114,61,!1],[109,59,!1],[31,0,!0],[62,149,!1],[46,96,!1]]],["object",[[2,3,!0],[115,61,!0],[3,5,!1]]],["object",[[68,133,!1],[116,0,!0],[69,135,!1],[70,135,!1],[71,135,!1]]],["object",[[60,1,!0]]],["ref",43],["array",205],["union",206,8],["ref",191],["array",208],["ref",60],["array",210],["ref",158],["array",212],["object",[[74,141,!1],[5,11,!1],[117,207,!1],[118,209,!1],[41,59,!1],[119,211,!1],[9,19,!1],[120,61,!0],[31,0,!0],[121,213,!1],[107,191,!1]]],["ref",61,189,190],["array",215],["object",[[122,216,!1],[42,85,!0],[123,61,!0],[97,59,!1],[31,0,!0],[124,112,!1]]],["object",[[125,0,!0]]],["object",[[126,59,!1],[58,59,!1],[101,59,!1],[0,0,!0]]],["object",[[127,59,!1],[128,0,!0]]],["ref",64],["array",221],["ref",65,66],["union",223,8],["object",[[5,11,!1],[129,222,!1],[130,0,!0],[31,0,!0],[131,178,!1],[132,224,!1],[107,191,!1]]],["ref",55],["array",226],["ref",37,59],["union",228,8],["object",[[133,227,!1],[56,229,!1],[3,5,!1],[134,128,!1]]],["union",138,8],["ref",70],["union",232,8],["object",[[72,231,!1],[42,86,!1],[135,233,!1]]],["ref",71],["array",235],["object",[[136,236,!1]]],["object",[[137,0,!0]]],["object",[[41,59,!1],[31,0,!0]]],["ref",74],["union",240,8],["object",[[138,241,!1],[41,59,!1],[139,241,!1],[140,149,!1],[31,0,!0],[141,0,!0]]],["object",[[72,231,!1],[41,59,!1],[42,86,!1],[135,233,!1]]],["object",[[142,0,!0]]],["object",[[142,0,!0],[92,93,!1]]],["object",[[143,0,!0]]],["object",[[144,0,!0],[31,0,!0]]],["ref",3,15,51,82],["object",[[145,135,!1],[146,59,!1],[147,248,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[148,55,!0],[149,250,!0]]],["object",[[116,0,!0],[3,93,!1]]],["object",[[2,3,!0],[45,0,!0],[3,5,!1]]],["ref",85],["array",254],["object",[[133,255,!1],[150,0,!0],[0,0,!0]]],["object",[[60,1,!0],[0,0,!0]]],["array",1],["object",[[151,258,!1]]],["union",0,61,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[152,262,!0],[1,263,!0]]],["const","ExactNumber"],["string","^(?:0|-?(?:[1-9][0-9]{0,28}|(?:0|[1-9][0-9]{0,28})\\.[0-9]{0,27}[1-9]))$"],["object",[[152,265,!0],[1,266,!0]]],["union",260,261,264,267],["object",[[1,268,!1]]],["ref",36,91],["enum","And","Or"],["object",[[86,270,!0],[87,271,!0],[88,270,!0]]],["ref",8,28,92,135],["object",[[86,273,!0],[87,271,!0],[88,273,!0]]],["object",[[86,77,!0],[87,271,!0],[88,77,!0]]],["ref",47],["array",276],["union",277,8],["ref",67],["array",279],["union",280,8],["ref",150],["array",282],["object",[[74,141,!1],[5,11,!1],[117,207,!1],[118,209,!1],[41,59,!1],[153,278,!1],[119,211,!1],[9,19,!1],[154,281,!1],[120,61,!0],[31,0,!0],[155,283,!1],[107,191,!1]]],["object",[[68,133,!1],[69,135,!1],[70,135,!1],[71,135,!1],[156,0,!0]]],["object",[[2,3,!0],[64,126,!1],[0,0,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[68,133,!1],[157,287,!0],[97,0,!0],[98,61,!0],[69,135,!1],[70,135,!1],[71,135,!1]]],["object",[[68,133,!1],[158,0,!0],[69,135,!1],[70,135,!1],[71,135,!1]]],["ref",102],["array",290],["object",[[159,291,!1]]],["object",[[31,0,!0],[1,1,!0]]],["object",[[72,231,!1],[42,86,!1]]],["object",[[41,59,!1],[31,0,!0],[14,112,!1]]],["object",[[160,61,!1],[161,59,!1],[162,59,!1],[163,0,!0],[164,56,!1],[165,56,!1]]],["union",273,8],["object",[[72,231,!1],[146,297,!1],[42,86,!1],[31,0,!0]]],["ref",56],["union",299,8],["ref",73],["union",301,8],["union",270,8],["object",[[45,0,!0],[130,128,!1],[166,300,!1],[167,302,!1],[3,93,!1],[46,96,!1],[47,303,!1]]],["object",[[2,3,!0],[64,126,!1],[42,86,!1],[56,229,!1],[31,0,!0],[168,59,!1],[169,59,!1],[16,36,!1]]],["ref",110],["array",306],["object",[[64,126,!1],[170,307,!1],[31,0,!0]]],["object",[[0,0,!0],[51,1,!0]]],["object",[[171,61,!1],[172,61,!1],[31,0,!0],[39,80,!0]]],["ref",115],["object",[[31,0,!0],[51,311,!0],[39,81,!1]]],["object",[[51,311,!0]]],["ref",116],["array",314],["object",[[129,315,!1]]],["object",[[1,1,!0]]],["object",[[129,93,!1]]],["object",[[31,0,!0],[51,128,!1],[39,80,!0]]],["ref",121],["union",320,8],["array",320],["ref",104],["union",323,8],["object",[[74,141,!1],[127,321,!1],[41,59,!1],[173,322,!1],[174,61,!1],[31,0,!0],[175,324,!1],[176,80,!0],[177,59,!1]]],["object",[[68,133,!1],[69,135,!1],[70,135,!1],[71,135,!1],[147,0,!0]]],["ref",126],["array",327],["object",[[41,59,!1],[31,0,!0],[20,328,!1],[178,303,!1]]],["ref",184],["array",330],["ref",84],["array",332],["union",333,8],["union",147,8],["ref",83,95,136],["object",[[72,231,!1],[179,331,!1],[41,59,!1],[42,86,!1],[180,334,!1],[77,335,!1],[78,152,!1],[51,336,!0]]],["object",[[41,59,!1],[42,86,!1],[31,0,!0],[62,149,!1]]],["object",[[36,59,!1],[127,59,!1],[168,0,!0]]],["object",[[72,231,!1],[41,59,!1],[45,0,!0],[42,86,!1]]],["ref",129],["array",341],["object",[[41,59,!1],[31,0,!0],[168,0,!0],[104,342,!1]]],["object",[[68,133,!1],[69,135,!1],[70,135,!1],[71,135,!1],[128,0,!0]]],["object",[[45,0,!0],[56,128,!1],[134,128,!1]]],["enum","Error","Information","Warning"],["object",[[146,270,!0],[97,59,!1],[181,346,!0]]],["object",[[182,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",349,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[183,56,!1],[184,350,!1],[185,351,!0]]],["object",[[116,0,!0],[101,59,!1],[102,178,!1]]],["object",[[186,10,!0]]],["object",[[101,59,!1],[0,0,!0]]],["object",[[127,59,!1],[128,0,!0],[39,80,!0]]],["object",[[101,0,!0],[0,0,!0]]],["object",[[127,59,!1],[156,0,!0]]],["ref",137,138,139,141,143,144,145,146,148,149,151,152],["array",359],["object",[[187,360,!1],[31,0,!0]]],["ref",142],["array",362],["object",[[129,363,!1],[188,0,!0]]],["object",[[187,360,!1],[42,86,!1],[31,0,!0]]],["ref",140],["array",366],["object",[[5,11,!1],[189,367,!1],[190,178,!1],[188,0,!0],[107,191,!1]]],["ref",145],["array",369],["object",[[31,0,!0],[106,370,!1]]],["object",[[105,187,!1],[5,11,!1],[191,59,!1],[31,0,!0],[106,189,!1],[107,191,!1]]],["object",[[141,190,!0]]],["object",[[45,0,!0],[62,93,!1]]],["ref",153],["array",375],["object",[[192,0,!0],[133,376,!1]]],["ref",154],["array",378],["object",[[193,379,!1]]],["object",[[68,133,!1],[69,135,!1],[70,135,!1],[71,135,!1],[188,0,!0],[1,0,!0]]],["ref",23],["array",382],["ref",34],["array",384],["array",299],["array",301],["ref",111],["array",388],["ref",122],["array",390],["ref",125],["array",392],["ref",127],["array",394],["union",395,8],["ref",130],["array",397],["union",398,8],["ref",147],["array",400],["ref",174],["array",402],["enum","StateChange","StateView","Automation","Translate"],["object",[[194,383,!1],[195,385,!1],[196,216,!1],[41,59,!1],[133,386,!1],[42,86,!1],[31,0,!0],[197,387,!1],[198,389,!1],[199,391,!1],[200,393,!1],[201,396,!1],[202,399,!1],[203,401,!1],[204,403,!1],[39,404,!0]]],["object",[[205,59,!1],[31,0,!0]]],["object",[[56,1,!0],[31,0,!0]]],["object",[[39,0,!0],[1,0,!0]]],["ref",162],["array",409],["object",[[206,61,!0],[207,410,!1],[208,112,!1]]],["object",[[209,0,!0],[210,93,!1]]],["object",[[211,0,!0]]],["object",[[212,0,!0],[130,128,!1],[213,93,!1],[92,93,!1]]],["object",[[31,59,!1]]],["object",[[214,0,!0],[130,128,!1],[92,93,!1]]],["object",[[215,61,!0],[62,93,!1]]],["ref",171],["array",418],["object",[[68,93,!1],[215,61,!0],[128,0,!0],[216,419,!1]]],["object",[[215,61,!0],[31,0,!0],[62,93,!1]]],["ref",169],["array",422],["ref",163],["union",424,8],["ref",164],["array",426],["ref",165],["union",428,8],["ref",75],["array",430],["ref",173],["array",432],["union",433,8],["ref",161],["array",435],["ref",77],["array",437],["ref",167],["union",439,8],["ref",168],["array",441],["ref",170],["union",443,8],["ref",76],["array",445],["ref",172],["array",447],["ref",119,120],["union",449,8],["ref",166],["union",451,8],["union",422,8],["union",426,8],["ref",176],["union",455,8],["ref",175],["union",457,8],["object",[[42,86,!1],[217,423,!1],[218,425,!1],[219,427,!1],[220,429,!1],[221,431,!1],[222,434,!1],[31,0,!0],[16,36,!1],[223,436,!1],[224,438,!1],[225,440,!1],[226,442,!1],[227,423,!1],[228,61,!0],[229,444,!1],[230,446,!1],[231,448,!1],[232,434,!1],[233,419,!1],[234,450,!1],[47,452,!1],[235,453,!1],[236,454,!1],[237,429,!1],[238,456,!1],[239,458,!1]]],["object",[[147,0,!0],[92,93,!1]]],["object",[[68,93,!1],[128,0,!0]]],["object",[[56,0,!0]]],["ref",181,182],["array",463],["object",[[89,464,!1]]],["object",[[240,112,!1],[31,0,!0]]],["object",[[179,331,!1],[41,59,!1],[42,86,!1],[31,0,!0]]],["object",[[241,61,!0],[242,61,!0],[31,0,!0]]],["object",[[243,59,!1],[244,59,!1],[31,0,!0],[245,112,!1],[246,112,!1],[247,59,!1]]],["object",[[122,216,!1],[45,0,!0],[123,61,!0],[97,59,!1],[31,0,!0],[124,112,!1]]],["object",[[248,112,!1],[122,216,!1],[45,0,!0],[123,61,!0],[97,59,!1],[31,0,!0],[0,0,!0],[124,112,!1]]],["object",[[188,0,!0]]],["ref",12],["array",473],["object",[[68,474,!1],[186,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[72,231,!1],[42,86,!1],[135,233,!1],[97,59,!1],[0,0,!0],[249,476,!0],[181,346,!0],[1,128,!1]]],["ref",106],["array",478],["object",[[27,0,!0],[250,479,!1],[29,0,!0]]]],contracts:[2,6,51,52,58,60,62,71,72,73,76,78,79,82,89,91,99,104,107,108,79,111,113,120,121,123,124,127,129,130,131,136,137,139,160,163,165,168,169,173,174,175,176,179,130,185,130,192,193,193,176,194,72,197,198,199,201,202,203,204,214,217,218,176,219,72,220,225,230,234,237,238,239,242,243,244,245,244,246,130,247,249,251,251,252,253,256,257,192,259,269,272,274,275,284,193,285,136,286,288,289,292,293,176,294,295,296,193,298,304,199,305,308,309,310,130,312,313,316,317,318,319,325,326,238,329,337,338,339,340,343,344,199,345,347,348,352,353,354,139,355,356,357,358,361,361,364,365,368,371,372,238,373,374,377,380,309,381,405,406,176,407,408,411,412,413,414,72,415,416,72,417,420,421,459,460,461,462,2,317,465,204,238,466,82,467,468,338,469,470,471,472,475,477,480]};var li=Ee.rules,zl=new Map(li.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),no=new Map(Ee.kinds.map((t,e)=>[t,li[Ee.contracts[e]][1]])),Vl=new Map([...no].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>Ee.names[n])])])),to=c(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function di(t){let e=no.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!io(t,e))throw new H(`Invalid typed members for syntax kind '${t.kind}'.`)}c(di,"validateSyntaxMembers");function rn(t,e){let n=on(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new H(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}c(rn,"validateClosedSyntaxMembers");function on(t){let e=Vl.get(t);if(e===void 0)throw new H(`Unknown syntax kind '${t}'.`);return e}c(on,"syntaxMemberNames");function io(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,Ee.names[n])?pi(t[Ee.names[n]],i):!r)}c(io,"matchesMembers");function Ql(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!pi(t[n],e))return!1;return!0}c(Ql,"allIndicesMatch");function pi(t,e){let[n,...i]=li[e];switch(n){case"ref":return to(t)&&typeof t.kind=="string"&&i.some(r=>Ee.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,a)=>o+(pi(t,a)?1:0),0);return n==="one"?r===1:r>0}case"const":return t===i[0];case"enum":return i.includes(t);case"null":return t===null;case"array":return Array.isArray(t)&&Ql(t,i[0]);case"object":return to(t)&&Object.keys(t).every(r=>i[0].some(([o])=>Ee.names[o]===r))&&io(t,i[0]);case"integer":case"number":return typeof t=="number"&&Number.isFinite(t)&&(n!=="integer"||Number.isInteger(t))&&(i.length===0||t>=i[0]&&t<=i[1]&&!(n==="integer"&&i[0]===0&&Object.is(t,-0)));case"string":return typeof t=="string"&&(i.length===0||zl.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}c(pi,"matches");var Zl=Object.fromEntries("ApplicationSyntax:policies,seeds;ConceptSyntax:validations;DeclarativeValidateSyntax:requirements;CodeValidateSyntax:code;CaptureAppendSyntax:when,mappings,tags;CaptureChildrenSyntax:map;CaptureNestedSyntax:map;CaptureSyntax:map;EventSpecSyntax:key;FromSyntax:key,parentKey;ChildrenSyntax:identifiedBy;RemoveWithSyntax:key,parentKey;RemoveViaJoinSyntax:key;ProjectionEntersOnSyntax:key;ProjectionSyntax:key;QueryParameterSyntax:source;ProducesSyntax:when;InvokesSyntax:mappings;ReactionSyntax:where;SpecificationSyntax:thenAbsentReadModels,thenQueries".split(";").map(t=>t.split(":")).map(([t,e])=>[t,new Set(e.split(","))])),Gl=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function Kl(t,e){return Zl[t]?.has(e)===!0||Gl.test(t)&&(e==="source"||e==="value")}c(Kl,"isExactOnlyMember");function ro(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:Kl(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}c(ro,"isLegacyOmittedMember");var sn=c(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),an=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers"]),cn=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function dn(t){let e=_l(t);return fi(e,"legacy",0),ln(e)}c(dn,"toSyntaxJson");function _l(t){let e=new WeakMap,n=[];function i(o){if(typeof o!="object"||o===null)return o;if(e.has(o))return e.get(o);if(Array.isArray(o)){let p=oo();e.set(o,p);let f=o.length;for(let y=f-1;y>=0;y--)n.push(()=>{p[y]=i(Object.hasOwn(o,y)?o[y]:void 0)});return p}let a=Object.create(null);e.set(o,a);let s=Object.keys(o);!s.includes("kind")&&"kind"in o&&s.unshift("kind");for(let p=s.length-1;p>=0;p--)n.push(()=>{let f=s[p],y=o[f];f==="sourceOptions"&&n.push(()=>{typeof y=="object"&&y!==null&&(Object.getPrototypeOf(y)!==Object.prototype&&Object.getPrototypeOf(y)!==null||Reflect.ownKeys(y).length!==Object.keys(y).length)&&(a[f]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),a[f]=i(y)});return a}c(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}c(_l,"snapshot");function oo(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}c(oo,"dataArray");function ln(t,e="legacy",n=!1){if(Array.isArray(t)){let o=oo();for(let a=0;a<t.length;a++)o.push(ln(t[a],e,n));return o}if(sn(t)){if(cn.has(t.kind)&&(e=Ze(t.sourceOptions??fe).numericMode),He(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&rn(t,an),t.kind==="ValidationRuleSyntax"){let f=t;f.implementation!=null&&(f.file!=null&&rn(f.file,an),f.code!=null&&rn(f.code,an))}let o=Object.create(null);o.kind=t.kind;let a={...t};t.kind==="ApplicationSyntax"&&a.eventSources===void 0&&(a.eventSources=[]),t.kind==="CommandSyntax"&&a.stream===void 0&&(a.stream=null),t.kind==="CommandSyntax"&&a.streamCandidates===void 0&&(a.streamCandidates=[]);let s=e==="exact"?on(t.kind):void 0,p=Object.keys(a).filter(f=>(s===void 0||s.has(f))&&!(e==="legacy"&&!n&&ro(t,f))&&!an.has(f)&&!(t.kind==="OperationSyntax"&&f==="usesLocation")).sort(Jl);for(let f of p){let y=a[f];f==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(y)&&y.length===0||f==="sourceOptions"&&y?.numericMode==="legacy"||(o[f]=ln(y,e,n))}return o}if(t===void 0)return null;if(typeof t!="object"||t===null)return t;let i=t,r=Object.create(null);if(i.literalType==="ExactNumber")return r.literalType="ExactNumber",r.value=i.value,r;for(let o of Object.keys(i))o!=="toJSON"&&i[o]!==void 0&&(r[o]=ln(i[o],e,n));return r}c(ln,"write");function fi(t,e,n){if(n>96&&e==="exact")throw new H("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)fi(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(cn.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?Ze(i.sourceOptions):fe;if(n>0&&e!==o.numericMode)throw new H("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!cn.has(i.kind))throw new H("Exact syntax requires a complete source root.");if(e==="exact"&&sn(i)&&di(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&at(i.text))throw new H("An exact numeric operand must be an explicit ExactNumber, not opaque numeric text.");if(i.kind==="LiteralExpressionSyntax"&&Object.hasOwn(i,"value")){if(e==="exact"&&(typeof i.value=="number"||i.value!==null&&!["string","boolean","object"].includes(typeof i.value)))throw new H("Exact source requires supported primitive values or an explicit ExactNumber literal.");if(typeof i.value=="object"&&i.value!==null){let o=i.value;if(o.literalType==="ExactNumber"){if(e!=="exact"||typeof o.value!="string"||be(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new H("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new H("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&sn(i)?on(i.kind):void 0;for(let[o,a]of Object.entries(i))(r===void 0||r.has(o)||sn(a)&&cn.has(a.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&fi(a,e,n+1)}c(fi,"validateNumbers");function Jl(t,e){return t<e?-1:t>e?1:0}c(Jl,"ordinal");function ao(t){let e=[],n=t.map(g=>g.value),i=new Map,r=!1;for(let g of n)try{i.set(g,Object.hasOwn(g,"sourceOptions")?Ze(g.sourceOptions):fe)}catch(P){if(!(P instanceof H))throw P;r=!0,e.push(fn(l.IncompatibleNumericSource,P.message,g.location))}let o=n.filter(g=>i.get(g)?.numericMode==="exact"||Hl(g)),a=i.get(o[0])??fe;for(let g of o.slice(1))i.get(g)?.numericMode!==a.numericMode&&(r=!0,e.push(fn(l.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",g.location)));r&&(a=rr);let s=new Map,p=pn(n.flatMap(g=>g.concepts),"declaration of",e,void 0,s),f=pn(n.flatMap(g=>g.types),"declaration of",e,void 0,s),y=n.map(g=>g.domain).filter(g=>g!==null);for(let g of y.slice(1))e.push(fn(l.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${un(y[0].location.path)}' - a folder compiles to one application, which can have at most one`,g.location));let u=Xl(n.flatMap(g=>g.modules),e),m=pn(n.flatMap(g=>g.personas),"persona",e),S={kind:"ApplicationSyntax",sourceOptions:a,domain:y[0]??null,imports:ed(n.flatMap(g=>g.imports),g=>g.qualifiedName),concepts:p,types:f,systems:n.flatMap(g=>g.systems??[]),eventSources:n.flatMap(g=>g.eventSources??[]),declaredTriggers:n.flatMap(g=>g.declaredTriggers??[]),modules:u,personas:m,policies:n.flatMap(g=>g.policies??[]),seeds:n.flatMap(g=>g.seeds??[]),fileImports:n.flatMap(g=>g.fileImports),location:n[0]?.location??{line:1,column:1}},v=[...t.flatMap(g=>g.diagnostics),...e];return{value:S,diagnostics:v,success:!v.some(g=>g.severity==="error")}}c(ao,"mergeDocuments");function Hl(t){if(sr(t)||t.domain!==null||t.concepts.length>0||t.types.length>0||t.personas.length>0||(t.policies?.length??0)>0||(t.seeds?.length??0)>0||(t.systems?.length??0)>0||(t.eventSources?.length??0)>0)return!0;let e=c(n=>!n.isPlacement||n.slices.length>0||n.features.some(e),"feature");return t.modules.some(n=>!n.isPlacement||n.features.some(e))}c(Hl,"hasDeclarations");function Xl(t,e){return fo(t).map(lo).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(ui)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),description:uo(n,`module '${n[0].name}'`,e),authorize:po(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:co(n),features:so(n.flatMap(i=>i.features),e)})}c(Xl,"mergeModules");function so(t,e){return fo(t).map(lo).map(n=>n.length===1?ui(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),description:uo(n,`feature '${n[0].name}'`,e),authorize:po(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:co(n),features:so(n.flatMap(i=>i.features),e),slices:pn(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}c(so,"mergeFeatures");function co(t){return[...t].sort((e,n)=>(e.location.path??"")<(n.location.path??"")?-1:(e.location.path??"")>(n.location.path??"")?1:0).flatMap(e=>e.dependsOn??[])}c(co,"groupDependencies");function lo(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}c(lo,"placedLast");function ui(t){return{...t,isPlacement:!1,features:t.features.map(ui)}}c(ui,"unplaced");function po(t,e,n){let i=[];for(let r of t.filter(o=>o!==null)){let o=i.find(a=>a.location.path!==r.location.path&&JSON.stringify(dn(a))===JSON.stringify(dn(r)));if(o!==void 0){n.push(yo(l.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${un(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>$e(r,o),null)}c(po,"combineAuthorization");function ed(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}c(ed,"firstOfEach");function fo(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}c(fo,"groupByName");function uo(t,e,n){let i=t.filter(r=>r.description!==null);for(let r of i.slice(1).filter(o=>o.description!==i[0].description))n.push(yo(l.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${un(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}c(uo,"firstDescription");function pn(t,e,n,i,r=new Map){let o=[];for(let a of t){let s=r.get(a.name);if(s!==void 0&&s.path!==a.location.path){n.push(fn(l.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${a.name}'${i===void 0?"":` in ${i}`} - already declared in '${un(s.path)}'`,a.location));continue}s===void 0&&r.set(a.name,a.location),o.push(a)}return o}c(pn,"declaredInOneFile");var un=c(t=>t??"another file","describe"),fn=c((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),yo=c((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function So(t,e){return id(t,e).result}c(So,"parsePlacedDocuments");function id(t,e){let n=Ge.capturePlaced(t.filter(S=>S.isPlacementResolved!==!1).map(S=>({lines:Be(S.source,!1,S.path),placement:S.placement})),e),i=t.map(S=>Ne(S.source,S.path,S.isPlacementResolved===!1?[]:S.placement,!1,n,e)),r=i.flatMap((S,v)=>(S.value.eventSources??[]).map(g=>({source:g,placementResolved:t[v].isPlacementResolved!==!1}))),o=t.every(S=>S.isPlacementResolved!==!1)&&i.every(S=>!_e.hasUnknownExtent(S.diagnostics)),a=i.map((S,v)=>t[v].isPlacementResolved===!1?{...S,value:{...S.value,eventSources:[]}}:S),s=ao(a),p=new se(new je([]),void 0,e);s.value.sourceOptions!==void 0&&(p.sourceOptions=s.value.sourceOptions),Xt(s.value,p),_t(s.value,p),Kt(s.value,p),Qt(s.value,p,a.flatMap(S=>S.inputUses)),en(s.value,p),tn(s.value,p);let f=Et(s.value,p),y=s.diagnostics,u=new Set(y.map(mo)),m=[...y,...p.diagnostics.filter(S=>!u.has(mo(S)))];return{result:{...s,value:f,diagnostics:m,success:!m.some(S=>S.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(a.map((S,v)=>[t[v].path,S.value]))}}c(id,"parsePlacedDocumentsWithSyntax");function mo(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}c(mo,"diagnosticKey");var zb="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",gt=new Map;function rd(t,e){let n=ae(t),i=t.flatMap((u,m)=>!n[m]&&z(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:t.join(`
|
|
7
|
-
`),locations:t.map((u,m)=>({line:m+1,column:0}))};let r=[],o=[],a=!1;t.forEach((u,m)=>{!n[m]&&z(u)===0&&/^\w/.test(u)&&(a=/^(?:concept|type|import|domain|system|eventsource)\b/.test(u)),(a?r:o).push(m)});let s=i.includes("feature")?1:i.includes("slice")?2:3,p=e.slice(0,s),f=[...r.map(u=>t[u]),...p,...o.map(u=>" ".repeat(s*2)+t[u])].join(`
|
|
8
|
-
`),y=[...r.map(u=>({line:u+1,column:0})),...p.map(()=>({line:0,column:0})),...o.map(u=>({line:u+1,column:s*2}))];return{source:f,locations:y}}c(rd,"authoringSource");function od(t,e,n,i="current.play",r=!0){let o=e.map((I,T)=>typeof I=="string"?{path:`other-${T}.play`,source:I}:I).filter(I=>I.path!==i),a=[{path:i,source:t.join(`
|
|
9
|
-
`),placement:n,isPlacementResolved:r},...o],s=new Set(a.flatMap(I=>[...I.source.matchAll(/\w+/g)].map(T=>T[0]).concat(I.placement??[]))),p=c(I=>{let T=I;for(let D=1;s.has(T);D++)T=`${I}${D}`;return s.add(T),T},"fresh"),f=p("EditorAuthoring"),y=p("FragmentFeature"),u=new Set([f,y]),m=a.map((I,T)=>{let D=T===0?t:I.source.split(`
|
|
10
|
-
`),N=p(`Fragment${T}`);u.add(N);let tt=I.placement?.length?{source:I.source,locations:D.map((Sn,bt)=>({line:bt+1,column:0}))}:rd(D,[`module ${f}`,` feature ${y}`,` slice StateChange ${N}`]);return{...I,...tt,placement:I.placement??[]}}),S=m[0],v=new Map(m.map(I=>[I.path,I.locations])),g=So([...m.slice(1),S]),P=new Map,b=new Map,O=new WeakSet,k=c(I=>{if(I===null||typeof I!="object"||O.has(I))return;if(O.add(I),Array.isArray(I)){I.forEach(k);return}let T=I;if(typeof T.path=="string"&&typeof T.line=="number"&&typeof T.column=="number"){let D=v.get(T.path)?.[T.line-1];D&&(T.line=D.line,T.column=Math.max(1,T.column-D.column));return}for(let D of Object.values(T))k(D);T.location?.path===i&&(T.kind==="CommandSyntax"&&P.set(T.location.line-1,I),T.kind==="SpecificationSyntax"&&b.set(T.location.line-1,I))},"walk");k(g.value),k(g.physicalEventSources);for(let I of g.diagnostics)k(I.location);let h=g.diagnostics.some(I=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(I.code))return!1;let T=m.find(N=>N.path===I.location.path),D=a.find(N=>N.path===I.location.path)?.source.split(`
|
|
11
|
-
`)[I.location.line-1];return T?.locations.some(N=>N.line===0)&&D!==void 0&&z(D)===0}),x=g.diagnostics.filter(I=>I.location.path===i).flatMap(I=>(k(I.location),I.location.line>0?[I]:[])),E=new oe(g.value),$=new Set(E.slices.flatMap(({slice:I})=>[...I.commands.flatMap(T=>T.produces),...I.reactions.flatMap(T=>T.triggers).flatMap(T=>T.produces)].filter(T=>T.location.path===i&&!E.isEventProduction(T,I)).map(T=>T.location.line-1)));for(let I of x)I.code==="PLAY0499"&&$.add(I.location.line-1);let w=E.declarations.filter(I=>I.kind===K.Operation).map(I=>({...I.node,scope:I.scope.filter(T=>!u.has(T))})),A=new Map,M=ae(t),L=c(I=>{let T=[],D=z(t[I]);for(let N=I;N<t.length&&!(N>I&&!M[N]&&Oe(t[N]).trim()&&z(t[N])<=D);N++)T.push(N);return T},"range");for(let{slice:I,scope:T}of E.slices){if(I.location.path===i&&I.location.line>0)for(let D of L(I.location.line-1))A.set(D,{scope:T});for(let D of I.specifications.filter(N=>N.location.path===i&&N.location.line>0))for(let N of L(D.location.line-1))A.set(N,{scope:T});for(let D of I.commands.filter(N=>N.location.path===i&&N.location.line>0))for(let N of L(D.location.line-1))A.set(N,{scope:T,commandLine:D.location.line-1})}let q=new Map(E.declarations.map(I=>[I.node.location,I.scope]));for(let I of w.filter(T=>T.location.path===i)){let T=q.get(I.location);for(let D of L(I.location.line-1))A.set(D,{...A.get(D),scope:T,operation:I})}let Y=new Map(w.map(I=>[I.location,I])),B=c((I,T)=>{let D=Oe(t[I.line-1]??""),N=D.slice(I.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return N&&D.slice(I.column-1+N.length,I.column-1+N.length+T.length)===T?{...I,column:I.column+N.length}:I},"referenceLocation"),j=[];for(let{slice:I}of E.slices){for(let T of I.commands)for(let D of T.produces){if(D.location.path!==i)continue;let N=E.resolve(D.event,I),tt=N.declaration?Y.get(N.declaration.node.location)??null:null,Sn={name:D.event,location:D.location,targetLocation:D.targetLocation??D.location,kind:N.kind,declaration:tt,mappings:D.mappings};if(j.push(Sn),N.kind===K.Operation)for(let bt of L(D.location.line-1)){let Pi=A.get(bt);Pi&&A.set(bt,{...Pi,production:Sn})}}for(let T of I.specifications)for(let D of[...T.givenOperationFailures??[],...T.thenOperations??[],...T.thenCompensated??[]]){if(D.location.path!==i)continue;let N=E.resolve(D.operation,I);j.push({name:D.operation,location:D.location,targetLocation:B(D.location,D.operation),kind:N.kind,declaration:N.declaration?Y.get(N.declaration.node.location)??null:null,mappings:[]})}}let F={declarations:w,systems:g.value.systems??[],references:j,contexts:A,types:g.value.types,concepts:g.value.concepts,targets:c(I=>{let T=E.slices.find(D=>D.scope.length===I.length&&D.scope.every((N,tt)=>N===I[tt]))?.slice;return T?w.flatMap(D=>{let N=E.resolve(D.name,T).declaration?.node.location===D.location?D.name:[...D.scope,D.name].join(".");return E.resolve(N,T).kind===K.Operation&&E.resolve(N,T).declaration?.node.location===D.location?[{name:N,declaration:D}]:[]}):[]},"targets")},J=g.physicalEventSources.map(I=>I.source),xe=new _e(g.physicalEventSources,g.sourceInventoryComplete&&!h),Pe=new Map,Ci=c((I,T)=>{let D=JSON.stringify([I,T]),N=Pe.get(D);return N||(N=xe.resolve(I,T),Pe.set(D,N)),{...N,source:N.state==="unique"?N.sources[0]:void 0,stream:N.state==="unique"?N.streams[0]:void 0}},"resolve"),bo=new Set(g.value.imports.map(I=>I.qualifiedName)),Co=J.flatMap(I=>I.streams.filter(T=>Ci(I.name,T.name).state==="unique"&&!bo.has(`${I.name}.${T.name}`)).map(T=>({name:`${I.name}.${T.name}`,source:I,stream:T}))),qe=new Map,Ei=[];for(let I of P.values()){for(let T of L(I.location.line-1))qe.set(T,{command:I});for(let T of[...I.produces,...I.validations,...I.handler?[I.handler]:[]])for(let D of L(T.location.line-1))qe.delete(D);if(I.stream){Ei.push(I.stream);for(let T of L(I.stream.location.line-1))qe.set(T,{command:I,route:I.stream})}}for(let I of J.filter(T=>T.location.path===i)){for(let T of L(I.location.line-1))qe.set(T,{source:I});for(let T of I.streams)for(let D of L(T.location.line-1))qe.set(D,{source:I,stream:T})}let Eo=[...P.values()].flatMap(I=>I.streamCandidates??[]).filter(I=>I.propertyCandidate!==null);return{commands:P,specifications:b,diagnostics:x,operationProductionLines:$,operations:F,eventSources:{declarations:J,routes:Ei,ambiguousCandidates:Eo,contexts:qe,targets:Co,resolve:Ci}}}c(od,"analyze");function Xe(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),a=gt.get(o);return a===void 0&&(a=od(t,e,n,i,r),gt.size>=16&>.delete(gt.keys().next().value),gt.set(o,a)),a}c(Xe,"responseAnalysis");var yi="file",ad=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,sd=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function Gb(t){return sd.test(t)}c(Gb,"isAbsoluteFileReferencePath");function cd(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(cd,"withoutComment");function mi(t,e){let n=z(t),i=cd(t.slice(n)).trimEnd();if(vn(i)!==yi)return;let r=i.slice(yi.length),o=r.trim();if(o.length===0||ad.test(o))return;let a=r.length-r.trimStart().length,s=n+yi.length+a+1;return{path:o,line:e,startColumn:s,endColumn:s+o.length}}c(mi,"fileReferenceOn");function Kb(t){let e=ae(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=mi(t[i],i);r&&n.push(r)}return n}c(Kb,"fileReferences");function Ie(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=Oe(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}c(Ie,"eventAnalysisSource");var ld=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,dd=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?\s*$/,ho=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,pd=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,fd=["authorize","produces","reads"],ud=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,yd=ot,md=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],Sd=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function Re(t){return t.typeReference??nt(t.type)}c(Re,"propertyTypeReference");function Si(t,e){let n=t.slice(e-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??"";return{text:n,startColumn:e,endColumn:e+n.length}}c(Si,"sourceTypeAt");function hi(t,e,n){return e.map(i=>({index:i,match:t[i].match(dd)})).filter(i=>i.match!==null).filter(({match:i})=>i[1].startsWith("@")||i[1]==="as"||!n.includes(i[1])).map(({index:i,match:r})=>({name:r[1].replace(/^@/,""),type:r[2],typeReference:nt(r[2]),sourceType:Si(t[i],t[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]!==void 0?{isGenerated:!0}:{},line:i}))}c(hi,"propertiesIn");function $t(t,e,n,i){let r=[];for(let o=n+1;o<t.length;o++){if(e[o])continue;let a=t[o];if(a.trim().length!==0){if(z(a)<=i)break;r.push(o)}}return r}c($t,"collectBody");function et(t,e,n,i){let r=$t(t,e,n,i).filter(s=>!e[s]&&!/^\s*(?:\/\/|#)/.test(t[s]));if(!/^\s*command\b/.test(t[n]))return r;let o,a=!1;return r.filter(s=>{let p=z(t[s]),f=t[s].trim();return o!==void 0&&p>o&&(!a||ud.test(f))?!1:(o=f!=="validate csharp"&&hi(t,[s],fd).length>0||/^description(?:\s|$)/.test(f)?void 0:p,a=/^authorize(?:\s|$)/.test(f),!0)})}c(et,"directBody");var xt=new Map;function vt(t){let e=t.join(`
|
|
12
|
-
`),n=xt.get(e);if(n)return n;let i=Xe(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=Ie(t);let o=ae(t),a=t,s=o,p=t.map(f=>f.replace(/\s*=(?!=|>).*/,""));for(let f=0;f<t.length;f++){if(o[f])continue;let y=t[f],u=y.trim(),m=z(y),S=a[f].trim().match(/^import\s+([\w.]+)\s*$/);if(S&&m===0){let E=S[1],$=E.split(".").pop()??E;r.imports.push({qualifiedName:E,shortName:$,line:f});continue}let v=u.match(ld);if(v){let E=$t(t,o,f,m).map(A=>t[A].trim()),$={};for(let A of E){let M=A.match(ho);M&&$[M[1]]===void 0&&($[M[1]]=M[2])}let w=v[2]==="Enum"?E.filter(A=>!ho.test(A)):[];r.concepts.push({name:v[1],primitive:v[2],attributes:v[3].trim().split(/\s+/).filter(Boolean),attributeReasons:$,enumValues:w,line:f});continue}let g=u.match(/^type\s+(\w+)\s*$/);if(g){r.types.push({name:g[1],properties:hi(t,$t(t,o,f,m),Oi),line:f});continue}let P=u.match(/^policy\s+(\w+)\s*$/);if(P){let E=$t(t,o,f,m).filter($=>!o[$]).map($=>t[$].trim());r.policies.push({name:P[1],requires:E,line:f});continue}let b=a[f].trim().match(/^(?:produces\s+)?event\s+(\w+)(?:\s+generation\s+(\d+))?\s*$/);if(b){let E=u.startsWith("produces "),$=et(a,s,f,m),w=E?$:$.filter(A=>mi(a[A],A)===void 0);r.events.push({name:b[1],...b[2]?{generation:Number(b[2])}:{},inline:E,properties:hi(E?p:a,w,E?md:yd),line:f});continue}let O=i.commands.get(f);if(O){let E=et(t,o,f,m),$=E.filter(w=>/^\s*produces\b/.test(t[w])&&!i.operationProductionLines?.has(w));r.commands.push({name:O.name,properties:O.properties.map(w=>({name:w.name,type:`${w.type.name}${w.type.isCollection?"[]":""}${w.type.isOptional?" optional":""}`,typeReference:{name:w.type.name,isCollection:w.type.isCollection,isOptional:w.type.isOptional},sourceType:Si(t[w.type.location.line-1],w.type.location.column),isIdentifier:w.isIdentifier||/\sidentifier\s*$/.test(t[w.location.line-1]),...w.isGenerated?{isGenerated:!0}:{},line:w.location.line-1})),response:O.response,productionHeaders:$,produces:$.flatMap(w=>{let A=a[w].trim(),M=/^produces\s+event\b/.test(A),L=/^produces\s+when\b/.test(A),q=L?et(a,s,w,z(a[w]))[0]:w;if(q===void 0)return[];let Y=L?a[q].trim():A.match(M?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(Y===void 0||!/^[A-Za-z_]\w*$/.test(Y))return[];let B=et(a,s,q,z(a[q])),j=B.map(xe=>a[xe].trim().match(/^for(?:\s+(.*))?$/)).filter(xe=>xe!==null),F=j.length===0?void 0:j.length===1?j[0][1]??"":"",J=B.flatMap(xe=>{let Pe=a[xe].trim().match(M?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return Pe===null?[]:[{name:Pe[1].replace(/^@/,""),source:Pe[2],line:xe}]});return[{name:Y,inline:M,conditional:L,line:w,target:F,mappings:J}]}),reads:E.filter(w=>!o[w]).map(w=>({line:w,match:t[w].match(pd)})).filter(w=>w.match!==null).map(({line:w,match:A})=>({view:A[1],...A[2]?{alias:A[2]}:{},...A[3]?{by:A[3]}:{},line:w})),line:f});continue}let k=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(k){let E=$t(t,o,f,m).map($=>({index:$,match:t[$].match(Sd)})).filter($=>$.match!==null).map(({index:$,match:w})=>({name:w[1],type:w[2],typeReference:nt(w[2]),sourceType:Si(t[$],t[$].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:$}));r.queries.push({name:k[1],returnType:k[2],returnTypeReference:nt(k[2]),parameters:E,line:f});continue}let h=u.match(/^screen\s+(\w+)\s*$/);if(h){r.screens.push({name:h[1],line:f});continue}let x=u.match(/^trigger\s+(\w+)\s*$/);x&&m===0&&r.triggers.push({name:x[1],line:f})}return xt.size>=16&&xt.delete(xt.keys().next().value),xt.set(e,r),r}c(vt,"scanDocument");function yn(...t){return{authoringSources:t.flatMap(e=>e.authoringSources??[]),...t.some(e=>e.authoringDocuments)?{authoringDocuments:t.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:t.flatMap(e=>e.eventSources??[]),imports:t.flatMap(e=>e.imports),concepts:t.flatMap(e=>e.concepts),types:t.flatMap(e=>e.types),policies:t.flatMap(e=>e.policies),events:t.flatMap(e=>e.events),commands:t.flatMap(e=>e.commands),queries:t.flatMap(e=>e.queries),screens:t.flatMap(e=>e.screens),triggers:t.flatMap(e=>e.triggers)}}c(yn,"mergeSymbols");function go(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...yn(vt(t),e??yn()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}c(go,"symbolsForBuffer");function mn(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}c(mn,"knownEventNames");var hd=["Startup","Shutdown"];function d1(t){return[...mn(t),...t.triggers.map(e=>e.name),...hd]}c(d1,"knownTriggerNames");function gi(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}c(gi,"knownTypeNames");var xo="EventContext",kt={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."}]},gd=[{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 xi(t,e){if(t.kind==="function")return e===t.name||e===`${t.name}()`;let n=t.name[0].toUpperCase()+t.name.slice(1);return e===n||e.length>0&&e[0].toUpperCase()+e.slice(1)===n}c(xi,"namesEventContextMember");var $i=kt[xo];function xd(t){let e=$i;for(let n of t){let i=e.find(r=>xi(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=kt[i.type]??[]}return e}c(xd,"eventContextMembersAfter");function m1(t){return t.length===0?void 0:xd(t.slice(0,-1))?.find(n=>xi(n,t[t.length-1]))}c(m1,"eventContextMemberAt");function vi(t){let e,n=$i;for(let i of t.split(".")){if(i.length===0)return{status:"missing",member:e,expected:n};if(e?.kind==="collection")return{status:"belowCollection",member:e,segment:i,expected:[]};let r=n.find(o=>xi(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:kt[r.type]??[]}return{status:"known",member:e,expected:[]}}c(vi,"resolveEventContextPath");function S1(){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:**",...$i.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
13
|
-
`)}c(S1,"describeEventContext");function h1(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:kt[e.type]??[],i=[`**$eventContext.${t}**: \`${e.type}\``,"",e.description];return n.length>0&&i.push("",`**Members:** ${n.map(r=>`\`${r.name}\``).join(", ")}`),i.join(`
|
|
14
|
-
`)}c(h1,"describeEventContextMember");function ki(t){let e=t.properties.filter(o=>o.isIdentifier&&!Re(o).isOptional&&!Re(o).isCollection),n=e.length===1?e[0].name:void 0,i=t.produces??[],r=i.some(o=>o.target!==void 0&&o.target!==n)||i.some(o=>o.inline&&o.target===void 0)&&i.some(o=>!o.inline&&o.target===void 0);return{identifier:n,mixed:r}}c(ki,"productionDestinations");function E1(t,e){let n=Xe(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=Ie(t);return vt(i).commands.map(r=>({...r,produces:r.produces?.filter(o=>!n.operationProductionLines?.has(o.line)&&n.operations.references.some(a=>a.location.line-1===o.line&&a.kind==="event")),productionHeaders:r.productionHeaders?.filter(o=>!n.operationProductionLines?.has(o))})).flatMap(r=>{let{identifier:o,mixed:a}=ki(r);if(a||r.productionHeaders?.length!==r.produces?.length)return[];let s=r.produces?.some(p=>p.target!==void 0||p.inline);return(r.produces??[]).flatMap(p=>p.target!==void 0||p.inline&&(o===void 0||/\bgeneration\b/.test(i[p.line]))?[]:!p.inline&&s?[]:[{line:p.line,column:i[p.line].length+1,label:p.inline?`for ${o}`:"for <new event source>"}])})}c(E1,"destinationHints");var W={invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",eventFromLaterSlice:"PLAY0516",timelineCycleGroup:"PLAY0517",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 $d=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,vd=/^import\s+"/;function vo(t){return vd.test(t.trim())}c(vo,"isFileImportLine");function bi(t,e){let n=z(t),i=t.slice(n).match($d);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}c(bi,"fileImportOn");function I1(t){let e=ae(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=bi(t[i],i);r&&n.push(r)}return n}c(I1,"fileImports");var $o=c(t=>t.split("/").slice(0,-1),"folderOf");function kd(t,e){let n=e.split("/"),i=0;for(;i<t.length&&i<n.length-1&&t[i]===n[i];)i++;return[...t.slice(i).map(()=>".."),...n.slice(i)].join("/")}c(kd,"relativeTo");function R1(t,e){let n=$o(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=kd(n,r),a=$o(o);i.add(o),i.add([...a,"*.play"].join("/"));for(let s=0;s<=a.length;s++)i.add([...a.slice(0,s),"**","*.play"].join("/"))}return[...i].sort()}c(R1,"importablePaths");var bd=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),Cd=/^id\s+"((?:[^"\\]|\\.)*)"$/;function ko(t,e,n,i=new Set){t=Ie(t);let r=[],o=ae(t),a=Ed(t,o),s=new Set(e.commands.flatMap(m=>m.productionHeaders??[])),p=new Map,f=new Set;for(let m of[e,n]){for(let S of m.events)p.set(S.name,(p.get(S.name)??0)+1);for(let S of m.imports)f.add(S.shortName)}let y=c((m,S,v,g="error")=>{r.push({line:m,startColumn:z(t[m])+1,endColumn:t[m].length+1,code:S,message:v,severity:g})},"report");for(let m of e.events){let S=et(t,o,m.line,z(t[m.line]));if(m.inline){let P=new Set;for(let b of m.properties)P.has(b.name)&&y(b.line,W.duplicateDeclaration,`Event '${m.name}' already declares property '${b.name}'.`),P.add(b.name);s.has(m.line)||y(m.line,W.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),m.generation!==void 0&&y(m.line,W.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((p.get(m.name)??0)>1||f.has(m.name))&&y(m.line,W.inlineEventCollision,`Inline event '${m.name}' collides with another declaration or import.`)}let v=!1,g=!1;for(let P of S){let b=t[P].trim(),O=b.split(/\s+/)[0];if(m.inline&&O==="generation"&&y(P,W.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),m.inline&&O==="origin"&&y(P,W.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(b)){if(O==="id"){let k=b.match(Cd);v||k===null||k[1].trim().length===0?y(P,W.invalidEventId,'Expected one nonempty id "<old-name>".'):k[1]===m.name&&y(P,W.redundantEventId,"This id repeats the event name; remove it.","information"),v=!0}if(O==="documentation"){let k=P+1;for(;k<t.length&&t[k].trim().length===0;)k++;(g||b!=="documentation"||t[k]?.trim()!=="```markdown"||z(t[k])<=z(t[P])||!a.has(k))&&y(P,W.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),g=!0}}}}let u=[];for(let m=0;m<t.length;m++){if(o[m]||t[m].trim().length===0)continue;let S=z(t[m]);for(;u.length>0&&u[u.length-1].indent>=S;)u.pop();let v=t[m].trim().split(/\s+/)[0];bd.has(v)&&u.at(-1)?.event&&y(m,W.reservedProductionMetadata,`'${v}' is system-assigned production metadata.`),v==="produces"&&u.push({indent:S,event:!i.has(m)&&!/^\s*produces\s+operation\b/.test(t[m])})}for(let m of e.commands){let{identifier:S,mixed:v}=ki(m);for(let g of m.produces??[]){v&&g.target===void 0&&y(g.line,W.explicitProducesTargetsRequired,`Production '${g.name}' must state for explicitly when destinations differ.`);let P=g.target??(g.inline?S:void 0);if(!(S===void 0||P!==S))for(let b of g.mappings.filter(O=>O.source===S))y(b.line,W.eventSourceIdInPayload,`The payload copies '${S}', which already identifies the event source.`,g.inline?"warning":"information")}}return r}c(ko,"validateInlineEvents");function Ed(t,e){let n=new Set,i,r=!1;for(let o=0;o<t.length;o++){if(!e[o])continue;let a=t[o].trim();i===void 0?(i=o,r=!1):a==="```"?(r&&t[i].trim()==="```markdown"&&n.add(i),i=void 0):a.length>0&&(r=!0)}return n}c(Ed,"nonemptyMarkdownBlocks");function ue(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}c(ue,"issue");function ge(t,e,n,i,r,o){let a=n.indexOf(i)+1;return ue(t,e,a,i.length,r,o)}c(ge,"tokenIssue");function Pd(t,e,n){let i=[],r=new Set([...gi(e,Ct),...gi(n,[])]),o=c((s,p)=>{for(let f of s.filter(y=>!r.has(Re(y).name))){let y=Re(f).name;i.push(ue("warning",f.line,f.sourceType.startColumn,f.sourceType.text.length,y==="optional"?`Unknown type 'optional' on '${f.name}' of ${p} \u2014 did you forget the type before 'optional'?`:`Unknown type '${y}' on '${f.name}' of ${p} \u2014 declare it with 'concept ${y} : <Primitive>' or 'type ${y}'.`,W.unknownType))}},"checkProperties");for(let s of e.types)o(s.properties,`type '${s.name}'`);for(let s of e.events)o(s.properties,`event '${s.name}'`);for(let s of e.queries)o(s.parameters,`query '${s.name}'`);for(let s of e.commands){o(s.properties,`command '${s.name}'`);let p=s.properties.filter(f=>f.isIdentifier);for(let f of p.slice(1))i.push(ge("error",f.line,t[f.line],"identifier",`Command '${s.name}' already marks '${p[0].name}' as identifier \u2014 only one property can be the identifier.`,W.duplicateCommandIdentifier))}let a=new Map;for(let s of[...e.concepts,...e.types]){if(a.get(s.name)===void 0){a.set(s.name,s.line);continue}i.push(ge("error",s.line,t[s.line],s.name,`Duplicate declaration of '${s.name}' \u2014 concept and type names must be unique.`,W.duplicateDeclaration))}return i}c(Pd,"validateDeclarations");function iC(t,e={}){let n=ae(t),i=vt(t),r=e.application??yn(),o=go(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),a=Xe(t,o.authoringDocuments??o.authoringSources?.filter(k=>k!==t.join(`
|
|
15
|
-
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),s=new Set(a.eventSources.routes.map(k=>k.location.line-1)),p={...i,commands:i.commands.map(k=>({...k,properties:k.properties.filter(h=>!s.has(h.line)),produces:k.produces?.filter(h=>!a.operationProductionLines?.has(h.line)),productionHeaders:k.productionHeaders?.filter(h=>!a.operationProductionLines?.has(h))}))},f=new Set([...mn(p),...mn(r)]),y=new Set([...p.policies,...r.policies].map(k=>k.name)),u=Pd(t,p,r);u.push(...Od(t,p));let m=new Set([l.LegacyOptionalSuffix,l.InvalidOptionalModifierOrder,l.OptionalReadsNotSupported]),S=new Set([l.UnknownEvent,l.UnknownReadModelProperty,l.PiiNotSupportedOnIdentifier]),v=new Set([l.EventFromLaterSlice,l.TimelineCycleGroup]),g=new Set;for(let k of e.compilerDiagnostics??a.diagnostics){if(!m.has(k.code)&&!S.has(k.code)&&!v.has(k.code)&&k.code!==l.UnknownRuleImplementationDirective&&k.code!==l.InvalidValidationRule&&k.code!==l.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY048[2-9]$|^PLAY004[56]$/.test(k.code))continue;let h=k.location.line-1;k.code===l.UnknownEvent&&g.add(h);let x=ci(t[h],k)||t[h].length-k.location.column+1;u.push(ue(k.severity,h,k.location.column,x,k.message,k.code))}let P=c((k,h,x)=>{!f.has(x)&&!g.has(k)&&u.push(ge("warning",k,h,x,`Unknown event type '${x}' \u2014 declare it in a slice or import it.`,W.unknownEvent))},"checkEvent"),b=-1;for(let k=0;k<t.length;k++){let h=t[k],x=h.trim();if(n[k]||x.length===0)continue;let E=h.match(/^[ ]*(\t+)/);if(E&&u.push(ue("warning",k,E[0].length-E[1].length+1,E[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",W.tabIndentation)),b>=0){if(z(h)>b&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(x)){for(let j of x.split(/\s+/).filter(F=>F!=="or"))y.has(j)||u.push(ge("warning",k,h,j,`Unknown policy '${j}' \u2014 declare it with 'policy ${j}'.`,W.unknownPolicy));continue}b=-1}let $=Ad(t,n,k);$&&u.push($);let w=x.match(/^slice\s+(\w+)/);w&&!$n.includes(w[1])&&u.push(ge("error",k,h,w[1],`Unknown slice type '${w[1]}' \u2014 expected ${$n.join(", ")}.`,W.unknownSliceType));let A=x.match(/^concept\s+\w+\s*:\s*(\w+)/);A&&A[1]!=="Enum"&&!Ct.includes(A[1])&&u.push(ge("error",k,h,A[1],`Unknown primitive type '${A[1]}' \u2014 expected ${Ct.join(", ")} or Enum.`,W.unknownPrimitiveType));let M=x.match(/^authorize\s+(.*)$/);if(M){b=z(h);for(let j of M[1].split(/\s+/).filter(F=>F!=="or"&&F.length>0))y.has(j)||u.push(ge("warning",k,h,j,`Unknown policy '${j}' \u2014 declare it with 'policy ${j}'.`,W.unknownPolicy))}let L=x.match(/^on\s+([A-Z]\w*)\s*$/);L&&P(k,h,L[1]);let q=x.match(/^produces\s+([A-Z]\w*)\s*$/);if(q&&!a.operationProductionLines?.has(k)&&P(k,h,q[1]),/^produces\s+when\b/.test(x)&&!a.operationProductionLines?.has(k))for(let j=k+1;j<t.length;j++){let F=t[j];if(!(n[j]||F.trim().length===0)){if(z(F)>z(h)){let J=F.trim().match(/^([A-Z]\w*)\s*$/);J&&P(j,F,J[1])}break}}let Y=x.match(/^unique\s+event\s+([A-Z]\w*)/);Y&&P(k,h,Y[1]);let B=x.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);B&&P(k,h,B[1]);for(let j of h.match(/\$context\.[\w.]+/g)??[]){let F=j.substring(9).split(".");hn.includes(F[0])?F[0]==="causedBy"&&F.length>1&&!gn.includes(F[1])?u.push(ge("warning",k,h,j,`Unknown $context.causedBy property '${F[1]}' \u2014 expected ${gn.join(", ")}.`,W.unknownContextCausedByProperty)):F[0]==="identity"&&F.length>1&&!xn.includes(F[1])&&u.push(ge("warning",k,h,j,`Unknown $context.identity property '${F[1]}' \u2014 expected ${xn.join(", ")}.`,W.unknownContextIdentityProperty)):u.push(ge("warning",k,h,j,`Unknown $context path '${F.join(".")}' \u2014 expected one of ${hn.join(", ")}.`,W.unknownContextPath))}}u.push(...Id(t,n)),u.push(...ko(t,p,r,a.operationProductionLines));let O=t.map((k,h)=>({line:k,index:h})).filter(({line:k})=>/^\s*```(?:[a-z]+)?\s*$/.test(k));if(O.length%2===1){let k=O[O.length-1];u.push(ue("error",k.index,1,k.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",W.unclosedCodeBlock))}return u}c(iC,"validateLines");function Od(t,e){let n=[];t=Ie(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!Re(o).isOptional&&!Re(o).isCollection);if(r.length===1)for(let o of i.produces??[]){if(o.inline||o.conditional||o.target!==void 0)continue;let a=o.line;n.push(ue("information",a,z(t[a])+1,t[a].trim().length,`Plain 'produces ${o.name}' omits its destination \u2014 use 'for ${r[0].name}' to explicitly select the command's identifier.`,W.omittedProductionDestination))}}return n}c(Od,"validateProductionDestinations");function Ad(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||bi(i,n))return;let o=z(i);if(!(!(o>0&&["module","feature"].includes(Ai(t,e,n,o)[0]))&&!vo(i)))return ue("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,W.invalidFileImport)}c(Ad,"validateImport");var wd=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Id(t,e){let n=[],i=c(r=>r.map(o=>o.name).join(", "),"names");for(let r=0;r<t.length;r++){let o=t[r];if(e[r])continue;for(let p of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let f=p[0].substring(p[1]?.length??0),y=p[2];if(y.length===0){p[1]&&n.push(ue("error",r,(p.index??0)+2,f.length,`'$eventContext' names no member - expected one of ${i(vi("").expected)}.`,W.missingEventContextPath));continue}let u=y.substring(1),m=vi(u),S=(p.index??0)+(p[1]?.length??0)+1;switch(m.status){case"missing":n.push(ue("error",r,S,f.length,`'$eventContext.${u}' names no member - expected one of ${i(m.expected)}.`,W.missingEventContextPath));break;case"unknownMember":n.push(ue("warning",r,S,f.length,`Unknown event context member '${m.segment}' in '$eventContext.${u}' - expected one of ${i(m.expected)}.`,W.unknownEventContextMember));break;case"unknownSubPath":{let v=m.expected.length===0?"no members to address":`members ${i(m.expected)}`;n.push(ue("warning",r,S,f.length,`Unknown event context path '$eventContext.${u}' - '${m.member?.name}' (${m.member?.type}) has ${v}.`,W.unknownEventContextPath));break}case"belowCollection":n.push(ue("error",r,S,f.length,`'$eventContext.${u}' cannot resolve - '${m.member?.name}' is a collection (${m.member?.type}) and cannot be addressed below.`,W.eventContextPathBelowCollection));break}}let a=o.trim().match(wd)?.[1],s=a?.match(/\.\$(\w+)/)?.[1];a&&s&&s!=="eventContext"&&n.push(ge("warning",r,o,a,`Dynamic dictionary key '$${s}' in '${a}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${s}' becomes the key.`,W.unresolvedDynamicKeySource))}return n}c(Id,"validateEventContextPaths");export{Po as a,Td as b,Md as c,Oi as d,Dd as e,hn as f,gn as g,$n as h,Ct as i,jd as j,Oo as k,Nd as l,nt as m,qd as n,l as o,de as p,Rn as q,Tn as r,g$ as s,x$ as t,Oe as u,z as v,vn as w,ae as x,Ai as y,Yd as z,Wd as A,Ie as B,zb as C,Xe as D,yi as E,Gb as F,mi as G,Kb as H,Re as I,et as J,vt as K,yn as L,go as M,mn as N,hd as O,d1 as P,gi as Q,gd as R,xi as S,$i as T,xd as U,m1 as V,S1 as W,h1 as X,ki as Y,E1 as Z,W as _,vo as $,bi as aa,I1 as ba,R1 as ca,iC as da,Id as ea};
|
|
16
|
-
//# sourceMappingURL=chunk-X5DNGVII.js.map
|