@cratis/screenplay-language 4.99.0 → 4.100.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-6AH7HSFP.js +33 -0
- package/dist/bundles/chunk-6AH7HSFP.js.map +7 -0
- package/dist/bundles/index.js +63 -63
- package/dist/bundles/index.js.map +3 -3
- package/dist/bundles/sub-languages/projection/index.js +1 -1
- package/dist/code-actions.d.ts.map +1 -1
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/completion-planner.d.ts.map +1 -1
- package/dist/diagnostic-codes.d.ts +10 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/dist/hover-content.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/language.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-TIRY74MT.js +0 -33
- package/dist/bundles/chunk-TIRY74MT.js.map +0 -7
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-AYDF3IFZ.js";var vs="screenplay",ju={id:vs,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Lu=["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","example","seed","behavior"];var Jr=["depends","description","documentation","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","component","context","property","literal","icons","packages","outlet","toolbar","item","presentation","exposes","mode","oneWay","twoWay","null","propagate","clear","preserve","expected","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","open","close","refresh","set","notify","confirm","raise","interval","success","failure","click","double","select","submit","change","load","unload","enter","leave","info","warning"],qu=["csharp","typescript","react","html","sql"],Ii=["command","arguments","tenant","causedBy","causation","occurred","identity"],Ti=["subject","name","userName"],Ri=["id","name","userName","isAuthenticated","roles","claims"],Di=["StateChange","StateView","Automation","Translate"],gn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Bu=["@pii","@sensitive"],$s=/^\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[^=]*$/,Fu={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:$s,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|action|otherwise(?=\s*$|\s+execute\b)|concurrency|seed|for|when|then|arguments|result|every|at|invokes|on)\b.*$/,decreaseIndentPattern:/(?!)/}};function Wt(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}l(Wt,"typeReferenceSymbol");function Uu(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}l(Uu,"typeReferenceText");function Me(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}l(Me,"withoutComment");function J(t){return t.length-t.trimStart().length}l(J,"indentOf");function Mi(t){return t.trim().split(/\s+/)[0]??""}l(Mi,"firstWord");function ke(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}l(ke,"fenceMap");function Xr(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Me(t[s]);if(a.trim().length===0)continue;let c=J(a);c<o&&(r.push(Mi(a)),o=c)}return r}l(Xr,"enclosingChain");function Vu(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=Me(t[r]);if(o.trim().length!==0&&J(o)<i)return o.trim()}}l(Vu,"nearestEnclosingLine");function Qu(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Me(t[s]);if(a.trim().length===0)continue;let c=J(a);c<o&&(r.push(a.trim()),o=c)}return r}l(Qu,"enclosingHeaders");var eo="EventContext",zt={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."}]},Ni=[{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 ji(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}l(ji,"namesEventContextMember");var Li=zt[eo];function ks(t){let e=Li;for(let n of t){let i=e.find(r=>ji(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=zt[i.type]??[]}return e}l(ks,"eventContextMembersAfter");function Hu(t){return t.length===0?void 0:ks(t.slice(0,-1))?.find(n=>ji(n,t[t.length-1]))}l(Hu,"eventContextMemberAt");function qi(t){let e,n=Li;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=>ji(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:zt[r.type]??[]}return{status:"known",member:e,expected:[]}}l(qi,"resolveEventContextPath");function Ju(){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:**",...Li.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
2
|
-
`)}l(Ju,"describeEventContext");function Xu(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:zt[e.type]??[],i=[`**$eventContext.${t}**: \`${e.type}\``,"",e.description];return n.length>0&&i.push("",`**Members:** ${n.map(r=>`\`${r.name}\``).join(", ")}`),i.join(`
|
|
3
|
-
`)}l(Xu,"describeEventContextMember");var rt={label:"documentation",insertText:"documentation\n ```markdown\n ${1:Reasoning, assumptions or rejected alternatives}\n ```",documentation:"One nonempty authoring-only Markdown block; report-only (PLAY0270), with no executable effect."};var gt=[{label:"example",insertText:"example ${1:Name} : ${2:Type}\n ${3:property} = ${4:value}",documentation:"One possibly partial event, command or read-model fixture. Step assignments override its values; no implicit defaults."}];var Bi=[{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction - a click, a submit, entering or leaving the screen."},{label:"uses",insertText:"uses ${1:Behavior}",documentation:"Attaches a named behavior declared at the top level."}],bs=[rt,...gt,{label:"description",insertText:'description "${1:what this module is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the module."},{label:"depends on",insertText:"depends on ${1:Name}",documentation:"Declares an allowed module or feature dependency. Opts this container into independent explicit-reference checks."},{label:'import "\u2026"',insertText:'import "${1:*/*.play}"',documentation:"Imports `.play` files into this module \u2014 their top level is the module's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Groups related slices into a vertical feature."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a module-level UI screen."},{label:"screen template",insertText:"screen template ${1:Name}\n fits slot ${2:content}\n\n ${3:slot}",documentation:"Declares a reusable screen shape that fits a slot of the shell."},{label:"dialog template",insertText:"dialog template ${1:Name}\n ${2:body}\n ${3:actions}",documentation:"Declares a reusable dialog shape that opens over the shell."},{label:"form",insertText:'form ${1:Name} for ${2:Command}\n field ${3:property} label "${4:Label}"',documentation:"Declares a form bound to a command."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a slot of the shell, such as navigation."},...Bi],Es=[rt,...gt,{label:"description",insertText:'description "${1:what this feature is for}"',documentation:"A human-readable description."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"Policies that must pass for everything in the feature."},{label:"depends on",insertText:"depends on ${1:Name}",documentation:"Declares an allowed module or feature dependency. Sibling feature names resolve before module names."},{label:'import "\u2026"',insertText:'import "${1:*.play}"',documentation:"Imports `.play` files into this feature \u2014 their top level is the feature's body."},{label:"feature",insertText:"feature ${1:Name}\n ",documentation:"Declares a nested sub-feature."},{label:"slice StateChange",insertText:"slice StateChange ${1:Name}\n ",documentation:"A command \u2192 events flow; something that changes the system."},{label:"slice StateView",insertText:"slice StateView ${1:Name}\n ",documentation:"A query + projection + screen; something that reads the system."},{label:"slice Automation",insertText:"slice Automation ${1:Name}\n ",documentation:"A reaction or reducer; something that runs when something happens."},{label:"slice Translate",insertText:"slice Translate ${1:Name}\n ",documentation:"A capture; converts external data into events."},{label:"contribute",insertText:'contribute to ${1:Navigation}\n navigate to ${2:Screen}\n label "${3:Label}"',documentation:"Contributes an entry to a slot of the shell, such as navigation."},...Bi],am=[rt,{label:"description",insertText:'description "${1:what one instance holds}"',documentation:"A human-readable description."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the file this read model is realized by."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the read model \u2014 a name and a type reference."}],sm=[{label:"description",insertText:'description "${1:what the reducer does}"',documentation:"A human-readable description."},{label:"on",insertText:"on ${1:EventType}\n ```csharp\n ${2}\n ```",documentation:"A rule applied when the event occurs, in code or from a file."}],lm=[{label:"populate via query",insertText:"populate via query ${1:Query} by ${2:parameter}",documentation:"Fills the form from a query before it is shown."},{label:"populate from item",insertText:"populate from item",documentation:"Fills the form from the item the screen was opened for."},{label:"field",insertText:'field ${1:property} label "${2:Label}"',documentation:"A form field bound to a command property."},...Bi],cm=[{label:"navigate to",insertText:"navigate to ${1:Screen}",documentation:"The screen the entry opens."},{label:"label",insertText:'label "${1:Label}"',documentation:"The text of the entry."},{label:"order",insertText:"order ${1:10}",documentation:"Where the entry sits among the others; lower comes first."}],dm=[{label:"description",insertText:'description "${1:what the behavior does}"',documentation:"A human-readable description."},{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"A value the behavior is given where it is attached."},{label:"order",insertText:"order ${1:10}",documentation:"The order behaviors attached to the same element run in."},{label:"on",insertText:"on ${1|click,select,submit,change,load,unload,enter,leave|}\n ${2:execute command}",documentation:"Wires what happens on an interaction."}],Ne=l((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),Cs=[Ne("execute","execute ${1:command}","Runs a command."),Ne("navigate to","navigate to ${1:Screen}","Opens a screen."),Ne("open","open ${1:Dialog}","Opens a dialog."),Ne("close","close","Closes the dialog."),Ne("refresh","refresh ${1:query}","Reloads a query."),Ne("set","set ${1:name} ${2:value}","Sets a value."),Ne("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),Ne("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),Ne("raise","raise ${1:Trigger}","Raises a trigger.")],pm=[Ne("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),Ne("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Cs],fm=[{label:"description",insertText:'description "${1:who they are}"',documentation:"A human-readable description."},{label:"policy",insertText:"policy ${1:PolicyName}",documentation:"A policy this persona holds."}],um=[{label:"provider",insertText:"provider ${1:Name}",documentation:"An identity provider."},{label:"provider (named)",insertText:"provider ${1:Kind} name ${2:Name}",documentation:"An identity provider of a kind, under its own name."}],mm=[{label:"for",insertText:'for ${1:"event-source-id"}\n ${2:EventType}\n ${3:property} = ${4:value}',documentation:"Events to seed for one event source id."}],ym=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],hm=[{label:"target platform",insertText:"target platform ${1:web}",documentation:"The platforms the profile is for."},{label:"target size",insertText:"target size ${1|compact,regular|}",documentation:"The screen sizes the profile is for."},{label:"packages",insertText:"packages\n ${1:Package}",documentation:"The component packages the profile uses."},{label:"layout",insertText:"layout ${1:Layout}",documentation:"The layout of the profile."},{label:"theme",insertText:"theme ${1:Theme}",documentation:"The theme of the profile."}],Ps=[{label:"slot",insertText:"${1:slot}",documentation:"A named slot of the shell."},{label:"slot contributes",insertText:"${1:slot} contributes ${2:Name}",documentation:"A slot other declarations contribute to, such as `navigation contributes Navigation`."},{label:"arrangement",insertText:`arrangement flow
|
|
4
|
-
column
|
|
5
|
-
\${1:slot}`,documentation:"How the slots are placed."}],Sm=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...Ps,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var bm=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],be=l(t=>`\`\`\`${t}
|
|
6
|
-
\${1}
|
|
7
|
-
\`\`\``,"fenced"),Em=[...gt,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"system",insertText:'system ${1:Name}\n description "${2:external system}"',documentation:"Application-scoped external system; not admitted by any supported executable model (ESM) version yet."},{label:"import",insertText:"import ${1:Module}.${2:Type}",documentation:"Imports a type from another module by its qualified name."},{label:'import "\u2026"',insertText:'import "${1:**/*.play}"',documentation:"Imports other `.play` files by path or glob, relative to this file's folder, as whole documents of the application."},{label:"concept",insertText:"concept ${1:Name} : ${2|Uuid,String,Int,Decimal,Bool,Date,DateTime|}",documentation:"Declares a formalized value type wrapping a primitive."},{label:"concept (enum)",insertText:"concept ${1:Name} : Enum\n ${2:value}",documentation:"Declares an enumeration concept with a fixed set of values."},{label:"concept (@pii with reason)",insertText:'concept ${1:Name} : ${2|String,Uuid,Int,Decimal,Bool,Date,DateTime|} @pii\n pii reason "${3:why this is personal data, its purpose and lawful basis}"',documentation:"Declares a personal-data concept together with the reason it is personal data."},{label:"type",insertText:"type ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a composite value type \u2014 a named shape built from several properties."},{label:"policy",insertText:"policy ${1:Name}\n require ${2:authenticated}",documentation:"Declares a named authorization rule for commands and queries."},{label:"module",insertText:"module ${1:Name}\n ",documentation:"Declares the top-level namespace \u2014 maps to a bounded context."},{label:"domain",insertText:"domain ${1:Name}",documentation:"The domain the file belongs to \u2014 optional, at most one per file, before everything else."},{label:"persona",insertText:'persona ${1:Name}\n description "${2:who they are}"',documentation:"A named role interacting with the application, with the policies it holds."},{label:"authentication",insertText:"authentication\n provider ${1:Name}\n ${2:setting} ${3:value}",documentation:"Declares the identity providers of the application \u2014 at most one block per file."},{label:"seed",insertText:"seed\n for ${1:EventSourceId}\n ${2:EventType}",documentation:"Declares events to seed into the event store per event source id."},{label:"layout",insertText:"layout ${1:Name}\n ${2:slot}",documentation:"Declares the application shell with named slots."},{label:"theme",insertText:"theme ${1:Name}\n compatible with ${2:Package}",documentation:"Declares a theme and the component packages it is compatible with."},{label:"ui profile",insertText:"ui profile ${1:Name}\n target platform ${2:web}\n layout ${3:Layout}\n theme ${4:Theme}",documentation:"Binds a target platform and size to a layout, theme and component packages."},{label:"behavior",insertText:"behavior ${1:Name}\n on ${2:click}\n ${3:execute command}",documentation:"A named interaction wiring, attached to a screen, form or dialog with `uses`."},{label:"trigger",insertText:"trigger ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an integration signal a reaction can run on."}],Cm=[{label:"uses",insertText:"uses ${1:System}",documentation:"Exactly one application-scoped external system."},{label:"description",insertText:'description "${1:intent}"',documentation:"Describes operation intent, without requiring code."},{label:"input",insertText:"${1:input} ${2:Type}",documentation:"Typed operation input; no identifier or generated modifier."},{label:"execute",insertText:'execute\n description "${1:effect}"',documentation:"Optional execution intent; not admitted by any supported executable model (ESM) version yet."},{label:"compensate",insertText:'compensate\n description "${1:undo intent}"',documentation:"Optional compensation intent; not admitted by any supported executable model (ESM) version yet."}],As=[{label:"hint",insertText:'hint "${1:implementation guidance}"',documentation:"Ordered authoring guidance; not an executable implementation role."},{label:"file",insertText:"file ${1:Path}",documentation:"Selects the phase\u2019s sole source attachment."},...["csharp","typescript","react","html","sql"].map(t=>({label:t,insertText:be(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],Pm=[{label:"description",insertText:'description "${1:phase intent}"',documentation:"A description-only phase is valid, pending intent."},{label:"implementation",insertText:'implementation\n hint "${1:guidance}"',documentation:"Hints with optional source; phase owns File/Code, wrapper owns hints only."},...As.filter(t=>t.label!=="hint")],Am=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"pii reason",insertText:'pii reason "${1:why this is personal data, its purpose and lawful basis}"',documentation:"Records why the `@pii` marker applies \u2014 purpose, lawful basis, whose subject it lives under."},{label:"sensitive reason",insertText:'sensitive reason "${1:why this value is sensitive}"',documentation:"Records why the `@sensitive` marker applies."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],wm=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"description",insertText:'description "${1:what this shape represents}"',documentation:"A human-readable description of the type."},{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the type \u2014 a name and a type reference."}],to=[rt,...gt,{label:"operation",insertText:"operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type}",documentation:"Reusable slice-owned operation intent; not admitted by any supported executable model (ESM) version yet."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"event",insertText:"event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares an event type \u2014 an immutable, past-tense fact."},{label:"event generation",insertText:"event ${1:Name} generation ${2:2}\n ${3:property} ${4:Type}",documentation:"Declares a complete numbered event generation; start at 1 and do not skip a number."},{label:"command",insertText:"command ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a command \u2014 an imperative intent that produces events."},{label:"query",insertText:"query ${1:Name} => ${2:ReadModel}",documentation:"Declares a read-side entry point mapping to a return type."},{label:"query observable",insertText:"query ${1:Name} => observable ${2:ReadModel}",documentation:"Declares a live read \u2014 the query keeps pushing as the read model changes, instead of answering once."},{label:"readmodel",insertText:"readmodel ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares the shape of a read model \u2014 its properties \u2014 that a projection, reducer or query fills and returns."},{label:"reducer",insertText:"reducer ${1:Name} => ${2:ReadModel}\n on ${3:EventType}\n ```csharp\n ${4}\n ```",documentation:"Declares a reducer building a read model from events with imperative code, for what a projection cannot express."},{label:"specification",insertText:"specification ${1:Name}\n given ${2:EventType}\n when ${3:Command}\n then ${4:EventType}",documentation:"Given/when/then acceptance criteria for the slice."},{label:"projection",insertText:"projection ${1:Name} => ${2:ReadModel}\n from ${3:EventType}",documentation:"Declares how events project into a read model (PDL)."},{label:"capture",insertText:"capture ${1:Name}\n source ${2:api}",documentation:"Declares a change data capture converting external data into events (CDL)."},{label:"reaction",insertText:"reaction ${1:Name}\n when ${2:Trigger}",documentation:"Declares behavior that runs when something happens."},{label:"screen",insertText:"screen ${1:Name}\n data ${2:ReadModel} via query ${3:QueryName}",documentation:"Declares a UI screen."},{label:"constraint",insertText:"constraint ${1:Name}\n unique ${2:property} on ${3:EventType}",documentation:"Declares a server-side rule enforced before events are committed."}],Om=[rt,{label:"property",insertText:"${1:property} ${2:Type}",documentation:"An input of the command \u2014 a name and a type reference."},{label:"produces operation",insertText:"produces operation ${1:Name}\n uses ${2:System}\n ${3:input} ${4:Type} = ${5:source}",documentation:"Declares ordered operation intent; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"returns property",insertText:"returns @${1:property}",documentation:"Scalar response from a direct command property, only on acceptance. Executable as ESM v7."},{label:"returns block",insertText:"returns\n ${1:field} = ${2:property}",documentation:"Unnamed record response with inferred or explicit field types, only on acceptance. Executable as ESM v7."},{label:"produces event",insertText:"produces event ${1:Name}\n ${2:property} ${3:Type} = ${4:source}",documentation:"Declares a slice-owned generation-1 event and maps its properties. An omitted for uses the command identifier."},{label:"identifier property",insertText:"${1:property} ${2:Type} identifier",documentation:"Marks the property a runtime resolves the event source id from. At most one per command."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"References the policies that must pass for the command to execute."},{label:"reads",insertText:"reads ${1:View} by ${2:property}",documentation:"Declares a view the command consults. Executable binding is not yet supported."},{label:"reads as",insertText:"reads ${1:View} as ${2:alias} by ${3:property}",documentation:"Names one instance of a view; every instance needs a unique alias when reading the same view more than once."},{label:"validate",insertText:'validate\n ${1:property} not empty message "${2:message}"',documentation:"Declarative validation rules with messages."},{label:"validate csharp",insertText:`validate
|
|
8
|
-
${be("csharp")}`,documentation:"Imperative validation in C#, yielding the message of every rule the artifact breaks."},{label:"produces",insertText:"produces ${1:EventType}\n ${2:property} = ${3:source}",documentation:"Declares the event the command emits, with property mappings."},{label:"produces when",insertText:"produces when ${1:condition}\n ${2:EventType}\n ${3:property} = ${4:source}",documentation:"Conditionally emits an event when the condition holds."},{label:"description",insertText:'description "${1:what the command asks for}"',documentation:"A human-readable description."},{label:"concurrency",insertText:"concurrency\n ${1|eventSource,sourceType,streamType,streamId,events|}",documentation:"The scope of the concurrency check made when the command appends events."},{label:"handler",insertText:`handler
|
|
9
|
-
`,documentation:"Fully imperative command implementation \u2014 file reference or inline C#, instead of produces."}],ws=[{label:"property",insertText:"${1:property} ${2:Type}",documentation:"A property of the event \u2014 a name and a type reference."},{label:"description",insertText:'description "${1:what happened}"',documentation:"Authoring metadata, as one line or a text/markdown fence."},{label:"documentation",insertText:"documentation\n ```markdown\n ${1:Details}\n ```",documentation:"Authoring-only Markdown documentation."},{label:"id",insertText:'id "${1:OldName}"',documentation:"Preserves a previous persisted event name after a rename. Leave absent for new events."},{label:"tag",insertText:"tag ${1:audit}",documentation:"An event-type tag stamped on every occurrence."}],Im=[...ws,{label:"for",insertText:"for ${1:identifier}",documentation:"Explicitly names the command identifier used as the event source."},{label:"property mapping",insertText:"${1:property} ${2:Type} = ${3:source}",documentation:"Declares and maps an event property on one line."}],Tm=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Rm=[{label:"hint",insertText:'hint "${1:implementation guidance}"',documentation:"Ordered nonblank guidance for a handler implementation. Not an execution guarantee."},{label:"file",insertText:"file ${1:Path}",documentation:"Selects one existing model-relative attachment."},...["csharp","typescript","react","html","sql"].map(t=>({label:t,insertText:be(t),documentation:"Selects one inline payload. Handler execution remains unsupported."}))],Dm=[{label:"implementation",insertText:'implementation\n hint "${1:implementation guidance}"',documentation:"Handler-only implementation intent with optional file or tagged fence. With no payload it is pending."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the command implementation to an external C# file."},{label:"csharp",insertText:be("csharp"),documentation:"Inline C# returning the events to append."}],Mm=[{label:"description",insertText:'description "${1:what this query is trying to accomplish}"',documentation:"What the query is for, in prose \u2014 what a generator or reviewer works from."},{label:"by",insertText:"by ${1:param} ${2:Type}",documentation:"Declares the identifying parameter of the query."},{label:"filter",insertText:"filter ${1:param} ${2:Type} optional",documentation:"Declares an optional filter parameter supplied by the caller."},{label:"filter from context",insertText:"filter ${1:param} ${2:Type} from $context.${3|tenant,causedBy.subject,occurred|}",documentation:"Declares a parameter filled from the query context instead of the caller."},{label:"authorize",insertText:"authorize ${1:PolicyName}",documentation:"References the policies that must pass for the query to execute."},{label:"performer",insertText:`performer
|
|
10
|
-
`,documentation:"The code that performs the query \u2014 a file reference or an inline csharp/sql block."}],Nm=[{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the query implementation to an external file."},{label:"csharp",insertText:be("csharp"),documentation:"Inline C# returning the query result, with the QueryContext in scope as context."},{label:"sql",insertText:be("sql"),documentation:"Inline SQL returning the query result."}],jm=[{label:"unique",insertText:"unique ${1:property} on ${2:EventType}",documentation:"Enforces a unique property value across an event type."},{label:"unique event",insertText:"unique event ${1:EventType}",documentation:"Enforces that the event type occurs at most once per event source."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the constraint to a custom C# implementation."}],Lm=[rt,{label:"description",insertText:'description "${1:what this reaction does}"',documentation:"What the reaction does \u2014 a complete statement of intent before any code exists."},{label:"when",insertText:"when ${1:Trigger}",documentation:"An event, a declared trigger or a host signal that sets the reaction off. A trigger needs no body."},{label:"every",insertText:"every ${1:15} ${2|seconds,minutes,hours,days|}",documentation:"Runs the reaction on an interval."},{label:"at",insertText:"at ${1:08:00}",documentation:"Runs the reaction at a time of day \u2014 every day unless narrowed with `on <Weekday>` or `on day <n>`."},{label:"where",insertText:"where ${1:condition}",documentation:"Narrows which occurrences actually run the reaction."}],qm=[{label:"reads",insertText:"reads ${1:View}",documentation:"The view this trigger consults. Optionally use `as <alias> by <trigger value>`; clock triggers take no values and cannot use `by`."},{label:"description",insertText:'description "${1:what this reaction does}"',documentation:"What this particular reaction does \u2014 enough on its own, with no file to point at."},{label:"produces",insertText:"produces ${1:EventType}",documentation:"An event the reaction appends."},{label:"invokes",insertText:"invokes ${1:Command}",documentation:"A command the reaction hands on. A command is asked for, not produced \u2014 it may still be rejected."},{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the reaction to an external C# file."},{label:"csharp",insertText:be("csharp"),documentation:"Inline C# returning event side effects."}],ot="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",Bm=[{label:"on refused",insertText:`on refused
|
|
11
|
-
acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${ot}`},{label:"on refused by validation",insertText:`on refused by validation
|
|
12
|
-
acknowledge`,documentation:`Handles validation refusals. ${ot}`},{label:"on refused by constraint",insertText:"on refused by constraint ${1:Name}\n acknowledge",documentation:`Handles a named constraint refusal; omit the name for any constraint. ${ot}`},{label:"on refused by authorization",insertText:`on refused by authorization
|
|
13
|
-
acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${ot}`}],Fm=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${ot}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${ot}`}],Ym=[{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"description",insertText:'description "${1:when this occurs}"',documentation:"What makes an occurrence of this trigger happen."},{label:"value",insertText:"${1:name} ${2:Type}",documentation:"A value an occurrence hands the reaction. The type is optional."}],Um=[{label:"description",insertText:'description "${1:rule or case witnessed}"',documentation:"Authoring-only description of what this scenario demonstrates."},{label:"when redelivered",insertText:"when redelivered ${1:Event} to ${2:Reaction}\n for ${3:value}",documentation:`Selects exactly one given event occurrence for one event-trigger reaction; does not append it again. ${ot}`},{label:"given operation fails",insertText:"given operation ${1:Name} fails",documentation:"Failure fixture leaf; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"then operation",insertText:"then operation ${1:Name}\n ${2:input} = ${3:value}",documentation:"Partial requested-operation assertion; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"then compensated",insertText:"then compensated ${1:Name}",documentation:"Compensation assertion leaf; not admitted by any supported executable model (ESM) version yet (PLAY0268)."},{label:"file",insertText:"file ${1:Path}",documentation:"Names the repository relative file this declaration is realized by, so the document can be navigated back to the code."},{label:"given",insertText:"given ${1:EventType}\n ${2:property} = ${3:value}",documentation:"Establishes prior state by replaying an event before the command runs."},{label:"given readmodel",insertText:"given readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"Establishes prior read model state directly."},{label:"when",insertText:"when ${1:CommandType}\n ${2:property} = ${3:value}",documentation:"The command being exercised."},{label:"then",insertText:"then ${1:EventType}\n ${2:property} = ${3:value}",documentation:"An event expected to be produced by the command."},{label:"then readmodel",insertText:"then readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"The read model state expected after the command."},{label:"then no readmodel",insertText:"then no readmodel ${1:ReadModelType} for ${2:key}",documentation:"Asserts that precisely one keyed read-model instance does not exist; another key may still be present."},{label:"then query",insertText:"then query ${1:QueryName}\n arguments\n ${2:argument} = ${3:value}\n result\n ${4:property} = ${5:value}",documentation:"The ordered query results expected for explicit arguments. Remove the result block to assert an empty result."},{label:"then error",insertText:"then error",documentation:"A rejection, for a reason this specification does not name."},{label:'then error "..."',insertText:'then error "${1:reason}"',documentation:"A rejection, for the named reason."},{label:"given clock",insertText:'given clock "${1:2026-10-05T08:00:00Z}"',documentation:"The instant the scenario happens at - the occurrence time of everything it does. At most once."},{label:"given capture",insertText:"given capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"A record the capture's source held before."},{label:"when clock",insertText:'when clock "${1:2026-10-05T09:00:00Z}"',documentation:"The clock reaches an instant, as the action."},{label:"when trigger",insertText:"when trigger ${1:Trigger}\n ${2:value} = ${3:value}",documentation:"An application trigger fires, as the action."},{label:"when capture",insertText:"when capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"The record a capture's source holds now, as the action."},{label:"when query",insertText:"when query ${1:Query}\n ${2:argument} = ${3:value}",documentation:"Performs a query, as the action."},{label:"then result",insertText:"then result\n ${1:property} = ${2:value}",documentation:"One result the query performed by `when query` returns, in order."},{label:"then no result",insertText:"then no result",documentation:"The query performed by `when query` returns nothing."},{label:"then no events",insertText:"then no events",documentation:"Syntax-only assertion of no new events after a non-append action (PLAY0268); cannot accompany event, error or denial expectations."}],no={given:[{label:"operation",insertText:"operation ${1:Name} fails",documentation:"Syntax-only failure fixture; no children."},{label:"clock",insertText:'clock "${1:2026-10-05T08:00:00Z}"',documentation:"The instant the scenario happens at - the occurrence time of everything it does."},{label:"capture",insertText:"capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"A record the capture's source held before. Repeat it for several records."},{label:"readmodel",insertText:"readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"Establishes prior read model state directly."},{label:"caller",insertText:"caller\n ${1:authenticated}",documentation:"The identity the scenario runs as."}],when:[{label:"redelivered",insertText:"redelivered ${1:Event} to ${2:Reaction}\n for ${3:value}",documentation:`Selects exactly one given event occurrence for one reaction. ${ot}`},{label:"clock",insertText:'clock "${1:2026-10-05T09:00:00Z}"',documentation:"The clock reaches an instant - what a scheduled reaction responds to."},{label:"trigger",insertText:"trigger ${1:Trigger}\n ${2:value} = ${3:value}",documentation:"An application trigger fires, with the values it carries."},{label:"capture",insertText:"capture ${1:Capture}\n ${2:field} = ${3:value}",documentation:"The record a capture's source holds now."},{label:"query",insertText:"query ${1:Query}\n ${2:argument} = ${3:value}",documentation:"Performs a query; assert what it returns with `then result` or `then no result`."},{label:"append",insertText:"append ${1:EventType}\n ${2:property} = ${3:value}",documentation:"An event occurs, instead of a command being executed."}],then:[{label:"operation",insertText:"operation ${1:Name}\n ${2:input} = ${3:value}",documentation:"Syntax-only partial operation assertion; not admitted by any supported executable model (ESM) version yet."},{label:"compensated",insertText:"compensated ${1:Name}",documentation:"Syntax-only compensation assertion; no children."},{label:"returns value",insertText:"returns ${1:value}",documentation:"Scalar response expectation, compared by semantic value equality. Executable as ESM v7."},{label:"returns block",insertText:"returns\n ${1:field} = ${2:value}",documentation:"Nonempty subset of response fields asserted by name. Executable as ESM v7."},{label:"result",insertText:"result\n ${1:property} = ${2:value}",documentation:"One result the query performed by `when query` returns, in order."},{label:"result exactly",insertText:"result exactly\n ${1:property} = ${2:value}",documentation:"One result, with every property asserted."},{label:"no result",insertText:"no result",documentation:"The query performed by `when query` returns nothing."},{label:"no events",insertText:"no events",documentation:"Syntax-only assertion of no new events after a non-append action; not yet executable (PLAY0268)."},{label:"readmodel",insertText:"readmodel ${1:ReadModelType}\n ${2:property} = ${3:value}",documentation:"The read model state expected afterwards."},{label:"error",insertText:'error "${1:reason}"',documentation:"A rejection, for the named reason."},{label:"denied",insertText:"denied",documentation:"The action is denied to the caller."}]},Os=[{label:"hint",insertText:'hint "${1:predicate guidance}"',documentation:"Ordered nonblank authoring guidance. Does not execute or confirm the predicate."},{label:"file",insertText:"file ${1:Path}",documentation:"The sole named-rule predicate attachment."},{label:"csharp",insertText:be("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],Wm=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...Os.filter(t=>t.label!=="hint")],zm=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:be("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],Vm=[{label:"require authenticated",insertText:"require authenticated",documentation:"Requires an authenticated caller."},{label:"require role",insertText:'require role "${1:role}"',documentation:"Requires the caller to have a role."},{label:"require not role",insertText:'require not role "${1:role}"',documentation:"Excludes callers with a role. Add authenticated to require a signed-in caller."},{label:"require not claim",insertText:'require not claim "${1:claim}" matches ${2:subject}',documentation:"Requires that no claim value matches the subject or a value."},{label:"require claim",insertText:'require claim "${1:claim}" matches ${2:subject}',documentation:"Requires a claim to match the subject or a value."},{label:"csharp",insertText:be("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],Qm=[{label:"not empty",insertText:'${1:property} not empty message "${2:message}"',documentation:"The property must have a value."},{label:"max",insertText:'${1:property} max ${2:500} message "${3:message}"',documentation:"Maximum length or value."},{label:"min",insertText:'${1:property} min ${2:1} message "${3:message}"',documentation:"Minimum length or value."},{label:"matches",insertText:'${1:property} matches "${2:pattern}" message "${3:message}"',documentation:"The property must match a regular expression."},{label:"rule",insertText:'${1:property} rule ${2:PredicateName} message "${3:message}"',documentation:"Names a predicate \u2014 optionally followed by an indented `file` reference or inline `csharp` block giving it a body; bare, it just states that a constraint exists."},{label:"==",insertText:'${1:property} == ${2:value} message "${3:message}"',documentation:"The property must equal the value."},{label:"!=",insertText:'${1:property} != ${2:value} message "${3:message}"',documentation:"The property must not equal the value."},{label:"length ==",insertText:'${1:property} length == ${2:3} message "${3:message}"',documentation:"The property must have an exact length."},{label:"all >",insertText:'${1:collection}.${2:property} all > ${3:0} message "${4:message}"',documentation:"Every element of a collection must satisfy the comparison."}],Gm=[{label:"data",insertText:"data ${1:ReadModel} via query ${2:QueryName}",documentation:"Binds a read model to the screen through a query."},{label:"action",insertText:"action ${1:CommandName}",documentation:"Makes a command available as an action on the screen."},{label:'action "\u2026"',insertText:'action "${1:Label}"\n when item.${2:status} == "${3:open}" execute ${4:CommandName}\n otherwise hidden',documentation:"One labeled button selecting the first matching command; hidden without a subject or match."},{label:"layout",insertText:"layout ${1:LayoutName}",documentation:"Uses a layout template and fills its slots."},{label:"section",insertText:"section ${1:name}",documentation:"A named structural section of the screen."},{label:"table",insertText:'table ${1:name}\n column ${2:property} label "${3:text}"',documentation:"A table widget over a read model or collection."},{label:"summary",insertText:'summary ${1:ReadModel}\n field ${2:property} label "${3:text}"',documentation:"A summary widget showing labeled fields."},{label:"title",insertText:'title "${1:text}"',documentation:"The title of the screen or section."},{label:"file",insertText:"file ${1:Path}",documentation:"Full external implementation \u2014 Stage uses the referenced file."},{label:"react",insertText:be("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:be("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:be("html"),documentation:"Inline static HTML."}],Is=[{label:"navigate to",insertText:"navigate to ${1:ScreenName}",documentation:"Navigates to a screen after the action completes."},{label:"label",insertText:'label "${1:text}"',documentation:"The display label of the action."}],Zm=[{label:"when \u2026 execute",insertText:'when item.${1:status} == "${2:open}" execute ${3:CommandName}',documentation:"First matching alternative selects the command; authorization never falls through."},{label:"otherwise hidden",insertText:"otherwise hidden",documentation:"Hides the action when no alternative matches; also the default."},{label:"otherwise execute",insertText:"otherwise execute ${1:CommandName}",documentation:"Selects a fallback command when no alternative matches and a subject exists."},...Is.filter(t=>t.label!=="label")],Ts=[{label:"execute",insertText:"execute ${1:CommandName}",documentation:"Executes a command; denial never selects another alternative."},{label:"navigate to",insertText:"navigate to ${1:ScreenName}",documentation:"Navigates to the named screen."},{label:"open dialog",insertText:"open dialog ${1:DialogTemplate}",documentation:"Opens a dialog."},{label:"notify",insertText:'notify info "${1:Message}"',documentation:"Displays a message."},{label:"confirm",insertText:'confirm "${1:Message}"\n on success\n execute ${2:CommandName}',documentation:"Asks before continuing."},{label:"refresh",insertText:"refresh ${1:QueryName}",documentation:"Refreshes a query-backed element."}],Km=[{label:"when \u2026",insertText:'when item.${1:status} == "${2:open}"\n execute ${3:CommandName}',documentation:"Selects a whole action list once against the rendered subject at gesture time."},{label:"otherwise",insertText:'otherwise\n notify info "${1:Message}"',documentation:"Final fallback list; without a subject nothing runs, including fallback."},...Ts],_m=[{label:"with \u2026 from",insertText:"with ${1:property} from item.${2:property}",documentation:"Explicit input binding for this command alternative, before same-name item fields or its form."}],Hm=[{label:"column",insertText:'column ${1:property} label "${2:text}"',documentation:"A column bound to a property."},{label:"on row-click",insertText:"on row-click navigate to ${1:ScreenName} by ${2:param}",documentation:"Navigates when a row is clicked."}],Jm=[{label:"$context.occurred",insertText:"$context.occurred",documentation:"When the command or query was received."},{label:"$context.tenant",insertText:"$context.tenant",documentation:"The tenant the command or query is executing for."},{label:"$context.command.",insertText:"$context.command.${1:property}",documentation:"A property of the command being handled."},{label:"$context.arguments.",insertText:"$context.arguments.${1:name}",documentation:"An argument of the query being performed."},{label:"$context.causedBy.subject",insertText:"$context.causedBy.subject",documentation:"Subject of the identity that caused the command or query."},{label:"$context.causedBy.name",insertText:"$context.causedBy.name",documentation:"Display name of the identity that caused the command or query."},{label:"$context.causedBy.userName",insertText:"$context.causedBy.userName",documentation:"User name of the identity that caused the command or query."},{label:"$context.causation.type",insertText:"$context.causation.type",documentation:"What caused this \u2014 a command, a reactor, a schedule."},{label:"$context.identity.id",insertText:"$context.identity.id",documentation:"The identifier of the caller from the auth token."},{label:"$context.identity.name",insertText:"$context.identity.name",documentation:"The display name of the caller."},{label:"$context.identity.userName",insertText:"$context.identity.userName",documentation:"The user name of the caller."},{label:"$context.identity.isAuthenticated",insertText:"$context.identity.isAuthenticated",documentation:"Whether the caller is authenticated."},{label:"$context.identity.roles",insertText:"$context.identity.roles",documentation:"The roles the caller holds."},{label:"$context.identity.claims.",insertText:"$context.identity.claims.${1:name}",documentation:"The value of a claim the caller carries."},{label:"$env.",insertText:"$env.${1:VAR_NAME}",documentation:"An environment variable."},...Ni.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],Rs={StateChange:["operation","file","description","event","event generation","command","constraint","screen","specification"],StateView:["file","description","readmodel","query","query observable","projection","reducer","screen","specification","event","event generation"],Automation:["operation","file","description","reaction","reducer","command","event","event generation","readmodel","specification"],Translate:["file","description","capture","event","event generation","specification"]};function Xm(t){let e=t?Rs[t]:void 0;return e?to.filter(n=>n.label==="example"||n.label==="documentation"||e.includes(n.label)):to}l(Xm,"sliceItemsFor");var d={ConflictingScreenDataBinding:"PLAY0530",ScreenDataQueryMismatch:"PLAY0531",ActionWithoutInputSurface:"PLAY0532",CommandWithoutInputSurface:"PLAY0533",ReadModelFieldWithoutOrigin:"PLAY0534",QueryParameterNotHeldByView:"PLAY0535",UnconsumedEvent:"PLAY0536",UnreachableScreen:"PLAY0537",UnknownActionSubjectField:"PLAY0345",UnresolvedActionSubject:"PLAY0346",UnreachableActionAlternative:"PLAY0347",UnknownActionArgumentProperty:"PLAY0348",UnreachableRefusalBranch:"PLAY0540",InvalidRefusalValue:"PLAY0541",UnknownRefusalConstraint:"PLAY0542",UnknownRedeliveryReaction:"PLAY0544",IndeterminateNegatedClaimTarget:"PLAY0546",InvalidRefusalBranch:"PLAY0538",InvalidRefusalBranchBody:"PLAY0539",UnmatchedRedeliveredOccurrence:"PLAY0543",InvalidNoEventsExpectation:"PLAY0545",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",OmittedProductionDestination:"PLAY0478",UnknownConstraintProperty:"PLAY0391",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",ExpectedComparisonOperator:"PLAY0161",ExpectedComparisonValue:"PLAY0162",InvalidActionAlternative:"PLAY0341",GuardedActionWithoutAlternatives:"PLAY0342",MisplacedActionOtherwise:"PLAY0343",UnsupportedActionConditionOperand:"PLAY0344",InvalidInteractionArgument:"PLAY0319",UnclosedConditionGroup:"PLAY0160",InvalidNumericDirective:"PLAY0508",DuplicateNumericDirective:"PLAY0509",LateNumericDirective:"PLAY0510",InexactNumericLiteral:"PLAY0511",MixedNumericModes:"PLAY0512",IncompatibleNumericSource:"PLAY0513",EventFromLaterSlice:"PLAY0516",TimelineCycleGroup:"PLAY0517",InvalidSpecificationExample:"PLAY0518",DuplicateSpecificationAssignment:"PLAY0519",UnresolvedSpecificationExampleType:"PLAY0520",SpecificationExampleNameCollision:"PLAY0521",SpecificationExampleKindMismatch:"PLAY0522",InvalidSpecificationExampleValue:"PLAY0523",MissingSpecificationProperty:"PLAY0524",UnadmittedSpecificationExampleValue:"PLAY0525",InvalidSpecificationExampleBody:"PLAY0526",AmbiguousReference:"PLAY0198",InvalidSpecificationStream:"PLAY0547",SpecificationStreamOnCommand:"PLAY0548",InvalidSpecificationStreamRoute:"PLAY0549",InvalidSpecificationStreamEventSource:"PLAY0550",SpecificationStreamContradictsCommand:"PLAY0551",InvalidDependencyTarget:"PLAY0554",RepeatedDependencyDeclaration:"PLAY0555",UndeclaredDependency:"PLAY0552",UnusedDependencyDeclaration:"PLAY0553",MutualDependencyDeclarations:"PLAY0556",AuthorizationRefusalWithoutIdentity:"PLAY0557",InvalidDocumentation:"PLAY0558",ConflictingDocumentationAcrossFiles:"PLAY0559",UnsupportedInteractionAlternatives:"PLAY0560",MixedInteractionAlternatives:"PLAY0561",InteractionAlternativeWithoutActions:"PLAY0562",InlineInteractionAlternative:"PLAY0563",LegacyInteractionWhere:"PLAY0564",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"};var Fi="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",z="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function Q(t){let e=`(?=[\\u0000-\\uFFFF])[${Fi}]`,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")}l(Q,"nativePattern");function w(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?Fi:`[${Fi}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}l(w,"pattern");var Ds=new RegExp(`^depends${z}+on(?:${z}|$)`,"u"),Ms=new RegExp(`${z}+$`,"u");function Et(t,e=!1,n){let i=[],r=0,o=0;for(let s of t.split(`
|
|
14
|
-
`)){r++;let a=s.endsWith("\r")?s.replace(/\r+$/,""):s,c=a.length-a.trimStart().length,p=Ns(a.substring(c),e),m=Ds.test(p)?p.replace(Ms,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:c,content:m,startOffset:o}:{number:r,raw:a,indent:c,content:m,path:n,startOffset:o}),o+=s.length+1}return i}l(Et,"splitLines");function Vt(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}l(Vt,"commentStart");function Ns(t,e){let n=Vt(t,e);return n<0?t:t.substring(0,n)}l(Ns,"stripComment");function le(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}l(le,"eventDeclarations");function xn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}l(xn,"operationDeclarations");var ne;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(ne||(ne={}));var se=class{static{l(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e){let n=l((i,r)=>{for(let o of i){let s=[...r,o.name];for(let a of o.slices)this.slices.push({slice:a,scope:[...s,a.name]});n(o.features,s)}},"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 a of le(i)){let c=o.get(a.name)??[];c.push(a),o.set(a.name,c)}let s=[...o.values()].flatMap(a=>new Set(a.map(c=>c.generation)).size!==a.length?a:[a.reduce((c,p)=>c.generation>=p.generation?c:p)]);this.declarations.push(...s.map(a=>({kind:ne.Event,name:a.name,node:a,scope:r})),...xn(i).map(a=>({kind:ne.Operation,name:a.name,node:a,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:ne.Unresolved,declaration:null,candidates:[]};let r=this.resolutions.get(n)??new Map,o=r.get(e);if(o!==void 0)return o;let s=this.candidates(e,i),a=s.length===1?{kind:s[0].kind,declaration:s[0],candidates:[]}:{kind:s.length===0?ne.Unresolved:ne.Ambiguous,declaration:null,candidates:s};return r.set(e,a),this.resolutions.set(n,r),a}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===ne.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==ne.Operation&&!(i.kind===ne.Ambiguous&&i.candidates.some(r=>r.kind===ne.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(s=>o.length<=s.scope.length&&o.every((a,c)=>s.scope[s.scope.length-o.length+c]===a));for(let s=n.length;s>=0;s--){let a=r.filter(c=>s<=c.scope.length&&n.slice(0,s).every((p,m)=>c.scope[m]===p));if(a.length>0)return a}return[]}};function vn(t){let e=new se(t);return e.slices.flatMap(({slice:n})=>n.commands.flatMap(i=>{let r=i.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length!==1?[]:i.produces.filter(o=>e.isEventProduction(o,n)&&o.inlineEvent===null&&o.when===null&&o.for===null).map(o=>({severity:"information",code:d.OmittedProductionDestination,message:`Plain 'produces ${o.event}' omits its destination - use 'for ${r[0].name}' to explicitly select the command's identifier.`,location:o.location}))}))}l(vn,"productionDestinationDiagnostics");function $n(t,e){let n=new se(t).slices.map(r=>r.slice),i=n.flatMap(le);for(let r of n)for(let o of r.constraints.flatMap(s=>[s,...s.additionalRules])){if(o.kind!=="UniquePropertyConstraintSyntax")continue;let s=i.filter(a=>a.name===o.event);if(s.length!==0)for(let a of[o.property,...o.additionalProperties])a.includes(".")||s.some(c=>c.properties.some(p=>p.name===a))||e.error(d.UnknownConstraintProperty,`Constraint '${o.name}' names property '${a}', which event '${o.event}' does not declare.`,o.location)}}l($n,"validateConstraintProperties");var io=l((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),kn=l(t=>[...t.scope,t.name].join("."),"addressOf"),Ee=class{static{l(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=l((r,o)=>{n.push({name:r.name,scope:o}),r.features.forEach(s=>i(s,[...o,r.name]))},"inventory");for(let r of e.modules)n.push({name:r.name,scope:[]}),r.features.forEach(o=>i(o,[r.name]));return[...new Map(n.map(r=>[kn(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=kn(r);if(o===i||o.startsWith(i+".")||i.startsWith(o+"."))return[];let s=[...r.scope,r.name];for(let a=1;a<=s.length;a++){let c=s.slice(-a).join(".");if(this.resolve(c,e,n).resolved!==r)continue;let p=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:c,tier:p}]}return[]}).sort((r,o)=>(r.tier==="qualified"?e.length:r.tier)-(o.tier==="qualified"?e.length:o.tier))}static resolve(e,n,i){let r=e.split(".");if(r.length>1){let o=i.filter(s=>io([...s.scope,s.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 s=i.filter(a=>a.name===e&&io(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function bn(t,e){let n=l(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=Ee.containersOf(t),r=new Map,o=l((a,c)=>{let p=[],m=c.join(".");r.has(m)||r.set(m,new Set);let u=r.get(m);for(let y of a){let h=Ee.resolve(y.target,c,i),x=h.resolved===void 0?void 0:kn(h.resolved),v=x===void 0?`text:${y.target}`:`resolved:${x}`;if(u.has(v)){e.warning(d.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}u.add(v),p.push(y),h.ambiguous.length>0?e.warning(d.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(kn).join(", ")}`,y.location):(x===void 0||x===m||x.startsWith(m+".")||m.startsWith(x+"."))&&e.warning(d.InvalidDependencyTarget,`Invalid dependency target '${y.target}' on '${m}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,y.location)}return p},"keep"),s=l((a,c)=>{let p=[...c,a.name];return{...a,dependsOn:o(a.dependsOn??[],p),features:a.features.map(m=>s(m,p))}},"normalize");return{...t,modules:t.modules.map(a=>({...a,dependsOn:o(a.dependsOn??[],[a.name]),features:a.features.map(c=>s(c,[a.name]))}))}}l(bn,"validateDependencyDeclarations");var xt=[],Qt=l(t=>t.length===0,"isDocumentPlacement");function En(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}l(En,"describePlacement");var Ct=l((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var Yi=l(t=>t.content.length===0,"isBlank"),f=l(t=>Ct(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),ro=l(t=>Ct(t.number,1,t.path),"startOf");var js=w("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),Ls=new RegExp(w("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),qs=w("^[A-Z]\\w*$");function at(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&js.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=Bs(n),r=f(e);if(i.length===0)return t.error(d.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new Ui(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}l(at,"parseAuthorize");function Ye(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}}l(Ye,"combineAuthorize");function Bs(t){let e=[];for(let n of t.match(Ls)??[])e.length>0&&Fs(e[e.length-1])&&Ys(n)&&e.push("and"),e.push(n);return e}l(Bs,"tokenize");var oo=l(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),Fs=l(t=>t===")"||oo(t),"isOperandEnd"),Ys=l(t=>t==="("||oo(t),"isOperandStart"),Ui=class{static{l(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(d.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#r("or","Or",()=>this.#o())}#o(){return this.#r("and","And",()=>this.#n())}#r(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.#i();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(d.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#i(){if(this.#e>=this.tokens.length)return this.context.error(d.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return qs.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(d.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};var H='(?:[^"\\\\]|\\\\.)*',Us={"\\":"\\",'"':'"',n:`
|
|
15
|
-
`,r:"\r",t:" "};function X(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?Us[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}l(X,"unescapeString");function Pt(t,e,n,i=!1){let o=n.content.startsWith("```")?n:t.reader.peekSignificant(),s=e==="description"?"```text":`\`\`\`${e}`;if(o===void 0||o!==n&&o.indent<=n.indent||o.content!==s&&!(i&&e==="description"&&o.content==="```markdown")&&!(o.content==="```"&&o!==n))return t.error(d.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,f(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(d.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",f(o));let a=[];for(;;){let c=t.reader.takeRaw();if(c===void 0){t.error(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(o));break}if(c.raw.trim()==="```")break;let p=0;for(;p<o.indent&&p<c.raw.length&&c.raw[p]===" ";)p++;a.push(c.raw.substring(p))}return a.join(`
|
|
16
|
-
`)}l(Pt,"parseFencedText");var Ws=w(`^description\\s+"(${H})"$`);function Z(t,e,n,i,r=!1){if(e.content==="description"){let s=Pt(t,"description",e,r);return s===null?n:s.trim().length===0?(t.error(d.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,f(e)),n):ao(t,e,n,i,s)}let o=Ws.exec(e.content);return o===null?(t.error(d.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,f(e)),n):ao(t,e,n,i,X(o[1]))}l(Z,"parseDescription");function ao(t,e,n,i,r){return n!==null?(t.error(d.DuplicateDescription,`${i} already declares a description - at most one is allowed`,f(e)),n):r}l(ao,"keep");function ve(t,e,n,i,r=d.InvalidDocumentation){if(e.content!=="documentation"||t.peekChild(e.indent)?.content!=="```markdown")return t.error(r,`${i} documentation requires a fenced markdown block`,f(e)),t.skipOpaqueBlock(e.indent),n;let o=Pt(t,"markdown",e);return o===null||o.trim().length===0||n!==null?(t.error(r,`${i} accepts one nonempty documentation block`,f(e)),n):o}l(ve,"parseDocumentation");var zs=Q(`^depends${z}+on${z}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function Cn(t,e,n,i){let r=zs.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,f(e)),t.skipBlock(e.indent);return}if(n.some(o=>o.target===r)){t.warning(d.RepeatedDependencyDeclaration,`Dependency '${r}' is already declared on this container - this repeated declaration is ignored`,f(e));return}n.push({kind:"DependsOnSyntax",target:r,location:f(e)})}l(Cn,"parseDependsOn");var Vs=w('^import\\s+"([^"\\\\]+)"$'),Qs=w('^import\\s+"'),so=l(t=>Qs.test(t),"isFileImport");function lo(t){let e=Vs.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:f(t)}}l(lo,"tryParseFileImport");function At(t,e,n){let i=lo(e);if(i!==void 0){n.push(i);return}t.error(d.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,f(e)),t.skipBlock(e.indent)}l(At,"parseFileImport");var D=l(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),te=l(t=>t.replaceAll("@",""),"unescapeIdentifier");function co(t,e){let n=[],i=0,r=!1,o=!1;for(let s=0;s<t.length;s++){let a=t[s];a==="\\"&&r&&s+1<t.length?s++:a==='"'&&!o?r=!r:a==="`"&&!r?o=!o:a===e&&!r&&!o&&(n.push(t.substring(i,s)),i=s+1)}return n.push(t.substring(i)),n}l(co,"splitTopLevel");var Wi="79228162514264337593543950335";function Ge(t){let e=po(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),s=o<0?-o:0;if(o>28||r-i+s>Wi.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===Wi.length&&a>Wi)return;let c=Math.max(0,o),p=c===0?a:a.length>c?`${a.substring(0,a.length-c)}.${a.substring(a.length-c)}`:`0.${"0".repeat(c-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+p})}l(Ge,"parseExactNumber");function Gt(t){return po(t)!==void 0}l(Gt,"isExactNumberToken");function po(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&zi(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&zi(t[i]);)i++;if(i===a)return;o=t.substring(a,i)}let s=0;if(t[i]==="e"||t[i]==="E"){i++;let a=t[i]==="-";(t[i]==="+"||t[i]==="-")&&i++;let c=i,p=t.length+29;for(;i<t.length&&zi(t[i]);)s=Math.min(p,s*10+t.charCodeAt(i++)-48);if(i===c)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}l(po,"scan");function zi(t){return t>="0"&&t<="9"}l(zi,"isDigit");var fo=64,Ae=class extends Error{static{l(this,"InvalidStructuredValue")}},Pn=class{static{l(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.#s(),this.#e<this.text.length)throw new Ae(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#s();let n=this.#l(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=fo)throw new Ae(`The value nests deeper than ${fo} levels.`);return i==="["?this.#o(e,n):this.#r(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.#a(n)}#o(e,n){this.#e++;let i=[];if(this.#s(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#s(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#d(",")}}#r(e,n){this.#e++;let i=[],r=new Set;if(this.#s(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#s();let o=this.#l();if(this.text[this.#e]!=='"')throw new Ae("Expected a property name in double quotes.");let s=this.#n();this.#s(),this.#d(":");let a=this.#t(e+1);if(r.has(s)?this.context?.error(d.DuplicateStructuredValueMember,`Duplicate property '${s}' in structured value`,o):(r.add(s),i.push({kind:"ObjectMemberSyntax",name:s,value:a,location:o})),this.#s(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#d(",")}}#n(){let e=this.#i(this.#e),n=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(n)}catch{throw new Ae(`${n} is not a valid JSON string.`)}}#i(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 Ae("A string is not closed.")}#a(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new Ae(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=Ge(n[0]);return r===void 0?(this.context.error(d.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 Ae("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}}#s(){for(;this.#e<this.text.length&&`
|
|
17
|
-
\r`.includes(this.text[this.#e]);)this.#e++}#c(e){return this.text[this.#e]!==e?!1:(this.#e++,!0)}#d(e){if(!this.#c(e))throw new Ae(`Expected '${e}' at position ${this.#e}.`)}};var Gs=w("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Zs=Q("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Ks=w("^-?\\d+(\\.\\d+)?$"),uo=["command","arguments","tenant","causedBy","causation","occurred","identity"],mo=["subject","name","userName"],yo=["id","name","userName","isAuthenticated","roles","claims"];function we(t,e,n){return ie(t,e,n,!0)}l(we,"parseModeledMappingSource");function ie(t,e,n,i=!1){if(t=t.trim(),t==="$refusal"||t.startsWith("$refusal."))return{kind:"RefusalExpressionSyntax",member:t==="$refusal"?"":t.substring(9),location:e};if(t.startsWith("$context.")){let o=t.substring(9);return _s(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 Pn(t,e,n).parse()}catch(o){if(!(o instanceof Ae))throw o;return n?.error(d.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?Zt(t,e):Zt(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?Zs:Gs).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}l(ie,"parseMappingSource");function _s(t,e,n){let[i,r]=t.split(".");uo.includes(i)?r!==void 0&&i==="causedBy"&&!mo.includes(r)?n?.warning(d.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${mo.join(", ")}`,e):r!==void 0&&i==="identity"&&!yo.includes(r)&&n?.warning(d.UnknownContextIdentityProperty,`Unknown $context.identity property '${r}' - expected ${yo.join(", ")}`,e):n?.warning(d.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${uo.join(", ")}`,e)}l(_s,"warnOnUnknownContextPath");function Zt(t,e,n){let i=l(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(X(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!Gt(t))return;let o=Ge(t);return o!==void 0?i(o):(n.error(d.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(Ks.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}l(Zt,"parseLiteral");var Vi={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function je(t,e,n,i=!1){i||(t=t.valueContext);let r=i?z:"\\s",o=t.sourceOptions.numericMode==="exact"?`-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|${r}|[()])|`:"",s=t.sourceOptions.numericMode==="exact"&&!i?"[\\w.$-]+|[^\\s]":"[\\w.$-]+",a=new RegExp(Q(`"${H}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let x=e.replace(a,"").replace(new RegExp(z,"gu"),"");if(x.length>0)return t.error(d.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${x[0]}'`,n),null}let c=e.match(a)??[],p=0,m=l(()=>{if(c[p]==="("){p++;let C=y();return c[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(d.UnclosedConditionGroup,"Expected ')' in condition",n),C}let x=c[p++];if(i&&x===void 0)return t.error(d.ExpectedCondition,"Expected a condition",n),null;let v=c[p++];if(v==="starts"&&c[p]==="with"&&(v+=" with",p++),i&&!Object.hasOwn(Vi,v))return t.error(d.ExpectedComparisonOperator,`Expected a comparison operator after '${x}'`,n),null;let k=c[p++];return i&&k===void 0?(t.error(d.ExpectedComparisonValue,"Expected a value to compare against",n),null):x===void 0||k===void 0||Vi[v]===void 0?null:{kind:"ComparisonConditionSyntax",left:x,operator:Vi[v],right:we(k,n,t),location:n}},"group"),u=l(()=>{let x=m();for(;x!==null&&c[p]==="and";){p++;let v=m();if(v===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"And",right:v,location:n}}return x},"and"),y=l(()=>{let x=u();for(;x!==null&&c[p]==="or";){p++;let v=u();if(v===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"Or",right:v,location:n}}return x},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(d.ExpectedCondition,"Expected a condition",n):h!==null&&p<c.length&&t.error(d.UnexpectedTokenInCondition,`Unexpected '${c[p]}' in condition`,n)),h}l(je,"parseCondition");var Hs=w(`^when${z}+([^\\n]+)${z}+execute${z}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Js=w(`^otherwise${z}+execute${z}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Xs=w(`^with${z}+([A-Za-z_]\\w*)${z}+from${z}+([^\\n]+)$`),el=w("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),tl=new RegExp(`^${z}+|${z}+$`,"gu");function So(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){t.reader.takeSignificant();let p=Hs.exec(c.content),m=Js.exec(c.content);if(p!==null){a&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(c));let u=je(t,p[1],f(c),!0),y=ho(t,c);u!==null&&(wt(t,u),r.push({kind:"ScreenActionAlternativeSyntax",condition:u,command:p[2],arguments:y,location:f(c)}))}else if(c.content==="otherwise hidden"||m!==null)if(a&&t.error(d.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",f(c)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:ho(t,c),location:f(c)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:f(c)};for(let u=t.peekChild(c.indent);u!==void 0;u=t.peekChild(c.indent))t.reader.takeSignificant(),t.error(d.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",f(u)),t.skipBlock(u.indent)}else if(D(c.content)==="navigate")s!==null&&t.error(d.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",f(c)),s=i(t,c.content,c)??null;else{let u=D(c.content)==="label";t.error(u?d.UnknownActionDirective:d.InvalidActionAlternative,u?"A guarded action's header already supplies its label":`Unexpected '${c.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,f(c)),t.skipBlock(c.indent)}}return r.length===0&&t.error(d.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",f(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:f(e)}}l(So,"parseGuardedAction");function ho(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=Xs.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(tl,""),location:f(i)}):(t.error(d.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,f(i)),t.skipBlock(i.indent))}return n}l(ho,"parseArguments");function wt(t,e){if(e.kind==="LogicalConditionSyntax"){wt(t,e.left),wt(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=el.test(e.left)&&e.right.kind==="LiteralExpressionSyntax";["GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual"].includes(e.operator)?i&&=typeof n=="number"||typeof n=="object"&&n!==null:["Contains","StartsWith"].includes(e.operator)&&(i&&=typeof n=="string"),i||t.error(d.UnsupportedActionConditionOperand,"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string",e.location)}l(wt,"validateCondition");var Ze=class t{static{l(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(Yi)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&Yi(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}};var oe=class extends Error{static{l(this,"InvalidSyntaxJson")}};var Oe=Object.freeze({numericMode:"legacy"}),An=Object.freeze({numericMode:"exact"}),go=Object.freeze({numericMode:"invalid"});function Ot(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 oe("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new oe("Malformed source numeric options.");return e==="exact"?An:Oe}l(Ot,"validatedSourceOptions");var xo=new WeakSet;function vo(t){xo.add(t)}l(vo,"recordAuthoredDocument");function $o(t){return xo.has(t)}l($o,"isAuthoredDocument");var ge=class t{static{l(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=Oe;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 Ct(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 nl=w(`^when${z}+([^\\n]+)${z}+execute${z}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),il=w(`^on${z}+([^\\n]+)$`),bo=w(`^where${z}+([^\\n]+)$`),ko=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function Eo(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=il.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let u=n+1;u<e.length&&e[u].indent>i.indent;u++)o.push(e[u]);let s=o.filter(u=>u.indent===o[0]?.indent),a=s.filter(u=>["when","otherwise"].includes(D(u.content))),c=["click","double click","select"].includes(r[1].trim()),p=s.filter(u=>bo.test(u.content)),m=!1;for(let u of a){let y=D(u.content)==="when",h=y?nl.exec(u.content):null;if(y){m&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(u));let k=je(t,h?.[1]??u.content.slice(4).trim(),f(u),!0);k!==null&&wt(t,k),h!==null&&t.error(d.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",f(u))}else(m||u.content!=="otherwise")&&t.error(d.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",f(u)),m=!0;let x=o.indexOf(u),v=o[x+1];h===null&&(v===void 0||v.indent<=u.indent||!ko.has(D(v.content)))&&t.error(d.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",f(u))}if(a.length>0&&(c||t.error(d.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",f(i)),(p.length>0||s.some(u=>ko.has(D(u.content))))&&t.error(d.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",f(i)),a.some(u=>D(u.content)==="when")||t.error(d.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",f(i))),c)for(let u of p)rl(t,u)}}l(Eo,"validateInteractionBodies");function rl(t,e){let n=new ge(new Ze([]));n.sourceOptions=t.sourceOptions;let i=je(n,bo.exec(e.content)[1].trim(),f(e),!0);i!==null&&wt(n,i);let r="Opaque 'where' on click, double click and select is deprecated; use block-form 'when' item conditions";i!==null&&n.diagnostics.length===0?t.warning(d.LegacyInteractionWhere,r,f(e)):t.information(d.LegacyInteractionWhere,r,f(e))}l(rl,"deprecateWhere");var ol=w("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),al=w("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),sl=w("^field\\s+([\\w.]+)(?:\\s|$)"),ll=w("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),cl=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),dl=w("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),pl=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on","when","otherwise"]);function Ie(t,e){let n=[],i=new Set,r=[],o=D(e.content)==="behavior",s=l(c=>{for(;n.length>0&&n[n.length-1].indent>=c.indent;)n.pop();let p=o&&n.length===0?dl.exec(c.content):null;p!==null&&i.add(p[1]);let m=ol.exec(c.content),u=al.exec(c.content);if(m!==null)n.push({command:m[1],kind:"form",indent:c.indent});else if(u!==null)n.push({command:u[2],kind:u[1],indent:c.indent});else if(pl.has(D(c.content)))n.push({command:"",kind:"other",indent:c.indent});else{let y=n.at(-1);if(y===void 0||y.kind==="other")return;let h=(y.kind==="form"?sl:y.kind==="execute"?ll:cl).exec(c.content);h!==null&&r.push({command:y.command,property:te(h[1]),scope:t.scope,location:f(c)})}},"recognize");s(e);let a=[e];for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))t.reader.takeSignificant(),c.content.startsWith("```")?t.skipFencedBody():(a.push(c),s(c));Eo(t,a);for(let c of r)t.inputUses.push(i.has(c.command)?{...c,isParameter:!0}:c)}l(Ie,"collectInputUses");function me(t){return w(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}l(me,"sourceStreamPattern");var fl=me("^[A-Za-z_]\\w*(?![\\s\\S])"),ul=me("^[\\w.]+(?![\\s\\S])");function Qi(t){return typeof t=="string"&&fl.test(t)}l(Qi,"isSourceStreamName");function wn(t){return typeof t=="string"&&ul.test(t)}l(wn,"isSourceStreamTypeName");var ml=w("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?$"),yl=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier)(?:\\s+(?:optional|generated|identifier))*)$"),hl=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function st(t){let e=ml.exec(t.content);if(e===null)return;let n=f(t);return{kind:"PropertySyntax",name:te(e[1]),type:Te(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}}l(st,"tryParseProperty");function Te(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}}l(Te,"parseTypeRef");function Ue(t,e){let n=st(e);return n!==void 0?Le(t,n.type,e):On(t,e),n}l(Ue,"parseProperty");function Le(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(d.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}l(Le,"reportLegacyOptionalSuffix");function On(t,e){if(hl.test(e.content))return t.error(d.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",f(e)),!0;{let n=yl.exec(e.content);if(n!==null&&n[1].split(/\s+/).some(i=>i==="generated"||i==="identifier"))return t.error(d.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",f(e)),!0}return!1}l(On,"reportInvalidModifierOrder");var Sl=w(`^id\\s+"(${H})"$`),gl=me("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),xl=me("^eventsource\\s+([A-Za-z_]\\w*)$"),vl=me("^stream\\s+([A-Za-z_]\\w*)$");function Co(t,e){let n=xl.exec(e.content)?.[1]??"";n===""&&Ke(t,e,"Expected 'eventsource <Name>'.");let i=[],r=null,o=null,s=null;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(a.content)){case"stream":i.push($l(t,a));break;case"identifier":r=Po(t,a,"identifier",r);break;case"description":o=Z(t,a,o,`Event source '${n}'`,!0);break;case"id":s=Ao(t,a,n,s);break;default:Ke(t,a,"An event source accepts description, id, identifier and stream declarations."),t.skipBlock(a.indent);break}return{kind:"EventSourceSyntax",name:n,streams:i,identifier:r,description:o,id:s,location:f(e)}}l(Co,"parseEventSource");function $l(t,e){let n=vl.exec(e.content)?.[1]??"";n===""&&Ke(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,c=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(p.content)){case"streamId":o?(Ke(t,p,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(p.indent)):p.content==="streamId"?(o=!0,s.streamId=f(p),r=kl(t,p)):(i=Po(t,p,"streamId",i),o=i!==null);break;case"description":a=Z(t,p,a,`Stream '${n}'`,!0);break;case"id":c=Ao(t,p,n,c);break;default:Ke(t,p,"A stream accepts description, id and streamId declarations."),t.skipBlock(p.indent);break}return{kind:"EventStreamSyntax",name:n,streamId:i,streamIdParts:r,description:a,id:c,directiveLocations:s,location:f(e)}}l($l,"parseEventStream");function Po(t,e,n,i){let r=gl.exec(e.content);return r===null||i!==null?Ke(t,e,`Declare at most one '${n} <Type>'.`):(i=Te(r[2],{...f(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Le(t,i,e)),Kt(t,e,d.InvalidEventSourceDeclaration),i}l(Po,"parseType");function Ao(t,e,n,i){let r=Sl.exec(e.content),o=r===null?null:X(r[1]);return o===null||o.trim()===""||i!==null?Ke(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(d.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",f(e))),Kt(t,e,d.InvalidEventSourceDeclaration),i}l(Ao,"parsePin");function wo(t,e,n,i){let[r,o]=n.type.name.split("."),s={kind:"CommandStreamSyntax",eventSource:r,stream:o,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:n.type.location,referenceLength:n.type.name.length,location:f(e)};if(i)return t.error(d.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,f(e)),{...s,propertyCandidate:n};let a=null,c=[],p=!1,m={};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),u.content==="streamId"){a!==null||p?(t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent)):(p=!0,m.streamId=f(u),c=Gi(t,u,d.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(u.content);if(y===null||a!==null||p)t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent);else{let h={...f(u),column:u.indent+1+u.content.indexOf(y[1],u.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:ie(y[1],h,t),location:f(u)},Kt(t,u,d.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:c,directiveLocations:m}}l(wo,"parseCommandStream");function kl(t,e){let n=[],i=me("^([A-Za-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$");for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=i.exec(r.content);if(o===null){Ke(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=Te(o[2],{...f(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});Le(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:f(r)}),Kt(t,r,d.InvalidEventSourceDeclaration)}return n.length===0&&Ke(t,e,"A streamId part block cannot be empty."),n}l(kl,"parseStreamIdParts");function Gi(t,e,n){let i=[],r=me("^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$");for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=r.exec(o.content);if(s===null){t.error(n,"Expected '<part> = <source>' in a streamId part block.",f(o)),t.skipBlock(o.indent);continue}let a={...f(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:ie(s[2],a,t),location:f(o)}),Kt(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",f(e)),i}l(Gi,"parseRouteParts");function Kt(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",f(i)),t.skipBlock(e.indent))}l(Kt,"rejectChildren");function Ke(t,e,n){t.error(d.InvalidEventSourceDeclaration,n,f(e))}l(Ke,"invalid");var bl=w("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Oo=l(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),fe=l(t=>Oo(t).length>0,"isFileDirective"),In=l(t=>fe(t)&&!bl.test(Oo(t)),"isFileDirectiveAmongProperties");var El=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function Tn(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||El.has(n)))return!1}return!0}l(Tn,"isBlankImplementationHint");var Io=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),It=l(t=>D(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),_t=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function lt(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(d.AbsoluteFileReference,`'${n}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,f(e)),{kind:"FileReferenceSyntax",path:n,location:f(e)}}l(lt,"parseFile");var Zi=l(t=>t.raw.trim()==="```","isClosingCodeFence");function Re(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(d.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=e.indent||o.content!=="```"&&o.content!==`\`\`\`${n}`)return t.error(d.ExpectedCodeFence,`Expected an opening \`\`\`${n} fence after '${n}'`,f(e)),null;i=t.reader.takeSignificant()}let r=[];for(;;){let o=t.reader.takeRaw();if(o===void 0){t.error(d.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(i));break}if(Zi(o))break;let s=0;for(;s<i.indent&&o.raw[s]===" ";)s++;r.push(o.raw.substring(s))}return{kind:"CodeBlockSyntax",language:n,code:r.join(`
|
|
18
|
-
`),location:f(e)}}l(Re,"parseCode");function To(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(d.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",f(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return Cl(t,e,n);let i=It(n)?lt(t,n):null,r=i===null&&_t(t,n)?Re(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&D(o.content)==="implementation"&&(t.error(d.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",f(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:f(e)}}return t.error(d.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,f(n)),t.skipBlock(e.indent),null}l(To,"parseHandler");function Cl(t,e,n){let i=Ht(t,n);for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(D(r.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",f(r)),_t(t,r)?Re(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:f(e)}}l(Cl,"parseImplementation");function Ht(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(d.InvalidImplementationBlock,"Expected 'implementation' with no operand.",f(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||Io.test(s.content)){let a=Io.exec(s.content),c=a===null?null:X(a[1]);Tn(c)?t.error(d.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",f(s)):n.push({kind:"ImplementationHintSyntax",text:c,location:f(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(d.InvalidImplementationHint,"A hint cannot have children.",f(p)),t.skipBlock(s.indent))}else if(It(s)||s.content.startsWith("```")){o&&t.error(d.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",f(s));let a=It(s)?lt(t,s):null,c=a===null?Re(t,s):null;o||(i=a,r=c),o=!0;let p=t.peekChild(s.indent);a!==null&&p!==void 0&&(t.error(d.InvalidImplementationBlock,"A file directive cannot have children.",f(p)),t.skipBlock(s.indent))}else t.error(d.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,f(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:f(e)}}}l(Ht,"parseImplementationWrapper");var Pl=w("^system\\s+([A-Za-z_]\\w*)$"),Al=w("^operation\\s+([A-Za-z_]\\w*)$"),wl=w("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),Ki=w("^uses\\s+([A-Za-z_]\\w*)$"),Ol=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Il=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function Jt(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,f(r)),t.skipBlock(e.indent))}l(Jt,"rejectOperationChildren");function Ro(t,e){let n=Pl.exec(e.content);n===null&&t.error(d.InvalidSystemDeclaration,"Expected 'system <Name>'.",f(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="description"?i=Z(t,r,i,`System '${n?.[1]??""}'`):(t.error(d.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",f(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:f(e)}}l(Ro,"parseSystem");function Rn(t,e,n=!1){let i=(n?wl:Al).exec(e.content),r=i?.[1]??"";i===null&&t.error(d.InvalidOperationDeclaration,"Expected an operation declaration with one name.",f(e));let o=null,s=null,a=f(e),c=null,p=null,m=[],u=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let x=Ol.exec(h.content),v=n&&x!==null?{...h,content:x[1].trimEnd()}:h;if(x===null&&Il.has(D(h.content))){t.error(d.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",f(h)),t.skipBlock(h.indent);continue}if(!Ki.test(h.content)&&st(v)!==void 0){let k=Ue(t,v);n&&x===null&&t.error(d.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",f(h)),(k.isIdentifier||k.isGenerated)&&t.error(d.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",f(h)),y.has(k.name)&&t.error(d.DuplicateDeclaration,`Operation '${r}' already declares input '${k.name}'.`,f(h)),y.add(k.name),m.push(k),n&&x!==null&&u.push({kind:"PropertyMappingSyntax",property:k.name,source:ie(x[2],{...f(h),column:h.indent+h.content.length-x[2].length+1},t),location:f(h)}),Jt(t,h,d.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=Z(t,h,o,`Operation '${r}'`);else if(Ki.test(h.content))s!==null?t.error(d.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",f(h)):(s=Ki.exec(h.content)[1],a={...f(h),column:f(h).column+h.content.indexOf(s,4)}),Jt(t,h,d.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let k=Tl(t,h);h.content==="execute"?c!==null?t.error(d.InvalidOperationDeclaration,"An operation declares execute at most once.",f(h)):c=k:p!==null?t.error(d.InvalidOperationDeclaration,"An operation declares compensate at most once.",f(h)):p=k}else t.error(d.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,f(h)),t.skipBlock(h.indent)}return s===null&&t.error(d.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",f(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:c,compensate:p,location:f(e)},mappings:u}}l(Rn,"parseOperation");function Tl(t,e){let n=null,i=null,r=null,o=null,s=!1;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(a.content)==="description"){n=Z(t,a,n,`Operation phase '${e.content}'`);continue}if(D(a.content)==="implementation"){s&&t.error(d.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",f(a));let c=Ht(t,a);s||(i=c.file,r=c.code,o=c.implementation),s=!0}else if(fe(a)||a.content.startsWith("```")){s&&t.error(d.ConflictingImplementationSources,"A phase has at most one file or inline payload.",f(a));let c=fe(a)?lt(t,a):null,p=c===null?Re(t,a):null;s||(i=c,r=p),s=!0,c!==null&&Jt(t,a,d.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(d.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",f(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:f(e)}}l(Tl,"parseOperationPhase");var _i=w("^then\\s+returns\\b"),Dn=w("^generated\\s+(?=\\S)(?![=])"),Mn=w("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Rl=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Dl=w(`^(?:"${H}"|'(?:[^'\\\\]|\\\\.)*')$`);function Nn(t,e,n,i){if((e.startsWith('"')||e.startsWith("'"))&&!Dl.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ie(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}l(Nn,"parseConcrete");function Tt(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.",f(e)),t.skipBlock(e.indent),null;let o=f(e),s=Nn(t,r[2],{...o,column:o.column+e.content.indexOf(r[2],e.content.indexOf("=")+1)},i),a=t.peekChild(e.indent);return a!==void 0&&(t.error(i,"A fixture or return field cannot have child directives.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}l(Tt,"parseConcreteMapping");function Do(t,e){let n=_i.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=f(e);if(i.length>0){let s=Nn(t,i,{...r,column:r.column+e.content.indexOf(i,n)},d.InvalidReturnExpectation),a=t.peekChild(e.indent);return a!==void 0&&(t.error(d.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"ScalarSpecificationReturnSyntax",value:s,location:r}}let o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=Tt(t,s,Rl,d.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}l(Do,"parseReturn");var Ml=w("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),Nl=w("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),jl=w("^specification\\s+([A-Za-z_]\\w*)$"),Ll="([A-Z]\\w*(?:\\.\\w+)*)",ql="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",Rt=l((t,e="")=>Q(`^${t}\\s+${Ll}${e}${ql}$`.replaceAll("\\s",z)),"stepPattern"),Bl=Rt("given"),Fl=Rt("when\\s+append"),Yl=Rt("when"),Ul=Rt("then"),Wl=w("^then\\s+query\\b"),Mo=w("^(?:given|then)\\s+readmodel\\b"),zl=Rt("given\\s+readmodel"),Vl=Rt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),No=w("^then\\s+no\\b"),Ql=w(`^then\\s+error\\s+"(${H})"$`),Xi=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Gl=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Zl=w("^given\\s+clock\\b"),Kl=w("^given\\s+capture\\b"),_l=w("^when\\s+clock\\b"),Hl=w("^when\\s+trigger\\b"),Jl=w("^when\\s+capture\\b"),Xl=w("^when\\s+query\\b"),ec=w("^then\\s+result\\b"),tc=w("^then\\s+no\\s+result\\b"),nc=Q("^when\\s+redelivered\\b"),ic=Q("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),rc=w("^then\\s+no\\s+events\\b"),oc=w('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),ac=w("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),sc=w("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),lc=w("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),cc=w("^then\\s+result(\\s+exactly)?$"),jo=Q("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),dc=Q(`^(?:"${H}"|'(?:[^'\\\\]|\\\\.)*')$`),pc=Q("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function er(t,e){let n=jl.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,f(e));let i=null,r={givenOperationFailures:[],thenOperations:[],thenCompensated:[],thenAbsentReadModels:[],thenQueries:[],given:[],givenReadModels:[],when:null,whenAppended:null,whenRedelivered:null,whenDeclared:!1,thenEvents:[],thenEventsInAnyOrder:!1,thenNoEvents:!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 c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){if(t.reader.takeSignificant(),fe(c)||fc(t,c,r))continue;let p=No.test(c.content)?"then":D(c.content);p==="description"?i=Z(t,c,i,`Specification '${n}'`):p==="given"?uc(t,c,r):p==="when"?Sc(t,c,r,n):p==="then"?gc(t,c,r):(t.error(d.UnknownSpecificationDirective,`Unexpected '${D(c.content)}' in specification body`,f(c)),t.skipBlock(c.indent))}r.noEventsLine!==void 0&&(r.whenAppended!==null||r.thenEvents.length>0||r.thenEventsInAnyOrder||r.thenErrors.length>0||r.thenDenied!==null)&&t.error(d.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",f(r.noEventsLine));let{whenDeclared:o,noEventsLine:s,...a}=r;return{kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...a,location:f(e)}}l(er,"parseSpecification");function fc(t,e,n){if(!Ml.test(e.content))return!1;let i=Nl.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(d.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",f(e)),ye(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 s=Tt(t,o,Xi,d.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:f(e)})}else Jt(t,e,d.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:f(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:f(e)});return!0}l(fc,"parseOperationStep");function uc(t,e,n){if(Zl.test(e.content))n.givenClock!==null?(t.error(d.InvalidSpecificationClock,"A specification states its clock at most once.",f(e)),ye(t,e.indent)):n.givenClock=Lo(t,e,"given");else if(Kl.test(e.content)){let i=qo(t,e,"given");i!==null&&n.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))n.givenCaller!==null?(t.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",f(e)),t.skipBlock(e.indent)):n.givenCaller=hc(t,e);else if(Mo.test(e.content)){let i=Bo(t,e,zl,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=tr(t,e,Bl,"given");i!==void 0&&n.given.push(i)}}l(uc,"parseGiven");var mc=w(`^role${z}+"(${H})"$`),yc=w(`^claim${z}+"(${H})"${z}*=${z}*"(${H})"$`);function hc(t,e){if(e.content!=="given caller")return t.error(d.InvalidSpecificationCaller,"Expected exactly 'given caller'.",f(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 s=mc.exec(o.content),a=yc.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(X(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:X(a[1]),value:X(a[2]),location:f(o)}):t.error(d.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,f(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:f(e)}}l(hc,"parseCaller");function Sc(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let c=n.whenAppended!==null||r?d.ConflictingSpecificationActions:d.DuplicateSpecificationWhen;t.error(c,`Specification '${i}' already declares a 'when' - a specification can have at most one`,f(e)),ye(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=tr(t,e,Fl,"when append")??null;return}if(nc.test(e.content)){let c=ic.exec(e.content);c===null?(t.error(d.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",f(e)),ye(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:c[1],reaction:c[2],...Ji(t,e,void 0,void 0,"when redelivered"),location:f(e)};return}if(_l.test(e.content)){n.whenClock=Lo(t,e,"when");return}if(Hl.test(e.content)){n.whenTrigger=Hi(t,e,ac,d.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(c,p)=>({kind:"SpecificationTriggerSyntax",trigger:c,values:p,location:f(e)}));return}if(Jl.test(e.content)){n.whenCapture=qo(t,e,"when");return}if(Xl.test(e.content)){n.whenQuery=Hi(t,e,lc,d.InvalidSpecificationQueryAction,"when query","when query <Query>",(c,p)=>({kind:"SpecificationWhenQuerySyntax",query:c,arguments:p,location:f(e)}));return}let o=Yl.exec(e.content);if(o===null){t.error(d.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,f(e)),ye(t,e.indent);return}let s=[],a=Ji(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:f(e)}}l(Sc,"parseWhen");function gc(t,e,n){if(rc.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(d.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",f(e)):(n.thenNoEvents=!0,n.noEventsLine=e);let o=t.peekChild(e.indent);o!==void 0&&t.error(d.InvalidNoEventsExpectation,"'then no events' cannot have child mappings.",f(o)),ye(t,e.indent);return}if(_i.test(e.content)){let o=Do(t,e);n.thenReturns!==null?t.error(d.InvalidReturnExpectation,"A specification declares at most one return expectation.",f(e)):n.thenReturns=o;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||n.thenEventsInAnyOrder?t.error(d.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",f(e)):n.thenEventsInAnyOrder=!0,ye(t,e.indent);return}if(ec.test(e.content)){vc(t,e,n);return}if(tc.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(d.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",f(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:f(e)},ye(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(d.InvalidSpecificationDenied,"Expected exactly 'then denied'.",f(e)),ye(t,e.indent)):n.thenDenied!==null?t.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",f(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:f(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:f(e)});return}let i=Ql.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:X(i[1]),location:f(e)});return}if(D(e.content.substring(4).trim())==="error"){t.error(d.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,f(e)),ye(t,e.indent);return}if(No.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=xc(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=jo.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=ie(o[2].trim(),f(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:f(e)})}t.skipOpaqueBlock(e.indent);return}if(Wl.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=l((u,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(u,y,f(h)),t.skipBlock(h.indent)},"reject"),a=pc.exec(e.content);if(a===null)return s(d.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let c=[],p=[],m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))t.reader.takeSignificant(),u.content==="arguments"&&!m?c.push(...Xt(t.valueContext,u,!0)):u.content==="arguments"?s(d.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,u):u.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:Xt(t.valueContext,u,!0),exactly:!1,location:f(u)}):s(d.UnknownSpecificationQueryDirective,`Unexpected '${D(u.content)}' in 'then query' body - expected arguments or result`,u),m||=u.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:c,results:p,exactly:a[2]!==void 0,location:f(e)});return}if(Mo.test(e.content)){let o=Bo(t,e,Vl,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=tr(t,e,Ul,"then");r!==void 0&&n.thenEvents.push(r)}l(gc,"parseThen");function xc(t,e){let n=jo.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(d.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,f(e)),ye(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||dc.test(i)?ie(i,f(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax");s||t.error(d.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,f(e));let a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(d.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",f(c)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:f(e)}}l(xc,"parseAbsentReadModel");function ye(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}l(ye,"skipBody");function Lo(t,e,n){let i=oc.exec(e.content);return ye(t,e.indent),i===null||i[1]!==n?(t.error(d.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,f(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:f(e)}}l(Lo,"parseClock");function qo(t,e,n){return Hi(t,e,sc,d.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:f(e)}))}l(qo,"parseCapture");function Hi(t,e,n,i,r,o,s){let a=n.exec(e.content);return a===null?(t.error(i,`Invalid '${r}' declaration '${e.content}' - expected '${o}'`,f(e)),ye(t,e.indent),null):s(a[1],Xt(t,e))}l(Hi,"parseNamedStep");function vc(t,e,n){let i=cc.exec(e.content);if(i===null){t.error(d.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,f(e)),ye(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:Xt(t,e),exactly:i[1]!==void 0,location:f(e)})}l(vc,"parseResult");function Bo(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(d.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,f(e)),ye(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:Xt(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:f(e)}}l(Bo,"parseReadModelStep");function tr(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(d.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,f(e)),ye(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...Ji(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:f(e)}}l(tr,"parseEventStep");var nr=me("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),$c=w("^streamId\\s*=(?!=|>)\\s*(.+)$");function Ji(t,e,n,i,r){let o=[];Ln(t,e,i,o);let s=null,a,c,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&Dn.test(m.content)){let y=Tt(t,m,Mn,d.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let u=Xi.exec(m.content);if(u!==null)en(t,o,Fo(t,m,u));else if(D(m.content)==="stream"||m.content.startsWith("no stream")){if(r===void 0){t.error(d.SpecificationStreamOnCommand,"A command occurrence cannot declare a route; assert it on a then event.",f(m)),t.skipBlock(m.indent);continue}if(p){t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(m)),t.skipBlock(m.indent);continue}let y=nr.exec(m.content);m.content==="no stream"&&(r==="then"||r==="when redelivered")?(c={kind:"SpecificationNoStreamSyntax",location:f(m)},p=!0,jn(t,m)):y!==null?(a=ir(t,m,y),p=!0):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",f(m)),t.skipBlock(m.indent))}else if(D(m.content)==="for"){let y=m.content.substring(3).trim();y.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(m)):s!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(m)):s=ie(y,f(m),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,f(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...c===void 0?{}:{noStream:c}}}l(Ji,"parseValuesWithEventSource");function ir(t,e,n){let i=null,r=[],o=!1,s={};for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),a.content==="streamId"){i!==null||o?(t.error(d.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=f(a),r=Gi(t,a,d.InvalidSpecificationStream));continue}let c=$c.exec(a.content);if(c===null||i!==null||o){t.error(d.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent);continue}let p={...f(a),column:a.indent+1+a.content.indexOf(c[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:ie(c[1],p,t),location:f(a)},jn(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...f(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:f(e)}}l(ir,"parseSpecificationStream");function jn(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(d.InvalidSpecificationStream,"This directive cannot have children.",f(n)),t.skipBlock(e.indent))}l(jn,"rejectSpecificationRouteChildren");function Xt(t,e,n=!1,i){let r=[];Ln(t,e,i,r);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=(n||t.sourceOptions.numericMode==="exact"?Gl:Xi).exec(o.content);if(s===null){t.error(d.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,f(o));continue}en(t,r,Fo(t,o,s,n))}return r}l(Xt,"parseValues");function Fo(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:ie(n[2],f(e),t,i),location:f(e)}}l(Fo,"mappingOf");var kc=Q("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",z)),bc=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",z));function _e(t,e){let n=kc.exec(e.content);if(n===null)return t.error(d.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:f(e)};let i=Ec(t,e,void 0,!0,n[1]);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:f(e)}}l(_e,"parseExample");function Ln(t,e,n,i){if(n?.groups?.property===void 0)return;let r=n.groups.property,o=n.groups.value,s=e.content.length-o.length,a=f(e),c=Nn(t,o,{...a,column:a.column+s},d.InvalidSpecificationValue);c!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:c,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}l(Ln,"addInlineValue");function en(t,e,n,i=[]){if([...e,...i].some(r=>r.property===n.property)){t.error(d.DuplicateSpecificationAssignment,`Property '${n.property}' is assigned more than once in this fixture - assign it only once, inline or indented`,n.location);return}e.push(n)}l(en,"addFixtureValue");function Ec(t,e,n,i=!1,r){let o=[],s=[],a=null,c=null,p,m;Ln(t,e,n,o);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(u.content)==="description"){c=Z(t,u,c,`Example '${r}'`);continue}if(i&&Dn.test(u.content)){let h=Tt(t,u,Mn,d.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):en(t,s,h,o));continue}let y=bc.exec(u.content);if(r!==void 0&&y===null&&(D(u.content)==="stream"||u.content.startsWith("no stream"))){let h=nr.exec(u.content);p!==void 0||m!==void 0?(t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(u)),t.skipOpaqueBlock(u.indent)):u.content==="no stream"?(m={kind:"SpecificationNoStreamSyntax",location:f(u)},jn(t,u)):h!==null?p=ir(t,u,h):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",f(u)),t.skipOpaqueBlock(u.indent));continue}if(y!==null)en(t,o,{kind:"PropertyMappingSyntax",property:y[1],source:ie(y[2],f(u),t),location:f(u)},s);else if(D(u.content)==="for"){let h=u.content.substring(3).trim();h.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(u)):a!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(u)):a=ie(h,f(u),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${u.content}' - expected '<property> = <value>'`,f(u))}return{values:o,for:a,generatedValues:s,description:c,...p===void 0?{}:{stream:p},...m===void 0?{}:{noStream:m}}}l(Ec,"parseFixtureBody");var Yo=["StateChange","StateView","Automation","Translate"];var tn=["tag"];var Cc=w(`^id\\s+"(${H})"$`),Dt=class{static{l(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=f(n);switch(D(n.content)){case"id":{let r=Cc.exec(n.content),o=r===null?"":X(r[1]);return o.trim().length===0||this.value.id!==null?e.error(d.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(d.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=Z(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":return this.value.documentation=ve(e,n,this.value.documentation,`Event '${this.name}'`,d.InvalidEventDocumentation),!0;default:return!1}}};var Pc=w("^type\\s+([A-Za-z_]\\w*)$"),Ac=w("^event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+([0-9]+))?$"),wc=w("^readmodel\\s+([A-Za-z_]\\w*)$"),Uo=4294967295,Oc=w("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Ic=w("^[A-Za-z_]\\w*$"),Wo=l(t=>D(t.content)==="description"&&st(t)===void 0,"isDescription");function rr(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,f(n)),{...e,isIdentifier:!1}):e}l(rr,"withoutIdentifier");function zo(t,e){let n=Pc.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,f(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Wo(o)){r=Z(t,o,r,`Type '${n}'`);continue}if(In(o))continue;let s=Ue(t,o);if(s===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(rr(t,s,o,d.IdentifierOutsideCommand,`Property '${s.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(d.TypeWithoutProperties,`Type '${n}' must declare at least one property`,f(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:f(e)}}l(zo,"parseType");function Vo(t,e){let n=Ac.exec(e.content),i=n?.[1]??"";n===null&&t.error(d.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected 'event <Name> [generation <N>]'`,f(e));let r=n?.[2]!==void 0,o=1;if(r){let p=Number(n[2]);!Number.isSafeInteger(p)||p===0||p>=Uo?t.error(d.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Uo-1}`,f(e)):o=p}let s=[],a=[],c=new Dt(i);for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),In(p))continue;if(tn.includes(D(p.content))){let u=nn(t,p);u!==void 0&&a.push(u);continue}let m=Ue(t,p);if(m===void 0){c.tryParse(t,p)||t.error(d.InvalidPropertyDeclaration,`Invalid property '${p.content}' - expected '<name> <Type>'`,f(p));continue}s.push(rr(t,m,p,d.IdentifierOnEventProperty,`Property '${m.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:s,tags:a,generation:o,hasGenerationMarker:r,...c.value,location:f(e)}}l(Vo,"parseEvent");function nn(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&Oc.test(i)&&t.warning(d.TagPropertyReadAsTag,`'${e.content}' declares a static tag with the value '${i}', not a property named 'tag' - write 'tag "${i}"' for the tag, or '@${e.content}' for the property`,f(e)),i.length===0){t.error(d.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",f(e));return}if(Ic.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:f(e)},location:f(e)};let r=ie(i,f(e),t);if(r.kind==="RawExpressionSyntax"){t.error(d.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,f(e));return}return{kind:"TagSyntax",value:r,location:f(e)}}l(nn,"parseTag");function Qo(t,e){let n=wc.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,f(e));let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Wo(s))r=Z(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&st(s)===void 0)o=ve(t,s,o,`Read model '${n}'`);else{if(In(s))continue;{let a=Ue(t,s);if(a===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,f(s));continue}i.push(rr(t,a,s,d.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,documentation:o,location:f(e)}}l(Qo,"parseReadModel");var Tc=Q("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function he(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(d.UnterminatedTemplateExpression,"Unterminated template expression - expected a closing backtick",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};let s=t.substring(1,t.length-1),a=0;for(let c=0;c<s.length;c++){if(s[c]!=="$"||s[c+1]!=="{")continue;c>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,c),location:e});let p=s.indexOf("}",c);if(p<0)return n.error(d.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:he(s.substring(c+2,p),e,n),location:e}),c=p,a=p+1}return a<s.length&&o.push({kind:"TemplateTextSyntax",text:s.substring(a),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 we(i,e,n);if(t.startsWith("literal ")){let o=Zt(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(d.ExpectedLiteralValue,`Expected a literal value after 'literal', got '${t.substring(8).trim()}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}if(t==="$refusal"||t.startsWith("$refusal."))return{kind:"RefusalExpressionSyntax",member:t==="$refusal"?"":t.substring(9),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=Zt(t,e,n);return r!==void 0?r:Tc.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(d.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}l(he,"parseProjectionExpression");var Bn=l(t=>({legacy:w(t),native:Q(t)}),"grammar"),Rc=Bn("^capture\\s+([A-Za-z_]\\w*)$"),Dc=Bn("^append\\s+([A-Z]\\w*)$"),Mc=Bn("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),Nc=Bn("^nested\\s+([\\w.]+)$"),qn=l((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),jc=Q("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Lc=Q("^([a-z_]\\w*)\\s*=\\s*(.+)$"),qc=Q(`^"(${H})"\\s*=>\\s*(\\w+)$`),Bc=Q(`^split\\s+(\\S+)\\s+by\\s+"(${H})"$`),Fc=new RegExp(Q(`"${H}"|[\\w.]+`).source,"gu"),Yc=Q("^[\\w.]+$");function or(t,e){t=t.valueContext;let n=qn(t,Rc).exec(e.content)?.[1]??"";n===""&&t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,f(e));let i=null,r=null,o=[],s=[],a=[],c=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(p.content)){case"source":i=Uc(t,p);break;case"key":r=p.content.substring(3).trim();break;case"map":o.push(...Zo(t,p));break;case"append":Ko(t,p,s);break;case"children":{let m=qn(t,Mc).exec(p.content);if(m===null){t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${p.content}' - expected 'children <collection> identified by <key>'`,f(p)),t.skipOpaqueBlock(p.indent);break}let u=Go(t,p);m!==null&&a.push({kind:"CaptureChildrenSyntax",property:m[1],identifiedBy:m[2],...u,location:f(p)});break}case"nested":{let m=qn(t,Nc).exec(p.content);if(m===null){t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${p.content}' - expected 'nested <Property>'`,f(p)),t.skipOpaqueBlock(p.indent);break}let u=Go(t,p);m!==null&&c.push({kind:"CaptureNestedSyntax",property:m[1],...u,location:f(p)});break}default:t.error(d.UnknownCaptureDirective,`Unexpected '${p.content}' in capture body`,f(p)),t.skipOpaqueBlock(p.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:n,source:i,key:r,map:o,appends:s,children:a,nested:c,location:f(e)}}l(or,"parseCapture");function Uc(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.content);n.push({kind:"CaptureSourceSettingSyntax",name:r,value:i.content.substring(r.length).trim(),location:f(i)})}return{kind:"CaptureSourceSyntax",syntaxKind:e.content.substring(6).trim(),settings:n,location:f(e)}}l(Uc,"parseSource");function Zo(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=f(i);if(D(i.content)==="split"){let u=Bc.exec(i.content);if(u===null){t.error(d.InvalidSplitDeclaration,`Invalid split operation '${i.content}' - expected 'split <property> by "<separator>"'`,r),t.skipOpaqueBlock(i.indent);continue}let y=[];for(let h=t.peekChild(i.indent);h!==void 0;h=t.peekChild(i.indent))t.reader.takeSignificant(),Yc.test(h.content)?y.push(h.content):t.error(d.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,f(h));u!==null&&n.push({kind:"CaptureSplitSyntax",source:he(u[1],r,t),separator:X(u[2]),targets:y,location:r});continue}let o=Lc.exec(i.content);if(o===null){t.error(d.InvalidMapEntry,`Invalid map entry '${i.content}' - expected '<property> = <source> [translate]'`,r),t.skipOpaqueBlock(i.indent);continue}let s=o[2].trim(),a=s.startsWith("`")?s.indexOf("`",1):-1,c=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),p=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||c||s.substring(a+1).trim()==="")?s.substring(0,a+1):c?s.substring(0,s.length-10).trimEnd():s,m=[];if(c)for(let u=t.peekChild(i.indent);u!==void 0;u=t.peekChild(i.indent)){t.reader.takeSignificant();let y=qc.exec(u.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:X(y[1]),to:y[2],location:f(u)}):t.error(d.InvalidTranslation,`Invalid translation '${u.content}' - expected '"<source>" => <target>'`,f(u))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:he(p,r,t),translations:m,location:r})}return n}l(Zo,"parseMap");function Go(t,e){let n=[],i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="map"?n=Zo(t,r):D(r.content)==="append"?Ko(t,r,i):(t.error(d.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,f(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}l(Go,"mapAndAppends");function Ko(t,e,n){let i=qn(t,Dc).exec(e.content);if(i===null){t.error(d.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,f(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=l((c,p=!1)=>{let m=f(c);if(D(c.content)==="tag"){let y=nn(t.valueContext,c,!1);y!==void 0&&o.push(y);return}let u=jc.exec(c.content);u!==null?r.push({kind:"PropertyMappingSyntax",property:te(u[1]),source:we(u[2],m,t.valueContext),location:m}):t.error(p?d.InvalidPropertyMapping:d.UnknownAppendDirective,`Unexpected '${c.content}' in append body`,m)},"mapping");for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(c.content)==="when"){s=Wc(t,c);for(let p=t.peekChild(c.indent);p!==void 0;p=t.peekChild(c.indent))t.reader.takeSignificant(),a(p,!0)}else a(c);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:f(e)})}l(Ko,"pushAppend");function Wc(t,e){let n=e.content.substring(4).trim(),i=f(e),r=l((c,p=[],m=null,u=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:c,properties:p,fromValue:m,toValue:u,expression:y,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(d.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(d.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${H}"|[^\\s]+`,"gu"):Fc)??[]],s=l(c=>c.startsWith('"')&&c.endsWith('"')?X(c.substring(1,c.length-1)):c,"unquote");if(o.length===0)return t.error(d.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length===1)return r("PropertyChanged",[s(o[0])]);if(o[1]==="from")return o.length===5&&o[3]==="to"?r("ValueTransition",[s(o[0])],s(o[2]),s(o[4])):(t.error(d.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(d.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(d.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let a=[s(o[0])];for(let c=1;c<o.length-1;c+=2){if(o[c]!==o[1])return t.error(d.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;a.push(s(o[c+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}l(Wc,"parseWhen");var ar=w("^returns\\s+(@?[A-Za-z_]\\w*)$"),zc=w("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function sr(t,e){let n=f(e);if(e.content!=="returns"){let r=ar.exec(e.content);if(r===null)return t.error(d.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(d.InvalidCommandResponse,"A scalar response cannot have child directives.",f(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:te(r[1]),location:{...n,column:n.column+s}},location:n}}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=zc.exec(r.content);if(o===null){t.error(d.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",f(r)),t.skipBlock(r.indent);continue}let s=f(r),a=o[2]===void 0?null:Te(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&Le(t,a,r),i.push({kind:"ResponseFieldSyntax",name:te(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:te(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let c=t.peekChild(r.indent);c!==void 0&&(t.error(d.InvalidCommandResponse,"A response field cannot have child directives.",f(c)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}l(sr,"parseCommandResponse");var Fn=new WeakMap;var He=new WeakMap,qe=l(t=>He.get(t)??{},"dependencySourcesOf");function Yn(t){let e=Q(`^reads${z}+([A-Z]\\w*)(?:${z}+as${z}+([a-z_]\\w*))?(?:${z}+by${z}+([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:f(t)}}l(Yn,"captureReads");function _o(t){return new ge(t.reader.fork(),t.path,t.languages)}l(_o,"fork");function Ho(t,e){if(e.content!=="concurrency")return;let n=_o(t),i=!1,r={},o;for(let s=n.peekChild(e.indent);s!==void 0;s=n.peekChild(e.indent))switch(n.reader.takeSignificant(),D(s.content)){case"eventSource":s.content==="eventSource"&&(i=!0);break;case"sourceType":case"streamType":case"streamId":{let a=Q(`^(sourceType|streamType|streamId)${z}+([A-Za-z_]\\w*)$`).exec(s.content);a!==null&&(r[a[1]]??=a[2]);break}case"events":{if(o!==void 0)break;let a=s.content.slice(6).split(",").map(c=>c.replace(new RegExp(`^${z}+|${z}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(c=>Q("^[A-Z]\\w*$").test(c))&&(o=a);break}default:n.skipBlock(s.indent);break}return{kind:"ConcurrencySyntax",eventSource:i,eventSourceType:r.sourceType??null,eventStreamType:r.streamType??null,eventStreamId:r.streamId??null,eventTypes:o??[],location:f(e)}}l(Ho,"captureConcurrency");function Jo(t,e){let n=Q(`^reducer${z}+([A-Za-z_]\\w*)${z}*=>${z}*([A-Za-z_]\\w*)$`).exec(e.content),i=_o(t),r=[];for(let o=i.peekChild(e.indent);o!==void 0;o=i.peekChild(e.indent)){if(i.reader.takeSignificant(),D(o.content)==="description"){Z(i,o,null,"Reducer");continue}let s=Q(`^on${z}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:f(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:f(e)}}l(Jo,"captureReducer");var Vc=w("^produces\\s+operation(?:\\s|$)"),Qc=w("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),Gc=w("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Xo=w("^produces\\s+when\\s+(.+)$"),Zc=w("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Kc=w("^for\\s+(\\S.*)$"),_c=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Hc=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Jc=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function rn(t,e,n=!1){if(Vc.test(e.content)){if(!n){t.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",f(e)),t.skipOpaqueBlock(e.indent);return}let x=Rn(t,e,!0);return{kind:"ProducesSyntax",when:null,event:x.operation.name,targetLocation:{...f(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:x.operation,mappings:x.mappings,for:null,tags:[],location:f(e)}}let i=Qc.exec(e.content),r=e,o=null,s,a;if(i!==null){if(!n){t.error(d.InlineEventOutsideCommand,"Inline events can only be declared inside commands",f(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(d.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",f(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(Xo.test(e.content)){o=je(t,Xo.exec(e.content)[1],f(e));let x=t.peekChild(e.indent);if(x===void 0||!Zc.test(x.content)){t.error(d.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",f(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=x,s=x.content,a=x.indent+1}else{let x=Gc.exec(e.content);if(x===null){t.error(d.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,f(e)),t.skipOpaqueBlock(e.indent);return}s=x[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let c=[],p=new Set,m=[],u=[],y=new Dt(s),h=null;for(let x=t.peekChild(r.indent);x!==void 0;x=t.peekChild(r.indent)){t.reader.takeSignificant();let v=D(x.content),k=f(x);if(Jc.has(v)){t.error(d.ReservedProductionMetadata,`'${v}' is system-assigned production metadata and cannot be supplied here`,k),t.skipOpaqueBlock(x.indent);continue}if(i!==null&&(v==="generation"||v==="origin")){t.error(v==="generation"?d.InlineEventGeneration:d.ReservedProductionMetadata,v==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",k),t.skipOpaqueBlock(x.indent);continue}if(v==="tag"){let A=nn(t,x,!1);A!==void 0&&u.push(A);continue}let C=Kc.exec(x.content);if(C!==null){h!==null?t.error(d.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,k):h=ie(C[1],k,t);continue}let $=(i===null?_c:Hc).exec(x.content),P=$===null||i===null?void 0:Ue(t,{...x,content:$[1].trimEnd()});if($!==null&&(i===null||P!==void 0)){if(P!==void 0){P.isIdentifier&&(t.error(d.IdentifierOnEventProperty,`Property '${P.name}' of event '${s}' cannot be marked identifier - an event never carries its event source id`,k),P={...P,isIdentifier:!1});let A=P.name;p.has(A)&&t.error(d.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,k),p.add(A),c.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??te($[1]),source:ie($[2],{...k,column:x.indent+x.content.length-$[2].length+1},t),location:k})}else(i===null||!y.tryParse(t,x))&&t.error(d.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${x.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,k)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...f(r),column:a},inlineOperation:null,mappings:m,for:h,tags:i===null?u:[],location:f(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:c,tags:u,generation:1,hasGenerationMarker:!1,...y.value,location:f(e)}}}l(rn,"parseProduces");var Xc=w("^command\\s+([A-Za-z_]\\w*)$"),ed=me("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),td=w("\\bseverity\\s+(\\S+)$"),ta=w(`\\bmessage\\s+(?:"(${H})"|(\\$strings\\.\\S*))$`),nd=w("^([\\w.]+)\\s+(.+)$"),id=w("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),rd=me("^[A-Za-z_]\\w*$"),od=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),ad={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},na={information:"Information",warning:"Warning",error:"Error"},sd=new Set(["reads","concurrency"]),ld=new Set(["description","documentation","handler","concurrency"]);function ia(t,e){let n=new Set,i=new ge(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,ea(i,e,void 0,n),ea(t,e,n)}l(ia,"parseCommand");function ea(t,e,n,i){let r=Xc.exec(e.content)?.[1]??"";r===""&&t.error(d.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,f(e));let o=[],s=[],a,c=[],p=[],m=[],u=[],y,h=null,x=null,v=null,k=null,C=null,$=[];for(let b=t.peekChild(e.indent);b!==void 0;b=t.peekChild(e.indent)){t.reader.takeSignificant();let O=D(b.content),T=st(b);if(T!==void 0&&(ld.has(O)||O==="validate"&&b.content!=="validate csharp"))a=Un(t,o,T,r,b,a);else if(O==="returns"){let R=ar.exec(b.content);R!==null&&!R[1].startsWith("@")&&T!==void 0?n===void 0?(o.push(T),s.push({line:b,candidate:T,response:null})):n.has(T.type.name)?s.push({line:b,candidate:null,response:sr(t,b)}):a=Un(t,o,T,r,b,a):T!==void 0?a=Un(t,o,T,r,b,a):On(t,b)?t.skipBlock(b.indent):s.push({line:b,candidate:null,response:sr(t,b)})}else if(O==="stream"&&ed.test(b.content)&&T!==void 0&&t.streamCandidates?.hasSource(T.type.name.split(".")[0])===!0){let[R,N]=T.type.name.split("."),B=t.streamCandidates.hasPropertyType(T.type.name)&&t.streamCandidates.hasUniqueStream(R,N),j=wo(t,b,T,B);(C!==null||$.length>0)&&t.error(d.InvalidCommandStream,"A command declares at most one stream route.",f(b)),B||C!==null?$.push(j):C=j}else if(O==="description")h=Z(t,b,h,`Command '${r}'`);else if(O==="documentation")x=ve(t,b,x,`Command '${r}'`);else if(O==="authorize")v=Ye(v,at(t,b));else if(O==="validate"){let R=lr(t,b,"command");R!==void 0&&c.push(R)}else if(O==="produces"){let R=rn(t,b,!0);R!==void 0&&p.push(R)}else if(O==="handler")k=To(t,b);else if(sd.has(O)){let R=Yn(b);R!==void 0&&u.push(R),O==="concurrency"&&y===void 0&&(y=Ho(t,b));let N=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(b.content);N!==null&&m.push({readModel:N[1],alias:N[2]??null}),od.test(b.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(b)),t.skipOpaqueBlock(b.indent)}else T!==void 0?a=Un(t,o,T,r,b,a):(On(t,b),t.error(d.UnknownCommandDirective,`Unexpected '${b.content}' in command body`,f(b)),t.skipBlock(b.indent))}let P=new Set(s.flatMap(b=>b.candidate===null?[]:[b.candidate])),A=new Set(o.filter(b=>!P.has(b)).map(b=>b.name));s.some(b=>b.candidate!==null&&!A.has(b.candidate.type.name)&&b.candidate.type.name!=="returns")&&A.add("returns");for(let b of A)i?.add(b);let g=null,S=new Set;for(let b of s){let O=b.response;if(b.candidate!==null){if(!A.has(b.candidate.type.name))continue;S.add(b.candidate),O={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:b.candidate.type.name,location:b.candidate.type.location},location:f(b.line)}}O!==null&&(g!==null?t.error(d.InvalidCommandResponse,"A command declares at most one unconditional response.",f(b.line)):g=O)}k!==null&&p.length>0&&t.error(d.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,f(e));let E={kind:"CommandSyntax",name:r,description:h,documentation:x,authorize:v,properties:o.filter(b=>!S.has(b)),validations:c,produces:p,handler:k,response:g,stream:C,streamCandidates:$,location:f(e)};return Fn.set(E,m),He.set(E,{reads:u,concurrency:y}),E}l(ea,"parseCommandBody");function Un(t,e,n,i,r,o){return Le(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(d.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)}l(Un,"addProperty");function lr(t,e,n){if(e.content==="validate"){let i=t.peekChild(e.indent);if(i!==void 0&&i.content.startsWith("```")){t.reader.takeSignificant();let a=Re(t.valueContext,i);return a===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:a,location:f(e)}}let r=[],o=[],s;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&a.content.startsWith("```")){t.skipFencedBody();continue}if(s!==void 0&&a.indent<=s&&(s=void 0),s!==void 0||D(a.content)==="implementation"){t.error(d.InvalidValidationRule,`Invalid validation rule '${a.content}'`,f(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let p=je(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),f(a)),m=null,u="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let x=ta.exec(h.content);x!==null&&x.index===0?m=x[1]!==void 0?X(x[1]):x[2]:D(h.content)==="severity"?(y||(u=na[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:m,severity:u,location:f(a)});continue}let c=cd(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);c!==void 0&&r.push(c)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:f(e)}}if(e.content==="validate csharp"){let i=Re(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:f(e)}}t.error(d.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,f(e)),t.skipBlock(e.indent)}l(lr,"parseValidate");function cd(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=pd(e.content),s=fd(i,e,r);if(s===void 0)return;let a=nd.exec(s.content);if(a===null){i.error(d.InvalidValidationRule,`Invalid validation rule '${e.content}'`,f(e));return}let c=ud(i,a[2],e);if(c===void 0)return;let p=c.kind==="Rule"?dd(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:c.kind,value:c.value,message:o,severity:s.severity,...p,location:f(e)}}l(cd,"parseValidationRule");function dd(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&&D(i.content)==="implementation",o=r?Ht(t,i):{file:It(i)?lt(t,i):null,code:!It(i)&&_t(t,i)?Re(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(d.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,f(i)),t.skipBlock(i.indent));for(let s=t.peekChild(e.indent);s!==void 0&&(r||n&&D(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&D(s.content)==="implementation"?d.InvalidImplementationBlock:d.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",f(s)),_t(t,s)?Re(t,s):t.skipBlock(s.indent);return o}l(dd,"parseRuleImplementation");function pd(t){let e=ta.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?X(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}l(pd,"splitMessage");function fd(t,e,n){let i=td.exec(n);if(i===null)return{content:n,severity:"Error"};let r=na[i[1]];if(r===void 0){t.error(d.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,f(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}l(fd,"splitSeverity");function ud(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=id.exec(e);if(i===null){t.error(d.InvalidValidationRule,`Invalid validation rule '${n.content}'`,f(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!rd.test(r)){t.error(d.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,f(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:f(n)}}}return{kind:ad[i[1]],value:ie(i[2],f(n),t)}}l(ud,"parseRule");var md=w("^constraint\\s+([A-Za-z_]\\w*)$"),yd=w("^unique\\s+event\\s+([A-Z]\\w*)$"),hd=w("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Sd=w("^released\\s+by\\s+([A-Z]\\w*)$"),gd=w(`^message\\s+"(${H})"$`),xd=l(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function ra(t,e){let n=md.exec(e.content);n===null&&t.error(d.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,f(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,c=null,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=Sd.exec(m.content),y=gd.exec(m.content);u!==null?s.has(u[1])?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${u[1]}'`,f(m)):(o.push(u[1]),s.add(u[1])):y!==null?c!==null?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already has a message`,f(m)):c=X(y[1]):m.content==="ignore casing"?(p&&t.error(d.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,f(m)),p=!0):vd(t,i,m,r,a)}for(let m of o.filter(u=>a.has(u)))t.error(d.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${m}'`,f(e));return r.length===0&&(t.error(d.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,f(e)),r.push(Wn(i,f(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||c!==null||p)&&t.error(d.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,f(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:c,ignoreCasing:p}}l(ra,"parseConstraint");function vd(t,e,n,i,r){let o=$d(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(d.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,f(n));return}let s=xd(o);if(s!==void 0&&r.has(s)){t.error(d.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,f(n));return}s!==void 0&&r.add(s),i.push(o)}l(vd,"addRule");function $d(t,e,n){let i=f(n),r=yd.exec(n.content);if(r!==null)return Wn(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=hd.exec(n.content);if(o!==null){let s=o[1].split(",").map(a=>a.trim());if(new Set(s).size!==s.length){t.error(d.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return Wn(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(fe(n)){t.warning(d.FileConstraintOnlySupportsUniqueness,"A file constraint can only declare unique constraints in Chronicle - declare them with 'unique ...' so they are portable; a rule that is not uniqueness belongs in command validation or a 'require' condition",i);let s=n.content.substring(4).trim();return Wn(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(d.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}l($d,"parseRule");function Wn(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}l(Wn,"rule");var kd=w("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),bd=w("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Ed=w("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),Cd=w("^with\\s+(@?[\\w.]+)$"),Pd=w("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),Ad=w("^nested\\s+(@?[\\w.]+)$"),wd=w("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Od=w("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Id=w("^clear\\s+with\\s+(@?[\\w.]+)$"),Td=w("^variant\\s+(@?[\\w.]+)\\s*$"),Rd=w("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Dd=w("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),Md=w("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),Nd=w("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),oa=w("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),jd={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function dr(t,e){let n=kd.exec(e.content);if(n===null)return t.error(d.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:f(e)};let i=n[1],r=null,o="Inherit",s=null,a=[];for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){if(t.reader.takeSignificant(),fe(c))continue;let p=D(c.content);if(p==="sequence")r=c.content.substring(8).trim();else if(p==="automap")o="Enabled";else if(c.content==="no automap")o="Disabled";else if(p==="key")s=sa(t,c);else if(p==="variant")a.push(zd(t,c));else{let m=pr(t,c,!1);m!==void 0&&a.push(m)}}return Ld(t,a,i),a.length===0&&t.error(d.EmptyProjection,`Projection '${i}' must contain at least one directive`,f(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:o,key:s,blocks:a,location:f(e)}}l(dr,"parseProjection");function Ld(t,e,n){let i=e.filter(s=>s.kind==="ProjectionVariantSyntax"),r=new Map;i.forEach(s=>r.set(s.name,[...r.get(s.name)??[],s]));for(let s of[...r.values()].flatMap(a=>a.slice(1)))t.error(d.DuplicateProjectionVariant,`Duplicate variant '${s.name}' - a variant name is declared once`,s.location);let o=new Set;for(let s of e.flatMap(a=>a.kind==="ProjectionVariantSyntax"?a.entersOn:[]))s.event.length>0&&o.has(s.event)&&t.error(d.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${n}'`,s.location),o.add(s.event)}l(Ld,"reportVariantConflicts");function pr(t,e,n){let i=f(e);switch(D(e.content)){case"from":return qd(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=cr(t,e,a=>a.content!=="exclude children"?!1:(r=!1,!0));return{kind:"EverySyntax",includeChildren:r,autoMap:o,mappings:s,location:i}}case"all":{let{autoMap:r,mappings:o}=cr(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return Bd(t,e);case"children":return Fd(t,e);case"nested":return Yd(t,e);case"remove":return Ud(t,e);case"clear":return n||t.error(d.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),Wd(t,e);default:t.error(d.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}l(pr,"parseBlock");function qd(t,e){let n=[];for(let s of co(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(d.FromWithoutEvent,"Expected an event type after 'from'",f(e));continue}let c=bd.exec(a);if(c===null){t.error(d.InvalidEventReference,`Invalid event reference '${a}'`,f(e));continue}n.push({kind:"EventSpecSyntax",event:te(c[1]),key:c[2]===void 0?null:he(c[2],f(e),t),location:f(e)})}let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);a==="key"?r=sa(t,s):a==="parent"?o=he(s.content.substring(6),f(s),t):la(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:f(e)}}l(qd,"parseFrom");function Bd(t,e){let n=Ed.exec(e.content);if(n===null)return t.error(d.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,f(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:f(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Cd.exec(r.content);if(o===null){t.error(d.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=cr(t,r);i.push({kind:"JoinEventSyntax",event:te(o[1]),autoMap:s,mappings:a,location:f(r)})}return{kind:"JoinSyntax",property:te(n[1]),on:te(n[2]),events:i,location:f(e)}}l(Bd,"parseJoin");function Fd(t,e){let n=Pd.exec(e.content);if(n===null)return t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,f(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let{autoMap:i,blocks:r}=aa(t,e);return{kind:"ChildrenSyntax",property:te(n[1]),identifiedBy:he(n[2],f(e),t),autoMap:i,blocks:r,location:f(e)}}l(Fd,"parseChildren");function Yd(t,e){let n=Ad.exec(e.content);if(n===null)return t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,f(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let i=te(n[1]),{autoMap:r,blocks:o}=aa(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(d.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,f(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:f(e)}}l(Yd,"parseNested");function aa(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=pr(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}l(aa,"parseChildBlocks");function Ud(t,e){let n=Od.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:te(n[1]),key:n[2]===void 0?null:he(n[2],f(e),t),location:f(e)};let i=wd.exec(e.content);if(i===null){t.error(d.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,f(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(),D(o.content)==="parent"?r=he(o.content.substring(6),f(o),t):t.error(d.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,f(o));return{kind:"RemoveWithSyntax",event:te(i[1]),key:i[2]===void 0?null:he(i[2],f(e),t),parentKey:r,location:f(e)}}l(Ud,"parseRemove");function Wd(t,e){let n=Id.exec(e.content);return n===null?(t.error(d.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,f(e)),{kind:"ClearWithSyntax",event:"",location:f(e)}):{kind:"ClearWithSyntax",event:te(n[1]),location:f(e)}}l(Wd,"parseClearWith");function zd(t,e){let n=Td.exec(e.content);if(n===null)return t.error(d.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:f(e)};let i=te(n[1]),r=[],o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);if(a==="enters")r.push(Vd(t,s));else if(a==="variant")t.error(d.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",f(s)),t.skipBlock(s.indent);else{let c=pr(t,s,!1);c!==void 0&&o.push(c)}}return r.length===0&&t.error(d.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,f(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:f(e)}}l(zd,"parseVariant");function Vd(t,e){let n=Rd.exec(e.content);return n===null?(t.error(d.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:f(e)}):{kind:"ProjectionEntersOnSyntax",event:te(n[1]),key:n[2]===void 0?null:he(n[2],f(e),t),location:f(e)}}l(Vd,"parseEntersOn");function sa(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:he(n,f(e),t),location:f(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 s=oa.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,f(o));continue}let a=he(s[2],f(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(d.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",f(o)),i.push({kind:"KeyPartSyntax",property:te(s[1]),expression:a,location:f(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(d.EmptyCompositeKey,"Composite keys must contain at least one part",f(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:f(e)}}l(sa,"parseKey");function cr(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)||la(t,o,r);return{autoMap:i,mappings:r}}l(cr,"parseMappingBlock");function la(t,e,n){let i=f(e),r=Dd.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:jd[r[1]],property:te(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(d.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=Md.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:te(o[2]),value:he(o[3],i,t),location:i});return}let s=Nd.exec(e.content)??oa.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:te(s[1]),source:he(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}l(la,"pushMapping");var Qd=w("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Gd=w("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),Zd=w("^scoped\\s+to\\s+([a-z_]\\w*)$"),Kd=new Set(["performer"]);function da(t,e){let n=Qd.exec(e.content);if(n===null)return t.error(d.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,f(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:Te("",f(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:f(e)};let i=n[1],r=Te(n[3],{...f(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||Le(t,r,e);let o=null,s=[],a=null,c=null,p=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=D(m.content);if(u==="description")a=Z(t,m,a,`Query '${i}'`);else if(u==="by"){let y=ca(t,m,"by");y!==void 0&&(o!==null&&t.error(d.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,f(m)),o=y)}else if(u==="filter"){let y=ca(t,m,"filter");y!==void 0&&s.push(y)}else u==="authorize"?p=Ye(p,at(t,m)):u==="scoped"?c=_d(t,m,c,i)??c:Kd.has(u)?t.skipOpaqueBlock(m.indent):(t.error(d.UnknownQueryDirective,`Unexpected '${m.content}' in query body - expected description, by, filter, authorize, scoped or performer`,f(m)),t.skipBlock(m.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:c,authorize:p,location:f(e)}}l(da,"parseQuery");function ca(t,e,n){let i=Gd.exec(e.content.substring(n.length).trim());if(i===null){t.error(d.InvalidQueryParameter,`Invalid '${n}' parameter '${e.content}' - expected '${n} <name> <Type> [from <source>]'`,f(e));return}let r=e.content.indexOf(i[1],n.length),o=Te(i[2],{...f(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return Le(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ie(i[3],f(e),t.valueContext),location:f(e)}}l(ca,"parseParameter");function _d(t,e,n,i){let r=Zd.exec(e.content);if(r===null){t.error(d.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,f(e));return}if(n!==null){t.error(d.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,f(e));return}return r[1]}l(_d,"parseScope");var Hd=w("^@?[a-z_]\\w*\\s+[\\w.]+");function fr(t,e){let n=Ue(t,e);if(n!==void 0){n.isGenerated&&t.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),t.triggerData.push(n);return}Hd.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(d.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,f(e)),t.skipOpaqueBlock(e.indent)}l(fr,"parseTriggerData");function pa(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(),D(i.content)==="description"?Z(t,i,null,`Trigger '${e.content}'`):fe(i)||fr(t,i);return t.triggerData.slice(n)}l(pa,"parseTriggerDeclaration");var Jd=w("^reaction\\s+([A-Za-z_]\\w*)$"),Xd=w("^when\\s+([A-Za-z_]\\w*)$"),ep=w("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),tp=w("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),np=new Set(["when","every","at"]),ip=w("^invokes\\s+([A-Z]\\w*)$"),rp=Q("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),ur=Q("^on\\s+refused\\b(?=$|\\s+by\\b)"),op=Q("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),ap=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function fa(t,e){let n=Jd.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,f(e));let i=null,r=null,o=null,s=[],a=new Set,c=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let m=D(p.content);if(m==="description"){i=Z(t,p,i,`Reaction '${n}'`);continue}if(m==="documentation"){r=ve(t,p,r,`Reaction '${n}'`);continue}if(m==="where"){o=je(t,p.content.substring(5).trim(),f(p));continue}if(ur.test(p.content)){t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent),c=!0;continue}if(!np.has(m)){t.error(d.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>'`,f(p)),t.skipBlock(p.indent),c=!0;continue}let u=dp(t,p);if(u===void 0){c=!0;continue}let y=cp(u);if(a.has(y)){t.error(d.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,f(p)),t.skipBlock(p.indent);continue}a.add(y),s.push(sp(t,p,u))}return s.length===0&&!c&&t.error(d.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,f(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,where:o,triggers:s,location:f(e)}}l(fa,"parseReaction");function sp(t,e,n){let i=null,r=[],o=[],s=[],a=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let m=D(p.content);if(m==="description")i=Z(t,p,i,`Trigger '${p.content}'`);else if(m==="produces"){let u=rn(t,p);u!==void 0&&r.push(u)}else if(m==="invokes"){let u=ip.exec(p.content);if(u===null)t.error(d.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,f(p)),t.skipBlock(p.indent);else{let y=new ge(t.reader.fork(),t.path,t.languages);y.scope=t.scope,y.sourceOptions=t.sourceOptions,Ie(y,p),t.inputUses.push(...y.inputUses);let h=[],x=[];for(let v=t.peekChild(p.indent);v!==void 0;v=t.peekChild(p.indent)){if(t.reader.takeSignificant(),ur.test(v.content)){let C=lp(t,v);C!==void 0&&x.push(C);continue}let k=rp.exec(v.content);k!==null?h.push({kind:"PropertyMappingSyntax",property:k[1].replaceAll("@",""),source:we(k[2],f(v),t.valueContext),location:f(v)}):t.error(d.InvalidPropertyMapping,`Invalid property mapping '${v.content}' - expected '<property> = <source>'`,f(v))}o.push({kind:"InvokesSyntax",command:u[1],mappings:h,onRefused:x,location:f(p)})}}else if(ur.test(p.content))t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent);else if(m==="reads"||m==="file"||p.content==="csharp"||p.content.startsWith("```")){let u=Yn(p);u!==void 0&&s.push(u),ap.test(p.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let u=t.triggerData.length;fr(t,p);for(let y of t.triggerData.slice(u))a.push({kind:"TriggerDataSyntax",name:y.name,type:y.type,location:y.location})}}let c={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:f(e)};return He.set(c,{reads:s,data:a}),c}l(sp,"parseTrigger");function lp(t,e){let n=op.exec(e.content);if(n===null||n[2]!==void 0&&n[1]!=="constraint"){t.error(d.InvalidRefusalBranch,"Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.",f(e)),t.skipBlock(e.indent);return}let i=[],r=!1,o=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),s.content==="acknowledge")(r||i.length>0||t.peekChild(s.indent)!==void 0)&&(t.error(d.InvalidRefusalBranchBody,"A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.",f(s)),o=!0),r=!0,t.skipBlock(s.indent);else if(D(s.content)==="produces"){r&&(t.error(d.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",f(s)),o=!0);let a=rn(t,s);a!==void 0?i.push(a):o=!0}else t.error(d.InvalidRefusalBranchBody,"Expected 'acknowledge' or 'produces <Event>' in a refusal branch.",f(s)),t.skipBlock(s.indent),o=!0;return!r&&i.length===0&&!o&&t.error(d.InvalidRefusalBranchBody,"A refusal branch must acknowledge or produce an event.",f(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:f(e)}}l(lp,"parseRefusal");function cp(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])}}l(cp,"sourceKey");function dp(t,e){let n=f(e);switch(D(e.content)){case"when":{let i=Xd.exec(e.content);if(i===null){t.error(d.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=ep.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(d.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:up(i[2]),location:n}}default:return pp(t,e)}}l(dp,"parseTriggerSource");function pp(t,e){let n=f(e),i=tp.exec(e.content),r=i===null?void 0:fp(i[1]);if(i===null||r===void 0){t.error(d.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(d.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}}l(pp,"parseSchedule");function fp(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}l(fp,"timeOf");function up(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}l(up,"unitOf");var mp=w("^(data|query|component)\\s+(\\S+)(.*)$"),yp=w("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),hp=w("^([A-Za-z_]\\w*)\\.(.+)$"),Sp=w("^mode\\s+(oneWay|twoWay)\\b(.*)$"),gp=w("^null\\s+(propagate|clear|preserve)\\b(.*)$"),xp=w("^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$");function Mt(t,e,n){let i=e.trim(),r=i.split(/\s+/,1)[0];return r==="data"||r==="query"||r==="component"?ua(t,`from ${i}`,n):ua(t,i,n)}l(Mt,"parseFromClause");function ua(t,e,n){let i=e.trim();if(!i.startsWith("from "))return ma(t,vt("DataContext",i,n),"",n);let r=i.substring(5).trim(),o=mp.exec(r);if(o===null)return t.error(d.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from data <path>', 'from query <Query>[.<path>]' or 'from component <id>.<path>'`,n),{...vt("Invalid",r,n),rawText:i};let s=vp(t,o[1],o[2],i,n);return ma(t,s,o[3],n)}l(ua,"parseUiBinding");function vp(t,e,n,i,r){return e==="data"?vt("DataContext",n,r):e==="query"?$p(t,n,i,r):kp(t,n,i,r)}l(vp,"parseBindingSource");function $p(t,e,n,i){let r=yp.exec(e);return r===null?(t.error(d.UnknownScreenDirective,`Invalid query binding '${n}' - expected 'from query <Query>[.<path>]'.`,i),{...vt("Invalid",e,i),rawText:n}):{...vt("QueryResult",r[2]??"",i),query:r[1]}}l($p,"queryBinding");function kp(t,e,n,i){let r=hp.exec(e);return r===null?(t.error(d.UnknownScreenDirective,`Invalid component binding '${n}' - expected 'from component <stableInstanceId>.<outputPath>'.`,i),{...vt("Invalid",e,i),rawText:n}):{...vt("ComponentProperty",r[2],i),componentId:r[1],componentPropertyPath:r[2]}}l(kp,"componentBinding");function ma(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=Sp.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=gp.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let c=xp.exec(o);if(c!==null){r={...r,expectedValueType:c[1]},o=c[2].trim();continue}return t.error(d.UnknownScreenDirective,`Unsupported UI binding modifier '${o}' - supported modifiers are 'mode oneWay|twoWay', 'null propagate|clear|preserve' and 'expected <Type>'.`,i),{...r,rawText:r.rawText??o}}return r}l(ma,"withModifiers");function vt(t,e,n){return{kind:"UiBindingSyntax",bindingKind:t,path:e,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,rawText:null,location:n}}l(vt,"create");var ct=`(?:"(${H})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,bp=w("^screen\\s+([A-Za-z_]\\w*)$"),Ep=w("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Cp=w("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),ya=w(`^label\\s+${ct}$`),Pp=w(`^action\\s+${ct}$`),Ap=w("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),wp=w(`^route\\s+${ct}$`),ha=w("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),Op=w("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),Ip=w("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),Tp=w(`^property\\s+([\\w.]+)\\s*=\\s+${ct}$`),Rp=w("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),Dp=w(`^presentation\\s+([A-Za-z_]\\w*)\\s+${ct}$`),Mp=w("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Np=w("^[a-z_]\\w*$"),jp=w(`^title\\s+${ct}$`),Lp=w(`^column\\s+([\\w.]+)(?:\\s+label\\s+${ct})?$`),qp=w("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),Bp=w(`^field\\s+([\\w.]+)\\s+label\\s+${ct}$`),Je=l((t,e)=>t[e]!==void 0?X(t[e]):t[e+1],"operandText"),Fp=l(t=>["on","uses"].includes(D(t.content)),"isInteraction"),Yp=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function Sa(t,e){let n=bp.exec(e.content);n===null&&t.error(d.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),fe(r)||ga(t,r,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,location:f(e)}}l(Sa,"parseScreen");function ga(t,e,n){let i=Up(t,e);i!==void 0&&n.push(i)}l(ga,"pushDirective");function mr(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),ga(t,i,n);return n}l(mr,"parseDirectives");function Up(t,e){switch(D(e.content)){case"data":return Wp(t,e);case"action":return zp(t,e);case"template":return Vp(t,e);case"section":return Qp(t,e);case"title":return Gp(t,e);case"table":return Zp(t,e);case"summary":return Kp(t,e);case"component":return _p(t,e);case"toolbar":return ef(t,e);case"navigate":return zn(t,e.content,e);case"on":return Ie(t,e),{kind:"ScreenBehaviorSyntax",location:f(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:f(e)};default:if(Yp(t,e))return rf(t,e);t.error(d.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,f(e)),t.skipBlock(e.indent);return}}l(Up,"parseDirective");function Wp(t,e){let n=Ep.exec(e.content);if(n===null){t.error(d.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,f(e));return}return{kind:"ScreenDataSyntax",type:Te(n[1],f(e)),query:n[2],by:n[3]??null,location:f(e)}}l(Wp,"parseData");function zp(t,e){let n=Pp.exec(e.content);if(n!==null)return So(t,e,Je(n,1),zn);let i=Cp.exec(e.content);if(i===null){t.error(d.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,f(e)),t.skipBlock(e.indent);return}let r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=ya.exec(s.content);a!==null?r=Je(a,1):D(s.content)==="navigate"?o=zn(t,s.content,s)??null:t.error(d.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,f(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:f(e)}}l(zp,"parseAction");function zn(t,e,n){let i=Ap.exec(e);if(i===null){t.error(d.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,f(n));return}let r=[],o=null;for(let s=t.peekChild(n.indent);s!==void 0;s=t.peekChild(n.indent)){t.reader.takeSignificant();let a=ha.exec(s.content);if(a!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:a[1],binding:Mt(t,a[2],f(s)),location:f(s)});continue}let c=wp.exec(s.content);if(c!==null){o=Je(c,1);continue}t.error(d.InvalidNavigation,`Unexpected '${s.content}' in navigation - expected 'route "..."' or 'parameter <name> from <binding>'`,f(s))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,parameters:r,location:f(n)}}l(zn,"parseNavigate");function Vp(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(),!Np.test(r.content)){t.error(d.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:mr(t,r),location:f(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:f(e)}}l(Vp,"parseTemplateReference");function Qp(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:mr(t,e),location:f(e)}}l(Qp,"parseSection");function Gp(t,e){let n=jp.exec(e.content);return n===null?(t.error(d.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,f(e)),{kind:"ScreenTitleSyntax",text:"",location:f(e)}):{kind:"ScreenTitleSyntax",text:Je(n,1),location:f(e)}}l(Gp,"parseTitle");function Zp(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 s=Lp.exec(o.content),a=qp.exec(o.content);if(s!==null){let c=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:c?Je(s,2):null,location:f(o)})}else a!==null?r=zn(t,a[1],o)??null:D(o.content)==="on"?Ie(t,o):Fp(o)?t.skipOpaqueBlock(o.indent):t.error(d.UnknownTableDirective,`Unexpected '${o.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,f(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:f(e)}}l(Zp,"parseTable");function Kp(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=Bp.exec(r.content);if(o===null){t.error(d.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,f(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:Je(o,2),location:f(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:f(e)}}l(Kp,"parseSummary");function _p(t,e){let n=Op.exec(e.content);if(n===null){t.error(d.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[],a=[],c=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(p.content)){case"context":i=Hp(t,p);break;case"property":Jp(t,p,o);break;case"icon":r=p.content.substring(4).trim();break;case"presentation":xa(t,p,a);break;case"exposes":Xp(t,p,s);break;case"outlet":c.push({kind:"ComponentOutletSyntax",name:p.content.substring(6).trim(),directives:mr(t,p),location:f(p)});break;case"on":Ie(t,p);break;case"uses":t.skipOpaqueBlock(p.indent);break;default:t.error(d.UnknownScreenDirective,`Unexpected '${p.content}' in component - expected context, property, icon, presentation, exposes, outlet, on or uses`,f(p)),t.skipBlock(p.indent);break}return{kind:"ScreenComponentSyntax",component:n[1],name:n[2],context:i,properties:o,exposes:s,presentation:a,icon:r,outlets:c,location:f(e)}}l(_p,"parseComponent");function Hp(t,e){return nf(t,e.content.substring(7).trim(),e)}l(Hp,"parseUiContext");function Jp(t,e,n){let i=Ip.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:Mt(t,i[2],f(e)),value:null,location:f(e)});return}let r=Tp.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:Je(r,2),location:f(e)});return}t.error(d.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = "value"'`,f(e))}l(Jp,"parseComponentProperty");function Xp(t,e,n){let i=Rp.exec(e.content);if(i===null){t.error(d.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,f(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:Mt(t,i[2],f(e)),location:f(e)})}l(Xp,"parseExposedValue");function xa(t,e,n){let i=Dp.exec(e.content);if(i===null){t.error(d.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,f(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:Je(i,2),location:f(e)})}l(xa,"parsePresentationValue");function ef(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=tf(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:f(e)}}l(ef,"parseToolbar");function tf(t,e){let n=Mp.exec(e.content);if(n===null){t.error(d.UnknownScreenDirective,`Invalid toolbar item '${e.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[];for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent)){t.reader.takeSignificant();let p=ya.exec(c.content);if(p!==null){i=Je(p,1);continue}let m=ha.exec(c.content);if(m!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:m[1],binding:Mt(t,m[2],f(c)),location:f(c)});continue}if(D(c.content)==="icon"){r=c.content.substring(4).trim();continue}xa(t,c,s)}let a=n[2]==="navigate"?"Navigate":n[2]==="dialog"?"Dialog":"Action";return{kind:"ToolbarItemSyntax",name:n[1],syntaxKind:a,target:n[3],label:i,icon:r,parameters:o,presentation:s,location:f(e)}}l(tf,"parseToolbarItem");function nf(t,e,n){return Mt(t,e,f(n))}l(nf,"parseUiBindingValue");function rf(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(d.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e));return}e.content.startsWith("```")||t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let i=Pt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:f(e)},location:f(e)}}l(rf,"parseCode");var of=w("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),af=new Set(["reducer"]);function va(t,e){let n=of.exec(e.content),i="StateChange",r="";n===null?t.error(d.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,f(e)):(r=n[2],Yo.includes(n[1])?i=n[1]:t.error(d.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,f(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=null,c=[],p=[],m=[],u=[],y=[],h=[],x=[],v=[],k=[],C=[],$=[],P=[],A=[];for(let S=t.peekChild(e.indent);S!==void 0;S=t.peekChild(e.indent)){if(t.reader.takeSignificant(),fe(S))continue;let E=D(S.content);E==="description"?s=Z(t,S,s,`Slice '${r}'`):E==="documentation"?a=ve(t,S,a,`Slice '${r}'`):E==="operation"?p.push(Rn(t,S).operation):E==="event"?c.push(Vo(t,S)):E==="command"?m.push(ia(t,S)):E==="query"?u.push(da(t,S)):E==="projection"?y.push(dr(t,S)):E==="capture"?x.push(or(t,S)):E==="reaction"?h.push(fa(t,S)):E==="constraint"?v.push(ra(t,S)):E==="example"?C.push(_e(t,S)):E==="specification"?k.push(er(t,S)):E==="readmodel"?$.push(Qo(t,S)):E==="screen"?P.push(Sa(t,S)):af.has(E)?(A.push(Jo(t,S)),t.skipOpaqueBlock(S.indent)):(t.warning(d.UnknownSliceDirective,`Unknown construct '${E}' in slice '${r}'`,f(S)),t.skipBlock(S.indent))}t.scope=o;let g={kind:"SliceSyntax",type:i,name:r,description:s,documentation:a,examples:C,events:c,operations:p,commands:m,queries:u,projections:y,captures:x,reactions:h,constraints:v,specifications:k,readModels:$,screens:P,location:f(e)};return He.set(g,{reducers:A}),g}l(va,"parseSlice");var sf=w("^feature\\s+([A-Za-z_]\\w*)$"),lf=new Set(["on","uses","contribute"]),yr="description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",on=class{static{l(this,"FeatureBody")}name;#e=[];#t=[];#o=[];#r=[];#n=[];#i=null;#a=null;#l=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#i=Z(e,n,this.#i,`Feature '${this.name}'`),!0;case"documentation":return this.#a=ve(e,n,this.#a,`Feature '${this.name}'`),!0;case"depends":return Cn(e,n,this.#n,d.UnknownFeatureDirective),!0;case"authorize":return this.#l=Ye(this.#l,at(e,n)),!0;case"import":return At(e,n,this.#r),!0;case"feature":return this.#e.push(Vn(e,n)),!0;case"example":return this.#o.push(_e(e,n)),!0;case"slice":return this.#t.push(va(e,n)),!0;default:return lf.has(i)?(Ie(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#i,documentation:this.#a,authorize:this.#l,dependsOn:this.#n,features:this.#e,slices:this.#t,examples:this.#o,fileImports:this.#r,isPlacement:n,location:e}}};function Vn(t,e){let n=sf.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,f(e));let i=new on(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(d.UnknownFeatureDirective,`Unexpected '${D(o.content)}' in feature body - expected ${yr}`,f(o)),t.skipBlock(o.indent));return t.scope=r,i.build(f(e))}l(Vn,"parseFeature");var hr=w("^module\\s+([A-Za-z_]\\w*)$"),cf=new Set(["on","uses","screen","dialog","form","contribute"]),Sr="description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",an=class{static{l(this,"ModuleBody")}name;#e=[];#t=[];#o=[];#r=[];#n=null;#i=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#n=Z(e,n,this.#n,`Module '${this.name}'`),!0;case"documentation":return this.#i=ve(e,n,this.#i,`Module '${this.name}'`),!0;case"depends":return Cn(e,n,this.#r,d.UnknownModuleDirective),!0;case"authorize":return this.#a=Ye(this.#a,at(e,n)),!0;case"import":return At(e,n,this.#o),!0;case"example":return this.#t.push(_e(e,n)),!0;case"feature":return this.#e.push(Vn(e,n)),!0;default:return cf.has(i)?(Ie(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(d.UnknownModuleDirective,`Unexpected '${D(i.content)}' in module body - expected ${Sr}`,f(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#n,documentation:this.#i,authorize:this.#a,dependsOn:this.#r,features:this.#e,examples:this.#t,fileImports:this.#o,isPlacement:n,location:e}}};function gr(t,e){let n=hr.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,f(e));let i=new an(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(f(e))}l(gr,"parseModule");var ff=new WeakMap,Be=l(t=>JSON.stringify(t),"authoredOrderKey");function sn(t){return ff.get(t)??new Map}l(sn,"authoredOrderOf");function Qn(t){let e=[],n=l((a,c)=>{for(let p of a??[])e.push({name:p.name,scope:c,example:p})},"examples"),i=l((a,c)=>{for(let p of a){let m=[...c,p.name];n(p.examples,m);for(let u of p.slices){let y=[...c,p.name,u.name];n(u.examples,y);for(let h of new Set(le(u).map(x=>x.name)))e.push({name:h,scope:y,kind:"event"});for(let h of u.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of u.readModels)e.push({name:h.name,scope:y,kind:"readmodel"})}i(p.features,m)}},"features");n(t.examples,[]);for(let a of[...t.concepts,...t.types])e.push({name:a.name,scope:[],kind:"type"});for(let a of t.modules)n(a.examples,[a.name]),i(a.features,[a.name]);let r=l((a,c)=>{let p=l(y=>{let h=y.split("."),x=e.filter(k=>k.name===h.at(-1)),v=h.slice(0,-1);if(v.length)return x.filter(k=>v.length<=k.scope.length&&v.every((C,$)=>k.scope[k.scope.length-v.length+$]===C));for(let k=c.length;k>=0;k--){let C=x.filter($=>k<=$.scope.length&&c.slice(0,k).every((P,A)=>$.scope[A]===P));if(C.length)return C}return[]},"candidates"),m=p(a),u=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&u.length===1&&(m=p(u[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=l((a,c,p)=>{let m=r(a,p),u=m?.example;if(!u)return null;let y=r(u.type,m.scope);return y?.kind===c?{example:u,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=l((a,c)=>[...a.filter(p=>!c.some(m=>m.property===p.property)),...c],"merge");return{resolvedExamples:e.filter(a=>a.example!==void 0).flatMap(a=>{let c=r(a.example.type,a.scope);return c?.kind===void 0?[]:[{example:a.example,kind:c.kind,name:[...c.scope,c.name].join("."),scope:c.scope}]}),eventStep:l((a,c,p)=>{let m=o(a.eventType,"event",p),u=m?.example??null,y=u?.stream??u?.noStream??null,h=a.stream??a.noStream??null,x=h??y,v=m===null?a:{...a,eventType:m.name,values:s(u.values,a.values),for:a.for??u.for,stream:x?.kind==="SpecificationStreamSyntax"?x:null,noStream:x?.kind==="SpecificationNoStreamSyntax"?x:null},k=v.values.map(C=>{let $=u?.values.find(A=>A.property===C.property),P=a.values.includes(C);return{property:C.property,value:C.source,origin:P?$===void 0?"authored":"override":"example",overriddenValue:P?$?.source??null:null}});return v.for!==null&&k.push({property:"for",value:v.for,origin:a.for===null?"example":u?.for==null?"authored":"override",overriddenValue:a.for===null?null:u?.for??null}),{role:c,authored:a,effective:v,example:u,values:k,route:x===null?null:{value:x,origin:h===null?"example":y===null?"authored":"override",overriddenValue:h===null?null:y}}},"eventStep"),command:l((a,c)=>{if(!a)return a;let p=o(a.commandType,"command",c);if(!p)return a;let{example:m,name:u}=p;return{...a,commandType:u,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),readModel:l((a,c)=>{let p=o(a.name,"readmodel",c);return p?{...a,name:p.name,properties:s(p.example.values,a.properties)}:a},"readModel")}}l(Qn,"specificationExamples");function Gn(t){return Qn(t).command}l(Gn,"specificationCommandExamples");function $t(t){return Zn(t).application}l($t,"expandSpecificationExamples");function Zn(t){let e=Qn(t),n=[],i=l((r,o)=>r.map(s=>{let a=[...o,s.name];return{...s,features:i(s.features,a),slices:s.slices.map(c=>{let p=[...o,s.name,c.name],m={...c,specifications:c.specifications.map(u=>{let y=[],h=l((v,k)=>{let C=e.eventStep(v,k,p);return y.push(C),C.effective},"event"),x={...u,given:u.given.map(v=>h(v,"given")),givenReadModels:u.givenReadModels.map(v=>e.readModel(v,p)),when:e.command(u.when,p),whenAppended:u.whenAppended===null?null:h(u.whenAppended,"when append"),thenEvents:u.thenEvents.map(v=>h(v,"then")),thenReadModels:u.thenReadModels.map(v=>e.readModel(v,p))};return n.push({authored:u,effective:x,steps:y}),x})};return He.set(m,qe(c)),m})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}l(Zn,"expandEffectiveSpecificationExamples");var dt=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var et=class extends Error{static{l(this,"InvalidDependencyQuery")}};var pt=class{static{l(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)),e.examples?.forEach(n=>this.visitSpecificationExample(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==="NotPolicyConditionSyntax"&&this.visitPolicyCondition(e.operand),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.examples?.forEach(n=>this.visitSpecificationExample(n)),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.examples?.forEach(n=>this.visitSpecificationExample(n)),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.examples?.forEach(n=>this.visitSpecificationExample(n)),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),e.streamIdParts.forEach(n=>this.visitEventStreamIdPart(n))}visitEventStreamIdPart(e){this.visitNode(e),this.visitTypeRef(e.type)}visitCommandStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n)),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)),e.onRefused?.forEach(n=>this.visitInvocationRefusal(n))}visitInvocationRefusal(e){this.visitNode(e),e.produces.forEach(n=>this.visitProduces(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){if(e.kind==="ScreenGuardedActionSyntax"){this.visitScreenGuardedAction(e);return}switch(this.visitNode(e),e.kind){case"ScreenDataSyntax":this.visitTypeRef(e.type);break;case"ScreenActionSyntax":e.navigate!==null&&this.visitScreenDirective(e.navigate);break;case"ScreenNavigateSyntax":e.parameters.forEach(n=>{this.visitNode(n),this.visitNode(n.binding)});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"ScreenComponentSyntax":e.context!==null&&this.visitNode(e.context),e.properties.forEach(n=>{this.visitNode(n),n.binding!==null&&this.visitNode(n.binding)}),e.exposes.forEach(n=>{this.visitNode(n),this.visitNode(n.binding)}),e.presentation.forEach(n=>this.visitNode(n)),e.outlets.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))});break;case"ScreenToolbarSyntax":e.items.forEach(n=>{this.visitNode(n),n.parameters.forEach(i=>{this.visitNode(i),this.visitNode(i.binding)}),n.presentation.forEach(i=>this.visitNode(i))});break;case"ScreenCodeSyntax":this.visitNode(e.code);break}}visitScreenGuardedAction(e){this.visitNode(e),e.alternatives.forEach(n=>this.visitScreenActionAlternative(n)),e.otherwise!==null&&this.visitScreenActionOtherwise(e.otherwise),e.navigate!==null&&this.visitScreenDirective(e.navigate)}visitScreenActionAlternative(e){this.visitNode(e),this.visitCondition(e.condition),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitScreenActionOtherwise(e){this.visitNode(e),e.arguments.forEach(n=>this.visitInteractionArgument(n))}visitInteractionArgument(e){this.visitNode(e)}visitSpecification(e){this.visitNode(e),e.examples?.forEach(n=>this.visitSpecificationExample(n)),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.whenRedelivered!=null&&this.visitSpecificationRedelivery(e.whenRedelivered),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))}visitSpecificationRedelivery(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(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))}visitSpecificationExample(e){this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.generatedValues.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationEvent(e){this.visitNode(e),e.stream!=null&&this.visitSpecificationStream(e.stream),e.noStream!=null&&this.visitSpecificationNoStream(e.noStream),e.values.forEach(n=>this.visitPropertyMapping(n)),e.for!==null&&this.visitExpression(e.for)}visitSpecificationStream(e){this.visitNode(e),e.streamId!==null&&this.visitPropertyMapping(e.streamId),e.streamIdParts.forEach(n=>this.visitPropertyMapping(n))}visitSpecificationNoStream(e){this.visitNode(e)}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 uf={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",actionAlternative:"asks",actionOtherwise:"asks",formCommand:"asks",dataQuery:"shows",populate:"shows",navigate:"shows",whenRedeliveredEvent:"verifiedWith",redeliveryReaction:"verifiedWith",refusalConstraint:null,refusalProduces:null,specificationEvent:"verifiedWith",givenEvent:"verifiedWith",whenAppendedEvent:"verifiedWith",thenEvent:"verifiedWith",whenCommand:"verifiedWith",declares:null,uses:null,commandEventSource:null,commandStream:null,specificationEventSource:null,specificationStream:null,thenOperation:null,givenOperationFailure:null,thenCompensated:null,produces:null,authorizes:null,queryResult:null,dataReadModel:null,type:null,exampleType: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 _n(t){let e=new Kn;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}}l(_n,"sliceReferences");function ba(t,e){let n=new Kn(e);return t.projections.forEach(i=>n.visitProjection(i)),qe(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}l(ba,"buildingReadModelReferences");function $r(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...$r(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?$r(e.blocks):[])}l($r,"variants");var Kn=class extends pt{static{l(this,"SliceReferenceCollector")}readModel;references=[];shared=[];specification;projection=!1;constructor(e){super(),this.readModel=e}matches(e){return e.toLowerCase()===this.readModel?.toLowerCase()}visitSlice(e){super.visitSlice(e),qe(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=qe(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=qe(e);n.data?.forEach(i=>this.visitTriggerData(i)),n.reads?.forEach(i=>this.visitReads(i)),super.visitReactionTrigger(e)}visitProjection(e){if(this.readModel!==void 0){let n=$r(e.blocks);if(n.length===0?!this.matches(e.readModel??e.name):!n.some(i=>this.matches(i.name)))return}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=l((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:uf[o],location:e.location,timeline:this.projection||["trigger","reads","reduces"].includes(o)})},"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"ScreenActionAlternativeSyntax":n(e.command,"Command","actionAlternative");break;case"ScreenActionOtherwiseSyntax":{let i=e.command;i!==null&&n(i,"Command","actionOtherwise");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"SpecificationRedeliverySyntax":{let i=e;n(i.eventType,"Event","whenRedeliveredEvent"),n(i.reaction,"Reaction","redeliveryReaction");break}case"ConcurrencySyntax":e.eventTypes.forEach(i=>n(i,"Event","concurrency"));break}}};function ln(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=l(a=>{e.set(a,e.size),n.set(a,e.get(a)),i.push(a),r.add(a);for(let m of[...t.get(a)].sort())e.has(m)?r.has(m)&&n.set(a,Math.min(n.get(a),e.get(m))):(s(m),n.set(a,Math.min(n.get(a),n.get(m))));if(n.get(a)!==e.get(a))return;let c=[],p;do p=i.pop(),r.delete(p),c.push(p);while(p!==a);o.push(c.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}l(ln,"stronglyConnectedGroups");var Ea=["usesFactsFrom","reactsTo","decidesFrom"],We=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),kr=l((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),br=l((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),Cr=l((t,e)=>t.rank-e.rank||We(t.key,e.key),"compareNodes"),cn=l(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(Cr),"distinctNodes"),Ca=l((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||dt.indexOf(t.kind)-dt.indexOf(e.kind)||t.producer.rank-e.producer.rank||We(t.location.path??"",e.location.path??"")||We(t.role,e.role)||We(t.name,e.name),"compareEvidence");function Pr(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...Pr(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?Pr(e.blocks):[])}l(Pr,"variants");var Nt=class t{static{l(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=br("application","",[],-1);static for(e,n=sn(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=$t(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=l(($,P)=>$.map((A,g)=>({syntax:A,index:g,rank:n.get(Be([...P.scope,A.name]))??Number.MAX_SAFE_INTEGER})).sort((A,g)=>A.rank-g.rank||A.index-g.index).map(A=>A.syntax),"ordered"),r=l(($,P)=>{let A=this.add("feature",$.name,P);for(let g of i($.slices,A))this.slices.push({node:this.add("slice",g.name,A),syntax:g});for(let g of i($.features,A))r(g,A)},"feature");for(let $ of i(e.modules,this.root)){let P=this.add("module",$.name,this.root);for(let A of i($.features,P))r(A,P)}let o=new Map,s=new Map,a=l(($,P,A,g)=>{let S=kr(P,A);$.has(S)||$.set(S,[]);let E=$.get(S);E.includes(g)||E.push(g);let b=kr(P,[...g.scope,A].join("."));$.has(b)||$.set(b,[]);let O=$.get(b);O.includes(g)||O.push(g)},"declare");for(let{node:$,syntax:P}of this.slices){for(let A of le(P))a(o,"Event",A.name,$);for(let A of P.commands)a(o,"Command",A.name,$);for(let A of P.reactions)a(o,"Reaction",A.name,$);for(let A of P.queries)a(o,"Query",A.name,$);for(let A of P.screens)a(o,"Screen",A.name,$);for(let A of P.readModels)a(o,"ReadModel",A.name,$);for(let A of P.projections){let g=Pr(A.blocks);g.length===0&&a(s,"ReadModel",A.readModel??A.name,$);for(let S of g)a(s,"ReadModel",S.name,$)}for(let A of qe(P).reducers??[])a(s,"ReadModel",A.readModel,$)}let c=new Set((e.declaredTriggers??[]).map($=>$.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map($=>$.name.toLowerCase())),m=new Set((e.policies??[]).map($=>$.name.toLowerCase())),u=e.imports.filter($=>$.qualifiedName.includes(".")).slice().sort(($,P)=>We($.location.path??"",P.location.path??"")||$.location.line-P.location.line||$.location.column-P.location.column||We($.qualifiedName,P.qualifiedName)),y=new Map,h=[],x=[],v=new Set,k=0;for(let{node:$,syntax:P}of this.slices){let A=_n(P);k+=A.shared.filter(g=>(g.kind==="type"?p:m).has(g.name.toLowerCase())).length;for(let g of A.references){let S=kr(g.targetKind,g.name),b=(g.targetKind==="ReadModel"&&s.has(S)?s:o).get(S);if(b!==void 0&&b.length>0){let T=b[0];T!==$&&h.push({consumer:$,producer:T,kind:g.kind,role:g.role,name:g.name,ambiguous:b.length>1,alternatives:b.slice(1),location:g.location,testOnly:g.kind==="verifiedWith"});continue}let O=g.targetKind==="Event"?u.filter(T=>T.qualifiedName.slice(T.qualifiedName.lastIndexOf(".")+1).toLowerCase()===g.name.toLowerCase()):[];if(O.length>0){let T=[];for(let R of O){v.add(R.qualifiedName);let N=R.qualifiedName.slice(0,R.qualifiedName.lastIndexOf(".")),B=`context:${N}`;if(!y.has(B)){let q=br("context",B,[N],this.modelNodes.length);this.modelNodes.push(q),y.set(B,q)}let j=y.get(B);T.includes(j)||T.push(j)}h.push({consumer:$,producer:T[0],kind:"outsideTheModel",role:g.role,name:g.name,ambiguous:T.length>1,alternatives:T.slice(1),location:g.location,testOnly:g.kind==="verifiedWith"});continue}if(g.role==="trigger"&&c.has(g.name.toLowerCase())){k++;continue}x.push({consumer:$,kind:g.kind,role:g.role,name:g.name,location:g.location})}}let C=new Map;for(let $ of h.sort(Ca)){let P=JSON.stringify([$.consumer.key,$.producer.key,$.kind]);C.has(P)||C.set(P,[]),C.get(P).push($)}this.edges=[...C.values()].map($=>({consumer:$[0].consumer,producer:$[0].producer,kind:$[0].kind,evidence:$})),this.unresolved=x.sort(($,P)=>$.consumer.rank-P.consumer.rank||$.location.line-P.location.line||$.location.column-P.location.column||dt.indexOf($.kind)-dt.indexOf(P.kind)||We($.location.path??"",P.location.path??"")||We($.name,P.name)),this.excludedReferences=k,this.unusedImports=[...new Set(u.filter($=>!v.has($.qualifiedName)).map($=>$.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new et(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new et(`Unsupported target level '${n}'.`);if(o<0)throw new et("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let c of this.at(a.consumer,e))for(let p of this.at(a.producer,n).filter(m=>this.disjoint(c,m))){let m=JSON.stringify([c.key,p.key]);s.has(m)||s.set(m,{source:c,target:p,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,c)=>a.source.rank-c.source.rank||a.target.rank-c.target.rank||We(a.source.key,c.source.key)||We(a.target.key,c.target.key)).map(a=>{let c=a.evidence.sort(Ca),p={};for(let m of dt){let u=c.filter(y=>y.kind===m).length;u>0&&(p[m]=u)}return{source:a.source,target:a.target,sliceEdges:new Set(c.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:c.length,byKind:p,consumers:cn(c.map(m=>m.consumer)),producers:cn(c.map(m=>m.producer)),evidence:c.slice(0,o),evidenceCount:c.length,evidenceTruncated:c.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new et(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Pa(n)),r=cn(i.flatMap(o=>[o.source,o.target]));return Aa(Er(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return Aa(Er(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let c=this.children.get(a.key),p=n.filter(k=>k.container===a),m=new Map(c.map(k=>[k.key,k])),u=ln(Er(c,p)).map(k=>k.map(C=>m.get(C)).sort(Cr)).sort((k,C)=>k[0].rank-C[0].rank),y=new Map(u.flatMap((k,C)=>k.map($=>[$.key,C]))),h=new Map(c.map(k=>[k.key,new Set]));for(let k of p)y.get(k.source.key)!==y.get(k.target.key)&&h.get(k.source.key).add(k.target.key);for(let k of u)for(let C=1;C<k.length;C++)h.get(k[C].key).add(k[C-1].key);let x=new Set(c.map(k=>k.key)),v=[];for(;x.size>0;){let k=[...x].filter(C=>h.get(C).size===0).sort((C,$)=>Cr(m.get(C),m.get($)))[0];v.push(m.get(k)),x.delete(k);for(let C of x)h.get(C).delete(k)}i.push({container:a,children:v,changed:c.some((k,C)=>k!==v[C])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=l(a=>{if(a.kind==="slice")o.push(a);else for(let c of[...r.get(a.key)].sort((p,m)=>+(p.kind!=="slice")-+(m.kind!=="slice")))s(c)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new et(`Unsupported dependency direction '${n}'.`);let o=this.evidence(i,r).map(p=>n==="incoming"?{source:p.producer,target:p.consumer}:{source:p.consumer,target:p.producer}),s=new Set([e]),a=[e],c=[];for(let p=0;p<a.length;p++)for(let m of o.filter(u=>u.source.address===a[p]).sort((u,y)=>u.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),c.push(m.target),a.push(m.target.address));return cn(c)}add(e,n,i){let r=[...i.scope,n],o=r.join("."),s=`${e}:${o}`,a=this.byKey.get(s);if(a!==void 0)return a;let c=br(e,o,r,this.modelNodes.length);return this.modelNodes.push(c),this.byKey.set(s,c),this.parents.set(s,i),this.children.get(i.key).push(c),e!=="slice"&&this.children.set(s,[]),c}ancestors(e){let n=[];for(let i=this.parents.get(e.key);i!==void 0;i=this.parents.get(i.key))n.push(i);return n}disjoint(e,n){return e.key!==n.key&&!this.ancestors(e).includes(n)&&!this.ancestors(n).includes(e)}at(e,n){return[e,...this.ancestors(e)].filter(i=>i.kind===n)}containers(){return[this.root,...this.modelNodes.filter(e=>e.kind==="module"||e.kind==="feature")]}evidence(e,n){let i=wa(e);return this.edges.flatMap(r=>r.evidence).filter(r=>i.has(r.kind)&&(n||!r.testOnly))}path(e){return[...this.ancestors(e).reverse(),e].filter(n=>n!==this.root)}siblingEdges(e){let n=[];for(let i of this.evidence(Pa(e),!1)){let r=this.path(i.consumer),o=this.path(i.producer),s=0;for(;s<r.length&&s<o.length&&r[s].key===o[s].key;)s++;s===r.length||s===o.length||n.push({container:s===0?this.root:r[s-1],source:r[s],target:o[s]})}return n}};function wa(t){let e=new Set(t??dt);if([...e].some(n=>!dt.includes(n)))throw new et("Unsupported dependency kind.");return e}l(wa,"selectedKinds");function Pa(t){return[...wa(t??Ea)].filter(e=>Ea.includes(e))}l(Pa,"selectedOrderingKinds");function Er(t,e){let n=new Map(t.map(i=>[i.key,new Set]));for(let i of e)n.get(i.source.key).add(i.target.key);return n}l(Er,"adjacency");function Aa(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return ln(t).filter(r=>r.length>1).map(r=>({container:n,members:cn(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}l(Aa,"groupsOf");var mf=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],ze=l((t,e)=>e===t||e.startsWith(t+"."),"contains"),jt=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),yf=l((t,e)=>jt(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||jt(t.kind,e.kind)||jt(t.consumer.address,e.consumer.address)||jt(t.producer.address,e.producer.address)||jt(t.role,e.role)||jt(t.name,e.name),"orderedEvidence"),Lt=class{static{l(this,"DeclaredDependencies")}static for(e){let n=new Map,i=l((u,y)=>{let h=u.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach(x=>i([...u,x.name],x))},"inventory");if(e.modules.forEach(u=>i([u.name],u)),![...n.values()].some(u=>u.dependencies.length))return{containers:[],diagnostics:[]};let r=Nt.for(e,new Map),o=r.nodes.filter(u=>u.kind==="module"||u.kind==="feature"),s=Ee.containersOf(e),a=l((u,y)=>{let h=Ee.resolve(u,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),c=[],p=[],m=l((u,y,h,x)=>p.push({code:u,severity:y,message:h,location:x}),"finding");for(let u of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(u.address),h=y.dependencies.map(k=>{let C=a(k.target,u.scope),$=C!==void 0&&!ze(u.address,C)&&!ze(C,u.address);return{syntax:k,resolved:C,status:$?"unused":"invalid"}}),x=[],v=new Map;for(let k of r.edges.flatMap(C=>C.evidence).filter(C=>mf.includes(C.kind)&&ze(u.address,C.consumer.address)).sort(yf)){let C=[k.producer,...k.alternatives].filter(A=>!ze(u.address,A.address)&&!ze(A.scope.slice(0,-1).join("."),u.address));if(!C.length)continue;let $=h.filter(A=>A.status!=="invalid"&&C.some(g=>ze(A.resolved,g.address)));for(let A of $)A.status=k.ambiguous&&A.status!=="used"?"provisional":"used";let P=k.ambiguous?"provisional":$.length?"declared":"undeclared";if(x.push({evidence:k,status:P,coveringDeclarations:$.map(A=>A.syntax)}),P==="undeclared"){let A=k.producer.scope[0];v.has(A)||v.set(A,[]),v.get(A).push(k)}}for(let k of v.values()){let C=k[0].producer.scope.slice(0,-1),$=C.findIndex((S,E)=>k.some(b=>E>=b.producer.scope.length-1||b.producer.scope[E]!==S));$>=0&&(C=C.slice(0,$));let P=C.join("."),A=ze(u.address,P)||ze(P,u.address)?[...new Set(k.map(S=>S.producer.scope.slice(0,-1).map((E,b)=>S.producer.scope.slice(0,b+1).join(".")).find(E=>!ze(u.address,E)&&!ze(E,u.address))))]:[P],g=k.map(S=>`${S.kind} ${S.role} '${S.name}' at ${S.location.path??""}:${S.location.line}:${S.location.column}`).join("; ");m(d.UndeclaredDependency,"warning",`Container '${u.address}' depends on '${A.join("', '")}' without declaring ${A.length===1?"it":"them"} - evidence: ${g}`,y.location)}for(let k of h)k.status==="unused"&&m(d.UnusedDependencyDeclaration,"information",`Dependency '${k.syntax.target}' on '${u.address}' is not used by any counted explicit reference`,k.syntax.location),k.status!=="invalid"&&n.get(k.resolved).dependencies.some(C=>a(C.target,k.resolved.split("."))===u.address)&&m(d.MutualDependencyDeclarations,"information",`Containers '${u.address}' and '${k.resolved}' declare each other`,k.syntax.location);c.push({container:u,location:y.location,declarations:h,edges:x})}return{containers:c,diagnostics:p}}static validate(e,n){for(let i of this.for(e).diagnostics)n[i.severity==="warning"?"warning":"information"](i.code,i.message,i.location)}};var Ar=class extends Error{static{l(this,"InvalidExactNumber")}};function wr(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||Ge(t.value)?.value!==t.value)throw new Ar("Expected a canonical, bounded ExactNumber value.");return t.value}l(wr,"canonicalExactText");function Oa(t){return!wr(t).includes(".")}l(Oa,"exactIsIntegral");var hf=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,Sf=/^([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 Or(t,e){let n=(e?Sf:hf).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]),a=[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>a[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 c=Number(n[7]),p=Number(n[8]);return c<=14&&p<=59&&(c!==14||p===0)}l(Or,"responseDateValue");var Hn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Jn(t,e,n=e.inputUses){let i=Gn(t),r=[],o=l((g,S)=>{let E=[...S,g.name];g.slices.forEach(b=>r.push({slice:b,scope:[...E,b.name]})),g.features.forEach(b=>o(b,E))},"collect");t.modules.forEach(g=>g.features.forEach(S=>o(S,[g.name])));let s=new Map,a=new Map,c=new Map;for(let{slice:g,scope:S}of r)for(let E of g.commands){let b=s.get(E.name)??[];b.push({command:E,scope:S}),s.set(E.name,b),a.set(E,ee(E.properties)),E.response?.kind==="RecordCommandResponseSyntax"&&c.set(E,ee(E.response.fields))}let p=new Map;for(let g of t.imports){let S=g.qualifiedName.split(".").at(-1);p.set(S,[...p.get(S)??[],g.qualifiedName])}let m=new Map,u=l((g,S)=>{let E=`${S.join(".")}|${g}`;if(m.has(E))return m.get(E);let b=p.get(g)??[],R=((s.get(g.split(".").at(-1))??[]).length===0&&b.length===1?b[0]:g).split("."),N=s.get(R.at(-1))??[];if(R.length>1){let j=R.slice(0,-1);N=N.filter(q=>j.length<=q.scope.length&&j.every((W,G)=>q.scope[q.scope.length-j.length+G]===W))}else for(let j=S.length;j>=0;j--){let q=N.filter(W=>j<=W.scope.length&&S.slice(0,j).every((G,Y)=>W.scope[Y]===G));if(q.length>0){N=q;break}}let B=N.length===1?N[0].command:null;return m.set(E,B),B},"resolve"),y=ee(t.concepts),h=new Set(t.concepts.map(g=>g.name)),x=new Map([...ee(t.types)].map(([g,S])=>[g,ee(S.properties)])),v=new Set(r.flatMap(g=>g.slice.readModels.map(S=>S.name))),k=new Set([...a.keys()].flatMap(g=>[...g.properties])),C=l(g=>{for(let S of g)S.isGenerated&&!k.has(S)&&e.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",S.location)},"checkDeclarations"),$=l(g=>{g.features.forEach($);for(let S of g.slices){for(let E of S.commands)for(let b of E.produces)b.inlineEvent!==null&&C(b.inlineEvent.properties);S.events.forEach(E=>C(E.properties)),S.readModels.forEach(E=>C(E.properties));for(let E of S.reactions)for(let b of E.triggers)for(let O of b.produces)O.inlineEvent!==null&&C(O.inlineEvent.properties)}},"checkFeature");t.types.forEach(g=>C(g.properties)),t.modules.forEach(g=>g.features.forEach($));let P=l((g,S,E)=>{let b=a.get(E).get(g.property);if(b===void 0){e.error(d.InvalidResponseSource,`Response source '${g.property}' must reference one direct command property.`,g.location);return}let O=b.type;(O.isCollection||v.has(O.name))&&e.error(d.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",g.location),S!==null&&(S.name!==O.name||S.isCollection!==O.isCollection||S.isOptional!==O.isOptional)&&e.error(d.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",S.location)},"validateSource");for(let g of a.keys()){for(let E of g.properties){if(!E.isGenerated)continue;let b=y.get(E.type.name);(E.type.isOptional||E.type.isCollection||(b===void 0?Hn.has(E.type.name)||x.has(E.type.name)||h.has(E.type.name)||v.has(E.type.name):b.type!=="Uuid"))&&e.error(d.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",E.location)}let S=g.response;if(S?.kind==="ScalarCommandResponseSyntax")P(S.source,null,g);else if(S?.kind==="RecordCommandResponseSyntax"){S.fields.length===0&&e.error(d.InvalidCommandResponse,"A response block requires at least one field.",S.location);let E=new Set;for(let b of S.fields)E.has(b.name)&&e.error(d.DuplicateResponseField,`Duplicate response field '${b.name}'.`,b.location),E.add(b.name),P(b.source,b.type,g)}}let A=l((g,S)=>{let E=i(g.when,S),b=E===null?null:u(E.commandType,S);if(E!==null&&b!==null){let N=a.get(b);for(let q of E.values)N.get(q.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${q.property}' cannot be supplied as request or form input.`,q.location);let B=[...N.values()].filter(q=>q.isIdentifier);if(E.for!==null&&B.length===1&&B[0].isGenerated){let q=B[0].type;(Hn.has(q.name)||y.has(q.name)||x.has(q.name))&&(q.isOptional||q.isCollection||y.get(q.name)?.type!=="Uuid"||E.for.kind!=="LiteralExpressionSyntax"||typeof E.for.value!="string"||!Ia(E.for.value))&&e.error(d.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",E.for.location)}let j=new Set;for(let q of E.generatedValues??[]){let W=N.get(q.property);(j.has(q.property)||W===void 0||!W.isGenerated||W.isIdentifier||!Ce(q.source,W.type,y,x))&&e.error(d.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",q.location),j.add(q.property)}}let O=g.thenReturns;if(O==null||((E===null||g.thenErrors.length>0||g.thenDenied!=null)&&e.error(d.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",O.location),b===null))return;let T=b.response,R=a.get(b);if(O.kind==="ScalarSpecificationReturnSyntax"&&T?.kind==="ScalarCommandResponseSyntax"&&R.has(T.source.property))Ce(O.value,R.get(T.source.property).type,y,x)||e.error(d.InvalidReturnExpectation,"The expected return value must match the response source's type.",O.location);else if(O.kind==="RecordSpecificationReturnSyntax"&&T?.kind==="RecordCommandResponseSyntax"){O.fields.length===0&&e.error(d.InvalidReturnExpectation,"A record return expectation requires at least one field.",O.location);let N=c.get(b),B=new Set;for(let j of O.fields){let q=N.get(j.property),W=q===void 0?void 0:R.get(q.source.property);(B.has(j.property)||W===void 0||!Ce(j.source,W.type,y,x))&&e.error(d.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",j.location),B.add(j.property)}}else e.error(d.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",O.location)},"validateSpecification");for(let{slice:g,scope:S}of r)g.specifications.forEach(E=>A(E,S));for(let g of n){if(g.isParameter===!0)continue;let S=u(g.command,g.scope);S!==null&&a.get(S).get(g.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${g.property}' cannot be supplied as request or form input.`,g.location)}}l(Jn,"validateResponses");function ee(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}l(ee,"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(a=>Ce(a,{...e,isCollection:!1,isOptional:!1},n,i));let r=i.get(e.name);if(r!==void 0)return t.kind==="ObjectExpressionSyntax"&&t.members.every(a=>{let c=r.get(a.name);return c!==void 0&&Ce(a.value,c.type,n,i)});let o=n.get(e.name),s=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(s){case"Uuid":return typeof t.value=="string"&&Ia(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&&Oa(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"&&Or(t.value,!1);case"DateTime":return typeof t.value=="string"&&Or(t.value,!0);default:return!Hn.has(s)}return!Hn.has(s)&&o===void 0}l(Ce,"compatibleValue");var gf=/^(?:[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 Ia(t){return gf.test(t)}l(Ia,"uuidValue");function Xn(t,e,n,i=!1){let r=[],o=[],s=Oe,a=!1,c=!1,p=!1,m=new Map,u=new ge(new Ze([]),e,n).languages;for(let h of t){let x=h;if(x.number===1&&x.raw.startsWith("\uFEFF")){let v=x.raw.substring(1),k=v.length-v.trimStart().length,C=Vt(v.substring(k),i);x={...x,indent:k,contentOffset:1,content:(C<0?v.substring(k):v.substring(k,k+C)).trimEnd()}}if(p){Zi(x)&&(p=!1),r.push(x);continue}if(x.content.startsWith("```")&&(["```","```text","```markdown"].includes(x.content)||u.has(x.content.substring(3)))&&(p=!0),!p&&x.indent===0&&D(x.content)==="numbers"){let v=x.content!=="numbers exact"?d.InvalidNumericDirective:a?d.DuplicateNumericDirective:c?d.LateNumericDirective:void 0;v!==void 0?(o.push({severity:"error",code:v,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:f(x)}),s=Object.freeze({numericMode:"invalid"})):s=An,a=!0,r.push({...x,content:""});continue}!p&&x.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(x.content)&&m.set(x.number,{severity:"error",code:d.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:f(x)}),c||=x.content.trim().length>0,r.push(x)}let y=new ge(new Ze(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}l(Xn,"sourceContext");function Ta(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}l(Ta,"eventProductions");function Ir(t,e){let n=Ta(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)}l(Ir,"requiresExplicitDestinations");function Ra(t,e,n){let i=Ta(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||Ir(t,n))return;if(e.inlineEvent===null)return i.some(o=>o.for!==null||o.inlineEvent!==null)?void 0:"new event source";let r=t.properties.filter(o=>o.isIdentifier&&!o.type.isOptional&&!o.type.isCollection);return r.length===1?r[0].name:void 0}l(Ra,"implicitDestination");function ei(t,e){let n=[],i=l(a=>{n.push(...a.slices),a.features.forEach(i)},"inFeature");t.modules.forEach(a=>a.features.forEach(i));let r=new Map;for(let a of n.flatMap(le))r.set(a.name,(r.get(a.name)??0)+1);let o=new Set(t.imports.map(a=>a.qualifiedName.split(".").at(-1))),s=new se(t);for(let{slice:a,command:c}of n.flatMap(p=>p.commands.map(m=>({slice:p,command:m})))){let p=c.produces.filter(y=>s.isEventProduction(y,a)),m=c.properties.find(y=>y.isIdentifier)?.name,u=Ir(c,{resolver:s,slice:a});for(let y of p){let h=y.inlineEvent;h!==null&&((r.get(h.name)??0)>1||o.has(h.name))&&e.error(d.InlineEventCollision,`Inline event '${h.name}' collides with another event declaration or import`,y.location),u&&y.for===null&&e.error(d.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${c.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let x=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||x!==m))for(let v of y.mappings.filter(k=>k.source.kind==="PathExpressionSyntax"&&k.source.path===m)){let k=`Event '${y.event}' copies command identifier '${m}' into payload property '${v.property}' although it already identifies the event source`;h===null?e.information(d.EventSourceIdInPayload,k,v.location):e.warning(d.EventSourceIdInPayload,k,v.location)}}}}l(ei,"validateInlineEvents");function ti(t,e){let n=new se(t),i=Gn(t),r=ee(t.concepts),o=new Map([...ee(t.types)].map(([$,P])=>[$,ee(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map($=>$.qualifiedName.split(".").at(-1))),c=new Map;for(let $ of t.imports){let P=$.qualifiedName.split(".").at(-1);c.set(P,[...c.get(P)??[],$.qualifiedName])}let p=l($=>{let P=new Map,A=new Map;for(let g of $){let S=P.get(g.name)??[];S.push(g),P.set(g.name,S)}return(g,S)=>{let E=JSON.stringify([g,S]);if(A.has(E))return A.get(E);let b=l(N=>{let B=N.split("."),j=P.get(B.at(-1))??[],q=B.slice(0,-1);if(q.length>0)return j.filter(W=>q.length<=W.scope.length&&q.every((G,Y)=>W.scope[W.scope.length-q.length+Y]===G));for(let W=S.length;W>=0;W--){let G=j.filter(Y=>W<=Y.scope.length&&S.slice(0,W).every((V,ae)=>Y.scope[ae]===V));if(G.length>0)return G}return[]},"candidates"),O=b(g),T=c.get(g)??[];O.length===0&&T.length===1&&(O=b(T[0]));let R=O.length===1?O[0].node:null;return A.set(E,R),R}},"scoped"),m=p(n.slices.flatMap(({slice:$,scope:P})=>$.readModels.map(A=>({name:A.name,scope:P,node:A})))),u=p(n.slices.flatMap(({slice:$,scope:P})=>$.commands.map(A=>({name:A.name,scope:P,node:{command:A,slice:$}})))),y=new Map;for(let $ of t.systems??[])y.has($.name)&&e.error(d.InvalidSystemDeclaration,`System '${$.name}' is declared more than once.`,$.location),y.set($.name,(y.get($.name)??0)+1);let h=l(($,P,A=!0)=>{let[g,...S]=P.split("."),E=$.filter(R=>R.name===g);if(E.length!==1)return{type:null,missing:E.length===0};let b=E[0].type;if(S.length===0)return{type:b,missing:!1};let O=o.get(b.name);if(O===void 0)return{type:null,missing:s.has(b.name)};let T=h([...O.values()],S.join("."),A);return T.type===null?T:{type:{...T.type,isOptional:A&&b.isOptional||T.type.isOptional,isCollection:b.isCollection||T.type.isCollection},missing:!1}},"pathType"),x=l(($,P,A,g,S=new Set)=>{if(A.has(P)||$.isOptional&&!g.has(P))return!0;if($.isCollection||S.has($.name))return!1;let E=o.get($.name);return E===void 0?g.has(P)&&!s.has($.name):[...E.values()].every(b=>x(b.type,`${P}.${b.name}`,A,g,new Set([...S,$.name])))},"covered"),v=l(($,P)=>{if($.kind==="ListExpressionSyntax"&&P.isCollection)return $.items.every(g=>v(g,{...P,isCollection:!1,isOptional:!1}));let A=o.get(P.name);return $.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every(g=>(g.type.isOptional||$.members.some(S=>S.name===g.name))&&$.members.filter(S=>S.name===g.name).every(S=>v(S.value,g.type)))},"completeValue"),k=l($=>$.kind==="LiteralExpressionSyntax"?typeof $.value!="number"||Number.isFinite($.value):$.kind==="ObjectExpressionSyntax"?$.members.every(P=>k(P.value)):$.kind==="ListExpressionSyntax"&&$.items.every(k),"concrete"),C=l(($,P,A,g,S)=>{let E=new Set,b=new Set($.map(T=>T.property)),O=new Set;for(let T of $){let R=T.property.split(".");for(let N=1;N<=R.length;N++)O.add(R.slice(0,N).join("."))}for(let T of $){E.has(T.property)&&e.error(d.InvalidOperationMapping,`Duplicate operation input mapping '${T.property}'.`,T.location),E.add(T.property);let R=h(P.inputs,T.property,!1);if(R.missing&&e.error(d.InvalidOperationMapping,`Operation '${P.name}' declares no input '${T.property}'.`,T.location),R.type===null)continue;let N=T.property.split(".");for(let B=1;B<N.length;B++)b.has(N.slice(0,B).join("."))&&e.error(d.InvalidOperationMapping,`Operation input mapping '${T.property}' overlaps a whole input mapping.`,T.location);if(A!==null&&T.source.kind==="PathExpressionSyntax"){let B=h(A.properties,T.source.path),j=T.source.path.split("."),q=(Fn.get(A)??[]).filter(Y=>(Y.alias??Y.readModel)===j[0]);if(B.missing&&q.length>0){B={type:null,missing:!1};let Y=q.length===1?m(q[0].readModel,S):null;j.length>1&&Y!==null&&(B=h(Y.properties,j.slice(1).join(".")))}B.missing&&e.error(d.InvalidOperationMapping,`Command '${A.name}' declares no source '${T.source.path}'.`,T.source.location);let W=B.type,G=R.type;W!==null&&s.has(W.name)&&s.has(G.name)&&(W.name!==G.name||W.isCollection!==G.isCollection||W.isOptional&&!G.isOptional)&&e.error(d.InvalidOperationMapping,`Source '${T.source.path}' is incompatible with input '${T.property}' of operation '${P.name}'.`,T.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(T.source.kind)&&(!Ce(T.source,R.type,r,o)||g&&!v(T.source,R.type))&&e.error(d.InvalidOperationMapping,`Value is incompatible with input '${T.property}' of operation '${P.name}'.`,T.source.location)}if(g)for(let T of P.inputs)x(T.type,T.name,E,O)||e.error(d.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${T.name}'.`,P.location)},"validateMappings");for(let{slice:$,scope:P}of n.slices){let A=xn($),g=new Set(le($).map(S=>S.name));for(let S of A){g.has(S.name)&&e.error(d.ProductionDeclarationCollision,`Operation '${S.name}' collides with another event or operation in slice '${$.name}'.`,S.location),g.add(S.name),S.uses.length>0&&y.get(S.uses)!==1&&e.error(d.InvalidSystemReference,`Operation '${S.name}' must use one declared system; '${S.uses}' does not resolve uniquely.`,S.usesLocation??S.location);for(let E of S.inputs)!s.has(E.type.name)&&!a.has(E.type.name)&&e.warning(d.UnknownType,`Unknown type '${E.type.name}' on input '${E.name}' of operation '${S.name}'.`,E.type.location)}for(let S of $.commands)for(let E of S.produces){let b=n.resolve(E.event,$);b.kind===ne.Ambiguous&&b.candidates.some(O=>O.kind===ne.Operation)&&e.error(d.InvalidProductionReference,`Production '${E.event}' is ambiguous.`,E.location),E.event.includes(".")&&b.kind!==ne.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",E.location),b.declaration?.node.kind==="OperationSyntax"&&((E.for!==null||E.tags.length>0)&&e.error(d.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",E.location),C(E.mappings,b.declaration.node,S,!0,P))}for(let S of $.reactions.flatMap(E=>E.triggers).flatMap(E=>E.produces)){let E=n.resolve(S.event,$);E.kind===ne.Ambiguous&&E.candidates.some(b=>b.kind===ne.Operation)&&e.error(d.InvalidProductionReference,`Production '${S.event}' is ambiguous.`,S.location),S.event.includes(".")&&n.resolve(S.event,$).kind!==ne.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",S.location),n.isOperation(S,$)&&e.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",S.location)}for(let S of $.specifications){let E=[...S.givenOperationFailures??[],...S.thenOperations??[],...S.thenCompensated??[]];if(E.length===0)continue;let b=u(i(S.when,P)?.commandType??"",P);(b===null||S.whenAppended!==null||S.whenQuery!==null||S.whenTrigger!==null||S.whenClock!==null||S.whenCapture!==null)&&e.error(d.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",S.location);let O=new Map;for(let T of E){if(T.kind==="SpecificationOperationSyntax")for(let B of T.values)k(B.source)||e.error(d.InvalidOperationSpecification,"Operation assertions require concrete input values.",B.source.location);let R=n.resolve(T.operation,$).declaration?.node;if(R?.kind!=="OperationSyntax"){e.error(d.InvalidOperationSpecification,`'${T.operation}' does not resolve uniquely to a declared operation.`,T.location);continue}let N=O.get(R)??new Set;if(N.has(T.kind)&&e.error(d.InvalidOperationSpecification,`Duplicate operation step '${T.operation}'.`,T.location),N.add(T.kind),O.set(R,N),T.kind==="SpecificationCompensatedSyntax"&&R.compensate===null&&e.error(d.InvalidOperationSpecification,`Operation '${T.operation}' declares no compensation.`,T.location),b!==null&&b.command.handler==null){let B=b.command.produces.map(j=>n.resolve(j.event,b.slice));B.every(j=>j.kind===ne.Event||j.kind===ne.Operation)&&!B.some(j=>j.declaration?.node===R)&&e.error(d.InvalidOperationSpecification,`Command '${b.command.name}' does not produce operation '${T.operation}'.`,T.location)}T.kind==="SpecificationOperationSyntax"&&C(T.values,R,null,!1,P)}}}}l(ti,"validateOperations");var xf=Q("^policy\\s+([A-Za-z_]\\w*)$");function Da(t,e){let n=t;t=t.valueContext;let i=xf.exec(e.content)?.[1]??"";i===""&&t.error(d.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,f(e));let r=null,o=null,s=null,a=!1;for(let c=t.peekChild(e.indent);c!==void 0;c=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(c.content)==="require"){let p=c.content.substring(7).trim();for(let y=t.peekChild(c.indent);y!==void 0;y=t.peekChild(c.indent))t.reader.takeSignificant(),p+=` ${y.content}`;let m=vf(t,p);m.includes("not")&&(t=n);let u=$f(t,m,f(c));a?t.error(d.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,f(c)):r=u,a=!0}else if(D(c.content)==="file"){let p=lt(t,c);o===null&&s===null?s=p:t.error(d.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(c))}else if(c.content.startsWith("```")||t.languages.has(c.content)){let p=Re(t,c);o===null&&s===null?o=p:t.error(d.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(c))}else t.error(d.UnknownPolicyDirective,`Unexpected '${c.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,f(c)),t.skipOpaqueBlock(c.indent);return r!==null&&(o!==null||s!==null)&&t.error(d.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,f(e)),r===null&&o===null&&s===null&&t.error(d.PolicyWithoutRequirement,`Policy '${i}' must declare a 'require' condition, a file reference or an inline code block`,f(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,location:f(e)}}l(Da,"parsePolicy");function vf(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(Q(`"${H}"|\\(|\\)|${n}`).source,"gu"))??[]]}l(vf,"tokenizePolicyCondition");function $f(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=l(u=>u!==void 0&&u.startsWith('"')&&u.endsWith('"'),"quoted"),s=l(u=>X(u.substring(1,u.length-1)),"unquote"),a=l(()=>{if(e[r]==="not"){r++;let x=a();return x===null?null:{kind:"NotPolicyConditionSyntax",operand:x,location:n}}if(e[r]==="("){r++;let x=p();return e[r]===")"?r++:i&&t.error(d.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),x}let u=e[r++];if(u==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(u!=="role"&&u!=="claim")return t.error(u===void 0?d.ExpectedPolicyCondition:d.UnexpectedTokenInPolicyCondition,u===void 0?"Expected a policy condition":`Unexpected '${u}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(u==="role"?d.ExpectedRoleName:d.ExpectedClaimName,`Expected a quoted ${u} name after '${u}'`,n),null;if(u==="role")return{kind:"RoleConditionSyntax",role:s(y),location:n};if(e[r++]!=="matches")return t.error(d.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let h=e[r++];return h===void 0?(t.error(d.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(y),matchesSubject:h==="subject",matches:h==="subject"?null:we(h,n,t),location:n}},"group"),c=l(()=>{let u=a();for(;u!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"And",right:y,location:n}}return u},"and"),p=l(()=>{let u=c();for(;u!==null&&e[r]==="or";){r++;let y=c();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"Or",right:y,location:n}}return u},"or"),m=p();return i&&m!==null&&r<e.length&&t.error(d.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}l($f,"parsePolicyCondition");var kf=new RegExp(`^for\\s+"(${H})"$`,"u"),bf=Q("^[A-Z]\\w*$"),Ef=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Ma(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(d.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:f(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=kf.exec(i.content);if(r===null){t.error(d.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,f(i)),t.skipOpaqueBlock(i.indent);continue}let o=[];for(let s=t.peekChild(i.indent);s!==void 0;s=t.peekChild(i.indent)){if(t.reader.takeSignificant(),!bf.test(s.content)){t.error(d.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,f(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let c=t.peekChild(s.indent);c!==void 0;c=t.peekChild(s.indent)){t.reader.takeSignificant();let p=Ef.exec(c.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:we(p[2],f(c),t),location:f(c)}):t.error(d.InvalidSeedPropertyAssignment,`Invalid property assignment '${c.content}' - expected '<property> = <value>'`,f(c))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:f(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:X(r[1]),events:o,location:f(i)})}return{kind:"SeedSyntax",groups:n,location:f(e)}}l(Ma,"parseSeed");var Cf=w("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),La=w("^import\\s+([\\w.]+)$"),Pf=w("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@\\w+)*)$"),Af=w("^@?[a-z_]\\w*$"),wf=w(`^([a-z_]\\w*)\\s+reason\\s+"(${H})"$`),Of=w("^persona\\s+([A-Za-z_]\\w*)$"),If=w("^policy\\s+([A-Za-z_]\\w*)$"),Tf=/^[ ]*\t/,Na=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],qa=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Rf=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function ni(t,e,n=xt){Lf(t,e);let i=n.length===1?new an(n[0]):void 0,r=n.length>1?new on(n[n.length-1]):void 0,o=i??r,s=null,a=[],c=[],p=[],m=[],u=[],y=[],h=[],x=[],v=[],k=[],C=[],$=[],P=!1;for(let g=t.reader.peekSignificant();g!==void 0;g=t.reader.peekSignificant()){t.reader.takeSignificant();let S=D(g.content);if(S==="domain"){t.authoredDeclarations=!0,s=jf(t,g,s,P);continue}if(P||=ja(S,g,n),t.authoredDeclarations||=S!=="import"&&ja(S,g,n),S==="import"&&so(g.content))o!==void 0?o.tryParse(t,g):At(t,g,c);else if(S==="import"){let E=La.exec(g.content);E===null?t.error(d.InvalidImportDeclaration,`Invalid import '${g.content}' - expected 'import <Qualified.Name>'`,f(g)):a.push({kind:"ImportSyntax",qualifiedName:E[1],location:f(g)})}else if(S==="example")o!==void 0?o.tryParse(t,g):C.push(_e(t,g));else if(S==="eventsource")y.push(Co(t,g));else if(S==="system")u.push(Ro(t,g));else if(S==="concept")p.push(qf(t,g));else if(S==="type")m.push(zo(t,g));else if(S==="module"&&!Qt(n))Df(t,g,n,i);else if(S==="module")h.push(gr(t,g));else if(S==="persona")x.push(Ff(t,g));else if(S==="seed")k.push(Ma(t.valueContext,g));else if(S==="policy")v.push(Da(t,g));else if(S==="trigger"){let E=pa(t,g),b=/^trigger\s+([A-Za-z_]\w*)$/.exec(g.content)?.[1];b!==void 0&&$.push({name:b,data:E})}else qa.has(S)?S==="behavior"||S==="layout"?Ie(t,g):t.skipOpaqueBlock(g.indent):o?.tryParse(t,g)!==!0&&Mf(t,g,n)}i!==void 0?h.unshift(i.build(t.start,!0)):r!==void 0&&h.unshift(Nf(n,r.build(t.start,!0),t.start));let A={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:s,imports:a,concepts:p,types:m,systems:u,eventSources:y,examples:C,modules:h,personas:x,policies:v,seeds:k,declaredTriggers:$,fileImports:c,location:t.start};return t.authoredDeclarations&&vo(A),A}l(ni,"parseApplication");function ja(t,e,n){return t==="import"?La.test(e.content):t==="module"?Qt(n):t==="example"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||qa.has(t)}l(ja,"declaresConstruct");function Df(t,e,n,i){let r=hr.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(d.ModuleInPlacedFile,`This file is imported into ${En(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,f(e)),t.skipBlock(e.indent)}l(Df,"parseModuleInPlacedFile");function Mf(t,e,n){let i=D(e.content);if(Qt(n)){let r=Rf.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(d.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,f(e))}else{let r=n.length===1?Sr:yr;t.error(d.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${En(n)} - expected an application declaration or ${r}`,f(e))}t.skipBlock(e.indent)}l(Mf,"reportUnexpectedTopLevel");function Nf(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}}l(Nf,"place");function jf(t,e,n,i){let r=Cf.exec(e.content);return r===null?(t.error(d.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,f(e)),n):n!==null?(t.error(d.DuplicateDomain,"The document already declares a domain - a document can have at most one",f(e)),n):(i&&t.error(d.DomainNotFirst,"'domain' must be declared before any other construct",f(e)),{kind:"DomainSyntax",name:r[1],location:f(e)})}l(jf,"parseDomain");function Lf(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&Tf.test(i.raw)&&t.warning(d.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",ro(i))}}l(Lf,"warnOnTabIndentation");function qf(t,e){let n=Pf.exec(e.content);if(n===null)return t.error(d.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,f(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:f(e)};let[,i,r,o]=n,s=o.split(" ").filter(m=>m.length>0).map(m=>({kind:"ConceptAttributeSyntax",name:m.replace(/^@+/,""),reason:null,location:f(e)}));r!=="Enum"&&!Na.includes(r)&&t.error(d.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${Na.join(", ")} or Enum`,f(e));let a=new Map;s.forEach((m,u)=>{a.has(m.name)||a.set(m.name,u)});let c=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=wf.exec(m.content);if(!fe(m))if(D(m.content)==="validate"){r==="Enum"&&m.content==="validate"&&t.peekChild(m.indent)===void 0&&t.warning(d.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,f(m));let y=lr(t,m,"concept");y!==void 0&&p.push(y)}else u!==null?Bf(t,m,i,s,a,u[1],X(u[2])):r==="Enum"&&Af.test(m.content)?c.push(te(m.content)):r==="Enum"?t.error(d.InvalidEnumerationValue,`Invalid enum value '${m.content}' - expected an identifier`,f(m)):(t.error(d.UnknownConceptDirective,`Unexpected '${m.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,f(m)),t.skipBlock(m.indent))}return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:c,validations:p,location:f(e)}}l(qf,"parseConcept");function Bf(t,e,n,i,r,o,s){let a=r.get(o);a===void 0?t.error(d.AttributeReasonWithoutAttribute,`Concept '${n}' declares a reason for '${o}' without the attribute - write 'concept ${n} : <Type> @${o}'`,f(e)):i[a].reason!==null?t.error(d.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${o}' - at most one is allowed`,f(e)):i[a]={...i[a],reason:s}}l(Bf,"applyAttributeReason");function Ff(t,e){let n=Of.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,f(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);if(s==="description")i=Z(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=If.exec(o.content);a===null?t.error(d.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,f(o)):r.push(a[1])}else t.error(d.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,f(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:f(e)}}l(Ff,"parsePersona");var qt=class t{static{l(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=xt,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:a,placement:c}of e){let p=Xn(a,a[0]?.path,n);p.scope=c;let m=ni(p,a,c);for(let u of m.types)r.add(u.name);for(let u of m.concepts)r.add(u.name);for(let u of m.imports)o.add(u.qualifiedName);for(let u of m.eventSources??[])i.set(u.name,[...i.get(u.name)??[],u.streams.map(y=>y.name)])}let s=new Set([...o].filter(a=>r.has(a.substring(a.lastIndexOf(".")+1))));return new t(i,s)}};var ce;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(ce||(ce={}));var Ve=class{static{l(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(s=>s.streams).filter(s=>s.name===n),o;return i.length===0?o=this.otherNames.has(e)?ce.WrongKind:ce.NotFound:i.length>1||r.length>1?o=ce.Ambiguous:o=r.length===1?ce.Unique:ce.NotFound,{kind:o,sources:i,streams:r}}};var ue;(function(t){t.Empty="Empty",t.NotNfc="NotNfc",t.LoneSurrogate="LoneSurrogate",t.OutOfRange="OutOfRange",t.NotIntegral="NotIntegral",t.MalformedUuid="MalformedUuid",t.Arity="Arity",t.Escape="Escape",t.Noncanonical="Noncanonical"})(ue||(ue={}));function Ba(t){return t.length===0?{value:null,failure:ue.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:ue.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:ue.NotNfc}:{value:t,failure:null}}l(Ba,"tryFormatText");function Fa(t){if(!/^(?:[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.test(t))return{value:null,failure:ue.MalformedUuid};let e=t.replace(/[{}()-]/g,"").toLowerCase();return{value:`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`,failure:null}}l(Fa,"tryFormatUuidText");function ii(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:ue.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:ue.OutOfRange}:{value:n.toString(),failure:null}}l(ii,"tryFormatInteger");function ri(t){switch(t){case ue.Empty:return"A stream id text literal cannot be empty.";case ue.NotNfc:return"A stream id text literal must be Unicode NFC.";case ue.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case ue.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case ue.NotIntegral:return"A stream id integer must be a finite integral value.";case ue.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case ue.Arity:return"A composite stream id must match the declared part count of at least two.";case ue.Escape:return"A composite stream id permits only %25 and %7C escapes.";case ue.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}l(ri,"streamIdFailureMessage");function Yf(t,e,n){let i=ee(n.types),r=t.properties,o=null,s=!1,a=!1;for(let c of e.split(".")){let p=r.filter(u=>u.name===c);if(p.length!==1)return null;let m=p[0].type;s||=m.isOptional,a||=m.isCollection,o={...m,isOptional:s,isCollection:a},r=i.get(m.name)?.properties??[]}return o}l(Yf,"commandPathType");function oi(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:Ra(t,e,i);return r==="new event source"?t.properties.find(o=>o.isGenerated&&o.isIdentifier)?.type??{kind:"TypeRefSyntax",name:"Uuid",isOptional:!1,isCollection:!1,location:e.location}:r===void 0?null:Yf(t,r,n)}l(oi,"commandDestinationType");function ai(t,e,n,i,r,o,s){if(n){o.error(r,"A composite stream requires a streamId part block, not a scalar mapping.",i);return}let a=t.streamIdParts;for(let p of a.filter(m=>!e.some(u=>u.property===m.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let c=new Set;for(let p of e){let m=a.find(u=>u.name===p.property);m===void 0?o.error(r,`Unknown stream id part '${p.property}'.`,p.location):c.has(p.property)?o.error(r,`Stream id part '${p.property}' is mapped more than once.`,p.location):(c.add(p.property),s(p,m.type))}}l(ai,"validateStreamIdParts");function si(t,e,n){let i=ee(n.concepts),r=ee(n.types),o=new Map([...r].map(([a,c])=>[a,ee(c.properties)]));if(t?.kind!=="LiteralExpressionSyntax"||!Ce(t,e,i,o))return null;let s=i.get(e.name)?.type??e.name;return["String","Uuid","Int"].includes(s)?dn(t,e,n)?.value??null:null}l(si,"formatSpecificationStreamId");function Ya(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Ve(i),o=r.resolve(t.eventSource,t.stream),s=r.resolve(e.eventSource,e.stream);if(o.kind!==ce.Unique||s.kind!==ce.Unique)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let a=s.streams[0],c=l((p,m,u)=>{let y=si(p,u,i),h=si(m,u,i);return y===null||h===null?null:y===h},"compare");if(a.streamIdParts.length>0){if(t.streamId!==null||e.streamId!==null||t.streamIdParts.length!==a.streamIdParts.length||e.streamIdParts.length!==a.streamIdParts.length)return null;let p=a.streamIdParts.map(m=>{let u=t.streamIdParts.filter(h=>h.property===m.name),y=e.streamIdParts.filter(h=>h.property===m.name);return u.length===1&&y.length===1?c(u[0].source,y[0].source,m.type):null});return p.includes(!1)?!1:p.includes(null)?null:!0}return t.streamIdParts.length>0||e.streamIdParts.length>0?null:a.streamId===null?t.streamId===null&&e.streamId===null?!0:null:c(t.streamId?.source,e.streamId?.source,a.streamId)}l(Ya,"matchesSpecificationRoute");function Ua(t,e){let n=Qn(t).resolvedExamples,i=Zn(t);t=i.application;let r=new se(t),o=new Set,s=n.flatMap($=>{if($.kind!=="event")return($.kind==="command"||$.kind==="readmodel")&&($.example.stream!=null||$.example.noStream!=null)&&e.error(d.InvalidSpecificationExampleBody,"only event examples carry routes; a command's route comes from its declaration, and read models have none",($.example.stream??$.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:$.name,values:$.example.values,for:$.example.for,stream:$.example.stream,noStream:$.example.noStream,location:$.example.location};return o.add(P),[{scope:$.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Ve(t),c=ee(t.concepts),p=ee(t.types),m=new Map([...p].map(([$,P])=>[$,ee(P.properties)])),u=l(($,P)=>Ce($,P,c,m),"compatible"),y=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...c.keys(),...p.keys()]),h=l(($,P)=>y.has($.name)&&y.has(P.name)?$.name===P.name&&$.isCollection===P.isCollection&&(!$.isOptional||P.isOptional):null,"nominallyCompatible"),x=l(($,P)=>si($,P,t),"formatStreamId"),v=l(($,P)=>{let A=r.resolve($,P).declaration;return A?.node.kind==="EventSyntax"?A.node:null},"eventOf"),k=[];for(let{slice:$}of r.slices){for(let P of $.commands)for(let A of P.produces){if(!r.isEventProduction(A,$))continue;let g=v(A.event,$);if(g===null)continue;let S=oi(P,A,t,{resolver:r,slice:$});k.push({event:g,command:P,type:S})}for(let P of $.reactions.flatMap(A=>A.triggers).flatMap(A=>A.produces)){let A=v(P.event,$);A!==null&&k.push({event:A,command:null,type:null})}for(let P of $.captures)for(let A of[...P.appends,...P.children.flatMap(g=>g.appends),...P.nested.flatMap(g=>g.appends)]){let g=v(A.event,$);g!==null&&k.push({event:g,command:null,type:null})}}let C=[...s.flatMap($=>r.slices.filter(P=>P.scope.join(".")===$.scope.join(".")).map(({slice:P,scope:A})=>({slice:P,scope:A,specification:$.specification}))),...r.slices.flatMap(({slice:$,scope:P})=>$.specifications.map(A=>({slice:$,scope:P,specification:A})))];for(let{slice:$,scope:P,specification:A}of C){let g=r.slices.flatMap(R=>R.slice.commands.map(N=>({command:N,scope:R.scope}))),S=A.when?.commandType.split(".")??[],E=S.slice(0,-1),b=g.filter(R=>R.command.name===S.at(-1)&&E.every((N,B)=>R.scope[R.scope.length-E.length+B]===N)),O=E.length>0&&b.length===1?b[0].command:null;for(let R=P.length;E.length===0&&R>=0&&O===null;R--){let N=b.filter(B=>P.slice(0,R).every((j,q)=>B.scope[q]===j));if(N.length>0){O=N.length===1?N[0].command:null;break}}let T=[...A.given.map(R=>({node:R,required:!0,expected:!1})),...A.whenAppended===null?[]:[{node:A.whenAppended,required:!0,expected:!1}],...A.thenEvents.map(R=>({node:R,required:!1,expected:!o.has(R)})),...A.whenRedelivered==null?[]:[{node:{...A.whenRedelivered,kind:"SpecificationEventSyntax"},required:!1,expected:!1}]];for(let{node:R,required:N,expected:B}of T){let j=i.specifications.flatMap(U=>U.steps).find(U=>U.effective===R),q=j?.route?.origin!=="example",W=q||R.for!==j?.example?.for,G=l((U,re,de)=>{e.error(U,j?.example==null?re:`${re} Example '${j.example.name}' is used here.`,j?.example==null?de:j.authored.location)},"contextualError");if(R.stream==null&&R.noStream==null)continue;N&&R.noStream!=null&&G(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",R.noStream.location);let Y=null,V=v(R.eventType,$),ae=k.filter(U=>U.event===V);if(R.stream!=null){let U=R.stream,re=a.resolve(U.eventSource,U.stream);if(re.kind!==ce.Unique){let pe={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[re.kind];q&&e.error(d.InvalidSpecificationStreamRoute,`Stream '${U.eventSource}.${U.stream}' is ${pe}; routing requires one physical source and stream.`,U.location);continue}let de=re.sources[0],$e=re.streams[0],ht=l((pe,Se)=>{let I=pe.source,M=dn(I,Se,t);M?.failure!=null?e.error(d.InvalidSpecificationStreamRoute,ri(M.failure),I.location):(I.kind!=="LiteralExpressionSyntax"||I.value===null||Se!==null&&!u(I,Se))&&e.error(d.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",I.location)},"validateLiteral");if(q&&($e.streamIdParts.length>0?ai($e,U.streamIdParts,U.streamId!==null,U.location,d.InvalidSpecificationStreamRoute,e,ht):U.streamIdParts.length>0?e.error(d.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",U.location):($e.streamId===null!=(U.streamId===null)&&e.error(d.InvalidSpecificationStreamRoute,$e.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",U.location),U.streamId!==null&&ht(U.streamId,$e.streamId))),Y=de.identifier,Y===null){let pe=ae.map(I=>I.type),Se=new Set(pe.filter(I=>I!==null).map(I=>`${I.name}:${I.isOptional}:${I.isCollection}`));pe.length===0||pe.some(I=>I===null)||Se.size!==1?q&&e.error(d.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${de.name}'; the event's producers do not supply one unambiguous destination type.`,U.location):Y=pe[0]}let St=!1;if(j?.example?.stream!=null&&R.for!==null&&R.for===j.example.for){let pe=a.resolve(j.example.stream.eventSource,j.example.stream.stream);if(pe.kind===ce.Unique){let Se=ae.map(L=>L.type),I=new Set(Se.filter(L=>L!==null).map(L=>`${L.name}:${L.isOptional}:${L.isCollection}`)),M=pe.sources[0].identifier??(Se.length>0&&!Se.some(L=>L===null)&&I.size===1?Se[0]:null);M!==null&&(St=R.for.kind!=="LiteralExpressionSyntax"||R.for.value===null||M.isCollection||M.isOptional||!u(R.for,M))}}N&&R.for===null?G(d.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",U.location):W&&!St&&R.for!==null&&(R.for.kind!=="LiteralExpressionSyntax"||R.for.value===null||Y!==null&&(Y.isCollection||Y.isOptional||!u(R.for,Y)))&&G(d.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",R.for.location)}if(!B||O===null||ae.length===0||ae.some(U=>U.command!==O))continue;let xe=O.stream?.propertyCandidate===null?O.stream:null,Pe=R.noStream!=null?xe!=null:xe==null||xe.eventSource!==R.stream.eventSource||xe.stream!==R.stream.stream;if(!Pe&&R.stream!=null&&xe!=null){let U=a.resolve(R.stream.eventSource,R.stream.stream),re=U.kind===ce.Unique?U.streams[0]:null;if(re!==null&&re.streamIdParts.length>0){if(xe.streamId===null&&R.stream.streamId===null&&xe.streamIdParts.length>0&&R.stream.streamIdParts.length>0)for(let de of re.streamIdParts){let $e=xe.streamIdParts.filter(Se=>Se.property===de.name),ht=R.stream.streamIdParts.filter(Se=>Se.property===de.name);if($e.length!==1||ht.length!==1)continue;let St=x($e[0].source,de.type),pe=x(ht[0].source,de.type);St!==null&&pe!==null&&St!==pe&&(Pe=!0)}}else if(re?.streamId!=null&&xe.streamIdParts.length===0&&R.stream.streamIdParts.length===0){let de=x(xe.streamId?.source,re.streamId),$e=x(R.stream.streamId?.source,re.streamId);de!==null&&$e!==null&&de!==$e&&(Pe=!0)}}R.for?.kind==="LiteralExpressionSyntax"&&ae.every(U=>U.type!==null&&(Y!==null?h(U.type,Y)===!1:!u(R.for,U.type)))&&(Pe=!0),Pe&&G(d.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(R.stream??R.noStream).location)}}}l(Ua,"validateSpecificationStreams");var li=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function dn(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:ee(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?Fa(i):Ba(i):typeof i=="number"?ii(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?ii(NaN):ii(BigInt(i.value),!1):null}l(dn,"formatStreamIdLiteral");function ci(t,e){let n=ee(t.concepts),i=ee(t.types),r=new Set([...li,...n.keys(),...i.keys()]),o=new Map([...i].map(([y,h])=>[y,ee(h.properties)])),s=l((y,h)=>r.has(y.name)&&r.has(h.name)?y.name===h.name&&y.isCollection===h.isCollection&&(!y.isOptional||h.isOptional):null,"compatible"),a=l((y,h)=>{if(y===null)return;if(y.isOptional||y.isCollection||t.types.some(k=>k.name===y.name)){e.error(d.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",y.location);return}let x=t.concepts.filter(k=>k.name===y.name),v=x.length===1?x[0].type:x.length===0&&li.has(y.name)?y.name:null;h&&v!==null&&(!["String","Uuid","Int"].includes(v)||v==="Int"&&x.length===0||x.some(k=>k.values.length>0))&&e.error(d.UnsupportedStreamIdType,"Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.",y.location),v===null&&!t.imports.some(k=>k.qualifiedName===y.name||k.qualifiedName.split(".").at(-1)===y.name)&&e.warning(d.UnknownType,`Unknown type '${y.name}' in event source declaration.`,y.location)},"validateType"),c=new Set;for(let y of t.eventSources??[]){c.has(y.name)&&e.error(d.InvalidEventSourceDeclaration,`Event source '${y.name}' has multiple physical declarations.`,y.location),c.add(y.name),a(y.identifier,!1);let h=new Set;for(let x of y.streams){h.has(x.name)&&e.error(d.InvalidEventSourceDeclaration,`Stream '${y.name}.${x.name}' has multiple declarations under this source.`,x.location),h.add(x.name),a(x.streamId,!0);let v=x.streamIdParts;if(v.length>0){v.length<2&&e.error(d.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",x.directiveLocations?.streamId??x.location);for(let k of new Set(v.map(C=>C.name)))for(let C of v.filter($=>$.name===k).slice(1))e.error(d.InvalidEventSourceDeclaration,`Stream id part '${C.name}' is declared more than once.`,C.location);for(let k of v)a(k.type,!0)}}}let p=l((y,h)=>{let[x,...v]=h.split(".");if(y===null)return{property:null,missing:!1};let k=y.filter(P=>P.name===x);if(k.length!==1)return{property:null,missing:k.length===0};let C=k[0];if(v.length===0)return{property:C,missing:!1};if(li.has(C.type.name)||n.has(C.type.name)&&!i.has(C.type.name))return{property:null,missing:!0};let $=p(i.get(C.type.name)?.properties??null,v.join("."));return $.property===null?$:{property:{...$.property,type:{...$.property.type,isCollection:C.type.isCollection||$.property.type.isCollection,isOptional:C.type.isOptional||$.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Ve(t),u=new se(t);for(let{slice:y}of u.slices)for(let h of y.commands){let x=h.stream;if(x==null||x.propertyCandidate!==null)continue;let v=m.resolve(x.eventSource,x.stream);if(v.kind!==ce.Unique){let A={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[v.kind];e.error(d.InvalidCommandStream,`Stream '${x.eventSource}.${x.stream}' is ${A}; routing requires one physical source and stream.`,x.location);continue}let k=v.sources[0],C=v.streams[0],$=h.properties.filter(A=>A.isIdentifier);k.identifier!==null&&$.length===1&&s($[0].type,k.identifier)===!1&&e.error(d.InvalidCommandStream,`Command identifier '${$[0].name}' does not have the source's nominal identifier type '${k.identifier.name}'. The stream does not supply a destination.`,$[0].location);for(let A of h.produces.filter(g=>u.isEventProduction(g,y))){if(k.identifier===null)continue;let g=oi(h,A,t,{resolver:u,slice:y});if(g===null||A.for===null&&A.inlineEvent!==null&&$.length===1&&s($[0].type,k.identifier)===!1)continue;let S=A.for===null&&A.inlineEvent===null&&!h.properties.some(O=>O.isGenerated&&O.isIdentifier),E=n.get(k.identifier.name)?.type??(li.has(k.identifier.name)?k.identifier.name:null);(S?E===null?null:E==="Uuid":s(g,k.identifier))===!1&&e.error(d.InvalidCommandStream,`Command production destination does not have the source's nominal identifier type '${k.identifier.name}'. The stream does not supply a destination.`,A.for?.location??A.location)}let P=l((A,g)=>{let S=A.source;if(S.kind==="PathExpressionSyntax"){let E=p(h.properties,S.path);(E.missing||E.property!==null&&s(E.property.type,g)===!1)&&e.error(d.InvalidCommandStream,`Stream id source '${S.path}' is absent or incompatible with nominal type '${g.name}'.`,S.location)}else if(S.kind==="LiteralExpressionSyntax"&&S.value!==null){let E=dn(S,g,t);E?.failure!=null?e.error(d.InvalidCommandStream,ri(E.failure),S.location):Ce(S,g,n,o)||e.error(d.InvalidCommandStream,`Stream id value is incompatible with nominal type '${g.name}'.`,S.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(S.kind)||S.kind==="LiteralExpressionSyntax"&&S.value===null)&&e.error(d.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",S.location)},"validateMapping");if(C.streamIdParts.length>0){ai(C,x.streamIdParts,x.streamId!==null,x.location,d.InvalidCommandStream,e,P);continue}if(x.streamIdParts.length>0){e.error(d.InvalidCommandStream,"A streamId part block requires a composite stream.",x.location);continue}(C.streamId===null&&x.streamId!==null||C.streamId!==null&&x.streamId===null)&&e.error(d.InvalidCommandStream,C.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",x.location),!(C.streamId===null||x.streamId===null)&&P(x.streamId,C.streamId)}Ua(t,e)}l(ci,"validateEventSources");function di(t,e){let n=new se(t),i=n.slices,r=new Set(t.imports.map(v=>v.qualifiedName)),o=new Set([...i.flatMap(({slice:v})=>le(v).map(k=>k.name)),...t.imports.map(v=>v.qualifiedName.split(".").at(-1))]),s=ee(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(v=>v.name)].filter(v=>!s.has(v))),c=l((v,k)=>{let[C,...$]=k.split(".");if(v===null)return{value:null,missing:!1};let P=v.filter(g=>g.name===C);if(P.length!==1)return{value:null,missing:P.length===0};let A=P[0];return $.length===0?{value:A,missing:!1}:a.has(A.type.name)?{value:null,missing:!0}:c(s.get(A.type.name)?.properties??null,$.join("."))},"property"),p=i.flatMap(({slice:v,scope:k})=>v.readModels.map(C=>({node:C,scope:k}))),m=l((v,k)=>{let C=l(A=>{let g=A.split("."),S=p.filter(b=>b.node.name===g.at(-1)),E=g.slice(0,-1);if(E.length>0)return S.filter(b=>E.length<=b.scope.length&&E.every((O,T)=>b.scope[b.scope.length-E.length+T]===O));for(let b=k.length;b>=0;b--){let O=S.filter(T=>b<=T.scope.length&&k.slice(0,b).every((R,N)=>T.scope[N]===R));if(O.length>0)return O}return[]},"candidates"),$=C(v),P=t.imports.filter(A=>A.qualifiedName.split(".").at(-1)===v);return $.length===0&&P.length===1&&($=C(P[0].qualifiedName)),$.length===1?$[0].node.properties:null},"viewProperties"),u=l((v,k,C)=>{let $=n.resolve(v,C);o.has(v)||r.has(v)||$.declaration?.kind===ne.Event||$.candidates.some(A=>A.kind===ne.Event)||e.warning(d.UnknownEvent,`Unknown event '${v}' - declare it with 'event ${v}'`,k)},"unknownEvent"),y=l((v,k)=>{for(let C of v)(C.kind==="RemoveWithSyntax"||C.kind==="RemoveViaJoinSyntax")&&u(C.event,C.location,k),"blocks"in C&&y(C.blocks,k)},"removals"),h=new Set,x=l((v,k,C=!1,$=!1)=>{let P=l((g,S)=>{let E=c(k,g),b=JSON.stringify([S.path,S.line,S.column]);return E.missing&&!h.has(b)&&(h.add(b),e.warning(d.UnknownReadModelProperty,`Projection target '${g}' is not a declared ${C?"element":"read-model"} property`,S)),E.value},"validate"),A=$||v.some(g=>g.kind==="FromSyntax"||g.kind==="JoinSyntax"||g.kind==="AllSyntax");for(let g of v){let S=g.kind==="EverySyntax"&&!A?[]:"mappings"in g?g.mappings:g.kind==="JoinSyntax"?g.events.flatMap(E=>E.mappings):[];for(let E of S)P(E.property,E.location);if(g.kind==="ChildrenSyntax"||g.kind==="NestedSyntax"){let E=P(g.property,g.location);x(g.blocks,E===null?null:s.get(E.type.name)?.properties??null,!0)}}},"walk");for(let{slice:v}of i){for(let k of v.projections)y(k.blocks,v);for(let k of v.captures)for(let C of[...k.appends,...k.children.flatMap($=>$.appends),...k.nested.flatMap($=>$.appends)])u(C.event,C.location,v)}for(let{slice:v,scope:k}of i)for(let C of v.projections){let $=C.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");$.length===0&&x(C.blocks,m(C.readModel??C.name,k));for(let P of $){let A=m(P.name,k);x(C.blocks.filter(S=>S.kind==="ChildrenSyntax"||S.kind==="NestedSyntax"),A);let g=P.entersOn.length>0||C.blocks.some(S=>S.kind==="FromSyntax"||S.kind==="JoinSyntax"||S.kind==="AllSyntax");x(P.blocks,A,!1,g)}}}l(di,"validateProjectionTargets");function pi(t,e){let n=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="pii")).map(u=>u.name)),i=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="sensitive")).map(u=>u.name)),r=ee(t.types),o=new se(t),s=new Set(t.imports.map(u=>u.qualifiedName.split(".").at(-1))),a=new Map;for(let u of t.declaredTriggers??[]){let y=a.get(u.name)??[];y.push(u.data),a.set(u.name,y)}let c=l((u,y,h="an event source identifier")=>{if(n.has(u.name)||i.has(u.name)){let x=n.has(u.name)?"@pii":"@sensitive";e.error(d.PiiNotSupportedOnIdentifier,`Concept '${u.name}' is ${x} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${x} value as a property`,y)}},"validate"),p=l((u,y)=>{let[h,...x]=y.split("."),v=u.filter(C=>C.name===h);if(v.length!==1)return null;let k=v[0];return x.length===0?k:p(r.get(k.type.name)?.properties??[],x.join("."))},"property");for(let u of t.eventSources??[]){u.identifier!=null&&c(u.identifier,u.identifier.location);for(let y of u.streams){y.streamId!==null&&c(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)c(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Ve(t);for(let{slice:u}of o.slices){for(let y of u.commands){for(let h of y.properties.filter(x=>x.isIdentifier))c(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter(x=>x.propertyCandidate===null)){let x=m.resolve(h.eventSource,h.stream),v=x.kind===ce.Unique?x.streams[0]:void 0,k=[...h.streamId===null?[]:[{mapping:h.streamId,target:v?.streamId}],...h.streamIdParts.map(C=>({mapping:C,target:v?.streamIdParts.find($=>$.name===C.property)?.type}))];for(let{mapping:C,target:$}of k){if(C.source.kind!=="PathExpressionSyntax")continue;let P=p(y.properties,C.source.path);P!==null&&(P.type.name===$?.name&&(n.has(P.type.name)||i.has(P.type.name))||c(P.type,C.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter(x=>o.isEventProduction(x,u))){if(h.for?.kind!=="PathExpressionSyntax")continue;let x=p(y.properties,h.for.path);x!==null&&!x.isIdentifier&&c(x.type,h.for.location)}}for(let y of u.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let x=o.resolve(y.source.name,u).declaration?.node,v=(qe(y).data??[]).flatMap(C=>C.type===null?[]:[{kind:"PropertySyntax",name:C.name,type:C.type,isIdentifier:!1,location:C.location}]),k=[x?.kind==="EventSyntax"?x.properties:[],v];x?.kind!=="EventSyntax"&&!s.has(y.source.name)&&k.push(...a.get(y.source.name)??[]);for(let C of y.produces.filter($=>o.isEventProduction($,u))){if(C.for?.kind!=="PathExpressionSyntax")continue;let $=C.for.path,P=k.map(A=>p(A,$)).find(A=>A!==null&&(n.has(A.type.name)||i.has(A.type.name)));P!=null&&c(P.type,C.for.location)}}}}l(pi,"validateIdentifierCompliance");var Wa=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),ft=class{static{l(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new se(e).slices,this.types=ee(e.types),this.concepts=ee(e.concepts),this.knownTypes=new Set([...Wa,...e.types.map(n=>n.name),...e.concepts.map(n=>n.name)]),this.events=new Map(this.slices.map(({slice:n})=>{let i=new Map;for(let r of le(n))(!i.has(r.name)||i.get(r.name).generation<r.generation)&&i.set(r.name,r);return[n,[...i.values()]]}))}resolve(e,n,i){let r=this.slices.flatMap(({slice:c,scope:p})=>i(c).map(m=>({node:m,slice:c,scope:p}))),o=this.slices.find(c=>c.slice===n)?.scope??[],s=l(c=>{let p=c.split("."),m=r.filter(y=>y.node.name===p.at(-1)),u=p.slice(0,-1);if(u.length>0)return m.filter(y=>u.length<=y.scope.length&&u.every((h,x)=>y.scope[y.scope.length-u.length+x]===h));for(let y=o.length;y>=0;y--){let h=m.filter(x=>y<=x.scope.length&&o.slice(0,y).every((v,k)=>x.scope[k]===v));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let c=this.application.imports.filter(p=>p.qualifiedName.split(".").at(-1)===e);c.length===1&&(a=s(c[0].qualifiedName))}return a.length===1?a[0]:null}event(e,n){return this.resolve(e,n,i=>this.events.get(i)??[])?.node??null}property(e,n){let i=n.split(".");for(let[r,o]of i.entries()){let s=e?.filter(c=>c.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(Wa.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(c=>c.name===a.type.name))return null;e=this.types.get(a.type.name)?.properties??null}return null}compatible(e,n){return this.knownTypes.has(e.name)&&this.knownTypes.has(n.name)?e.name===n.name&&e.isCollection===n.isCollection&&(!e.isOptional||n.isOptional):null}};var fi=class extends pt{static{l(this,"RefusalValueWalker")}declarations;context;slice=null;branch=null;properties=null;target=null;mapping=!1;constructor(e,n){super(),this.declarations=e,this.context=n}visitSlice(e){this.slice=e,super.visitSlice(e),this.slice=null}visitInvocationRefusal(e){this.branch=e,super.visitInvocationRefusal(e),this.branch=null}visitProduces(e){if(this.branch===null||this.slice===null){super.visitProduces(e);return}this.visitNode(e),e.for!==null&&this.visitExpression(e.for),e.when!=null&&this.visitCondition(e.when),e.tags.forEach(n=>this.visitTag(n)),this.properties=this.declarations.event(e.event,this.slice)?.properties??null,e.mappings.forEach(n=>this.visitPropertyMapping(n)),this.properties=null}visitPropertyMapping(e){this.mapping=this.branch!==null,this.target=this.declarations.property(this.properties,e.property)?.type??null,super.visitPropertyMapping(e),this.target=null,this.mapping=!1}visitObjectMember(e){let n=this.target;this.target=this.declarations.property(n===null?null:this.declarations.types.get(n.name)?.properties??null,e.name)?.type??null,super.visitObjectMember(e),this.target=n}visitExpression(e){e.kind==="RefusalExpressionSyntax"&&(!this.mapping||this.branch===null||!["reason","constraint","message"].includes(e.member)||e.member==="constraint"&&this.branch.selector!=="constraint"?this.context.error(d.InvalidRefusalValue,`'$refusal.${e.member}' is only available in a refusal branch's event mapping; constraint requires 'by constraint'.`,e.location):this.target!==null&&(this.target.isCollection||this.declarations.compatible({...this.target,name:"String",isOptional:!1,isCollection:!1},this.target)===!1&&!this.declarations.application.concepts.some(i=>i.name===this.target.name&&i.type==="String"))&&this.context.error(d.InvalidRefusalValue,`'$refusal.${e.member}' is a String value, incompatible with '${this.target.name}'.`,e.location));let n=this.target;e.kind==="ListExpressionSyntax"&&n!==null&&(this.target={...n,isCollection:!1}),super.visitExpression(e),this.target=n}};function Uf(){return!0}l(Uf,"invocationHasNoDeclaredIdentity");function Wf(t){let e=new Set,n=l((i,r)=>{let o=r||i.authorize!==null;o&&i.slices.forEach(s=>e.add(s)),i.features.forEach(s=>n(s,o))},"collect");return t.modules.forEach(i=>i.features.forEach(r=>n(r,i.authorize!==null))),e}l(Wf,"authorizationGatedSlices");function ui(t,e){let n=new ft($t(t));new fi(n,e).visitApplication(n.application);let i=Wf(n.application);for(let{slice:r}of n.slices){let o=l(c=>n.resolve(c,r,p=>p.constraints),"constraintOf"),s=l((c,p)=>c===p||o(c)!==null&&o(c)?.node===o(p)?.node,"sameConstraint"),a=l((c,p)=>c.selector==="any"&&["any","validation","constraint"].includes(p.selector)||c.selector===p.selector&&(c.selector!=="constraint"||c.constraint===null||p.constraint!==null&&s(c.constraint,p.constraint)),"covers");for(let c of r.reactions.flatMap(p=>p.triggers).flatMap(p=>p.invokes)){let p=n.resolve(c.command,r,y=>y.commands),m=p!==null&&(p.node.authorize!==null||i.has(p.slice)),u=[];for(let y of c.onRefused??[]){if(u.some(C=>a(C,y))&&e.warning(d.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",y.location),u.push(y),y.selector==="authorization"&&Uf()&&m&&e.warning(d.AuthorizationRefusalWithoutIdentity,`Command '${c.command}' is authorization-gated, but this invocation has no declared identity. This authorization refusal branch always fires in the reference runner because there is no caller; Arc runs reactor commands as the system. Declare an invoking identity once supported (#383).`,y.location),y.constraint===null)continue;let h=o(y.constraint);if(h===null){e.error(d.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${y.constraint}'.`,y.location);continue}if(p===null||p.node.handler!==null)continue;let x=[h.node,...h.node.additionalRules];if(x.some(C=>C.kind==="FileConstraintSyntax"))continue;let v=x.map(C=>C.kind==="FileConstraintSyntax"?null:n.event(C.event,h.slice)),k=p.node.produces.map(C=>n.event(C.event,p.slice));v.every(C=>C!==null)&&k.every(C=>C!==null)&&!v.some(C=>k.includes(C))&&e.warning(d.UnreachableRefusalBranch,`Constraint '${y.constraint}' targets none of the events produced by '${c.command}'.`,y.location)}}}}l(ui,"validateReactionRefusals");function mi(t,e,n){let i=e===null||e.isCollection?void 0:n.concepts.get(e.name),r=i!==void 0&&i.type==="Enum"?i:null,o=l(a=>r!==null&&a.startsWith(`${r.name}.`)?a.substring(r.name.length+1):a,"member");if(e?.isCollection&&t.kind==="ListExpressionSyntax"&&n.compatible({...e,isCollection:!1},{...e,isCollection:!1})===!0){let a=t.items.map(c=>mi(c,{...e,isCollection:!1,isOptional:!1},n));return a.some(c=>c===void 0)?void 0:{canonical:`[${a.map(yi).join(",")}]`}}let s=e===null?void 0:n.types.get(e.name)?.properties;if(e!==null&&!e.isCollection&&t.kind==="ObjectExpressionSyntax"&&s!==void 0){let a=t.members.map(c=>{let p=n.property(s,c.name);return{name:c.name,value:p===null?void 0:mi(c.value,p.type,n)}});return a.some(c=>c.value===void 0)?void 0:{canonical:`{${a.sort((c,p)=>c.name<p.name?-1:c.name>p.name?1:0).map(c=>`${JSON.stringify(c.name)}:${yi(c.value)}`).join(",")}}`}}if(t.kind==="LiteralExpressionSyntax")return r!==null&&typeof t.value=="string"?o(t.value):t.value;if(t.kind==="PathExpressionSyntax"&&r!==null)return o(t.path)}l(mi,"redeliveryValue");function yi(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:wr(t):JSON.stringify(t)}l(yi,"canonical");function Tr(t,e,n,i){let r=mi(t,n,i),o=mi(e,n,i);return r===void 0||o===void 0?null:yi(r)===yi(o)}l(Tr,"sameRedeliveryValue");function hi(t,e){t=$t(t);let n=new ft(t);for(let{slice:i}of n.slices)for(let r of i.specifications){let o=r.whenRedelivered;if(o==null)continue;let s=n.event(o.eventType,i),a=n.resolve(o.reaction,i,m=>m.reactions);if(a===null||s===null||!a.node.triggers.some(m=>m.source.kind==="NamedTriggerSourceSyntax"&&n.event(m.source.name,a.slice)===s)){e.error(d.UnknownRedeliveryReaction,`Reaction '${o.reaction}' must resolve unambiguously and observe event '${o.eventType}'.`,o.location);continue}let c=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>zf(m,o,s,n,t)),p=c.filter(m=>m===!0).length;c.some(m=>m===null)?e.error(d.UnmatchedRedeliveredOccurrence,`Cannot locate redelivery of '${o.eventType}' uniquely: a given source or locator value is not decidable; use 'for', values, 'stream' or 'no stream'.`,o.location):p!==1&&e.error(d.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${p} given occurrences; use 'for', values, 'stream' or 'no stream' to identify exactly one.`,o.location)}}l(hi,"validateSpecificationRedelivery");function zf(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:Tr(e.for,t.for,null,i));for(let s of e.values){let a=t.values.filter(c=>c.property===s.property);o.push(a.length===1?Tr(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(Ya(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}l(zf,"matches");var za=64;function Va(t,e){let n=[];for(let i of t.alternatives){let r=Rr(i.condition);r!==null&&(r.length>0&&r.every(o=>n.some(s=>[...s].every(a=>o.has(a))))&&e.warning(d.UnreachableActionAlternative,`Alternative executing '${i.command}' is shadowed by earlier alternatives in this action`,i.location),n.push(...r))}}l(Va,"validateGuardedActionShadowing");function Rr(t){if(t.kind==="ComparisonConditionSyntax"){if(t.right.kind!=="LiteralExpressionSyntax")return null;let i=t.right.value,r=JSON.stringify([t.left,t.operator,typeof i,i!==null&&typeof i=="object"?i.value:typeof i=="number"?String(i):i]);return[new Set([r])]}let e=Rr(t.left),n=Rr(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>za?null:[...e,...n]:e.length*n.length>za?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}l(Rr,"normalize");var Vf=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Si(t,e){let n=new ft(t);for(let{slice:i}of n.slices)for(let r of i.screens)Dr(r.directives,[],i,n,e)}l(Si,"validateGuardedActions");function Dr(t,e,n,i,r){let o=t.filter(a=>a.kind==="ScreenDataSyntax"),s=o.length===0?e:o;for(let a of t)switch(a.kind){case"ScreenGuardedActionSyntax":Qf(a,s,n,i,r);break;case"ScreenSectionSyntax":Dr(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let c of a.slots)Dr(c.directives,s,n,i,r);break}}l(Dr,"validateContainer");function Ga(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}l(Ga,"viewProperties");function Qf(t,e,n,i,r){let o=e.length===1?Ga(e[0].type.name,n,i):null;e.length!==1&&r.warning(d.UnresolvedActionSubject,"A guarded action requires exactly one nearest 'data' subject; no data or equally near data bindings leave 'item' unresolved",t.location);for(let s of t.alternatives){for(let a of Mr(s.condition))Za(a.left,a.location,o,n,i,r);Qa(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&Qa(t.otherwise.command,t.otherwise.arguments,o,n,i,r),Va(t,r)}l(Qf,"validateAction");function Qa(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let c=s?.properties.filter(m=>m.name===a.name);c?.length===0&&o.warning(d.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=Za(a.binding,a.location,n,i,r,o,!0);c?.length===1&&p!==null&&c[0].type.isCollection!==p.type.isCollection&&o.warning(d.UnknownActionArgumentProperty,`Command argument '${t}.${a.name}' and subject field '${a.binding}' must have matching collection cardinality`,a.location)}}l(Qa,"validateArguments");function Za(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[c,p]of a.entries()){let m=n.filter(y=>y.name===p);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||c<a.length-1))return o.warning(d.UnknownActionSubjectField,`Unknown or collection-valued subject field '${t}' - guarded actions require an item field path`,e),null;if(m.length!==1)return null;if(c===a.length-1)return m[0];let u=m[0].type;if(n=r.types.get(u.name)?.properties??Ga(u.name,i,r),n===null)return(Vf.has(u.name)||r.application.concepts.some(y=>y.name===u.name)&&!r.application.types.some(y=>y.name===u.name))&&o.warning(d.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}l(Za,"validateItemPath");function Mr(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...Mr(t.left),...Mr(t.right)]}l(Mr,"comparisons");function kt(t){return Array.from(t,e=>{if(e==="\u0131"||e==="\u017F")return e;let n=e.codePointAt(0);if(n>=8064&&n<=8071||n>=8080&&n<=8087||n>=8096&&n<=8103)return String.fromCodePoint(n+8);if(n===8115)return"\u1FBC";if(n===8131)return"\u1FCC";if(n===8179)return"\u1FFC";let i=e.toUpperCase();return Array.from(i).length===1?i:e}).join("")}l(kt,"ordinalIgnoreCaseKey");function Nr(t){let e=sn(t),n=l((h,x)=>h.map(v=>({syntax:v,rank:e.get(Be([...x,v.name]))??Number.MAX_SAFE_INTEGER})).sort((v,k)=>v.rank-k.rank).map(v=>v.syntax),"ordered"),i=[],r=l((h,x)=>{let v=[...x,h.name];for(let k of n(h.slices,v))i.push({syntax:k,scope:[...v,k.name],identity:[...v.map(C=>`container:${C}`),`slice:${k.name}`],index:i.length});for(let k of n(h.features,v))r(k,v)},"feature");for(let h of n(t.modules,[]))for(let x of n(h.features,[h.name]))r(x,[h.name]);let o=new Map(i.map(h=>[h,new Set([...le(h.syntax).map(x=>kt(x.name)),...h.syntax.commands.flatMap(x=>x.produces.map(v=>kt(v.event))),...h.syntax.reactions.flatMap(x=>x.triggers.flatMap(v=>v.produces.map(k=>kt(k.event))))])])),s=new Map;for(let h of i)for(let x of le(h.syntax)){let v=kt(x.name);s.has(v)||s.set(v,h)}let a=new Map;for(let h of i){let x=Be(h.scope);a.has(x)||a.set(x,h)}let c=new Map;for(let h of Nt.for(t,e).edges.filter(x=>x.kind==="decidesFrom"))for(let x of h.evidence){let v=Be([...h.consumer.scope,x.name.toLowerCase()]);c.has(v)||c.set(v,a.get(Be(h.producer.scope)))}let p=[];for(let h of i){let x=new Set,v=_n(h.syntax).references.filter(k=>k.timeline).map(k=>({event:k.name,location:k.location,readModel:k.targetKind==="ReadModel"}));for(let k of v){let C=kt(k.event),$=`${k.readModel?"ReadModel":"Event"}:${C}`;if(x.has($))continue;x.add($);let P=k.readModel?c.get(Be([...h.scope,k.event.toLowerCase()])):s.get(C);if(P===void 0||P===h)continue;let A=0;for(;A<h.scope.length&&A<P.scope.length&&h.identity[A]===P.identity[A];)A++;if(!(A===h.scope.length||A===P.scope.length)){if(k.readModel){let g=h.identity.slice(0,A+1),S=new Set(i.filter(E=>g.every((b,O)=>E.identity[O]===b)).flatMap(E=>[...o.get(E)]));if(ba(P.syntax,k.event).some(E=>E.timeline&&E.kind==="usesFactsFrom"&&E.targetKind==="Event"&&S.has(kt(E.name))))continue}p.push({...k,consumer:h,producer:P,container:Be(h.identity.slice(0,A)),left:h.identity[A],right:P.identity[A]})}}}let m=l((h,x)=>h.consumer.index-x.consumer.index||h.location.line-x.location.line||h.location.column-x.location.column,"compare"),u=new Set,y=[];for(let h of new Set(p.map(x=>x.container))){let x=p.filter(k=>k.container===h),v=new Map;for(let k of x)v.has(k.left)||v.set(k.left,new Set),v.has(k.right)||v.set(k.right,new Set),v.get(k.left).add(k.right);for(let k of ln(v).filter(C=>C.length>1)){let C=new Set(k),$=x.filter(g=>C.has(g.left)&&C.has(g.right));$.forEach(g=>u.add(g));let P=$.filter(g=>g.consumer.index<g.producer.index).sort(m)[0];if(P===void 0)continue;let A=l(g=>Math.min(...$.flatMap(S=>[S.consumer,S.producer]).filter(S=>{let E=JSON.parse(h);return S.identity[E.length]===g}).map(S=>S.index)),"memberIndex");k.sort((g,S)=>A(g)-A(S)),y.push({edge:P,diagnostic:{severity:"information",code:d.TimelineCycleGroup,message:`Timeline group ${k.map(g=>`${g.startsWith("slice:")?"slice":h===Be([])?"module":"feature"} '${g.slice(g.indexOf(":")+1)}'`).join(", ")} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:P.location}})}}for(let h of p){if(h.consumer.index>=h.producer.index||u.has(h))continue;let x=h.consumer.scope.slice(0,-1),k=h.producer.scope.length>h.consumer.scope.length&&x.every(($,P)=>h.producer.scope[P]===$)?" The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.":" Consider drawing the producer before the consumer.",C=h.readModel?`reads read model '${h.event}' built by`:`uses event '${h.event}' produced by`;y.push({edge:h,diagnostic:{severity:"information",code:d.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${C} slice '${h.producer.syntax.name}' drawn after it.${k}`,location:h.location}})}return y.sort((h,x)=>m(h.edge,x.edge)).map(h=>h.diagnostic)}l(Nr,"timelineOrderDiagnostics");function Xe(t,e,n=xt,i=!0,r,o){let s=Et(t,!1,e),a=Xn(s,e,o);a.scope=n,a.streamCandidates=r??qt.capture([s],n,o);let c=ni(a,s,n);if(i){ei(c,a),$n(c,a),ti(c,a),Jn(c,a),ci(c,a),di(c,a),pi(c,a),ui(c,a),hi(c,a),Si(c,a),c=bn(c,a),Lt.validate(c,a);for(let p of vn(c))a.information(p.code,p.message,p.location);for(let p of Nr(c))a.information(p.code,p.message,p.location)}return{value:c,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(p=>p.severity==="error")}}l(Xe,"parseForAuthoring");function NC(t){return t===d.LegacyOptionalSuffix||t===d.RedundantEventId}l(NC,"isQuickFixDiagnostic");function jr(t,e){return e.code!==d.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}l(jr,"legacyOptionalTypeLength");function jC(t,e={}){let n=Xe(t,void 0,e.placement);if(!n.success)return()=>[];let i=Et(t),r=new Map;new class extends pt{visitEvent(C){r.set(C.location.line,C)}}().visitApplication(n.value);let s=new Map,a=new Map,c=new Map,p;for(let C of i)p=r.get(C.number)??p,p!==void 0&&c.set(C.number,p);for(let C of n.diagnostics){s.set(C.code,(s.get(C.code)??0)+1);let $=i[C.location.line-1],P=jr($.raw,C);if(P>0)a.set($.number,{line:$.number,fix:{diagnosticCode:C.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:$.startOffset+C.location.column+P-2,length:1,text:" optional"}]}});else if(C.code===d.RedundantEventId&&Vt($.raw)<0){let A=c.get($.number);if(A?.id!==A?.name||A===void 0)continue;a.set($.number,{line:$.number,fix:{diagnosticCode:C.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:$.startOffset,length:(i[$.number]?.startOffset??t.length)-$.startOffset,text:""}]},change:{node:A,replacement:{...A,id:null}}})}}let m=[...a.values()].filter(C=>C.fix.diagnosticCode===d.LegacyOptionalSuffix),u=pn(n),y=new Map,h,x=!1,v,k=l((C,$)=>{let P=Ka(t,C.edits);if(P===void 0)return;let A=Xe(P,void 0,e.placement);if(!(!A.success||pn(A)!==($===void 0?u:pn(n,[$]))))return A.diagnostics.filter(g=>g.code===C.diagnosticCode).length===(s.get(C.diagnosticCode)??0)-C.edits.length?C:void 0},"verify");return(C,$)=>{let P=typeof C=="number"||C===void 0?void 0:C,A=P===void 0?$===void 0||$===d.LegacyOptionalSuffix:P.some(b=>b.diagnosticCode===d.LegacyOptionalSuffix);if(A&&!x&&(m.length>0&&(v=k({diagnosticCode:d.LegacyOptionalSuffix,title:"Use 'optional' throughout this document",scope:"document",edits:m.flatMap(b=>b.fix.edits)})),x=!0),P!==void 0){if(h===void 0){h=new Map;let O=i.flatMap(N=>a.has(N.number)?[a.get(N.number)]:[]),T=O.flatMap(N=>N.fix.edits),R=Ka(t,T);if(T.length>0&&R!==void 0){let N=Xe(R,void 0,e.placement),B=O.flatMap(j=>j.change===void 0?[]:[j.change]);if(N.success&&pn(N)===pn(n,B)){let j=new Map,q=new Map;for(let W of N.diagnostics)j.set(W.code,(j.get(W.code)??0)+1);for(let W of O)q.set(W.fix.diagnosticCode,(q.get(W.fix.diagnosticCode)??0)+W.fix.edits.length);if([...q].every(([W,G])=>(j.get(W)??0)===(s.get(W)??0)-G))for(let W of O)h.set(W.line,W.fix)}}}let b=new Map;for(let O of P){let T=h.get(O.line);T?.diagnosticCode===O.diagnosticCode&&b.set(O.line,T)}return[...b.values(),...A&&v!==void 0?[v]:[]]}let g=typeof C=="number"?C:void 0,S=g===void 0?void 0:a.get(g),E;return S!==void 0&&g!==void 0&&($===void 0||S.fix.diagnosticCode===$)&&(y.has(g)||(y.size===32&&y.delete(y.keys().next().value),y.set(g,k(S.fix,S.change))),E=y.get(g)),[E,A?v:void 0].filter(b=>b!==void 0)}}l(jC,"prepareQuickFixes");function pn(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)}l(pn,"verificationShape");function Ka(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("")}l(Ka,"applyQuickFixEdits");var Bt=class{static{l(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(p=>p.source.streams).filter(p=>p.name===n),o=i.length>1||r.length>1,s=!this.complete||i.some(p=>!p.placementResolved),a=o?"ambiguous":s?"incomplete":i.length===1&&(n===void 0||r.length===1)?"unique":"notFound",c=[];return i.length>1&&c.push("Multiple physical parent sources claim the exact name."),r.length>1&&c.push("Multiple physical streams claim the exact parent and local name."),i.some(p=>!p.placementResolved)&&c.push("A physical parent has unresolved import placement."),this.complete||c.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(p=>p.source),streams:r,reasons:c}}};var Gf=me("^[A-Za-z_]\\w*$"),Qe=l((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),K=l(t=>{throw new oe(t)},"refuse"),ut=l((t,e,n)=>{if(!Array.isArray(t))return K(n);for(let i=0;i<t.length;i++)Qe(t[i],e)||K(n)},"collection");function Ft(t){if(t.kind==="ConceptSyntax"){let e=t;for(let n of e.validations??[])n.kind==="DeclarativeValidateSyntax"&&n.rules.some(i=>i.implementation!=null)&&K("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let e=t;e.implementation!=null&&(Qe(e.implementation,"ImplementationSyntax")||K("A named rule requires an ImplementationSyntax wrapper."),(e.rule!=="Rule"||e.value?.kind!=="PathExpressionSyntax"||!Qe(e.value,"PathExpressionSyntax")||typeof e.value.path!="string"||Gf.exec(e.value.path)?.[0]!==e.value.path)&&K("An implementation wrapper requires a valid named rule."),e.file!=null&&e.code!=null&&K("A named rule has at most one file or inline payload."),e.file!=null&&(!Qe(e.file,"FileReferenceSyntax")||typeof e.file.path!="string")&&K("A named rule file requires a FileReferenceSyntax payload with a string path."),e.code!=null&&(!Qe(e.code,"CodeBlockSyntax")||typeof e.code.language!="string"||typeof e.code.code!="string")&&K("A named rule inline payload requires a CodeBlockSyntax with string language and code."),Ft(e.implementation))}if(t.kind==="ProducesSyntax"){let e=t,n=e.inlineOperation;if(n!=null){e.inlineEvent!=null&&K("A production cannot declare both an event and an operation."),(e.when!=null||e.event!==n.name||e.for!=null||(e.tags??[]).length>0)&&K("An inline operation requires a matching unconditional target without event metadata."),ut(n.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),ut(e.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),n.inputs.length!==e.mappings.length&&K("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&&K("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let e=t;e.file!=null&&e.code!=null&&K("An operation phase has at most one file or inline payload."),e.implementation!=null&&Ft(e.implementation)}if(t.kind==="HandlerSyntax"){let e=t;e.implementation!=null&&e.file!=null&&e.code!=null&&K("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let e=t;ut(e.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let n=0;n<e.hints.length;n++)Ft(e.hints[n])}if(t.kind==="ImplementationHintSyntax"){let e=t;(typeof e.text!="string"||Tn(e.text))&&K("An implementation hint must be nonblank.")}Lr(t)}l(Ft,"validateSyntaxInvariants");function Lr(t){let e=l(i=>{Qi(i)||K("Event source and stream names must be identifiers.")},"name"),n=l((i,r)=>{ut(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&K("A route cannot map both scalar and composite stream ids."),r.forEach(o=>e(o.property))},"mappings");if(t.kind==="ApplicationSyntax"){let i=t.eventSources;i!==void 0&&ut(i,"EventSourceSyntax","Event sources must be a collection of event source nodes without null elements.")}if(t.kind==="EventSourceSyntax"||t.kind==="EventStreamSyntax"){let i=t;e(i.name),i.id!==null&&(typeof i.id!="string"||i.id.trim()==="")&&K("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!Qe(r,"TypeRefSyntax")&&K("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&K("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!wn(r.name)&&K("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?ut(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(ut(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&K("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>Lr(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),Qe(i.type,"TypeRefSyntax")||K("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&K("Source identifiers and stream ids require nonoptional scalar type references."),wn(i.type.name)||K("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&K("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!Qe(i.stream,"CommandStreamSyntax")&&K("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&&ut(i.streamCandidates,"CommandStreamSyntax","Command stream candidates must be a collection without null elements.");let r=i.streamCandidates??[];for(let o=0;o<r.length;o++){let s=r[o];if(Lr(s),s.propertyCandidate===null&&i.stream==null&&K("A duplicate route candidate requires an authoritative route."),s.propertyCandidate!==null)for(let a=0;a<i.properties.length;a++)i.properties[a]===s.propertyCandidate&&K("An ambiguous property is owned only by its stream candidate.")}}if(t.kind==="SpecificationEventSyntax"||t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax"){let i=t;i.stream!=null&&i.noStream!=null&&K("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!Qe(i.stream,"SpecificationStreamSyntax")&&K("A specification stream requires a specification stream node."),i.noStream!=null&&!Qe(i.noStream,"SpecificationNoStreamSyntax")&&K("An unrouted expectation requires a specification no stream node.")}if(t.kind==="SpecificationStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&K("A specification stream maps only streamId."),n(i.streamId,i.streamIdParts)}if(t.kind==="CommandStreamSyntax"){let i=t;e(i.eventSource),e(i.stream),i.streamId!==null&&i.streamId.property!=="streamId"&&K("A command stream maps only streamId."),n(i.streamId,i.streamIdParts);let r=i.propertyCandidate;r!==null&&(r.name!=="stream"||r.type.name!==`${i.eventSource}.${i.stream}`||r.type.isCollection||r.type.isOptional||r.isGenerated||r.isIdentifier||i.streamId!==null||i.streamIdParts.length>0)&&K("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}l(Lr,"validateSourceStream");var tt={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","ComponentExposedValueSyntax","ComponentOutletSyntax","ComponentPropertySyntax","CodeValidateSyntax","CommandSyntax","CommandStreamSyntax","ComparisonConditionSyntax","CompositeKeySyntax","ConceptAttributeSyntax","ConceptSyntax","ConcurrencySyntax","ConfirmActionSyntax","ContextExpressionSyntax","ContributionSyntax","CountMappingSyntax","DeclarativeValidateSyntax","DecrementMappingSyntax","DialogTemplateSyntax","DomainSyntax","EnvironmentExpressionSyntax","EventContextExpressionSyntax","EventInteractionTriggerSyntax","EventSourceIdExpressionSyntax","EventSourceSyntax","EventStreamIdPartSyntax","EventStreamSyntax","EventSpecSyntax","EventSyntax","EverySyntax","ExecuteCommandActionSyntax","ExpressionKeySyntax","FeatureSyntax","FileConstraintSyntax","FileImportSyntax","FileReferenceSyntax","FormColumnSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationOperationFailureSyntax","SpecificationOperationSyntax","SpecificationCompensatedSyntax","ImportSyntax","IncrementMappingSyntax","InteractionAlternativeSyntax","InteractionOtherwiseSyntax","InteractionArgumentSyntax","InteractionBindingSyntax","IntervalInteractionTriggerSyntax","IntervalTriggerSourceSyntax","InvokesSyntax","InvocationRefusalSyntax","JoinEventSyntax","JoinSyntax","KeyPartSyntax","LayoutSyntax","ListExpressionSyntax","LiteralExpressionSyntax","LogicalConditionSyntax","LogicalPolicyConditionSyntax","LogicalPolicyRequirementSyntax","ModuleSyntax","NamedTriggerSourceSyntax","NavigateActionSyntax","NavigateBackActionSyntax","NestedSyntax","NotPolicyConditionSyntax","NotifyActionSyntax","OpenDialogActionSyntax","ObjectExpressionSyntax","ObjectMemberSyntax","PathExpressionSyntax","PerformerSyntax","PersonaSyntax","PlaceSyntax","PolicyReferenceSyntax","PolicySyntax","ProducesSyntax","ProjectionEntersOnSyntax","ProjectionSyntax","ProjectionVariantSyntax","PresentationValueSyntax","PropertyMappingSyntax","PropertySyntax","PropertyResponseSourceSyntax","ResponseFieldSyntax","ScalarCommandResponseSyntax","RecordCommandResponseSyntax","ScalarSpecificationReturnSyntax","RecordSpecificationReturnSyntax","QueryParameterSyntax","QuerySyntax","RaiseTriggerActionSyntax","RawExpressionSyntax","ReactionSyntax","ReactionTriggerSyntax","RefusalExpressionSyntax","ReadModelSyntax","ReadsSyntax","ReducerRuleSyntax","ReducerSyntax","RefreshQueryActionSyntax","RemoveViaJoinSyntax","RemoveWithSyntax","RequirementSyntax","RoleConditionSyntax","ScheduleTriggerSourceSyntax","ScreenActionSyntax","ScreenNavigationParameterSyntax","ScreenGuardedActionSyntax","ScreenActionAlternativeSyntax","ScreenActionOtherwiseSyntax","ScreenBehaviorSyntax","ScreenCodeSyntax","ScreenComponentSyntax","ScreenColumnSyntax","ScreenDataSyntax","ScreenFieldSyntax","ScreenNavigateSyntax","ScreenSectionSyntax","ScreenSlotSyntax","ScreenSummarySyntax","ScreenSyntax","ScreenTableSyntax","ScreenTemplateReferenceSyntax","ScreenTemplateSyntax","ScreenTitleSyntax","ScreenToolbarSyntax","ScreenUsesBehaviorSyntax","SeedEventSyntax","SeedGroupSyntax","SeedSyntax","SetMappingSyntax","TemplateAssignmentSyntax","TemplateExposedValueSyntax","TemplateOutletSyntax","SetStateActionSyntax","SliceSyntax","SlotSyntax","SourceItemExpressionSyntax","SpecificationAbsentReadModelSyntax","SpecificationCallerClaimSyntax","SpecificationCallerSyntax","SpecificationCaptureSyntax","SpecificationClockSyntax","SpecificationCommandSyntax","SpecificationDeniedSyntax","SpecificationErrorSyntax","SpecificationEventSyntax","SpecificationNoResultSyntax","SpecificationStreamSyntax","SpecificationNoStreamSyntax","SpecificationQueryResultSyntax","SpecificationQuerySyntax","SpecificationReadModelSyntax","SpecificationRedeliverySyntax","SpecificationSyntax","SpecificationTriggerSyntax","SpecificationWhenQuerySyntax","StringsExpressionSyntax","SubtractMappingSyntax","TagSyntax","ToolbarItemSyntax","TemplateExpressionSyntax","TemplateInterpolationSyntax","TemplateTextSyntax","ThemeSyntax","TriggerDataSyntax","TriggerSyntax","TypeRefSyntax","TypeSyntax","UiBindingSyntax","UiProfileSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","DependsOnSyntax","UsesBehaviorSyntax","ValidationRuleSyntax","VariantSyntax"],names:["property","value","autoMap","mappings","authentication","behaviors","concepts","domain","eventSources","examples","fileImports","imports","layouts","modules","personas","policies","seeds","sourceOptions","numericMode","systems","templates","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","binding","directives","authorize","concurrency","documentation","handler","produces","reads","response","stream","streamCandidates","validations","eventSource","propertyCandidate","streamId","streamIdParts","left","operator","right","parts","reason","attributes","values","eventSourceType","eventStreamId","eventStreamType","eventTypes","message","messageIsLiteral","path","contributionPoint","label","navigate","requirements","rules","arrangement","category","exposes","outlets","slots","templateType","usedBehaviors","eventName","id","identifier","streams","generation","hasGenerationMarker","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","composeUsing","by","query","columnMode","columns","fields","for","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","noStream","operation","qualifiedName","actions","condition","alternatives","otherwise","trigger","amount","unit","onRefused","acknowledge","constraint","selector","on","items","literalType","dialogTemplates","forms","screenTemplates","screen","operand","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","filters","isObservable","performer","returnType","scope","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","outcome","behavior","component","context","icon","presentation","route","target","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","operations","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","roles","capture","record","instant","commandType","inlineProperty","eventType","exactly","results","reaction","given","givenCaller","givenCaptures","givenClock","givenOperationFailures","givenReadModels","thenAbsentReadModels","thenCompensated","thenDenied","thenErrors","thenEvents","thenEventsInAnyOrder","thenNoEvents","thenNoResult","thenOperations","thenQueries","thenReadModels","thenResults","thenReturns","whenAppended","whenCapture","whenClock","whenQuery","whenRedelivered","whenTrigger","compatibleWith","isCollection","isOptional","bindingKind","componentId","componentPropertyPath","expectedValueType","nullBehavior","rawText","defaultSizeClass","icons","layout","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,45,52,53,55,98,99,111,113,135,138,181,201,205],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,29,47,49,85,174,202],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",42],["array",12],["ref",51],["union",14,8],["ref",56],["array",16],["ref",80],["array",18],["ref",66],["array",20],["ref",84],["array",22],["ref",97],["array",24],["union",25,8],["ref",103],["array",27],["ref",115],["array",29],["union",30,8],["ref",118],["array",32],["ref",173],["array",34],["union",35,8],["enum","legacy","exact"],["object",[[18,37,!0]]],["ref",77],["array",39],["ref",175],["array",41],["ref",208],["array",43],["union",44,8],["ref",210],["array",46],["union",47,8],["ref",212],["array",49],["union",50,8],["ref",214],["array",52],["union",53,8],["object",[[4,9,!1],[5,11,!1],[6,13,!1],[7,15,!1],[8,17,!1],[9,19,!1],[10,21,!1],[11,23,!1],[12,26,!1],[13,28,!1],[14,31,!1],[15,33,!1],[16,36,!1],[17,38,!1],[19,40,!1],[20,42,!1],[21,45,!1],[22,48,!1],[23,51,!1],[24,54,!1]]],["object",[[25,0,!0]]],["ref",4,6],["array",57],["integer",-2147483648,2147483647],["union",59,8],["enum","Flat","Row","Column","Grid"],["object",[[26,58,!1],[27,60,!1],[28,61,!0]]],["union",0,8],["object",[[29,63,!1],[30,57,!0],[31,63,!1]]],["boolean"],["object",[[32,65,!1],[29,60,!1],[33,0,!0],[34,60,!1],[31,60,!1]]],["enum","Flow","Freeform"],["ref",5],["array",68],["union",69,8],["union",57,8],["ref",220],["array",72],["union",73,8],["object",[[35,67,!0],[36,70,!1],[30,71,!1],[37,74,!1]]],["object",[]],["object",[[38,63,!1],[33,0,!0]]],["ref",9],["array",78],["object",[[39,79,!1]]],["ref",102,117],["object",[[40,81,!0]]],["object",[[33,0,!0],[1,0,!0]]],["ref",211],["union",84,8],["object",[[33,0,!0],[41,85,!1]]],["ref",89],["array",87],["ref",67],["union",89,8],["ref",13],["array",91],["object",[[42,88,!1],[43,63,!1],[44,90,!1],[33,63,!1],[45,60,!1],[46,92,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[28,94,!0]]],["ref",124],["array",96],["ref",203],["array",98],["union",99,8],["ref",25],["union",101,8],["object",[[47,0,!0],[3,97,!1],[48,100,!1],[49,102,!1]]],["ref",16],["array",104],["ref",18,22],["array",106],["object",[[50,105,!1],[51,0,!0],[52,107,!1],[0,0,!0]]],["ref",24],["array",109],["object",[[0,0,!0],[53,1,!0],[54,110,!1]]],["object",[[50,105,!1],[52,107,!1],[0,0,!0]]],["ref",20],["array",113],["object",[[55,114,!1],[28,0,!0]]],["array",0],["object",[[56,0,!0],[53,1,!0],[57,116,!1]]],["ref",17],["array",118],["ref",19],["array",120],["ref",21],["union",122,8],["object",[[50,105,!1],[26,119,!1],[58,63,!1],[52,107,!1],[33,0,!0],[59,121,!1],[53,123,!1],[17,38,!1]]],["object",[[60,0,!0],[61,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[62,63,!1],[63,63,!1],[64,116,!1],[28,126,!0],[65,63,!1]]],["object",[[0,63,!1]]],["ref",1,27,30,61,73,95,107,122,144,145],["array",129],["object",[[2,3,!0],[66,130,!1],[51,1,!0],[0,0,!0]]],["union",1,8],["object",[[67,0,!0],[68,132,!1],[69,65,!0]]],["object",[[0,0,!0]]],["object",[[47,0,!0]]],["ref",88],["array",136],["ref",31,44,62,105,106,109,110,134,143,178],["array",138],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1]]],["object",[[74,0,!0],[75,0,!0]]],["ref",213],["object",[[76,142,!0],[33,0,!0]]],["ref",149,151,154,155,156,158,160,161,162,163,165,166,168,169,170],["array",144],["object",[[77,145,!1],[33,0,!0]]],["union",142,8],["object",[[76,147,!1],[0,0,!0],[1,63,!1]]],["ref",32],["object",[[74,149,!0]]],["ref",11],["union",151,8],["ref",43],["union",153,8],["ref",74],["union",155,8],["ref",119],["array",157],["ref",125],["array",159],["ref",140],["array",161],["union",162,8],["ref",128,129],["union",164,8],["ref",38],["union",166,8],["array",166],["ref",36,48],["array",169],["object",[[78,152,!1],[79,154,!1],[43,63,!1],[80,63,!1],[81,156,!1],[33,0,!0],[82,158,!1],[64,160,!1],[83,163,!1],[84,165,!1],[85,167,!1],[86,168,!1],[87,170,!1]]],["union",159,8],["union",96,8],["object",[[88,0,!0],[89,172,!1],[85,0,!0],[90,173,!1],[91,97,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[92,0,!0],[93,175,!0],[94,1,!0]]],["ref",96],["array",177],["object",[[95,178,!1],[41,0,!0]]],["object",[[33,0,!0],[96,63,!1]]],["ref",41],["array",181],["union",170,8],["object",[[97,182,!1],[44,90,!1],[33,0,!0],[41,0,!0],[87,183,!1],[98,116,!1]]],["object",[[88,65,!0],[99,63,!1],[100,63,!1],[101,63,!1],[102,116,!1]]],["object",[[70,137,!1],[103,0,!0],[104,65,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["object",[[105,0,!0]]],["ref",160],["union",188,8],["object",[[106,0,!0],[107,63,!1],[108,189,!1],[45,60,!1]]],["ref",146],["array",191],["union",192,8],["ref",219],["array",194],["object",[[109,193,!1],[110,195,!1]]],["ref",7],["union",197,8],["ref",176],["array",199],["ref",177],["array",201],["ref",180],["array",203],["ref",218],["array",205],["object",[[111,198,!1],[5,11,!1],[112,63,!1],[113,200,!1],[33,0,!0],[114,202,!1],[115,204,!1],[116,63,!1],[117,206,!1]]],["object",[[33,0,!0]]],["object",[[118,0,!0]]],["ref",58],["array",210],["object",[[43,63,!1],[119,63,!1],[120,85,!1],[33,0,!0],[121,211,!1]]],["object",[[33,0,!0],[41,84,!0]]],["ref",57],["array",214],["object",[[43,63,!1],[119,63,!1],[33,0,!0],[90,85,!1],[91,215,!1]]],["object",[[47,0,!0],[58,132,!1]]],["integer",0,4294967295],["object",[[43,63,!1],[80,63,!1],[44,90,!1],[122,218,!1],[123,65,!1],[119,63,!1],[33,0,!0],[64,160,!1],[48,100,!1]]],["object",[[2,3,!0],[124,65,!0],[3,5,!1]]],["object",[[70,137,!1],[125,0,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["object",[[62,1,!0]]],["ref",46],["array",223],["union",224,8],["ref",217],["array",226],["ref",64],["array",228],["ref",179],["array",230],["object",[[78,152,!1],[5,11,!1],[126,225,!1],[127,227,!1],[43,63,!1],[80,63,!1],[9,19,!1],[128,229,!1],[10,21,!1],[129,65,!0],[33,0,!0],[130,231,!1],[20,42,!1],[117,206,!1]]],["ref",65,215,216],["array",233],["object",[[131,234,!1],[44,89,!0],[132,65,!0],[103,63,!1],[33,0,!0],[133,116,!1]]],["object",[[134,0,!0]]],["object",[[107,63,!1],[0,0,!0]]],["object",[[135,63,!1],[60,63,!1],[107,63,!1],[0,0,!0]]],["object",[[136,63,!1],[137,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",68],["array",241],["ref",69],["array",243],["ref",70,71],["union",245,8],["object",[[5,11,!1],[138,240,!0],[139,242,!1],[140,244,!1],[141,0,!0],[33,0,!0],[142,189,!1],[143,246,!1],[117,206,!1]]],["ref",59],["array",248],["ref",40,63],["union",250,8],["object",[[144,249,!1],[58,251,!1],[3,5,!1],[145,132,!1]]],["union",149,8],["ref",75],["union",254,8],["object",[[74,253,!1],[44,90,!1],[146,255,!1]]],["ref",76],["array",257],["object",[[147,258,!1]]],["object",[[148,0,!0]]],["object",[[43,63,!1],[33,0,!0]]],["ref",79],["union",262,8],["object",[[149,263,!1],[43,63,!1],[150,263,!1],[151,160,!1],[33,0,!0],[152,0,!0]]],["object",[[74,253,!1],[43,63,!1],[44,90,!1],[146,255,!1]]],["ref",193],["union",266,8],["ref",192],["union",268,8],["object",[[43,63,!1],[141,132,!1],[153,97,!1],[33,0,!0],[154,267,!1],[85,269,!1],[41,0,!0],[98,97,!1]]],["object",[[155,0,!0]]],["object",[[155,0,!0],[98,97,!1]]],["object",[[156,0,!0]]],["ref",39,100],["object",[[157,139,!1],[158,274,!0]]],["object",[[157,139,!1]]],["object",[[76,0,!0],[33,0,!0]]],["ref",86],["array",278],["ref",87],["union",280,8],["ref",3,15,54,90],["object",[[157,139,!1],[159,279,!1],[158,63,!1],[160,281,!1],[161,282,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[162,59,!0],[163,284,!0]]],["ref",93],["array",286],["object",[[125,0,!0],[3,97,!1],[164,287,!1]]],["object",[[165,65,!0],[166,63,!1],[82,158,!1],[167,0,!0]]],["object",[[2,3,!0],[47,0,!0],[3,5,!1]]],["ref",94],["array",291],["object",[[144,292,!1],[168,0,!0],[0,0,!0]]],["object",[[62,1,!0],[0,0,!0]]],["array",1],["object",[[169,295,!1]]],["union",0,65,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[170,299,!0],[1,300,!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",[[170,302,!0],[1,303,!0]]],["union",297,298,301,304],["object",[[1,305,!1]]],["enum","And","Or"],["object",[[92,274,!0],[93,307,!0],[94,274,!0]]],["ref",8,28,101,108,147],["object",[[92,309,!0],[93,307,!0],[94,309,!0]]],["object",[[92,81,!0],[93,307,!0],[94,81,!0]]],["ref",50],["array",312],["union",313,8],["ref",72],["array",315],["union",316,8],["ref",167],["array",318],["object",[[78,152,!1],[5,11,!1],[126,225,!1],[127,227,!1],[43,63,!1],[171,314,!1],[80,63,!1],[9,19,!1],[128,229,!1],[10,21,!1],[172,317,!1],[129,65,!0],[33,0,!0],[173,319,!1],[20,42,!1],[117,206,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[174,0,!0]]],["object",[[2,3,!0],[66,130,!1],[0,0,!0]]],["object",[[175,309,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[70,137,!1],[176,324,!0],[103,0,!0],[104,65,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["object",[[70,137,!1],[177,0,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["ref",112],["array",327],["object",[[178,328,!1]]],["object",[[33,0,!0],[1,1,!0]]],["object",[[74,253,!1],[44,90,!1]]],["object",[[43,63,!1],[33,0,!0],[15,116,!1]]],["object",[[179,65,!1],[180,63,!1],[181,63,!1],[182,0,!0],[183,60,!1],[184,60,!1]]],["union",309,8],["object",[[74,253,!1],[158,334,!1],[44,90,!1],[33,0,!0]]],["ref",60],["union",336,8],["ref",78],["union",338,8],["union",274,8],["object",[[47,0,!0],[141,132,!1],[185,337,!1],[186,339,!1],[3,97,!1],[48,100,!1],[49,340,!1]]],["object",[[2,3,!0],[66,130,!1],[44,90,!1],[58,251,!1],[33,0,!0],[187,63,!1],[188,63,!1],[17,38,!1]]],["ref",120],["array",343],["object",[[66,130,!1],[189,344,!1],[33,0,!0]]],["object",[[0,0,!0],[53,1,!0]]],["object",[[190,65,!1],[191,65,!1],[33,0,!0],[41,84,!0]]],["ref",126],["object",[[33,0,!0],[53,348,!0],[41,85,!1]]],["object",[[53,348,!0]]],["ref",127],["array",351],["object",[[140,352,!1]]],["object",[[1,1,!0]]],["object",[[140,97,!1]]],["object",[[33,0,!0],[53,132,!1],[41,84,!0]]],["ref",132],["union",357,8],["array",357],["ref",114],["union",360,8],["object",[[78,152,!1],[136,358,!1],[43,63,!1],[192,359,!1],[193,65,!1],[33,0,!0],[194,361,!1],[195,84,!0],[196,63,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[161,0,!0]]],["ref",137],["array",364],["object",[[43,63,!1],[80,63,!1],[33,0,!0],[22,365,!1],[197,340,!1]]],["ref",209],["array",367],["ref",92],["array",369],["union",370,8],["union",158,8],["ref",91,104,148],["object",[[74,253,!1],[198,368,!1],[43,63,!1],[44,90,!1],[199,371,!1],[82,372,!1],[83,163,!1],[53,373,!0]]],["object",[[200,0,!0]]],["object",[[43,63,!1],[80,63,!1],[44,90,!1],[33,0,!0],[64,160,!1]]],["object",[[38,63,!1],[136,63,!1],[187,0,!0]]],["object",[[74,253,!1],[43,63,!1],[47,0,!0],[44,90,!1]]],["ref",141],["array",379],["object",[[43,63,!1],[33,0,!0],[187,0,!0],[110,380,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[137,0,!0]]],["object",[[47,0,!0],[58,132,!1],[145,132,!1]]],["enum","Error","Information","Warning"],["object",[[158,274,!0],[103,63,!1],[201,384,!0]]],["object",[[202,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",387,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[203,60,!1],[204,388,!1],[205,389,!0]]],["object",[[125,0,!0],[107,63,!1],[108,189,!1]]],["ref",152],["array",392],["ref",153],["union",394,8],["object",[[159,393,!1],[107,0,!0],[108,189,!1],[160,395,!1]]],["object",[[70,137,!1],[125,0,!0],[158,274,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[70,137,!1],[125,63,!1],[206,398,!0]]],["object",[[207,10,!0]]],["ref",33],["array",401],["ref",34],["array",403],["ref",123],["array",405],["ref",35],["array",407],["object",[[5,11,!1],[208,0,!0],[209,147,!1],[113,402,!1],[210,63,!1],[33,0,!0],[114,404,!1],[211,406,!1],[64,408,!1],[117,206,!1]]],["object",[[136,63,!1],[137,0,!0],[41,84,!0]]],["object",[[107,0,!0],[0,0,!0]]],["ref",150],["array",412],["object",[[136,63,!1],[46,413,!1],[212,63,!1],[174,0,!0]]],["ref",159],["array",415],["object",[[140,416,!1],[213,0,!0]]],["object",[[77,145,!1],[44,90,!1],[33,0,!0]]],["ref",157],["array",419],["object",[[5,11,!1],[139,420,!1],[214,189,!1],[213,0,!0],[117,206,!1]]],["ref",162],["array",422],["object",[[33,0,!0],[115,423,!1]]],["object",[[111,198,!1],[5,11,!1],[112,63,!1],[113,200,!1],[215,63,!1],[33,0,!0],[114,202,!1],[115,204,!1],[116,63,!1],[117,206,!1]]],["ref",204],["array",426],["object",[[169,427,!1],[33,0,!0]]],["object",[[152,205,!0]]],["object",[[47,0,!0],[64,97,!1]]],["ref",171],["array",431],["object",[[216,0,!0],[144,432,!1]]],["ref",172],["array",434],["object",[[217,435,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[213,0,!0],[1,0,!0]]],["ref",23],["array",438],["ref",37],["array",440],["array",336],["array",338],["ref",121],["array",444],["ref",133],["array",446],["ref",136],["array",448],["ref",139],["array",450],["union",451,8],["ref",142],["array",453],["union",454,8],["ref",164],["array",456],["ref",198],["array",458],["enum","StateChange","StateView","Automation","Translate"],["object",[[218,439,!1],[219,441,!1],[220,234,!1],[43,63,!1],[80,63,!1],[144,442,!1],[9,19,!1],[44,90,!1],[33,0,!0],[221,443,!1],[222,445,!1],[223,447,!1],[224,449,!1],[225,452,!1],[226,455,!1],[227,457,!1],[228,459,!1],[20,42,!1],[41,460,!0]]],["object",[[229,63,!1],[33,0,!0]]],["object",[[58,1,!0],[33,0,!0]]],["object",[[41,0,!0],[1,0,!0]]],["ref",183],["array",465],["object",[[230,65,!0],[231,466,!1],[232,116,!1]]],["object",[[233,0,!0],[234,97,!1]]],["object",[[235,0,!0]]],["object",[[236,0,!0],[141,132,!1],[153,97,!1],[237,63,!1],[98,97,!1]]],["object",[[33,63,!1]]],["object",[[238,0,!0],[141,132,!1],[237,63,!1],[154,267,!1],[85,269,!1],[98,97,!1]]],["object",[[88,0,!0],[85,0,!0],[90,173,!1],[91,97,!1]]],["object",[[239,65,!0],[64,97,!1]]],["ref",194],["array",475],["object",[[70,97,!1],[239,65,!0],[137,0,!0],[240,476,!1]]],["object",[[239,65,!0],[237,63,!1],[33,0,!0],[64,97,!1]]],["object",[[238,0,!0],[141,132,!1],[154,267,!1],[241,0,!0],[85,269,!1],[98,97,!1]]],["ref",190],["array",480],["ref",184],["union",482,8],["ref",185],["array",484],["ref",186],["union",486,8],["ref",81],["array",488],["ref",196],["array",490],["union",491,8],["ref",182],["array",493],["ref",83],["array",495],["ref",188],["union",497,8],["ref",189],["array",499],["ref",191],["union",501,8],["ref",82],["array",503],["ref",195],["array",505],["ref",130,131],["union",507,8],["ref",187],["union",509,8],["union",480,8],["union",484,8],["ref",200],["union",513,8],["ref",197],["union",515,8],["ref",199],["union",517,8],["object",[[43,63,!1],[9,19,!1],[44,90,!1],[242,481,!1],[243,483,!1],[244,485,!1],[245,487,!1],[246,489,!1],[247,492,!1],[33,0,!0],[17,38,!1],[248,494,!1],[249,496,!1],[250,498,!1],[251,500,!1],[252,481,!1],[253,65,!0],[254,65,!1],[255,502,!1],[256,504,!1],[257,506,!1],[258,492,!1],[259,476,!1],[260,508,!1],[49,510,!1],[261,511,!1],[262,512,!1],[263,487,!1],[264,514,!1],[265,516,!1],[266,518,!1]]],["object",[[161,0,!0],[98,97,!1]]],["object",[[70,97,!1],[137,0,!0]]],["object",[[58,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[210,63,!1],[107,63,!1],[33,0,!0],[46,413,!1],[211,406,!1],[28,523,!0],[213,0,!0]]],["ref",206,207],["array",525],["object",[[95,526,!1]]],["object",[[267,116,!1],[33,0,!0]]],["object",[[198,368,!1],[43,63,!1],[44,90,!1],[33,0,!0]]],["object",[[268,65,!0],[269,65,!0],[33,0,!0]]],["object",[[43,63,!1],[44,90,!1],[33,0,!0],[64,160,!1]]],["enum","Invalid","DataContext","QueryResult","ComponentProperty"],["enum","OneWay","TwoWay"],["union",533,8],["enum","Propagate","Clear","Preserve"],["union",535,8],["object",[[270,532,!0],[271,63,!1],[272,63,!1],[273,63,!1],[35,534,!1],[274,536,!1],[105,0,!0],[137,63,!1],[275,63,!1]]],["object",[[276,63,!1],[277,116,!1],[278,63,!1],[33,0,!0],[279,116,!1],[280,116,!1],[281,63,!1]]],["object",[[131,234,!1],[47,0,!0],[132,65,!0],[103,63,!1],[33,0,!0],[133,116,!1]]],["object",[[282,116,!1],[131,234,!1],[47,0,!0],[132,65,!0],[103,63,!1],[33,0,!0],[0,0,!0],[133,116,!1]]],["object",[[213,0,!0]]],["ref",12],["array",542],["object",[[70,543,!1],[207,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[74,253,!1],[44,90,!1],[146,255,!1],[103,63,!1],[0,0,!0],[283,545,!0],[201,384,!0],[1,132,!1]]],["ref",116],["array",547],["object",[[29,0,!0],[284,548,!1],[31,0,!0]]]],contracts:[2,6,55,56,62,64,66,75,76,77,80,82,83,86,93,95,103,108,111,112,83,115,117,124,125,127,128,131,133,134,135,140,141,143,146,148,150,171,174,176,179,180,184,185,186,187,190,134,196,134,207,208,208,187,209,76,212,213,216,217,219,220,221,222,232,235,236,187,237,238,76,239,247,252,256,259,260,261,264,265,270,271,272,271,273,134,275,276,277,283,285,285,288,289,290,293,294,207,296,306,308,310,311,320,208,321,140,322,323,325,326,329,330,187,331,332,333,208,335,341,217,342,345,83,346,347,134,349,350,353,354,355,356,362,363,260,366,374,375,376,377,378,381,382,217,383,385,386,390,391,143,396,397,399,400,150,409,237,410,411,414,146,146,417,418,421,424,425,260,428,429,430,433,436,346,208,86,208,437,461,462,187,463,464,467,468,469,470,76,471,472,76,473,76,474,477,478,479,519,520,521,522,2,354,524,527,222,260,528,86,529,530,531,537,538,539,540,541,544,546,549]};var qr=tt.rules,Zf=new Map(qr.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),Ha=new Map(tt.kinds.map((t,e)=>[t,qr[tt.contracts[e]][1]])),Kf=new Map([...Ha].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>tt.names[n])])])),_a=l(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function Br(t){let e=Ha.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!Ja(t,e))throw new oe(`Invalid typed members for syntax kind '${t.kind}'.`)}l(Br,"validateSyntaxMembers");function gi(t,e){let n=xi(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new oe(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}l(gi,"validateClosedSyntaxMembers");function xi(t){let e=Kf.get(t);if(e===void 0)throw new oe(`Unknown syntax kind '${t}'.`);return e}l(xi,"syntaxMemberNames");function Ja(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,tt.names[n])?Fr(t[tt.names[n]],i):!r)}l(Ja,"matchesMembers");function _f(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!Fr(t[n],e))return!1;return!0}l(_f,"allIndicesMatch");function Fr(t,e){let[n,...i]=qr[e];switch(n){case"ref":return _a(t)&&typeof t.kind=="string"&&i.some(r=>tt.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(Fr(t,s)?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)&&_f(t,i[0]);case"object":return _a(t)&&Object.keys(t).every(r=>i[0].some(([o])=>tt.names[o]===r))&&Ja(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||Zf.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}l(Fr,"matches");var Hf=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(","))])),Jf=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function Xf(t,e){return Hf[t]?.has(e)===!0||Jf.test(t)&&(e==="source"||e==="value")}l(Xf,"isExactOnlyMember");function Xa(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:Xf(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}l(Xa,"isLegacyOmittedMember");var $i=l(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),vi=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),ki=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function Ei(t){let e=eu(t);return Yr(e,"legacy",0),bi(e)}l(Ei,"toSyntaxJson");function eu(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 c=es();e.set(o,c);let p=o.length;for(let m=p-1;m>=0;m--)n.push(()=>{c[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return c}let s=Object.create(null);e.set(o,s);let a=Object.keys(o);!a.includes("kind")&&"kind"in o&&a.unshift("kind");for(let c=a.length-1;c>=0;c--)n.push(()=>{let p=a[c],m=o[p];p==="sourceOptions"&&n.push(()=>{typeof m=="object"&&m!==null&&(Object.getPrototypeOf(m)!==Object.prototype&&Object.getPrototypeOf(m)!==null||Reflect.ownKeys(m).length!==Object.keys(m).length)&&(s[p]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[p]=i(m)});return s}l(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}l(eu,"snapshot");function es(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}l(es,"dataArray");function bi(t,e="legacy",n=!1){if(Array.isArray(t)){let o=es();for(let s=0;s<t.length;s++)o.push(bi(t[s],e,n));return o}if($i(t)){if(ki.has(t.kind)&&(e=Ot(t.sourceOptions??Oe).numericMode),Ft(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&gi(t,vi),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&gi(p.file,vi),p.code!=null&&gi(p.code,vi))}let o=Object.create(null);o.kind=t.kind;let s={...t};t.kind==="ApplicationSyntax"&&s.eventSources===void 0&&(s.eventSources=[]),t.kind==="CommandSyntax"&&s.stream===void 0&&(s.stream=null),t.kind==="CommandSyntax"&&s.streamCandidates===void 0&&(s.streamCandidates=[]);let a=e==="exact"?xi(t.kind):void 0,c=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&Xa(t,p))&&!vi.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(tu);for(let p of c){let m=s[p];p==="documentation"&&t.kind!=="EventSyntax"&&m==null||t.kind==="SpecificationSyntax"&&p==="description"&&m==null||p==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(m)&&m.length===0||p==="sourceOptions"&&m?.numericMode==="legacy"||p==="examples"&&Array.isArray(m)&&m.length===0||p==="inlineProperty"&&m==null||(t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax")&&(p==="stream"||p==="noStream")&&m==null||t.kind==="SpecificationSyntax"&&p==="thenNoEvents"&&m===!1||t.kind==="SpecificationSyntax"&&p==="whenRedelivered"&&m==null||t.kind==="InvokesSyntax"&&p==="onRefused"&&Array.isArray(m)&&m.length===0||(o[p]=bi(m,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]=bi(i[o],e,n));return r}l(bi,"write");function Yr(t,e,n){if(n>96&&e==="exact")throw new oe("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)Yr(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(ki.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?Ot(i.sourceOptions):Oe;if(n>0&&e!==o.numericMode)throw new oe("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!ki.has(i.kind))throw new oe("Exact syntax requires a complete source root.");if(e==="exact"&&$i(i)&&Br(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&Gt(i.text))throw new oe("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 oe("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"||Ge(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new oe("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new oe("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&$i(i)?xi(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||$i(s)&&ki.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&Yr(s,e,n+1)}l(Yr,"validateNumbers");function tu(t,e){return t<e?-1:t>e?1:0}l(tu,"ordinal");function ts(t){let e=[],n=t.map(v=>v.value),i=new Map,r=!1;for(let v of n)try{i.set(v,Object.hasOwn(v,"sourceOptions")?Ot(v.sourceOptions):Oe)}catch(k){if(!(k instanceof oe))throw k;r=!0,e.push(Pi(d.IncompatibleNumericSource,k.message,v.location))}let o=n.filter(v=>i.get(v)?.numericMode==="exact"||nu(v)),s=i.get(o[0])??Oe;for(let v of o.slice(1))i.get(v)?.numericMode!==s.numericMode&&(r=!0,e.push(Pi(d.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",v.location)));r&&(s=go);let a=new Map,c=Ci(n.flatMap(v=>v.concepts),"declaration of",e,void 0,a),p=Ci(n.flatMap(v=>v.types),"declaration of",e,void 0,a),m=n.map(v=>v.domain).filter(v=>v!==null);for(let v of m.slice(1))e.push(Pi(d.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${fn(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,v.location));let u=iu(n.flatMap(v=>v.modules),e),y=Ci(n.flatMap(v=>v.personas),"persona",e),h={kind:"ApplicationSyntax",sourceOptions:s,domain:m[0]??null,imports:ru(n.flatMap(v=>v.imports),v=>v.qualifiedName),concepts:c,types:p,examples:n.flatMap(v=>v.examples??[]),systems:n.flatMap(v=>v.systems??[]),eventSources:n.flatMap(v=>v.eventSources??[]),declaredTriggers:n.flatMap(v=>v.declaredTriggers??[]),modules:u,personas:y,policies:n.flatMap(v=>v.policies??[]),seeds:n.flatMap(v=>v.seeds??[]),fileImports:n.flatMap(v=>v.fileImports),location:n[0]?.location??{line:1,column:1}},x=[...t.flatMap(v=>v.diagnostics),...e];return{value:h,diagnostics:x,success:!x.some(v=>v.severity==="error")}}l(ts,"mergeDocuments");function nu(t){if($o(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||(t.examples?.length??0)>0)return!0;let e=l(n=>!n.isPlacement||(n.examples?.length??0)>0||n.slices.length>0||n.features.some(e),"feature");return t.modules.some(n=>!n.isPlacement||(n.examples?.length??0)>0||n.features.some(e))}l(nu,"hasDeclarations");function iu(t,e){return as(t).map(rs).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(Ur)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:ls(n,`module '${n[0].name}'`,e),documentation:ss(n,`module '${n[0].name}'`,e),authorize:os(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:is(n),features:ns(n.flatMap(i=>i.features),e)})}l(iu,"mergeModules");function ns(t,e){return as(t).map(rs).map(n=>n.length===1?Ur(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:ls(n,`feature '${n[0].name}'`,e),documentation:ss(n,`feature '${n[0].name}'`,e),authorize:os(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:is(n),features:ns(n.flatMap(i=>i.features),e),slices:Ci(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}l(ns,"mergeFeatures");function is(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??[])}l(is,"groupDependencies");function rs(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}l(rs,"placedLast");function Ur(t){return{...t,isPlacement:!1,features:t.features.map(Ur)}}l(Ur,"unplaced");function os(t,e,n){let i=[];for(let r of t.filter(o=>o!==null)){let o=i.find(s=>s.location.path!==r.location.path&&JSON.stringify(Ei(s))===JSON.stringify(Ei(r)));if(o!==void 0){n.push(Wr(d.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${fn(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>Ye(r,o),null)}l(os,"combineAuthorization");function ru(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}l(ru,"firstOfEach");function as(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}l(as,"groupByName");function ss(t,e,n){let i=t.filter(r=>r.documentation!=null);for(let r of i.slice(1).filter(o=>o.documentation!==i[0].documentation))n.push(Wr(d.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${fn(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}l(ss,"firstDocumentation");function ls(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(Wr(d.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${fn(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}l(ls,"firstDescription");function Ci(t,e,n,i,r=new Map){let o=[];for(let s of t){let a=r.get(s.name);if(a!==void 0&&a.path!==s.location.path){n.push(Pi(d.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${fn(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}l(Ci,"declaredInOneFile");var fn=l(t=>t??"another file","describe"),Pi=l((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),Wr=l((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function ds(t,e){return su(t,e).result}l(ds,"parsePlacedDocuments");function su(t,e){let n=qt.capturePlaced(t.filter(h=>h.isPlacementResolved!==!1).map(h=>({lines:Et(h.source,!1,h.path),placement:h.placement})),e),i=t.map(h=>Xe(h.source,h.path,h.isPlacementResolved===!1?[]:h.placement,!1,n,e)),r=i.flatMap((h,x)=>(h.value.eventSources??[]).map(v=>({source:v,placementResolved:t[x].isPlacementResolved!==!1}))),o=t.every(h=>h.isPlacementResolved!==!1)&&i.every(h=>!Bt.hasUnknownExtent(h.diagnostics)),s=i.map((h,x)=>t[x].isPlacementResolved===!1?{...h,value:{...h.value,eventSources:[]}}:h),a=ts(s),c=new ge(new Ze([]),void 0,e);a.value.sourceOptions!==void 0&&(c.sourceOptions=a.value.sourceOptions),ci(a.value,c),ti(a.value,c),ei(a.value,c),$n(a.value,c),Jn(a.value,c,s.flatMap(h=>h.inputUses)),di(a.value,c),pi(a.value,c),ui(a.value,c),hi(a.value,c),Si(a.value,c);let p=bn(a.value,c);Lt.validate(p,c);for(let h of vn(p))c.information(h.code,h.message,h.location);let m=a.diagnostics,u=new Set(m.map(cs)),y=[...m,...c.diagnostics.filter(h=>!u.has(cs(h)))];return{result:{...a,value:p,diagnostics:y,success:!y.some(h=>h.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((h,x)=>[t[x].path,h.value]))}}l(su,"parsePlacedDocumentsWithSyntax");function cs(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}l(cs,"diagnosticKey");var ps=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,fs=l(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function lu(){let t="";for(let e=0;e<=65535;e++){if(!ps.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&ps.test(String.fromCharCode(e+1));)e++;t+=fs(n)+(e>n?`-${fs(e)}`:"")}return t}l(lu,"ranges");var Ai=lu();var cu=new RegExp(`^\\s*example\\s+[A-Z][${Ai}]*\\s*:\\s*([${Ai}.]*)$`),du=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${Ai}.]*)$`);function us(t,e,n,i,r,o){let s=t,a=[],c=o.some(g=>g.severity==="error")?o.some(g=>g.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,m=[],u=l((g,S)=>{if(g.location.path===e&&g.location.line>0)for(let E of i(g.location.line-1))p.set(E,S)},"own"),y=l((g,S)=>{for(let E of g??[])a.push({name:E.name,scope:S,example:E}),u(E,S)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map(g=>({name:g.name,scope:[]})));let h=l((g,S)=>{for(let E of g){let b=[...S,E.name];u(E,b),y(E.examples,b);for(let O of E.slices){let T=[...S,E.name,O.name];u(O,T),y(O.examples,T);let R=new Map;for(let N of le(O))R.set(N.name,[...R.get(N.name)??[],N]);for(let N of R.values()){let B=Math.max(...N.map(j=>j.generation));a.push(...N.filter(j=>j.generation===B).map(j=>({name:j.name,scope:T,fixtureKind:"event"})))}a.push(...O.commands.map(N=>({name:N.name,scope:T,fixtureKind:"command"})),...O.readModels.map(N=>({name:N.name,scope:T,fixtureKind:"readmodel"})));for(let N of O.specifications)m.push({node:N,scope:T}),u(N,T),y(N.examples,T)}h(E.features,b)}},"features");for(let g of s.modules)u(g,[g.name]),y(g.examples,[g.name]),h(g.features,[g.name]);let x=l((g,S)=>{let E=g.split("."),b=a.filter(T=>T.name===E.at(-1)),O=E.slice(0,-1);if(O.length)return b.filter(T=>O.length<=T.scope.length&&O.every((R,N)=>T.scope[T.scope.length-O.length+N]===R));for(let T=S.length;T>=0;T--){let R=b.filter(N=>T<=N.scope.length&&S.slice(0,T).every((B,j)=>N.scope[j]===B));if(R.length)return R}return[]},"candidates"),v=l((g,S)=>{let E=x(g,S);return E.length===1?E[0]:void 0},"unique"),k=l(g=>g.example?v(g.example.type,g.scope)?.fixtureKind:g.fixtureKind,"kind"),C=l(g=>[...g.scope.filter(S=>!r.has(S)),g.name].join("."),"display"),$=l((g,S,E=!1,b="")=>a.flatMap(O=>{let T=k(O);if(!T||S&&T!==S||E&&O.example)return[];let R=[...O.scope,O.name].join("."),N=v(O.name,g)===O?O.name:R;if(v(N,g)!==O)return[];let B=b.split(".").slice(0,-1).join(".");return B&&!R.endsWith(`${B}.${O.name}`)?[]:N===R&&O.scope.some(j=>r.has(j))&&v(O.name,g)!==O?[]:[{label:v(O.name,g)===O?O.name:C(O),insertText:B?O.name:N,documentation:O.example?`Example of ${O.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${T}.`}]}),"targets"),P=l((g,S,E,b,O)=>{if(c)return c;let T=l((V,ae,xe="")=>{if(new Set(V.map(U=>U.property)).size!==V.length||new Set(ae.map(U=>U.property)).size!==ae.length)return null;let Pe=new Map(V.map(U=>[U.property,{value:U,origin:"example",replaced:void 0}]));for(let U of ae){let re=Pe.get(U.property)?.value;Pe.delete(U.property),Pe.set(U.property,{value:U,origin:re?"override":"authored",replaced:re})}return[...Pe.values()].map(({value:U,origin:re,replaced:de})=>`${xe}${U.property} = ${nt(U.source)} \u2014 ${re}${re==="example"?` ${g.name}`:""}${de?` (replaces ${nt(de.source)} from ${g.name})`:""}`)},"merge"),R=T(g?.values??[],S),N=T(g?.generatedValues??[],E,"generated ");if(!R||!N)return"**Invalid duplicate assignments; no effective values selected.**";let B=b??g?.for,j=g?.stream??g?.noStream,q=O?.stream??O?.noStream,W=q??j,G=l(V=>V.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${V.eventSource}.${V.stream}${V.streamId?` streamId = ${nt(V.streamId.source)}`:V.streamIdParts.length?` streamId ${V.streamIdParts.map(ae=>`${ae.property} = ${nt(ae.source)}`).join(", ")}`:""}`,"routeText"),Y=W?[`${G(W)} \u2014 ${q?j?`override (replaces ${G(j)} from ${g.name})`:"authored":`example ${g.name}`}`]:[];return[...R,...N,...Y,...B?[`for ${nt(B)} \u2014 ${b?g?.for?`override (replaces ${nt(g.for)} from ${g.name})`:"authored":`example ${g.name}`}`]:[]].join(`
|
|
19
|
-
`)},"effective"),A=new Map;for(let g of a.filter(S=>S.example?.location.path===e)){let S=g.example,E=S.location.line-1,b=Me(n[E]??"").match(/^\s*example\s+/)?.[0];b&&A.set(E,{start:b.length+1,length:S.name.length,content:`**example ${C(g)} : ${S.type}**
|
|
20
|
-
|
|
21
|
-
${k(g)?P(S,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:g,scope:S}of m){let E=[...g.given.map(b=>({step:b,name:b.eventType,expected:"event",values:b.values,generated:[],destination:b.for,prefix:/^\s*given\s+/})),...g.givenReadModels.map(b=>({step:b,name:b.name,expected:"readmodel",values:b.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...g.when?[{step:g.when,name:g.when.commandType,expected:"command",values:g.when.values,generated:g.when.generatedValues??[],destination:g.when.for,prefix:/^\s*when\s+/}]:[],...g.whenAppended?[{step:g.whenAppended,name:g.whenAppended.eventType,expected:"event",values:g.whenAppended.values,generated:[],destination:g.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...g.thenEvents.map(b=>({step:b,name:b.eventType,expected:"event",values:b.values,generated:[],destination:b.for,prefix:/^\s*then\s+/})),...g.thenReadModels.map(b=>({step:b,name:b.name,expected:"readmodel",values:b.properties,generated:[],destination:null,prefix:/^\s*then\s+readmodel\s+/}))];for(let{step:b,name:O,expected:T,values:R,generated:N,destination:B,prefix:j}of E.filter(q=>q.step.location.path===e)){let q=v(O,S),W=x(O,S).some(ae=>ae.example);if(!q?.example&&(q||!W))continue;let G=b.location.line-1,Y=Me(n[G]??"").match(j)?.[0].length;if(Y===void 0)continue;let V=q?k(q)!==T?"**Example kind mismatch; no effective values selected.**":`**${T} ${q.example?.type??O}${q.example?` \u2014 example ${C(q)}`:""}**
|
|
22
|
-
|
|
23
|
-
${P(q.example,R,N,B,"eventType"in b?b:void 0)}
|
|
24
|
-
|
|
25
|
-
Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";A.set(G,{start:Y+1,length:O.length,content:V})}}return{eventExamples:a.filter(g=>g.example?.location.path===e&&k(g)==="event").map(g=>g.example),completions(g,S){let E=p.get(g)??[],b=S.match(cu);if(b)return $(E,void 0,!0,b[1]);if(!m.some(({node:B})=>B.location.path===e&&i(B.location.line-1).includes(g)))return null;let T=S.match(du);if(!T||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(T[3]))return null;let R=T[2]==="readmodel"?"readmodel":T[2]==="append"||T[1]!=="when"?"event":"command",N=$(E,R,!1,T[3]);return N.length?T[2]?N:[...no[T[1]],...N]:null},hover(g,S,E){let b=A.get(g);return b&&S>=b.start&&E<=b.start+b.length?b.content:null}}}l(us,"exampleAnalysis");function nt(t){switch(t.kind){case"LiteralExpressionSyntax":return typeof t.value=="object"&&t.value!==null?t.value.value:JSON.stringify(t.value);case"ListExpressionSyntax":return`[${t.items.map(nt).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${nt(e.value)}`).join(", ")} }`;case"RawExpressionSyntax":return t.text;case"PathExpressionSyntax":return t.path;case"ContextExpressionSyntax":return`$context.${t.path}`;case"EventContextExpressionSyntax":return`$eventContext.${t.path}`;case"RefusalExpressionSyntax":return`$refusal.${t.member}`;case"EventSourceIdExpressionSyntax":return"$eventSourceId";case"CausedByExpressionSyntax":return`$causedBy${t.property?`.${t.property}`:""}`;case"EnvironmentExpressionSyntax":return`$env.${t.name}`;case"StringsExpressionSyntax":return`$strings.${t.key}`;case"SourceItemExpressionSyntax":return`$.${t.path}`;case"TemplateExpressionSyntax":return"`"+t.parts.map(e=>e.kind==="TemplateTextSyntax"?e.text:"${"+nt(e.expression)+"}").join("")+"`"}}l(nt,"expressionText");function ms(t,e,n,i,r){let o=t,s=e,a=Ee.containersOf(o).filter(u=>![...u.scope,u.name].some(y=>r.has(y))),c=new Map,p=new Map,m=l((u,y,h)=>{for(let x of u){let v=[...y,x.name];if(h){if(x.location.path===n&&x.location.line>0)for(let k of i(x.location.line-1))c.set(k,v)}else{let k=v.join(".");p.set(k,[...p.get(k)??[],...(x.dependsOn??[]).map(C=>({target:C.target,...C.location}))])}m(x.features,v,h)}},"inventory");return m(o.modules,[],!1),m(s.modules,[],!0),{completions(u,y,h){let x=c.get(u)??h;if(!x?.length||x.some(k=>r.has(k))||!a.some(k=>[...k.scope,k.name].join(".")===x.join(".")))return[];let v=new Set((p.get(x.join("."))??[]).filter(k=>k.path!==n||k.line!==u+1).map(k=>Ee.resolve(k.target,x,a).resolved));return Ee.candidates(x,a).flatMap(({container:k,reference:C,tier:$})=>{if(v.has(k))return[];let P=[...k.scope,k.name].join(".");if(y&&(C=y+k.name,Ee.resolve(C,x,a).resolved!==k))return[];let A=k.scope.length===0?"module":$===0?"sibling feature":$!=="qualified"?`feature of ${k.scope.join(".")}`:`feature in ${k.scope.join(".")}`,g=a.indexOf(k);return[{label:y?k.name:C,insertText:y?k.name:C,documentation:`${P} \u2014 ${A}.`,detail:A,sortText:`${String($==="qualified"?x.length:$).padStart(6,"0")}:${String(g).padStart(6,"0")}`}]})}}}l(ms,"dependencyTargetAnalysis");var IO="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",un=new Map;function pu(t,e){let n=ke(t),i=t.flatMap((u,y)=>!n[y]&&J(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(`
|
|
26
|
-
`),locations:t.map((u,y)=>({line:y+1,column:0}))};let r=[],o=[],s=!1;t.forEach((u,y)=>{!n[y]&&J(u)===0&&/^\w/.test(u)&&(s=/^(?:concept|type|import|domain|system|eventsource)\b/.test(u)),(s?r:o).push(y)});let a=i.includes("feature")?1:i.includes("slice")?2:3,c=e.slice(0,a),p=[...r.map(u=>t[u]),...c,...o.map(u=>" ".repeat(a*2)+t[u])].join(`
|
|
27
|
-
`),m=[...r.map(u=>({line:u+1,column:0})),...c.map(()=>({line:0,column:0})),...o.map(u=>({line:u+1,column:a*2}))];return{source:p,locations:m}}l(pu,"authoringSource");function fu(t,e,n,i="current.play",r=!0){let o=e.map((I,M)=>typeof I=="string"?{path:`other-${M}.play`,source:I}:I).filter(I=>I.path!==i),s=[{path:i,source:t.join(`
|
|
28
|
-
`),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(I=>[...I.source.matchAll(/\w+/g)].map(M=>M[0]).concat(I.placement??[]))),c=l(I=>{let M=I;for(let L=1;a.has(M);L++)M=`${I}${L}`;return a.add(M),M},"fresh"),p=c("EditorAuthoring"),m=c("FragmentFeature"),u=new Set([p,m]),y=s.map((I,M)=>{let L=M===0?t:I.source.split(`
|
|
29
|
-
`),F=c(`Fragment${M}`);u.add(F);let it=I.placement?.length?{source:I.source,locations:L.map((bt,Sn)=>({line:Sn+1,column:0}))}:pu(L,[`module ${p}`,` feature ${m}`,` slice StateChange ${F}`]);return{...I,...it,placement:I.placement??[]}}),h=y[0],x=new Map(y.map(I=>[I.path,I.locations])),v=ds([...y.slice(1),h]),k=new Map,C=new Map,$=new WeakSet,P=l(I=>{if(I===null||typeof I!="object"||$.has(I))return;if($.add(I),Array.isArray(I)){I.forEach(P);return}let M=I;if(typeof M.path=="string"&&typeof M.line=="number"&&typeof M.column=="number"){let L=x.get(M.path)?.[M.line-1];L&&(M.line=L.line,M.column=Math.max(1,M.column-L.column));return}for(let L of Object.values(M))P(L);M.location?.path===i&&(M.kind==="CommandSyntax"&&k.set(M.location.line-1,I),M.kind==="SpecificationSyntax"&&C.set(M.location.line-1,I))},"walk");P(v.value),P(v.physicalEventSources);for(let I of v.diagnostics)P(I.location);let A=v.diagnostics.some(I=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(I.code))return!1;let M=y.find(F=>F.path===I.location.path),L=s.find(F=>F.path===I.location.path)?.source.split(`
|
|
30
|
-
`)[I.location.line-1];return M?.locations.some(F=>F.line===0)&&L!==void 0&&J(L)===0}),g=v.diagnostics.filter(I=>I.location.path===i).flatMap(I=>(P(I.location),I.location.line>0?[I]:[])),S=new se(v.value),E=new Set(S.slices.flatMap(({slice:I})=>[...I.commands.flatMap(M=>M.produces),...I.reactions.flatMap(M=>M.triggers).flatMap(M=>M.produces)].filter(M=>M.location.path===i&&!S.isEventProduction(M,I)).map(M=>M.location.line-1)));for(let I of g)I.code==="PLAY0499"&&E.add(I.location.line-1);let b=S.declarations.filter(I=>I.kind===ne.Operation).map(I=>({...I.node,scope:I.scope.filter(M=>!u.has(M))})),O=new Map,T=ke(t),R=l(I=>{let M=[],L=J(t[I]);for(let F=I;F<t.length&&!(F>I&&!T[F]&&Me(t[F]).trim()&&J(t[F])<=L);F++)M.push(F);return M},"range");for(let{slice:I,scope:M}of S.slices){if(I.location.path===i&&I.location.line>0)for(let L of R(I.location.line-1))O.set(L,{scope:M});for(let L of I.specifications.filter(F=>F.location.path===i&&F.location.line>0))for(let F of R(L.location.line-1))O.set(F,{scope:M});for(let L of I.commands.filter(F=>F.location.path===i&&F.location.line>0))for(let F of R(L.location.line-1))O.set(F,{scope:M,commandLine:L.location.line-1})}let N=new Map(S.declarations.map(I=>[I.node.location,I.scope]));for(let I of b.filter(M=>M.location.path===i)){let M=N.get(I.location);for(let L of R(I.location.line-1))O.set(L,{...O.get(L),scope:M,operation:I})}let B=new Map(b.map(I=>[I.location,I])),j=l((I,M)=>{let L=Me(t[I.line-1]??""),F=L.slice(I.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return F&&L.slice(I.column-1+F.length,I.column-1+F.length+M.length)===M?{...I,column:I.column+F.length}:I},"referenceLocation"),q=[];for(let{slice:I}of S.slices){for(let M of I.commands)for(let L of M.produces){if(L.location.path!==i)continue;let F=S.resolve(L.event,I),it=F.declaration?B.get(F.declaration.node.location)??null:null,bt={name:L.event,location:L.location,targetLocation:L.targetLocation??L.location,kind:F.kind,declaration:it,mappings:L.mappings};if(q.push(bt),F.kind===ne.Operation)for(let Sn of R(L.location.line-1)){let Hr=O.get(Sn);Hr&&O.set(Sn,{...Hr,production:bt})}}for(let M of I.specifications)for(let L of[...M.givenOperationFailures??[],...M.thenOperations??[],...M.thenCompensated??[]]){if(L.location.path!==i)continue;let F=S.resolve(L.operation,I);q.push({name:L.operation,location:L.location,targetLocation:j(L.location,L.operation),kind:F.kind,declaration:F.declaration?B.get(F.declaration.node.location)??null:null,mappings:[]})}}let W={declarations:b,systems:v.value.systems??[],references:q,contexts:O,types:v.value.types,concepts:v.value.concepts,targets:l(I=>{let M=S.slices.find(L=>L.scope.length===I.length&&L.scope.every((F,it)=>F===I[it]))?.slice;return M?b.flatMap(L=>{let F=S.resolve(L.name,M).declaration?.node.location===L.location?L.name:[...L.scope,L.name].join(".");return S.resolve(F,M).kind===ne.Operation&&S.resolve(F,M).declaration?.node.location===L.location?[{name:F,declaration:L}]:[]}):[]},"targets")},G=v.physicalEventSources.map(I=>I.source),Y=new Bt(v.physicalEventSources,v.sourceInventoryComplete&&!A),V=new Map,ae=l((I,M)=>{let L=JSON.stringify([I,M]),F=V.get(L);return F||(F=Y.resolve(I,M),V.set(L,F)),{...F,source:F.state==="unique"?F.sources[0]:void 0,stream:F.state==="unique"?F.streams[0]:void 0}},"resolve"),xe=new Set(v.value.imports.map(I=>I.qualifiedName)),Pe=G.flatMap(I=>I.streams.filter(M=>ae(I.name,M.name).state==="unique"&&!xe.has(`${I.name}.${M.name}`)).map(M=>({name:`${I.name}.${M.name}`,source:I,stream:M}))),U=new Map,re=[];for(let I of k.values()){for(let M of R(I.location.line-1))U.set(M,{command:I});for(let M of[...I.produces,...I.validations,...I.handler?[I.handler]:[]])for(let L of R(M.location.line-1))U.delete(L);if(I.stream){re.push(I.stream);for(let M of R(I.stream.location.line-1))U.set(M,{command:I,route:I.stream})}}let de=us(v.value,i,t,R,u,v.diagnostics),$e=[...[...C.values()].flatMap(I=>[...I.given.map(M=>({event:M,expectation:!1})),...I.whenAppended?[{event:I.whenAppended,expectation:!1}]:[],...I.thenEvents.map(M=>({event:M,expectation:!0})),...I.whenRedelivered?[{event:I.whenRedelivered,expectation:!0}]:[]]),...(de.eventExamples??[]).map(I=>({event:I,expectation:!0}))];for(let I of $e){let M=I.event;for(let L of R(M.location.line-1))U.set(L,I);if(M.stream){re.push(M.stream);for(let L of R(M.stream.location.line-1))U.set(L,{...I,route:M.stream})}}for(let I of G.filter(M=>M.location.path===i)){for(let M of R(I.location.line-1))U.set(M,{source:I});for(let M of I.streams)for(let L of R(M.location.line-1))U.set(L,{source:I,stream:M})}let ht=[...k.values()].flatMap(I=>I.streamCandidates??[]).filter(I=>I.propertyCandidate!==null),St={declarations:G,routes:re,ambiguousCandidates:ht,contexts:U,targets:Pe,resolve:ae},pe;return{commands:k,specifications:C,diagnostics:g,operationProductionLines:E,operations:W,eventSources:St,examples:de,dependencies:{completions(I,M,L){if(pe===void 0){let F=Xe(h.source,i,h.placement,!1).value,it=l(bt=>{P(bt.location),bt.features.forEach(it)},"remapDependencyHeaders");F.modules.forEach(it),pe=ms(v.value,F,i,R,u)}return pe.completions(I,M,L)}}}}l(fu,"analyze");function Yt(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=un.get(o);return s===void 0&&(s=fu(t,e,n,i,r),un.size>=16&&un.delete(un.keys().next().value),un.set(o,s)),s}l(Yt,"responseAnalysis");var zr="file",uu=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,mu=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function MO(t){return mu.test(t)}l(MO,"isAbsoluteFileReferencePath");function yu(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}l(yu,"withoutComment");function Vr(t,e){let n=J(t),i=yu(t.slice(n)).trimEnd();if(Mi(i)!==zr)return;let r=i.slice(zr.length),o=r.trim();if(o.length===0||uu.test(o))return;let s=r.length-r.trimStart().length,a=n+zr.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}l(Vr,"fileReferenceOn");function NO(t){let e=ke(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=Vr(t[i],i);r&&n.push(r)}return n}l(NO,"fileReferences");function mt(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=Me(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}l(mt,"eventAnalysisSource");var hu=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,Su=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?\s*$/,ys=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,gu=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,xu=["authorize","produces","reads"],vu=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,$u=tn,ku=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],bu=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function yt(t){return t.typeReference??Wt(t.type)}l(yt,"propertyTypeReference");function Qr(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}}l(Qr,"sourceTypeAt");function Gr(t,e,n){return e.map(i=>({index:i,match:t[i].match(Su)})).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:Wt(r[2]),sourceType:Qr(t[i],t[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]!==void 0?{isGenerated:!0}:{},line:i}))}l(Gr,"propertiesIn");function yn(t,e,n,i){let r=[];for(let o=n+1;o<t.length;o++){if(e[o])continue;let s=t[o];if(s.trim().length!==0){if(J(s)<=i)break;r.push(o)}}return r}l(yn,"collectBody");function Ut(t,e,n,i){let r=yn(t,e,n,i).filter(a=>!e[a]&&!/^\s*(?:\/\/|#)/.test(t[a]));if(!/^\s*command\b/.test(t[n]))return r;let o,s=!1;return r.filter(a=>{let c=J(t[a]),p=t[a].trim();return o!==void 0&&c>o&&(!s||vu.test(p))?!1:(o=p!=="validate csharp"&&Gr(t,[a],xu).length>0||/^description(?:\s|$)/.test(p)?void 0:c,s=/^authorize(?:\s|$)/.test(p),!0)})}l(Ut,"directBody");var mn=new Map;function hn(t){let e=t.join(`
|
|
31
|
-
`),n=mn.get(e);if(n)return n;let i=Yt(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=mt(t);let o=ke(t),s=t,a=o,c=t.map(p=>p.replace(/\s*=(?!=|>).*/,""));for(let p=0;p<t.length;p++){if(o[p])continue;let m=t[p],u=m.trim(),y=J(m),h=s[p].trim().match(/^import\s+([\w.]+)\s*$/);if(h&&y===0){let S=h[1],E=S.split(".").pop()??S;r.imports.push({qualifiedName:S,shortName:E,line:p});continue}let x=u.match(hu);if(x){let S=yn(t,o,p,y).map(O=>t[O].trim()),E={};for(let O of S){let T=O.match(ys);T&&E[T[1]]===void 0&&(E[T[1]]=T[2])}let b=x[2]==="Enum"?S.filter(O=>!ys.test(O)):[];r.concepts.push({name:x[1],primitive:x[2],attributes:x[3].trim().split(/\s+/).filter(Boolean),attributeReasons:E,enumValues:b,line:p});continue}let v=u.match(/^type\s+(\w+)\s*$/);if(v){r.types.push({name:v[1],properties:Gr(t,yn(t,o,p,y),Jr),line:p});continue}let k=u.match(/^policy\s+(\w+)\s*$/);if(k){let S=yn(t,o,p,y).filter(E=>!o[E]).map(E=>t[E].trim());r.policies.push({name:k[1],requires:S,line:p});continue}let C=s[p].trim().match(/^(?:produces\s+)?event\s+(\w+)(?:\s+generation\s+(\d+))?\s*$/);if(C){let S=u.startsWith("produces "),E=Ut(s,a,p,y),b=S?E:E.filter(O=>Vr(s[O],O)===void 0);r.events.push({name:C[1],...C[2]?{generation:Number(C[2])}:{},inline:S,properties:Gr(S?c:s,b,S?ku:$u),line:p});continue}let $=i.commands.get(p);if($){let S=Ut(t,o,p,y),E=S.filter(b=>/^\s*produces\b/.test(t[b])&&!i.operationProductionLines?.has(b));r.commands.push({name:$.name,properties:$.properties.map(b=>({name:b.name,type:`${b.type.name}${b.type.isCollection?"[]":""}${b.type.isOptional?" optional":""}`,typeReference:{name:b.type.name,isCollection:b.type.isCollection,isOptional:b.type.isOptional},sourceType:Qr(t[b.type.location.line-1],b.type.location.column),isIdentifier:b.isIdentifier||/\sidentifier\s*$/.test(t[b.location.line-1]),...b.isGenerated?{isGenerated:!0}:{},line:b.location.line-1})),response:$.response,productionHeaders:E,produces:E.flatMap(b=>{let O=s[b].trim(),T=/^produces\s+event\b/.test(O),R=/^produces\s+when\b/.test(O),N=R?Ut(s,a,b,J(s[b]))[0]:b;if(N===void 0)return[];let B=R?s[N].trim():O.match(T?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(B===void 0||!/^[A-Za-z_]\w*$/.test(B))return[];let j=Ut(s,a,N,J(s[N])),q=j.map(Y=>s[Y].trim().match(/^for(?:\s+(.*))?$/)).filter(Y=>Y!==null),W=q.length===0?void 0:q.length===1?q[0][1]??"":"",G=j.flatMap(Y=>{let V=s[Y].trim().match(T?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return V===null?[]:[{name:V[1].replace(/^@/,""),source:V[2],line:Y}]});return[{name:B,inline:T,conditional:R,line:b,target:W,mappings:G}]}),reads:S.filter(b=>!o[b]).map(b=>({line:b,match:t[b].match(gu)})).filter(b=>b.match!==null).map(({line:b,match:O})=>({view:O[1],...O[2]?{alias:O[2]}:{},...O[3]?{by:O[3]}:{},line:b})),line:p});continue}let P=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let S=yn(t,o,p,y).map(E=>({index:E,match:t[E].match(bu)})).filter(E=>E.match!==null).map(({index:E,match:b})=>({name:b[1],type:b[2],typeReference:Wt(b[2]),sourceType:Qr(t[E],t[E].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:E}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:Wt(P[2]),parameters:S,line:p});continue}let A=u.match(/^screen\s+(\w+)\s*$/);if(A){r.screens.push({name:A[1],line:p});continue}let g=u.match(/^trigger\s+(\w+)\s*$/);g&&y===0&&r.triggers.push({name:g[1],line:p})}return mn.size>=16&&mn.delete(mn.keys().next().value),mn.set(e,r),r}l(hn,"scanDocument");function wi(...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)}}l(wi,"mergeSymbols");function hs(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...wi(hn(t),e??wi()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}l(hs,"symbolsForBuffer");function Oi(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}l(Oi,"knownEventNames");var Eu=["Startup","Shutdown"];function _O(t){return[...Oi(t),...t.triggers.map(e=>e.name),...Eu]}l(_O,"knownTriggerNames");function Zr(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}l(Zr,"knownTypeNames");function Kr(t){let e=t.properties.filter(o=>o.isIdentifier&&!yt(o).isOptional&&!yt(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}}l(Kr,"productionDestinations");function rI(t,e){let n=Yt(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=mt(t);return hn(i).commands.map(r=>({...r,produces:r.produces?.filter(o=>!n.operationProductionLines?.has(o.line)&&n.operations.references.some(s=>s.location.line-1===o.line&&s.kind==="event")),productionHeaders:r.productionHeaders?.filter(o=>!n.operationProductionLines?.has(o))})).flatMap(r=>{let{identifier:o,mixed:s}=Kr(r);if(s||r.productionHeaders?.length!==r.produces?.length)return[];let a=r.produces?.some(c=>c.target!==void 0||c.inline);return(r.produces??[]).flatMap(c=>c.target!==void 0||c.inline&&(o===void 0||/\bgeneration\b/.test(i[c.line]))?[]:!c.inline&&a?[]:[{line:c.line,column:i[c.line].length+1,label:c.inline?`for ${o}`:"for <new event source>"}])})}l(rI,"destinationHints");var _={conflictingScreenDataBinding:"PLAY0530",screenDataQueryMismatch:"PLAY0531",actionWithoutInputSurface:"PLAY0532",commandWithoutInputSurface:"PLAY0533",readModelFieldWithoutOrigin:"PLAY0534",queryParameterNotHeldByView:"PLAY0535",unconsumedEvent:"PLAY0536",unreachableScreen:"PLAY0537",invalidActionAlternative:"PLAY0341",guardedActionWithoutAlternatives:"PLAY0342",misplacedActionOtherwise:"PLAY0343",unsupportedActionConditionOperand:"PLAY0344",unknownActionSubjectField:"PLAY0345",unresolvedActionSubject:"PLAY0346",unreachableActionAlternative:"PLAY0347",unknownActionArgumentProperty:"PLAY0348",invalidRefusalBranch:"PLAY0538",invalidRefusalBranchBody:"PLAY0539",unreachableRefusalBranch:"PLAY0540",invalidRefusalValue:"PLAY0541",unknownRefusalConstraint:"PLAY0542",unmatchedRedeliveredOccurrence:"PLAY0543",unknownRedeliveryReaction:"PLAY0544",invalidNoEventsExpectation:"PLAY0545",indeterminateNegatedClaimTarget:"PLAY0546",invalidAbsentReadModelStep:"PLAY0453",unknownConstraintProperty:"PLAY0391",invalidSpecificationExample:"PLAY0518",duplicateSpecificationAssignment:"PLAY0519",unknownReadModelProperty:"PLAY0514",piiNotSupportedOnIdentifier:"PLAY0515",invalidEventSourceDeclaration:"PLAY0503",invalidCommandStream:"PLAY0504",invalidSpecificationStream:"PLAY0547",specificationStreamOnCommand:"PLAY0548",invalidSpecificationStreamRoute:"PLAY0549",invalidSpecificationStreamEventSource:"PLAY0550",specificationStreamContradictsCommand:"PLAY0551",ambiguousCommandStream:"PLAY0505",unsupportedStreamIdType:"PLAY0506",redundantSourceStreamId:"PLAY0507",eventFromLaterSlice:"PLAY0516",timelineCycleGroup:"PLAY0517",invalidSpecificationExampleBody:"PLAY0526",undeclaredDependency:"PLAY0552",unusedDependencyDeclaration:"PLAY0553",invalidDependencyTarget:"PLAY0554",repeatedDependencyDeclaration:"PLAY0555",mutualDependencyDeclarations:"PLAY0556",authorizationRefusalWithoutIdentity:"PLAY0557",invalidDocumentation:"PLAY0558",conflictingDocumentationAcrossFiles:"PLAY0559",unsupportedInteractionAlternatives:"PLAY0560",mixedInteractionAlternatives:"PLAY0561",interactionAlternativeWithoutActions:"PLAY0562",inlineInteractionAlternative:"PLAY0563",legacyInteractionWhere:"PLAY0564",ambiguousReference:"PLAY0198",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 Cu=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,Pu=/^import\s+"/;function gs(t){return Pu.test(t.trim())}l(gs,"isFileImportLine");function _r(t,e){let n=J(t),i=t.slice(n).match(Cu);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}l(_r,"fileImportOn");function cI(t){let e=ke(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=_r(t[i],i);r&&n.push(r)}return n}l(cI,"fileImports");var Ss=l(t=>t.split("/").slice(0,-1),"folderOf");function Au(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("/")}l(Au,"relativeTo");function dI(t,e){let n=Ss(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=Au(n,r),s=Ss(o);i.add(o),i.add([...s,"*.play"].join("/"));for(let a=0;a<=s.length;a++)i.add([...s.slice(0,a),"**","*.play"].join("/"))}return[...i].sort()}l(dI,"importablePaths");var wu=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),Ou=/^id\s+"((?:[^"\\]|\\.)*)"$/;function xs(t,e,n,i=new Set){t=mt(t);let r=[],o=ke(t),s=Iu(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),c=new Map,p=new Set;for(let y of[e,n]){for(let h of y.events)c.set(h.name,(c.get(h.name)??0)+1);for(let h of y.imports)p.add(h.shortName)}let m=l((y,h,x,v="error")=>{r.push({line:y,startColumn:J(t[y])+1,endColumn:t[y].length+1,code:h,message:x,severity:v})},"report");for(let y of e.events){let h=Ut(t,o,y.line,J(t[y.line]));if(y.inline){let k=new Set;for(let C of y.properties)k.has(C.name)&&m(C.line,_.duplicateDeclaration,`Event '${y.name}' already declares property '${C.name}'.`),k.add(C.name);a.has(y.line)||m(y.line,_.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,_.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((c.get(y.name)??0)>1||p.has(y.name))&&m(y.line,_.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let x=!1,v=!1;for(let k of h){let C=t[k].trim(),$=C.split(/\s+/)[0];if(y.inline&&$==="generation"&&m(k,_.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&$==="origin"&&m(k,_.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(C)){if($==="id"){let P=C.match(Ou);x||P===null||P[1].trim().length===0?m(k,_.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(k,_.redundantEventId,"This id repeats the event name; remove it.","information"),x=!0}if($==="documentation"){let P=k+1;for(;P<t.length&&t[P].trim().length===0;)P++;(v||C!=="documentation"||t[P]?.trim()!=="```markdown"||J(t[P])<=J(t[k])||!s.has(P))&&m(k,_.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),v=!0}}}}let u=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=J(t[y]);for(;u.length>0&&u[u.length-1].indent>=h;)u.pop();let x=t[y].trim().split(/\s+/)[0];wu.has(x)&&u.at(-1)?.event&&m(y,_.reservedProductionMetadata,`'${x}' is system-assigned production metadata.`),x==="produces"&&u.push({indent:h,event:!i.has(y)&&!/^\s*produces\s+operation\b/.test(t[y])})}for(let y of e.commands){let{identifier:h,mixed:x}=Kr(y);for(let v of y.produces??[]){x&&v.target===void 0&&m(v.line,_.explicitProducesTargetsRequired,`Production '${v.name}' must state for explicitly when destinations differ.`);let k=v.target??(v.inline?h:void 0);if(!(h===void 0||k!==h))for(let C of v.mappings.filter($=>$.source===h))m(C.line,_.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,v.inline?"warning":"information")}}return r}l(xs,"validateInlineEvents");function Iu(t,e){let n=new Set,i,r=!1;for(let o=0;o<t.length;o++){if(!e[o])continue;let s=t[o].trim();i===void 0?(i=o,r=!1):s==="```"?(r&&t[i].trim()==="```markdown"&&n.add(i),i=void 0):s.length>0&&(r=!0)}return n}l(Iu,"nonemptyMarkdownBlocks");function De(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}l(De,"issue");function Fe(t,e,n,i,r,o){let s=n.indexOf(i)+1;return De(t,e,s,i.length,r,o)}l(Fe,"tokenIssue");function Tu(t,e,n){let i=[],r=new Set([...Zr(e,gn),...Zr(n,[])]),o=l((a,c)=>{for(let p of a.filter(m=>!r.has(yt(m).name))){let m=yt(p).name;i.push(De("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${p.name}' of ${c} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${p.name}' of ${c} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,_.unknownType))}},"checkProperties");for(let a of e.types)o(a.properties,`type '${a.name}'`);for(let a of e.events)o(a.properties,`event '${a.name}'`);for(let a of e.queries)o(a.parameters,`query '${a.name}'`);for(let a of e.commands){o(a.properties,`command '${a.name}'`);let c=a.properties.filter(p=>p.isIdentifier);for(let p of c.slice(1))i.push(Fe("error",p.line,t[p.line],"identifier",`Command '${a.name}' already marks '${c[0].name}' as identifier \u2014 only one property can be the identifier.`,_.duplicateCommandIdentifier))}let s=new Map;for(let a of[...e.concepts,...e.types]){if(s.get(a.name)===void 0){s.set(a.name,a.line);continue}i.push(Fe("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,_.duplicateDeclaration))}return i}l(Tu,"validateDeclarations");function jI(t,e={}){let n=ke(t),i=hn(t),r=e.application??wi(),o=hs(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=Yt(t,o.authoringDocuments??o.authoringSources?.filter(S=>S!==t.join(`
|
|
32
|
-
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(S=>S.location.line-1)),c={...i,commands:i.commands.map(S=>({...S,properties:S.properties.filter(E=>!a.has(E.line)),produces:S.produces?.filter(E=>!s.operationProductionLines?.has(E.line)),productionHeaders:S.productionHeaders?.filter(E=>!s.operationProductionLines?.has(E))}))},p=new Set([...Oi(c),...Oi(r)]),m=new Set([...c.policies,...r.policies].map(S=>S.name)),u=Tu(t,c,r);u.push(...Ru(t,c));let y=new Set([d.LegacyOptionalSuffix,d.InvalidOptionalModifierOrder,d.OptionalReadsNotSupported]),h=new Set([d.UnexpectedTokenInPolicyCondition,d.ExpectedPolicyCondition,d.UnclosedPolicyConditionGroup,d.ExpectedRoleName,d.ExpectedClaimName,d.ExpectedClaimMatches,d.ExpectedClaimMatchTarget]),x=new Set([d.UnknownEvent,d.UnknownReadModelProperty,d.PiiNotSupportedOnIdentifier]),v=new Set([d.EventFromLaterSlice,d.TimelineCycleGroup]),k=new Set([d.UndeclaredDependency,d.UnusedDependencyDeclaration,d.InvalidDependencyTarget,d.RepeatedDependencyDeclaration,d.MutualDependencyDeclarations,d.AmbiguousReference]),C=new Set([d.UnsupportedInteractionAlternatives,d.MixedInteractionAlternatives,d.InteractionAlternativeWithoutActions,d.InlineInteractionAlternative,d.LegacyInteractionWhere,d.InvalidDocumentation,d.ConflictingDocumentationAcrossFiles,d.InvalidAbsentReadModelStep,d.UnknownConstraintProperty,d.OmittedProductionDestination,d.InvalidSpecificationExample,d.DuplicateSpecificationAssignment]),$=new Set;for(let S of e.compilerDiagnostics??s.diagnostics){if(!y.has(S.code)&&!h.has(S.code)&&!x.has(S.code)&&!v.has(S.code)&&!k.has(S.code)&&!C.has(S.code)&&S.code!==d.InvalidSpecificationExampleBody&&S.code!==d.UnknownRuleImplementationDirective&&S.code!==d.InvalidValidationRule&&S.code!==d.RepeatedDeclarationAcrossFiles&&!/^PLAY049[0-9]$|^PLAY050[0-7]$|^PLAY054[7-9]$|^PLAY055[01]$|^PLAY048[2-9]$|^PLAY004[56]$|^PLAY053[0-9]$|^PLAY054[0-6]$|^PLAY034[1-8]$|^PLAY0557$/.test(S.code))continue;let E=S.location.line-1;if(S.code===d.OmittedProductionDestination&&u.some(O=>O.code===S.code&&O.line===E))continue;S.code===d.UnknownEvent&&$.add(E);let b=jr(t[E],S)||t[E].length-S.location.column+1;u.push(De(S.severity,E,S.location.column,b,S.message,S.code))}let P=l((S,E,b)=>{!p.has(b)&&!$.has(S)&&u.push(Fe("warning",S,E,b,`Unknown event type '${b}' \u2014 declare it in a slice or import it.`,_.unknownEvent))},"checkEvent"),A=-1;for(let S=0;S<t.length;S++){let E=t[S],b=E.trim();if(n[S]||b.length===0)continue;let O=E.match(/^[ ]*(\t+)/);if(O&&u.push(De("warning",S,O[0].length-O[1].length+1,O[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",_.tabIndentation)),A>=0){if(J(E)>A&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(b)){for(let Y of b.split(/\s+/).filter(V=>V!=="or"))m.has(Y)||u.push(Fe("warning",S,E,Y,`Unknown policy '${Y}' \u2014 declare it with 'policy ${Y}'.`,_.unknownPolicy));continue}A=-1}let T=Du(t,n,S);T&&u.push(T);let R=b.match(/^slice\s+(\w+)/);R&&!Di.includes(R[1])&&u.push(Fe("error",S,E,R[1],`Unknown slice type '${R[1]}' \u2014 expected ${Di.join(", ")}.`,_.unknownSliceType));let N=b.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!gn.includes(N[1])&&u.push(Fe("error",S,E,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${gn.join(", ")} or Enum.`,_.unknownPrimitiveType));let B=b.match(/^authorize\s+(.*)$/);if(B){A=J(E);for(let Y of B[1].split(/\s+/).filter(V=>V!=="or"&&V.length>0))m.has(Y)||u.push(Fe("warning",S,E,Y,`Unknown policy '${Y}' \u2014 declare it with 'policy ${Y}'.`,_.unknownPolicy))}let j=b.match(/^on\s+([A-Z]\w*)\s*$/);j&&P(S,E,j[1]);let q=b.match(/^produces\s+([A-Z]\w*)\s*$/);if(q&&!s.operationProductionLines?.has(S)&&P(S,E,q[1]),/^produces\s+when\b/.test(b)&&!s.operationProductionLines?.has(S))for(let Y=S+1;Y<t.length;Y++){let V=t[Y];if(!(n[Y]||V.trim().length===0)){if(J(V)>J(E)){let ae=V.trim().match(/^([A-Z]\w*)\s*$/);ae&&P(Y,V,ae[1])}break}}let W=b.match(/^unique\s+event\s+([A-Z]\w*)/);W&&P(S,E,W[1]);let G=b.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);G&&P(S,E,G[1]);for(let Y of E.match(/\$context\.[\w.]+/g)??[]){let V=Y.substring(9).split(".");Ii.includes(V[0])?V[0]==="causedBy"&&V.length>1&&!Ti.includes(V[1])?u.push(Fe("warning",S,E,Y,`Unknown $context.causedBy property '${V[1]}' \u2014 expected ${Ti.join(", ")}.`,_.unknownContextCausedByProperty)):V[0]==="identity"&&V.length>1&&!Ri.includes(V[1])&&u.push(Fe("warning",S,E,Y,`Unknown $context.identity property '${V[1]}' \u2014 expected ${Ri.join(", ")}.`,_.unknownContextIdentityProperty)):u.push(Fe("warning",S,E,Y,`Unknown $context path '${V.join(".")}' \u2014 expected one of ${Ii.join(", ")}.`,_.unknownContextPath))}}u.push(...Nu(t,n)),u.push(...xs(t,c,r,s.operationProductionLines));let g=t.map((S,E)=>({line:S,index:E})).filter(({line:S})=>/^\s*```(?:[a-z]+)?\s*$/.test(S));if(g.length%2===1){let S=g[g.length-1];u.push(De("error",S.index,1,S.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",_.unclosedCodeBlock))}return u}l(jI,"validateLines");function Ru(t,e){let n=[];t=mt(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!yt(o).isOptional&&!yt(o).isCollection);if(r.length===1)for(let o of i.produces??[]){if(o.inline||o.conditional||o.target!==void 0)continue;let s=o.line;n.push(De("information",s,J(t[s])+1,t[s].trim().length,`Plain 'produces ${o.name}' omits its destination \u2014 use 'for ${r[0].name}' to explicitly select the command's identifier.`,_.omittedProductionDestination))}}return n}l(Ru,"validateProductionDestinations");function Du(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||_r(i,n))return;let o=J(i);if(!(!(o>0&&["module","feature"].includes(Xr(t,e,n,o)[0]))&&!gs(i)))return De("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,_.invalidFileImport)}l(Du,"validateImport");var Mu=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Nu(t,e){let n=[],i=l(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 c of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let p=c[0].substring(c[1]?.length??0),m=c[2];if(m.length===0){c[1]&&n.push(De("error",r,(c.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(qi("").expected)}.`,_.missingEventContextPath));continue}let u=m.substring(1),y=qi(u),h=(c.index??0)+(c[1]?.length??0)+1;switch(y.status){case"missing":n.push(De("error",r,h,p.length,`'$eventContext.${u}' names no member - expected one of ${i(y.expected)}.`,_.missingEventContextPath));break;case"unknownMember":n.push(De("warning",r,h,p.length,`Unknown event context member '${y.segment}' in '$eventContext.${u}' - expected one of ${i(y.expected)}.`,_.unknownEventContextMember));break;case"unknownSubPath":{let x=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(De("warning",r,h,p.length,`Unknown event context path '$eventContext.${u}' - '${y.member?.name}' (${y.member?.type}) has ${x}.`,_.unknownEventContextPath));break}case"belowCollection":n.push(De("error",r,h,p.length,`'$eventContext.${u}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,_.eventContextPathBelowCollection));break}}let s=o.trim().match(Mu)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(Fe("warning",r,o,s,`Dynamic dictionary key '$${a}' in '${s}' is never resolved - only '$eventContext.<path>' is, so the literal text '$${a}' becomes the key.`,_.unresolvedDynamicKeySource))}return n}l(Nu,"validateEventContextPaths");export{vs as a,ju as b,Lu as c,Jr as d,qu as e,Ii as f,Ti as g,Di as h,gn as i,Bu as j,$s as k,Fu as l,Ai as m,Wt as n,Uu as o,d as p,me as q,Qi as r,wn as s,NC as t,jC as u,Me as v,J as w,Mi as x,ke as y,Xr as z,Vu as A,Qu as B,mt as C,Ni as D,ji as E,Li as F,ks as G,Hu as H,Ju as I,Xu as J,bs as K,Es as L,am as M,sm as N,lm as O,cm as P,dm as Q,pm as R,fm as S,um as T,mm as U,ym as V,hm as W,Ps as X,Sm as Y,bm as Z,Em as _,Cm as $,As as aa,Pm as ba,Am as ca,wm as da,Om as ea,ws as fa,Im as ga,Tm as ha,Rm as ia,Dm as ja,Mm as ka,Nm as la,jm as ma,Lm as na,qm as oa,Bm as pa,Fm as qa,Ym as ra,Um as sa,no as ta,Os as ua,Wm as va,zm as wa,Vm as xa,Qm as ya,Gm as za,Is as Aa,Zm as Ba,Ts as Ca,Km as Da,_m as Ea,Hm as Fa,Jm as Ga,Xm as Ha,IO as Ia,Yt as Ja,zr as Ka,MO as La,Vr as Ma,NO as Na,yt as Oa,Ut as Pa,hn as Qa,wi as Ra,hs as Sa,Oi as Ta,Eu as Ua,_O as Va,Zr as Wa,Kr as Xa,rI as Ya,_ as Za,gs as _a,_r as $a,cI as ab,dI as bb,jI as cb,Nu as db};
|
|
33
|
-
//# sourceMappingURL=chunk-TIRY74MT.js.map
|