@cratis/screenplay-language 4.103.0 → 4.105.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.
@@ -1,33 +0,0 @@
1
- import{a as l}from"./chunk-AYDF3IFZ.js";var ws="screenplay",Vf={id:ws,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Qf=["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 to=["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"],Gf=["csharp","typescript","react","html","sql"],Ti=["command","arguments","tenant","causedBy","causation","occurred","identity"],Ri=["subject","name","userName"],Di=["id","name","userName","isAuthenticated","roles","claims"],Mi=["StateChange","StateView","Automation","Translate"],xn=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Zf=["pii","personal","secret"],Os=/^\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[^=]*$/,_f={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Os,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 Hf(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}l(Hf,"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 X(t){return t.length-t.trimStart().length}l(X,"indentOf");function ji(t){return t.trim().split(/\s+/)[0]??""}l(ji,"firstWord");function be(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(be,"fenceMap");function no(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=X(a);c<o&&(r.push(ji(a)),o=c)}return r}l(no,"enclosingChain");function em(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&&X(o)<i)return o.trim()}}l(em,"nearestEnclosingLine");function tm(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=X(a);c<o&&(r.push(a.trim()),o=c)}return r}l(tm,"enclosingHeaders");var io="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 Li(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(Li,"namesEventContextMember");var qi=zt[io];function Is(t){let e=qi;for(let n of t){let i=e.find(r=>Li(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=zt[i.type]??[]}return e}l(Is,"eventContextMembersAfter");function am(t){return t.length===0?void 0:Is(t.slice(0,-1))?.find(n=>Li(n,t[t.length-1]))}l(am,"eventContextMemberAt");function Bi(t){let e,n=qi;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=>Li(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(Bi,"resolveEventContextPath");function sm(){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:**",...qi.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
2
- `)}l(sm,"describeEventContext");function lm(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(lm,"describeEventContextMember");var ot={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 Yi=[{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."}],Ts=[ot,...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."},...Yi],Rs=[ot,...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."},...Yi],ym=[ot,{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."}],hm=[{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."}],Sm=[{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."},...Yi],gm=[{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."}],xm=[{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."}],je=l((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),Ds=[je("execute","execute ${1:command}","Runs a command."),je("navigate to","navigate to ${1:Screen}","Opens a screen."),je("open","open ${1:Dialog}","Opens a dialog."),je("close","close","Closes the dialog."),je("refresh","refresh ${1:query}","Reloads a query."),je("set","set ${1:name} ${2:value}","Sets a value."),je("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),je("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),je("raise","raise ${1:Trigger}","Raises a trigger.")],vm=[je("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),je("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Ds],$m=[{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."}],bm=[{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."}],km=[{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."}],Em=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],Cm=[{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."}],Ms=[{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."}],Pm=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...Ms,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var Rm=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],ke=l(t=>`\`\`\`${t}
6
- \${1}
7
- \`\`\``,"fenced"),Dm=[...gt,{label:"eventsource",insertText:"eventsource ${1:Name}\n identifier ${2:Type}\n stream ${3:Name}",documentation:"Application-owned source with nested streams, admitted by ESM v8. Pin the stored name before renaming a source with stored events; Default is reserved."},{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 value is personal data}"',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."}],Mm=[{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."}],js=[{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:ke(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],jm=[{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."},...js.filter(t=>t.label!=="hint")],Nm=[{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 value is personal data}"',documentation:"A free-text concept note, not a lawful basis."},{label:"secret reason",insertText:'secret reason "${1:why this value is an operational secret}"',documentation:"Records why the secret marker applies."},{label:"secret scope",insertText:"secret scope ${1|subject,namespace,global|}",documentation:"Explicit encryption scope; omitted scope keeps Chronicle\u2019s Subject default."},{label:"pii special",insertText:"pii special ${1|racialOrEthnicOrigin,politicalOpinions,religiousOrPhilosophicalBeliefs,tradeUnionMembership,genetic,biometric,health,sexLifeOrSexualOrientation|}",documentation:"GDPR Art. 9(1) special category of personal data."},{label:"pii criminal",insertText:"pii criminal",documentation:"Personal data relating to criminal convictions and offenses (GDPR Art. 10)."},{label:"validate",insertText:'validate\n ${1:not empty} message "${2:message}"',documentation:"Validation rules that travel with the value everywhere it appears."}],Lm=[{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."}],ro=[ot,...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."}],qm=[ot,{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
- ${ke("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."}],Ns=[{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."}],Bm=[...Ns,{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."}],Ym=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Fm=[{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:ke(t),documentation:"Selects one inline payload. Handler execution remains unsupported."}))],Um=[{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:ke("csharp"),documentation:"Inline C# returning the events to append."}],Wm=[{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."}],zm=[{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the query implementation to an external file."},{label:"csharp",insertText:ke("csharp"),documentation:"Inline C# returning the query result, with the QueryContext in scope as context."},{label:"sql",insertText:ke("sql"),documentation:"Inline SQL returning the query result."}],Vm=[{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."}],Qm=[ot,{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."}],Gm=[{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:ke("csharp"),documentation:"Inline C# returning event side effects."}],at="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",Zm=[{label:"on refused",insertText:`on refused
11
- acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${at}`},{label:"on refused by validation",insertText:`on refused by validation
12
- acknowledge`,documentation:`Handles validation refusals. ${at}`},{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. ${at}`},{label:"on refused by authorization",insertText:`on refused by authorization
13
- acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${at}`}],_m=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${at}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${at}`}],Km=[{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."}],Hm=[{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. ${at}`},{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."}],oo={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. ${at}`},{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."}]},Ls=[{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:ke("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],Jm=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...Ls.filter(t=>t.label!=="hint")],Xm=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:ke("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],ey=[{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:ke("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],ty=[{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."}],ny=[{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:ke("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:ke("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:ke("html"),documentation:"Inline static HTML."}],qs=[{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."}],iy=[{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."},...qs.filter(t=>t.label!=="label")],Bs=[{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."}],ry=[{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."},...Bs],oy=[{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."}],ay=[{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."}],sy=[{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)`}))],Ys={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 ly(t){let e=t?Ys[t]:void 0;return e?ro.filter(n=>n.label==="example"||n.label==="documentation"||e.includes(n.label)):ro}l(ly,"sliceItemsFor");var d={LegacyComplianceMarker:"PLAY0565",UnknownComplianceMarker:"PLAY0566",InvalidSecretScope:"PLAY0567",DuplicateSecretScope:"PLAY0568",SecretScopeIgnoredForPii:"PLAY0569",InvalidPersonalDataQualifier:"PLAY0570",DuplicateSpecialCategory:"PLAY0571",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",DuplicateEventSubject:"PLAY0590",InvalidSubjectType:"PLAY0591",ProtectedSubjectType:"PLAY0592",InvalidSubjectOwner:"PLAY0593",ReadModelSubjectNotSupported:"PLAY0594",InvalidSubjectModifierOrder:"PLAY0595",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}",U="[\\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 Fs=new RegExp(`^depends${U}+on(?:${U}|$)`,"u"),Us=new RegExp(`${U}+$`,"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=Ws(a.substring(c),e),y=Fs.test(p)?p.replace(Us,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:c,content:y,startOffset:o}:{number:r,raw:a,indent:c,content:y,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 Ws(t,e){let n=Vt(t,e);return n<0?t:t.substring(0,n)}l(Ws,"stripComment");function se(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}l(se,"eventDeclarations");function vn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}l(vn,"operationDeclarations");var ie;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(ie||(ie={}));var ae=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 se(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:ie.Event,name:a.name,node:a,scope:r})),...vn(i).map(a=>({kind:ie.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:ie.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?ie.Unresolved:ie.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===ie.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==ie.Operation&&!(i.kind===ie.Ambiguous&&i.candidates.some(r=>r.kind===ie.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,y)=>c.scope[y]===p));if(a.length>0)return a}return[]}};function $n(t){let e=new ae(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($n,"productionDestinationDiagnostics");function bn(t,e){let n=new ae(t).slices.map(r=>r.slice),i=n.flatMap(se);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(bn,"validateConstraintProperties");var ao=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=>ao([...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&&ao(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function En(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=[],y=c.join(".");r.has(y)||r.set(y,new Set);let f=r.get(y);for(let m of a){let h=Ee.resolve(m.target,c,i),g=h.resolved===void 0?void 0:kn(h.resolved),v=g===void 0?`text:${m.target}`:`resolved:${g}`;if(f.has(v)){e.warning(d.RepeatedDependencyDeclaration,`Dependency '${m.target}' is already declared on this container - this repeated declaration is ignored`,m.location);continue}f.add(v),p.push(m),h.ambiguous.length>0?e.warning(d.AmbiguousReference,`Ambiguous dependency target '${m.target}' - candidates: ${h.ambiguous.map(kn).join(", ")}`,m.location):(g===void 0||g===y||g.startsWith(y+".")||y.startsWith(g+"."))&&e.warning(d.InvalidDependencyTarget,`Invalid dependency target '${m.target}' on '${y}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,m.location)}return p},"keep"),s=l((a,c)=>{let p=[...c,a.name];return{...a,dependsOn:o(a.dependsOn??[],p),features:a.features.map(y=>s(y,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(En,"validateDependencyDeclarations");var xt=[],Qt=l(t=>t.length===0,"isDocumentPlacement");function Cn(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}l(Cn,"describePlacement");var Ct=l((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var Ui=l(t=>t.content.length===0,"isBlank"),u=l(t=>Ct(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),so=l(t=>Ct(t.number,1,t.path),"startOf");var zs=w("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),Vs=new RegExp(w("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),Qs=w("^[A-Z]\\w*$");function st(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&zs.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=Gs(n),r=u(e);if(i.length===0)return t.error(d.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new Wi(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}l(st,"parseAuthorize");function Fe(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(Fe,"combineAuthorize");function Gs(t){let e=[];for(let n of t.match(Vs)??[])e.length>0&&Zs(e[e.length-1])&&_s(n)&&e.push("and"),e.push(n);return e}l(Gs,"tokenize");var lo=l(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),Zs=l(t=>t===")"||lo(t),"isOperandEnd"),_s=l(t=>t==="("||lo(t),"isOperandStart"),Wi=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 J='(?:[^"\\\\]|\\\\.)*',Ks={"\\":"\\",'"':'"',n:`
15
- `,r:"\r",t:" "};function ee(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?Ks[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}l(ee,"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}'`,u(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(d.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",u(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",u(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 Hs=w(`^description\\s+"(${J})"$`);function _(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`,u(e)),n):co(t,e,n,i,s)}let o=Hs.exec(e.content);return o===null?(t.error(d.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,u(e)),n):co(t,e,n,i,ee(o[1]))}l(_,"parseDescription");function co(t,e,n,i,r){return n!==null?(t.error(d.DuplicateDescription,`${i} already declares a description - at most one is allowed`,u(e)),n):r}l(co,"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`,u(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`,u(e)),n):o}l(ve,"parseDocumentation");var Js=Q(`^depends${U}+on${U}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function Pn(t,e,n,i){let r=Js.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,u(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`,u(e));return}n.push({kind:"DependsOnSyntax",target:r,location:u(e)})}l(Pn,"parseDependsOn");var Xs=w('^import\\s+"([^"\\\\]+)"$'),el=w('^import\\s+"'),po=l(t=>el.test(t),"isFileImport");function uo(t){let e=Xs.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:u(t)}}l(uo,"tryParseFileImport");function At(t,e,n){let i=uo(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>"'`,u(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"),ne=l(t=>t.replaceAll("@",""),"unescapeIdentifier");function fo(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(fo,"splitTopLevel");var zi="79228162514264337593543950335";function Ze(t){let e=mo(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>zi.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===zi.length&&a>zi)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(Ze,"parseExactNumber");function Gt(t){return mo(t)!==void 0}l(Gt,"isExactNumberToken");function mo(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&Vi(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&Vi(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&&Vi(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(mo,"scan");function Vi(t){return t>="0"&&t<="9"}l(Vi,"isDigit");var yo=64,Ae=class extends Error{static{l(this,"InvalidStructuredValue")}},An=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>=yo)throw new Ae(`The value nests deeper than ${yo} 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=Ze(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 tl=w("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),nl=Q("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),il=w("^-?\\d+(\\.\\d+)?$"),ho=["command","arguments","tenant","causedBy","causation","occurred","identity"],So=["subject","name","userName"],go=["id","name","userName","isAuthenticated","roles","claims"];function we(t,e,n){return re(t,e,n,!0)}l(we,"parseModeledMappingSource");function re(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 rl(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 An(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"?nl:tl).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}l(re,"parseMappingSource");function rl(t,e,n){let[i,r]=t.split(".");ho.includes(i)?r!==void 0&&i==="causedBy"&&!So.includes(r)?n?.warning(d.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${So.join(", ")}`,e):r!==void 0&&i==="identity"&&!go.includes(r)&&n?.warning(d.UnknownContextIdentityProperty,`Unknown $context.identity property '${r}' - expected ${go.join(", ")}`,e):n?.warning(d.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${ho.join(", ")}`,e)}l(rl,"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(ee(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!Gt(t))return;let o=Ze(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(il.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}l(Zt,"parseLiteral");var Qi={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function Ne(t,e,n,i=!1){i||(t=t.valueContext);let r=i?U:"\\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(`"${J}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let g=e.replace(a,"").replace(new RegExp(U,"gu"),"");if(g.length>0)return t.error(d.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${g[0]}'`,n),null}let c=e.match(a)??[],p=0,y=l(()=>{if(c[p]==="("){p++;let C=m();return c[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(d.UnclosedConditionGroup,"Expected ')' in condition",n),C}let g=c[p++];if(i&&g===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(Qi,v))return t.error(d.ExpectedComparisonOperator,`Expected a comparison operator after '${g}'`,n),null;let $=c[p++];return i&&$===void 0?(t.error(d.ExpectedComparisonValue,"Expected a value to compare against",n),null):g===void 0||$===void 0||Qi[v]===void 0?null:{kind:"ComparisonConditionSyntax",left:g,operator:Qi[v],right:we($,n,t),location:n}},"group"),f=l(()=>{let g=y();for(;g!==null&&c[p]==="and";){p++;let v=y();if(v===null)return null;g={kind:"LogicalConditionSyntax",left:g,operator:"And",right:v,location:n}}return g},"and"),m=l(()=>{let g=f();for(;g!==null&&c[p]==="or";){p++;let v=f();if(v===null)return null;g={kind:"LogicalConditionSyntax",left:g,operator:"Or",right:v,location:n}}return g},"or"),h=m();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(Ne,"parseCondition");var ol=w(`^when${U}+([^\\n]+)${U}+execute${U}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),al=w(`^otherwise${U}+execute${U}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),sl=w(`^with${U}+([A-Za-z_]\\w*)${U}+from${U}+([^\\n]+)$`),ll=w("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),cl=new RegExp(`^${U}+|${U}+$`,"gu");function vo(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=ol.exec(c.content),y=al.exec(c.content);if(p!==null){a&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",u(c));let f=Ne(t,p[1],u(c),!0),m=xo(t,c);f!==null&&(wt(t,f),r.push({kind:"ScreenActionAlternativeSyntax",condition:f,command:p[2],arguments:m,location:u(c)}))}else if(c.content==="otherwise hidden"||y!==null)if(a&&t.error(d.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",u(c)),a=!0,y!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:y[1],arguments:xo(t,c),location:u(c)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:u(c)};for(let f=t.peekChild(c.indent);f!==void 0;f=t.peekChild(c.indent))t.reader.takeSignificant(),t.error(d.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",u(f)),t.skipBlock(f.indent)}else if(D(c.content)==="navigate")s!==null&&t.error(d.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",u(c)),s=i(t,c.content,c)??null;else{let f=D(c.content)==="label";t.error(f?d.UnknownActionDirective:d.InvalidActionAlternative,f?"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 ...'`,u(c)),t.skipBlock(c.indent)}}return r.length===0&&t.error(d.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",u(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:u(e)}}l(vo,"parseGuardedAction");function xo(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=sl.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(cl,""),location:u(i)}):(t.error(d.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,u(i)),t.skipBlock(i.indent))}return n}l(xo,"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=ll.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 _e=class t{static{l(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(Ui)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&Ui(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 le=class extends Error{static{l(this,"InvalidSyntaxJson")}};var Oe=Object.freeze({numericMode:"legacy"}),wn=Object.freeze({numericMode:"exact"}),$o=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 le("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new le("Malformed source numeric options.");return e==="exact"?wn:Oe}l(Ot,"validatedSourceOptions");var bo=new WeakSet;function ko(t){bo.add(t)}l(ko,"recordAuthoredDocument");function Eo(t){return bo.has(t)}l(Eo,"isAuthoredDocument");var xe=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 dl=w(`^when${U}+([^\\n]+)${U}+execute${U}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),pl=w(`^on${U}+([^\\n]+)$`),Po=w(`^where${U}+([^\\n]+)$`),Co=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function Ao(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=pl.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let f=n+1;f<e.length&&e[f].indent>i.indent;f++)o.push(e[f]);let s=o.filter(f=>f.indent===o[0]?.indent),a=s.filter(f=>["when","otherwise"].includes(D(f.content))),c=["click","double click","select"].includes(r[1].trim()),p=s.filter(f=>Po.test(f.content)),y=!1;for(let f of a){let m=D(f.content)==="when",h=m?dl.exec(f.content):null;if(m){y&&t.error(d.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",u(f));let $=Ne(t,h?.[1]??f.content.slice(4).trim(),u(f),!0);$!==null&&wt(t,$),h!==null&&t.error(d.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",u(f))}else(y||f.content!=="otherwise")&&t.error(d.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",u(f)),y=!0;let g=o.indexOf(f),v=o[g+1];h===null&&(v===void 0||v.indent<=f.indent||!Co.has(D(v.content)))&&t.error(d.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",u(f))}if(a.length>0&&(c||t.error(d.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",u(i)),(p.length>0||s.some(f=>Co.has(D(f.content))))&&t.error(d.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",u(i)),a.some(f=>D(f.content)==="when")||t.error(d.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",u(i))),c)for(let f of p)ul(t,f)}}l(Ao,"validateInteractionBodies");function ul(t,e){let n=new xe(new _e([]));n.sourceOptions=t.sourceOptions;let i=Ne(n,Po.exec(e.content)[1].trim(),u(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,u(e)):t.information(d.LegacyInteractionWhere,r,u(e))}l(ul,"deprecateWhere");var fl=w("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),ml=w("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),yl=w("^field\\s+([\\w.]+)(?:\\s|$)"),hl=w("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),Sl=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),gl=w("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),xl=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?gl.exec(c.content):null;p!==null&&i.add(p[1]);let y=fl.exec(c.content),f=ml.exec(c.content);if(y!==null)n.push({command:y[1],kind:"form",indent:c.indent});else if(f!==null)n.push({command:f[2],kind:f[1],indent:c.indent});else if(xl.has(D(c.content)))n.push({command:"",kind:"other",indent:c.indent});else{let m=n.at(-1);if(m===void 0||m.kind==="other")return;let h=(m.kind==="form"?yl:m.kind==="execute"?hl:Sl).exec(c.content);h!==null&&r.push({command:m.command,property:ne(h[1]),scope:t.scope,location:u(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));Ao(t,a);for(let c of r)t.inputUses.push(i.has(c.command)?{...c,isParameter:!0}:c)}l(Ie,"collectInputUses");function ye(t){return w(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}l(ye,"sourceStreamPattern");var vl=ye("^[A-Za-z_]\\w*(?![\\s\\S])"),$l=ye("^[\\w.]+(?![\\s\\S])");function Gi(t){return typeof t=="string"&&vl.test(t)}l(Gi,"isSourceStreamName");function On(t){return typeof t=="string"&&$l.test(t)}l(On,"isSourceStreamTypeName");var bl=w("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$"),wo=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$"),kl=w("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function Ue(t){let e=bl.exec(t.content);if(e===null)return;let n=u(t);return{kind:"PropertySyntax",name:ne(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,...e[5]!==void 0?{isSubject:!0}:{},location:n}}l(Ue,"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 We(t,e){let n=Ue(e);return n!==void 0?Le(t,n.type,e):In(t,e),n}l(We,"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 In(t,e){let n=wo.exec(e.content);if(n!==null&&n[1].split(/\s+/).includes("subject"))return t.error(d.InvalidSubjectModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.",u(e)),!0;if(kl.test(e.content))return t.error(d.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",u(e)),!0;{let i=wo.exec(e.content);if(i!==null&&i[1].split(/\s+/).some(r=>r==="generated"||r==="identifier"))return t.error(d.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",u(e)),!0}return!1}l(In,"reportInvalidModifierOrder");var El=w(`^id\\s+"(${J})"$`),Cl=ye("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Pl=ye("^eventsource\\s+([A-Za-z_]\\w*)$"),Al=ye("^stream\\s+([A-Za-z_]\\w*)$");function Oo(t,e){let n=Pl.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(wl(t,a));break;case"identifier":r=Io(t,a,"identifier",r);break;case"description":o=_(t,a,o,`Event source '${n}'`,!0);break;case"id":s=To(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:u(e)}}l(Oo,"parseEventSource");function wl(t,e){let n=Al.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=u(p),r=Ol(t,p)):(i=Io(t,p,"streamId",i),o=i!==null);break;case"description":a=_(t,p,a,`Stream '${n}'`,!0);break;case"id":c=To(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:u(e)}}l(wl,"parseEventStream");function Io(t,e,n,i){let r=Cl.exec(e.content);return r===null||i!==null?Ke(t,e,`Declare at most one '${n} <Type>'.`):(i=Te(r[2],{...u(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Le(t,i,e)),_t(t,e,d.InvalidEventSourceDeclaration),i}l(Io,"parseType");function To(t,e,n,i){let r=El.exec(e.content),o=r===null?null:ee(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.",u(e))),_t(t,e,d.InvalidEventSourceDeclaration),i}l(To,"parsePin");function Ro(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:u(e)};if(i)return t.error(d.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,u(e)),{...s,propertyCandidate:n};let a=null,c=[],p=!1,y={};for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){if(t.reader.takeSignificant(),f.content==="streamId"){a!==null||p?(t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",u(f)),t.skipBlock(f.indent)):(p=!0,y.streamId=u(f),c=Zi(t,f,d.InvalidCommandStream));continue}let m=/^streamId\s*=\s*(.+)$/.exec(f.content);if(m===null||a!==null||p)t.error(d.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",u(f)),t.skipBlock(f.indent);else{let h={...u(f),column:f.indent+1+f.content.indexOf(m[1],f.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:re(m[1],h,t),location:u(f)},_t(t,f,d.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:c,directiveLocations:y}}l(Ro,"parseCommandStream");function Ol(t,e){let n=[],i=ye("^([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],{...u(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:u(r)}),_t(t,r,d.InvalidEventSourceDeclaration)}return n.length===0&&Ke(t,e,"A streamId part block cannot be empty."),n}l(Ol,"parseStreamIdParts");function Zi(t,e,n){let i=[],r=ye("^([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.",u(o)),t.skipBlock(o.indent);continue}let a={...u(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:re(s[2],a,t),location:u(o)}),_t(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",u(e)),i}l(Zi,"parseRouteParts");function _t(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",u(i)),t.skipBlock(e.indent))}l(_t,"rejectChildren");function Ke(t,e,n){t.error(d.InvalidEventSourceDeclaration,n,u(e))}l(Ke,"invalid");var Il=w("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Do=l(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),ue=l(t=>Do(t).length>0,"isFileDirective"),Tn=l(t=>ue(t)&&!Il.test(Do(t)),"isFileDirectiveAmongProperties");var Tl=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function Rn(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||Tl.has(n)))return!1}return!0}l(Rn,"isBlankImplementationHint");var Mo=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"),Kt=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`,u(e)),{kind:"FileReferenceSyntax",path:n,location:u(e)}}l(lt,"parseFile");var _i=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}'`,u(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,u(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}'`,u(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",u(i));break}if(_i(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:u(e)}}l(Re,"parseCode");function jo(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",u(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return Rl(t,e,n);let i=It(n)?lt(t,n):null,r=i===null&&Kt(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.",u(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:u(e)}}return t.error(d.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,u(n)),t.skipBlock(e.indent),null}l(jo,"parseHandler");function Rl(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.",u(r)),Kt(t,r)?Re(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:u(e)}}l(Rl,"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.",u(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||Mo.test(s.content)){let a=Mo.exec(s.content),c=a===null?null:ee(a[1]);Rn(c)?t.error(d.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",u(s)):n.push({kind:"ImplementationHintSyntax",text:c,location:u(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(d.InvalidImplementationHint,"A hint cannot have children.",u(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.",u(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.",u(p)),t.skipBlock(s.indent))}else t.error(d.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,u(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:u(e)}}}l(Ht,"parseImplementationWrapper");var Dl=w("^system\\s+([A-Za-z_]\\w*)$"),Ml=w("^operation\\s+([A-Za-z_]\\w*)$"),jl=w("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),Ki=w("^uses\\s+([A-Za-z_]\\w*)$"),Nl=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Ll=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,u(r)),t.skipBlock(e.indent))}l(Jt,"rejectOperationChildren");function No(t,e){let n=Dl.exec(e.content);n===null&&t.error(d.InvalidSystemDeclaration,"Expected 'system <Name>'.",u(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=_(t,r,i,`System '${n?.[1]??""}'`):(t.error(d.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",u(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:u(e)}}l(No,"parseSystem");function Dn(t,e,n=!1){let i=(n?jl:Ml).exec(e.content),r=i?.[1]??"";i===null&&t.error(d.InvalidOperationDeclaration,"Expected an operation declaration with one name.",u(e));let o=null,s=null,a=u(e),c=null,p=null,y=[],f=[],m=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let g=Nl.exec(h.content),v=n&&g!==null?{...h,content:g[1].trimEnd()}:h;if(g===null&&Ll.has(D(h.content))){t.error(d.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",u(h)),t.skipBlock(h.indent);continue}if(!Ki.test(h.content)&&Ue(v)!==void 0){let $=We(t,v);n&&g===null&&t.error(d.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",u(h)),$.isSubject&&t.error(d.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).",u(h)),($.isIdentifier||$.isGenerated)&&t.error(d.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",u(h)),m.has($.name)&&t.error(d.DuplicateDeclaration,`Operation '${r}' already declares input '${$.name}'.`,u(h)),m.add($.name),y.push($),n&&g!==null&&f.push({kind:"PropertyMappingSyntax",property:$.name,source:re(g[2],{...u(h),column:h.indent+h.content.length-g[2].length+1},t),location:u(h)}),Jt(t,h,d.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=_(t,h,o,`Operation '${r}'`);else if(Ki.test(h.content))s!==null?t.error(d.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",u(h)):(s=Ki.exec(h.content)[1],a={...u(h),column:u(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 $=ql(t,h);h.content==="execute"?c!==null?t.error(d.InvalidOperationDeclaration,"An operation declares execute at most once.",u(h)):c=$:p!==null?t.error(d.InvalidOperationDeclaration,"An operation declares compensate at most once.",u(h)):p=$}else t.error(d.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,u(h)),t.skipBlock(h.indent)}return s===null&&t.error(d.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",u(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:y,description:o,execute:c,compensate:p,location:u(e)},mappings:f}}l(Dn,"parseOperation");function ql(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=_(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.",u(a));let c=Ht(t,a);s||(i=c.file,r=c.code,o=c.implementation),s=!0}else if(ue(a)||a.content.startsWith("```")){s&&t.error(d.ConflictingImplementationSources,"A phase has at most one file or inline payload.",u(a));let c=ue(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.",u(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:u(e)}}l(ql,"parseOperationPhase");var Hi=w("^then\\s+returns\\b"),Mn=w("^generated\\s+(?=\\S)(?![=])"),jn=w("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),Bl=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Yl=w(`^(?:"${J}"|'(?:[^'\\\\]|\\\\.)*')$`);function Nn(t,e,n,i){if((e.startsWith('"')||e.startsWith("'"))&&!Yl.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=re(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.",u(e)),t.skipBlock(e.indent),null;let o=u(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.",u(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}l(Tt,"parseConcreteMapping");function Lo(t,e){let n=Hi.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=u(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.",u(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,Bl,d.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}l(Lo,"parseReturn");var Fl=w("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),Ul=w("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),Wl=w("^specification\\s+([A-Za-z_]\\w*)$"),zl="([A-Z]\\w*(?:\\.\\w+)*)",Vl="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",Rt=l((t,e="")=>Q(`^${t}\\s+${zl}${e}${Vl}$`.replaceAll("\\s",U)),"stepPattern"),Ql=Rt("given"),Gl=Rt("when\\s+append"),Zl=Rt("when"),_l=Rt("then"),Kl=w("^then\\s+query\\b"),qo=w("^(?:given|then)\\s+readmodel\\b"),Hl=Rt("given\\s+readmodel"),Jl=Rt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),Bo=w("^then\\s+no\\b"),Xl=w(`^then\\s+error\\s+"(${J})"$`),er=w("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),ec=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),tc=w("^given\\s+clock\\b"),nc=w("^given\\s+capture\\b"),ic=w("^when\\s+clock\\b"),rc=w("^when\\s+trigger\\b"),oc=w("^when\\s+capture\\b"),ac=w("^when\\s+query\\b"),sc=w("^then\\s+result\\b"),lc=w("^then\\s+no\\s+result\\b"),cc=Q("^when\\s+redelivered\\b"),dc=Q("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),pc=w("^then\\s+no\\s+events\\b"),uc=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}))"$'),fc=w("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),mc=w("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),yc=w("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),hc=w("^then\\s+result(\\s+exactly)?$"),Yo=Q("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Sc=Q(`^(?:"${J}"|'(?:[^'\\\\]|\\\\.)*')$`),gc=Q("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function tr(t,e){let n=Wl.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,u(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(),ue(c)||xc(t,c,r))continue;let p=Bo.test(c.content)?"then":D(c.content);p==="description"?i=_(t,c,i,`Specification '${n}'`):p==="given"?vc(t,c,r):p==="when"?Ec(t,c,r,n):p==="then"?Cc(t,c,r):(t.error(d.UnknownSpecificationDirective,`Unexpected '${D(c.content)}' in specification body`,u(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.",u(r.noEventsLine));let{whenDeclared:o,noEventsLine:s,...a}=r;return{kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...a,location:u(e)}}l(tr,"parseSpecification");function xc(t,e,n){if(!Fl.test(e.content))return!1;let i=Ul.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>'.",u(e)),he(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,er,d.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:u(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:u(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:u(e)});return!0}l(xc,"parseOperationStep");function vc(t,e,n){if(tc.test(e.content))n.givenClock!==null?(t.error(d.InvalidSpecificationClock,"A specification states its clock at most once.",u(e)),he(t,e.indent)):n.givenClock=Fo(t,e,"given");else if(nc.test(e.content)){let i=Uo(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.",u(e)),t.skipBlock(e.indent)):n.givenCaller=kc(t,e);else if(qo.test(e.content)){let i=Wo(t,e,Hl,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=nr(t,e,Ql,"given");i!==void 0&&n.given.push(i)}}l(vc,"parseGiven");var $c=w(`^role${U}+"(${J})"$`),bc=w(`^claim${U}+"(${J})"${U}*=${U}*"(${J})"$`);function kc(t,e){if(e.content!=="given caller")return t.error(d.InvalidSpecificationCaller,"Expected exactly 'given caller'.",u(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=$c.exec(o.content),a=bc.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(ee(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:ee(a[1]),value:ee(a[2]),location:u(o)}):t.error(d.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,u(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:u(e)}}l(kc,"parseCaller");function Ec(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`,u(e)),he(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=nr(t,e,Gl,"when append")??null;return}if(cc.test(e.content)){let c=dc.exec(e.content);c===null?(t.error(d.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",u(e)),he(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:c[1],reaction:c[2],...Xi(t,e,void 0,void 0,"when redelivered"),location:u(e)};return}if(ic.test(e.content)){n.whenClock=Fo(t,e,"when");return}if(rc.test(e.content)){n.whenTrigger=Ji(t,e,fc,d.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(c,p)=>({kind:"SpecificationTriggerSyntax",trigger:c,values:p,location:u(e)}));return}if(oc.test(e.content)){n.whenCapture=Uo(t,e,"when");return}if(ac.test(e.content)){n.whenQuery=Ji(t,e,yc,d.InvalidSpecificationQueryAction,"when query","when query <Query>",(c,p)=>({kind:"SpecificationWhenQuerySyntax",query:c,arguments:p,location:u(e)}));return}let o=Zl.exec(e.content);if(o===null){t.error(d.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,u(e)),he(t,e.indent);return}let s=[],a=Xi(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:u(e)}}l(Ec,"parseWhen");function Cc(t,e,n){if(pc.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(d.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",u(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.",u(o)),he(t,e.indent);return}if(Hi.test(e.content)){let o=Lo(t,e);n.thenReturns!==null?t.error(d.InvalidReturnExpectation,"A specification declares at most one return expectation.",u(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.",u(e)):n.thenEventsInAnyOrder=!0,he(t,e.indent);return}if(sc.test(e.content)){Ac(t,e,n);return}if(lc.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(d.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",u(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:u(e)},he(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(d.InvalidSpecificationDenied,"Expected exactly 'then denied'.",u(e)),he(t,e.indent)):n.thenDenied!==null?t.error(d.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",u(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:u(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:u(e)});return}let i=Xl.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:ee(i[1]),location:u(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>"'`,u(e)),he(t,e.indent);return}if(Bo.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=Pc(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=Yo.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=re(o[2].trim(),u(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:u(e)})}t.skipOpaqueBlock(e.indent);return}if(Kl.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=l((f,m,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(f,m,u(h)),t.skipBlock(h.indent)},"reject"),a=gc.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=[],y=!1;for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent))t.reader.takeSignificant(),f.content==="arguments"&&!y?c.push(...Xt(t.valueContext,f,!0)):f.content==="arguments"?s(d.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,f):f.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:Xt(t.valueContext,f,!0),exactly:!1,location:u(f)}):s(d.UnknownSpecificationQueryDirective,`Unexpected '${D(f.content)}' in 'then query' body - expected arguments or result`,f),y||=f.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:c,results:p,exactly:a[2]!==void 0,location:u(e)});return}if(qo.test(e.content)){let o=Wo(t,e,Jl,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=nr(t,e,_l,"then");r!==void 0&&n.thenEvents.push(r)}l(Cc,"parseThen");function Pc(t,e){let n=Yo.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>'`,u(e)),he(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Sc.test(i)?re(i,u(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.`,u(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.",u(c)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:u(e)}}l(Pc,"parseAbsentReadModel");function he(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}l(he,"skipBody");function Fo(t,e,n){let i=uc.exec(e.content);return he(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"'`,u(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:u(e)}}l(Fo,"parseClock");function Uo(t,e,n){return Ji(t,e,mc,d.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:u(e)}))}l(Uo,"parseCapture");function Ji(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}'`,u(e)),he(t,e.indent),null):s(a[1],Xt(t,e))}l(Ji,"parseNamedStep");function Ac(t,e,n){let i=hc.exec(e.content);if(i===null){t.error(d.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,u(e)),he(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:Xt(t,e),exactly:i[1]!==void 0,location:u(e)})}l(Ac,"parseResult");function Wo(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>'`,u(e)),he(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:u(e)}}l(Wo,"parseReadModelStep");function nr(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>'`,u(e)),he(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...Xi(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:u(e)}}l(nr,"parseEventStep");var ir=ye("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),wc=w("^streamId\\s*=(?!=|>)\\s*(.+)$");function Xi(t,e,n,i,r){let o=[];qn(t,e,i,o);let s=null,a,c,p=!1;for(let y=t.peekChild(e.indent);y!==void 0;y=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&Mn.test(y.content)){let m=Tt(t,y,jn,d.InvalidGeneratedFixture);m!==null&&n.push(m);continue}let f=er.exec(y.content);if(f!==null)en(t,o,zo(t,y,f));else if(D(y.content)==="stream"||y.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.",u(y)),t.skipBlock(y.indent);continue}if(p){t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",u(y)),t.skipBlock(y.indent);continue}let m=ir.exec(y.content);y.content==="no stream"&&(r==="then"||r==="when redelivered")?(c={kind:"SpecificationNoStreamSyntax",location:u(y)},p=!0,Ln(t,y)):m!==null?(a=rr(t,y,m),p=!0):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",u(y)),t.skipBlock(y.indent))}else if(D(y.content)==="for"){let m=y.content.substring(3).trim();m.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",u(y)):s!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",u(y)):s=re(m,u(y),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${y.content}' - expected '<property> = <value>'`,u(y))}return{values:o,for:s,...a===void 0?{}:{stream:a},...c===void 0?{}:{noStream:c}}}l(Xi,"parseValuesWithEventSource");function rr(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.",u(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=u(a),r=Zi(t,a,d.InvalidSpecificationStream));continue}let c=wc.exec(a.content);if(c===null||i!==null||o){t.error(d.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",u(a)),t.skipBlock(a.indent);continue}let p={...u(a),column:a.indent+1+a.content.indexOf(c[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:re(c[1],p,t),location:u(a)},Ln(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...u(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:u(e)}}l(rr,"parseSpecificationStream");function Ln(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(d.InvalidSpecificationStream,"This directive cannot have children.",u(n)),t.skipBlock(e.indent))}l(Ln,"rejectSpecificationRouteChildren");function Xt(t,e,n=!1,i){let r=[];qn(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"?ec:er).exec(o.content);if(s===null){t.error(d.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,u(o));continue}en(t,r,zo(t,o,s,n))}return r}l(Xt,"parseValues");function zo(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:re(n[2],u(e),t,i),location:u(e)}}l(zo,"mappingOf");var Oc=Q("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",U)),Ic=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",U));function He(t,e){let n=Oc.exec(e.content);if(n===null)return t.error(d.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,u(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:u(e)};let i=Tc(t,e,void 0,!0,n[1]);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:u(e)}}l(He,"parseExample");function qn(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=u(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(qn,"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 Tc(t,e,n,i=!1,r){let o=[],s=[],a=null,c=null,p,y;qn(t,e,n,o);for(let f=t.peekChild(e.indent);f!==void 0;f=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(f.content)==="description"){c=_(t,f,c,`Example '${r}'`);continue}if(i&&Mn.test(f.content)){let h=Tt(t,f,jn,d.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):en(t,s,h,o));continue}let m=Ic.exec(f.content);if(r!==void 0&&m===null&&(D(f.content)==="stream"||f.content.startsWith("no stream"))){let h=ir.exec(f.content);p!==void 0||y!==void 0?(t.error(d.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",u(f)),t.skipOpaqueBlock(f.indent)):f.content==="no stream"?(y={kind:"SpecificationNoStreamSyntax",location:u(f)},Ln(t,f)):h!==null?p=rr(t,f,h):(t.error(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",u(f)),t.skipOpaqueBlock(f.indent));continue}if(m!==null)en(t,o,{kind:"PropertyMappingSyntax",property:m[1],source:re(m[2],u(f),t),location:u(f)},s);else if(D(f.content)==="for"){let h=f.content.substring(3).trim();h.length===0?t.error(d.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",u(f)):a!==null?t.error(d.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",u(f)):a=re(h,u(f),t)}else t.error(d.InvalidSpecificationValue,`Invalid property mapping '${f.content}' - expected '<property> = <value>'`,u(f))}return{values:o,for:a,generatedValues:s,description:c,...p===void 0?{}:{stream:p},...y===void 0?{}:{noStream:y}}}l(Tc,"parseFixtureBody");var Vo=["StateChange","StateView","Automation","Translate"];var tn=["tag"];var Rc=w(`^id\\s+"(${J})"$`),Dt=class{static{l(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=u(n);switch(D(n.content)){case"id":{let r=Rc.exec(n.content),o=r===null?"":ee(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=_(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 Dc=w("^type\\s+([A-Za-z_]\\w*)$"),Mc=w("^event\\s+([A-Za-z_]\\w*)(?:\\s+generation\\s+([0-9]+))?$"),jc=w("^readmodel\\s+([A-Za-z_]\\w*)$"),Qo=4294967295,Nc=w("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),Lc=w("^[A-Za-z_]\\w*$"),Go=l(t=>D(t.content)==="description"&&Ue(t)===void 0,"isDescription");function or(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,u(n)),{...e,isIdentifier:!1}):e}l(or,"withoutIdentifier");function Zo(t,e){let n=Dc.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,u(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Go(o)){r=_(t,o,r,`Type '${n}'`);continue}if(Tn(o))continue;let s=We(t,o);if(s===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,u(o));continue}i.push(or(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`,u(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:u(e)}}l(Zo,"parseType");function _o(t,e){let n=Mc.exec(e.content),i=n?.[1]??"";n===null&&t.error(d.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected 'event <Name> [generation <N>]'`,u(e));let r=n?.[2]!==void 0,o=1;if(r){let p=Number(n[2]);!Number.isSafeInteger(p)||p===0||p>=Qo?t.error(d.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${Qo-1}`,u(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(),Tn(p))continue;if(tn.includes(D(p.content))){let f=nn(t,p);f!==void 0&&a.push(f);continue}let y=We(t,p);if(y===void 0){c.tryParse(t,p)||t.error(d.InvalidPropertyDeclaration,`Invalid property '${p.content}' - expected '<name> <Type>'`,u(p));continue}s.push(or(t,y,p,d.IdentifierOnEventProperty,`Property '${y.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:s,tags:a,generation:o,hasGenerationMarker:r,...c.value,location:u(e)}}l(_o,"parseEvent");function nn(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&Nc.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`,u(e)),i.length===0){t.error(d.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",u(e));return}if(Lc.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:u(e)},location:u(e)};let r=re(i,u(e),t);if(r.kind==="RawExpressionSyntax"){t.error(d.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,u(e));return}return{kind:"TagSyntax",value:r,location:u(e)}}l(nn,"parseTag");function Ko(t,e){let n=jc.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,u(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(),Go(s))r=_(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&Ue(s)===void 0)o=ve(t,s,o,`Read model '${n}'`);else{if(Tn(s))continue;{let a=We(t,s);if(a===void 0){t.error(d.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,u(s));continue}i.push(or(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:u(e)}}l(Ko,"parseReadModel");var qc=Q("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function Se(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:Se(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:qc.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(d.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}l(Se,"parseProjectionExpression");var Yn=l(t=>({legacy:w(t),native:Q(t)}),"grammar"),Bc=Yn("^capture\\s+([A-Za-z_]\\w*)$"),Yc=Yn("^append\\s+([A-Z]\\w*)$"),Fc=Yn("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),Uc=Yn("^nested\\s+([\\w.]+)$"),Bn=l((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),Wc=Q("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),zc=Q("^([a-z_]\\w*)\\s*=\\s*(.+)$"),Vc=Q(`^"(${J})"\\s*=>\\s*(\\w+)$`),Qc=Q(`^split\\s+(\\S+)\\s+by\\s+"(${J})"$`),Gc=new RegExp(Q(`"${J}"|[\\w.]+`).source,"gu"),Zc=Q("^[\\w.]+$");function ar(t,e){t=t.valueContext;let n=Bn(t,Bc).exec(e.content)?.[1]??"";n===""&&t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,u(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=_c(t,p);break;case"key":r=p.content.substring(3).trim();break;case"map":o.push(...Jo(t,p));break;case"append":Xo(t,p,s);break;case"children":{let y=Bn(t,Fc).exec(p.content);if(y===null){t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${p.content}' - expected 'children <collection> identified by <key>'`,u(p)),t.skipOpaqueBlock(p.indent);break}let f=Ho(t,p);y!==null&&a.push({kind:"CaptureChildrenSyntax",property:y[1],identifiedBy:y[2],...f,location:u(p)});break}case"nested":{let y=Bn(t,Uc).exec(p.content);if(y===null){t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${p.content}' - expected 'nested <Property>'`,u(p)),t.skipOpaqueBlock(p.indent);break}let f=Ho(t,p);y!==null&&c.push({kind:"CaptureNestedSyntax",property:y[1],...f,location:u(p)});break}default:t.error(d.UnknownCaptureDirective,`Unexpected '${p.content}' in capture body`,u(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:u(e)}}l(ar,"parseCapture");function _c(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:u(i)})}return{kind:"CaptureSourceSyntax",syntaxKind:e.content.substring(6).trim(),settings:n,location:u(e)}}l(_c,"parseSource");function Jo(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=u(i);if(D(i.content)==="split"){let f=Qc.exec(i.content);if(f===null){t.error(d.InvalidSplitDeclaration,`Invalid split operation '${i.content}' - expected 'split <property> by "<separator>"'`,r),t.skipOpaqueBlock(i.indent);continue}let m=[];for(let h=t.peekChild(i.indent);h!==void 0;h=t.peekChild(i.indent))t.reader.takeSignificant(),Zc.test(h.content)?m.push(h.content):t.error(d.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,u(h));f!==null&&n.push({kind:"CaptureSplitSyntax",source:Se(f[1],r,t),separator:ee(f[2]),targets:m,location:r});continue}let o=zc.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,y=[];if(c)for(let f=t.peekChild(i.indent);f!==void 0;f=t.peekChild(i.indent)){t.reader.takeSignificant();let m=Vc.exec(f.content);m!==null?y.push({kind:"CaptureTranslationSyntax",from:ee(m[1]),to:m[2],location:u(f)}):t.error(d.InvalidTranslation,`Invalid translation '${f.content}' - expected '"<source>" => <target>'`,u(f))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:Se(p,r,t),translations:y,location:r})}return n}l(Jo,"parseMap");function Ho(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=Jo(t,r):D(r.content)==="append"?Xo(t,r,i):(t.error(d.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,u(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}l(Ho,"mapAndAppends");function Xo(t,e,n){let i=Bn(t,Yc).exec(e.content);if(i===null){t.error(d.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,u(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=l((c,p=!1)=>{let y=u(c);if(D(c.content)==="tag"){let m=nn(t.valueContext,c,!1);m!==void 0&&o.push(m);return}let f=Wc.exec(c.content);f!==null?r.push({kind:"PropertyMappingSyntax",property:ne(f[1]),source:we(f[2],y,t.valueContext),location:y}):t.error(p?d.InvalidPropertyMapping:d.UnknownAppendDirective,`Unexpected '${c.content}' in append body`,y)},"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=Kc(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:u(e)})}l(Xo,"pushAppend");function Kc(t,e){let n=e.content.substring(4).trim(),i=u(e),r=l((c,p=[],y=null,f=null,m=null)=>({kind:"CaptureWhenSyntax",syntaxKind:c,properties:p,fromValue:y,toValue:f,expression:m,location:i}),"value");if(n==="added")return r("Added");if(n==="removed")return r("Removed");if(n.startsWith("`"))return(!n.endsWith("`")||n.length<2)&&t.error(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(`"${J}"|[^\\s]+`,"gu"):Gc)??[]],s=l(c=>c.startsWith('"')&&c.endsWith('"')?ee(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(Kc,"parseWhen");var sr=w("^returns\\s+(@?[A-Za-z_]\\w*)$"),Hc=w("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function lr(t,e){let n=u(e);if(e.content!=="returns"){let r=sr.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.",u(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:ne(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=Hc.exec(r.content);if(o===null){Ue({...r,content:r.content.split("=",1)[0].trimEnd()})?.isSubject?t.error(d.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not response fields (decision 0008: one data subject per event).",u(r)):t.error(d.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",u(r)),t.skipBlock(r.indent);continue}let s=u(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:ne(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:ne(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.",u(c)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}l(lr,"parseCommandResponse");var Fn=new WeakMap;var Je=new WeakMap,qe=l(t=>Je.get(t)??{},"dependencySourcesOf");function Un(t){let e=Q(`^reads${U}+([A-Z]\\w*)(?:${U}+as${U}+([a-z_]\\w*))?(?:${U}+by${U}+([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:u(t)}}l(Un,"captureReads");function ea(t){return new xe(t.reader.fork(),t.path,t.languages)}l(ea,"fork");function ta(t,e){if(e.content!=="concurrency")return;let n=ea(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)${U}+([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(`^${U}+|${U}+$`,"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:u(e)}}l(ta,"captureConcurrency");function na(t,e){let n=Q(`^reducer${U}+([A-Za-z_]\\w*)${U}*=>${U}*([A-Za-z_]\\w*)$`).exec(e.content),i=ea(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"){_(i,o,null,"Reducer");continue}let s=Q(`^on${U}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:u(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:u(e)}}l(na,"captureReducer");var Jc=w("^produces\\s+operation(?:\\s|$)"),Xc=w("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),ed=w("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),ia=w("^produces\\s+when\\s+(.+)$"),td=w("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),nd=w("^for\\s+(\\S.*)$"),id=w("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),rd=w("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),od=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function rn(t,e,n=!1){if(Jc.test(e.content)){if(!n){t.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",u(e)),t.skipOpaqueBlock(e.indent);return}let g=Dn(t,e,!0);return{kind:"ProducesSyntax",when:null,event:g.operation.name,targetLocation:{...u(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:g.operation,mappings:g.mappings,for:null,tags:[],location:u(e)}}let i=Xc.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",u(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",u(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(ia.test(e.content)){o=Ne(t,ia.exec(e.content)[1],u(e));let g=t.peekChild(e.indent);if(g===void 0||!td.test(g.content)){t.error(d.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",u(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=g,s=g.content,a=g.indent+1}else{let g=ed.exec(e.content);if(g===null){t.error(d.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,u(e)),t.skipOpaqueBlock(e.indent);return}s=g[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let c=[],p=new Set,y=[],f=[],m=new Dt(s),h=null;for(let g=t.peekChild(r.indent);g!==void 0;g=t.peekChild(r.indent)){t.reader.takeSignificant();let v=D(g.content),$=u(g);if(od.has(v)){t.error(d.ReservedProductionMetadata,`'${v}' is system-assigned production metadata and cannot be supplied here`,$),t.skipOpaqueBlock(g.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",$),t.skipOpaqueBlock(g.indent);continue}if(v==="tag"){let A=nn(t,g,!1);A!==void 0&&f.push(A);continue}let C=nd.exec(g.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`,$):h=re(C[1],$,t);continue}let x=(i===null?id:rd).exec(g.content),P=x===null||i===null?void 0:We(t,{...g,content:x[1].trimEnd()});if(x!==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`,$),P={...P,isIdentifier:!1});let A=P.name;p.has(A)&&t.error(d.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,$),p.add(A),c.push(P)}y.push({kind:"PropertyMappingSyntax",property:P?.name??ne(x[1]),source:re(x[2],{...$,column:g.indent+g.content.length-x[2].length+1},t),location:$})}else(i===null||!m.tryParse(t,g))&&t.error(d.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${g.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,$)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...u(r),column:a},inlineOperation:null,mappings:y,for:h,tags:i===null?f:[],location:u(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:c,tags:f,generation:1,hasGenerationMarker:!1,...m.value,location:u(e)}}}l(rn,"parseProduces");var ad=w("^command\\s+([A-Za-z_]\\w*)$"),sd=ye("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),ld=w("\\bseverity\\s+(\\S+)$"),oa=w(`\\bmessage\\s+(?:"(${J})"|(\\$strings\\.\\S*))$`),cd=w("^([\\w.]+)\\s+(.+)$"),dd=w("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),pd=ye("^[A-Za-z_]\\w*$"),ud=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),fd={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},aa={information:"Information",warning:"Warning",error:"Error"},md=new Set(["reads","concurrency"]),yd=new Set(["description","documentation","handler","concurrency"]);function sa(t,e){let n=new Set,i=new xe(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,ra(i,e,void 0,n),ra(t,e,n)}l(sa,"parseCommand");function ra(t,e,n,i){let r=ad.exec(e.content)?.[1]??"";r===""&&t.error(d.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,u(e));let o=[],s=[],a,c=[],p=[],y=[],f=[],m,h=null,g=null,v=null,$=null,C=null,x=[];for(let E=t.peekChild(e.indent);E!==void 0;E=t.peekChild(e.indent)){t.reader.takeSignificant();let O=D(E.content),I=Ue(E);if(I!==void 0&&(yd.has(O)||O==="validate"&&E.content!=="validate csharp"))a=Wn(t,o,I,r,E,a);else if(O==="returns"){let R=sr.exec(E.content);R!==null&&!R[1].startsWith("@")&&I!==void 0?n===void 0?(o.push(I),s.push({line:E,candidate:I,response:null})):n.has(I.type.name)?s.push({line:E,candidate:null,response:lr(t,E)}):a=Wn(t,o,I,r,E,a):I!==void 0?a=Wn(t,o,I,r,E,a):In(t,E)?t.skipBlock(E.indent):s.push({line:E,candidate:null,response:lr(t,E)})}else if(O==="stream"&&sd.test(E.content)&&I!==void 0&&t.streamCandidates?.hasSource(I.type.name.split(".")[0])===!0){let[R,j]=I.type.name.split("."),N=t.streamCandidates.hasPropertyType(I.type.name)&&t.streamCandidates.hasUniqueStream(R,j),B=Ro(t,E,I,N);(C!==null||x.length>0)&&t.error(d.InvalidCommandStream,"A command declares at most one stream route.",u(E)),N||C!==null?x.push(B):C=B}else if(O==="description")h=_(t,E,h,`Command '${r}'`);else if(O==="documentation")g=ve(t,E,g,`Command '${r}'`);else if(O==="authorize")v=Fe(v,st(t,E));else if(O==="validate"){let R=cr(t,E,"command");R!==void 0&&c.push(R)}else if(O==="produces"){let R=rn(t,E,!0);R!==void 0&&p.push(R)}else if(O==="handler")$=jo(t,E);else if(md.has(O)){let R=Un(E);R!==void 0&&f.push(R),O==="concurrency"&&m===void 0&&(m=ta(t,E));let j=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(E.content);j!==null&&y.push({readModel:j[1],alias:j[2]??null}),ud.test(E.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",u(E)),t.skipOpaqueBlock(E.indent)}else I!==void 0?a=Wn(t,o,I,r,E,a):(In(t,E),t.error(d.UnknownCommandDirective,`Unexpected '${E.content}' in command body`,u(E)),t.skipBlock(E.indent))}let P=new Set(s.flatMap(E=>E.candidate===null?[]:[E.candidate])),A=new Set(o.filter(E=>!P.has(E)).map(E=>E.name));s.some(E=>E.candidate!==null&&!A.has(E.candidate.type.name)&&E.candidate.type.name!=="returns")&&A.add("returns");for(let E of A)i?.add(E);let S=null,k=new Set;for(let E of s){let O=E.response;if(E.candidate!==null){if(!A.has(E.candidate.type.name))continue;k.add(E.candidate),O={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:E.candidate.type.name,location:E.candidate.type.location},location:u(E.line)}}O!==null&&(S!==null?t.error(d.InvalidCommandResponse,"A command declares at most one unconditional response.",u(E.line)):S=O)}$!==null&&p.length>0&&t.error(d.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,u(e));let b={kind:"CommandSyntax",name:r,description:h,documentation:g,authorize:v,properties:o.filter(E=>!k.has(E)),validations:c,produces:p,handler:$,response:S,stream:C,streamCandidates:x,location:u(e)};return Fn.set(b,y),Je.set(b,{reads:f,concurrency:m}),b}l(ra,"parseCommandBody");function Wn(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(Wn,"addProperty");function cr(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:u(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}'`,u(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let p=Ne(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),u(a)),y=null,f="Error",m=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let g=oa.exec(h.content);g!==null&&g.index===0?y=g[1]!==void 0?ee(g[1]):g[2]:D(h.content)==="severity"?(m||(f=aa[h.content.substring(8).trim()]??"Error"),m=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:y,severity:f,location:u(a)});continue}let c=hd(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);c!==void 0&&r.push(c)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:u(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:u(e)}}t.error(d.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,u(e)),t.skipBlock(e.indent)}l(cr,"parseValidate");function hd(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=gd(e.content),s=xd(i,e,r);if(s===void 0)return;let a=cd.exec(s.content);if(a===null){i.error(d.InvalidValidationRule,`Invalid validation rule '${e.content}'`,u(e));return}let c=vd(i,a[2],e);if(c===void 0)return;let p=c.kind==="Rule"?Sd(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:u(e)}}l(hd,"parseValidationRule");function Sd(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)&&Kt(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`,u(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.",u(s)),Kt(t,s)?Re(t,s):t.skipBlock(s.indent);return o}l(Sd,"parseRuleImplementation");function gd(t){let e=oa.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?ee(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}l(gd,"splitMessage");function xd(t,e,n){let i=ld.exec(n);if(i===null)return{content:n,severity:"Error"};let r=aa[i[1]];if(r===void 0){t.error(d.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,u(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}l(xd,"splitSeverity");function vd(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=dd.exec(e);if(i===null){t.error(d.InvalidValidationRule,`Invalid validation rule '${n.content}'`,u(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!pd.test(r)){t.error(d.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,u(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:u(n)}}}return{kind:fd[i[1]],value:re(i[2],u(n),t)}}l(vd,"parseRule");var $d=w("^constraint\\s+([A-Za-z_]\\w*)$"),bd=w("^unique\\s+event\\s+([A-Z]\\w*)$"),kd=w("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Ed=w("^released\\s+by\\s+([A-Z]\\w*)$"),Cd=w(`^message\\s+"(${J})"$`),Pd=l(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function la(t,e){let n=$d.exec(e.content);n===null&&t.error(d.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,u(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,c=null,p=!1;for(let y=t.peekChild(e.indent);y!==void 0;y=t.peekChild(e.indent)){t.reader.takeSignificant();let f=Ed.exec(y.content),m=Cd.exec(y.content);f!==null?s.has(f[1])?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${f[1]}'`,u(y)):(o.push(f[1]),s.add(f[1])):m!==null?c!==null?t.error(d.DuplicateConstraintBody,`Constraint '${i}' already has a message`,u(y)):c=ee(m[1]):y.content==="ignore casing"?(p&&t.error(d.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,u(y)),p=!0):Ad(t,i,y,r,a)}for(let y of o.filter(f=>a.has(f)))t.error(d.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${y}'`,u(e));return r.length===0&&(t.error(d.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,u(e)),r.push(zn(i,u(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`,u(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:c,ignoreCasing:p}}l(la,"parseConstraint");function Ad(t,e,n,i,r){let o=wd(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`,u(n));return}let s=Pd(o);if(s!==void 0&&r.has(s)){t.error(d.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,u(n));return}s!==void 0&&r.add(s),i.push(o)}l(Ad,"addRule");function wd(t,e,n){let i=u(n),r=bd.exec(n.content);if(r!==null)return zn(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=kd.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 zn(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(ue(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 zn(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(d.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}l(wd,"parseRule");function zn(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}l(zn,"rule");var Od=w("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),Id=w("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Td=w("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),Rd=w("^with\\s+(@?[\\w.]+)$"),Dd=w("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),Md=w("^nested\\s+(@?[\\w.]+)$"),jd=w("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Nd=w("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Ld=w("^clear\\s+with\\s+(@?[\\w.]+)$"),qd=w("^variant\\s+(@?[\\w.]+)\\s*$"),Bd=w("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),Yd=w("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),Fd=w("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),Ud=w("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),ca=w("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),Wd={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function pr(t,e){let n=Od.exec(e.content);if(n===null)return t.error(d.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,u(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:u(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(),ue(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=pa(t,c);else if(p==="variant")a.push(Hd(t,c));else{let y=ur(t,c,!1);y!==void 0&&a.push(y)}}return zd(t,a,i),a.length===0&&t.error(d.EmptyProjection,`Projection '${i}' must contain at least one directive`,u(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:o,key:s,blocks:a,location:u(e)}}l(pr,"parseProjection");function zd(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(zd,"reportVariantConflicts");function ur(t,e,n){let i=u(e);switch(D(e.content)){case"from":return Vd(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=dr(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}=dr(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return Qd(t,e);case"children":return Gd(t,e);case"nested":return Zd(t,e);case"remove":return _d(t,e);case"clear":return n||t.error(d.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),Kd(t,e);default:t.error(d.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}l(ur,"parseBlock");function Vd(t,e){let n=[];for(let s of fo(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(d.FromWithoutEvent,"Expected an event type after 'from'",u(e));continue}let c=Id.exec(a);if(c===null){t.error(d.InvalidEventReference,`Invalid event reference '${a}'`,u(e));continue}n.push({kind:"EventSpecSyntax",event:ne(c[1]),key:c[2]===void 0?null:Se(c[2],u(e),t),location:u(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=pa(t,s):a==="parent"?o=Se(s.content.substring(6),u(s),t):ua(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:u(e)}}l(Vd,"parseFrom");function Qd(t,e){let n=Td.exec(e.content);if(n===null)return t.error(d.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,u(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:u(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Rd.exec(r.content);if(o===null){t.error(d.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,u(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=dr(t,r);i.push({kind:"JoinEventSyntax",event:ne(o[1]),autoMap:s,mappings:a,location:u(r)})}return{kind:"JoinSyntax",property:ne(n[1]),on:ne(n[2]),events:i,location:u(e)}}l(Qd,"parseJoin");function Gd(t,e){let n=Dd.exec(e.content);if(n===null)return t.error(d.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,u(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:u(e)};let{autoMap:i,blocks:r}=da(t,e);return{kind:"ChildrenSyntax",property:ne(n[1]),identifiedBy:Se(n[2],u(e),t),autoMap:i,blocks:r,location:u(e)}}l(Gd,"parseChildren");function Zd(t,e){let n=Md.exec(e.content);if(n===null)return t.error(d.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,u(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:u(e)};let i=ne(n[1]),{autoMap:r,blocks:o}=da(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(d.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,u(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:u(e)}}l(Zd,"parseNested");function da(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=ur(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}l(da,"parseChildBlocks");function _d(t,e){let n=Nd.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:ne(n[1]),key:n[2]===void 0?null:Se(n[2],u(e),t),location:u(e)};let i=jd.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>'`,u(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=Se(o.content.substring(6),u(o),t):t.error(d.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,u(o));return{kind:"RemoveWithSyntax",event:ne(i[1]),key:i[2]===void 0?null:Se(i[2],u(e),t),parentKey:r,location:u(e)}}l(_d,"parseRemove");function Kd(t,e){let n=Ld.exec(e.content);return n===null?(t.error(d.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,u(e)),{kind:"ClearWithSyntax",event:"",location:u(e)}):{kind:"ClearWithSyntax",event:ne(n[1]),location:u(e)}}l(Kd,"parseClearWith");function Hd(t,e){let n=qd.exec(e.content);if(n===null)return t.error(d.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,u(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:u(e)};let i=ne(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(Jd(t,s));else if(a==="variant")t.error(d.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",u(s)),t.skipBlock(s.indent);else{let c=ur(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`,u(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:u(e)}}l(Hd,"parseVariant");function Jd(t,e){let n=Bd.exec(e.content);return n===null?(t.error(d.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,u(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:u(e)}):{kind:"ProjectionEntersOnSyntax",event:ne(n[1]),key:n[2]===void 0?null:Se(n[2],u(e),t),location:u(e)}}l(Jd,"parseEntersOn");function pa(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:Se(n,u(e),t),location:u(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=ca.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,u(o));continue}let a=Se(s[2],u(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(d.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",u(o)),i.push({kind:"KeyPartSyntax",property:ne(s[1]),expression:a,location:u(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",u(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:u(e)}}l(pa,"parseKey");function dr(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)||ua(t,o,r);return{autoMap:i,mappings:r}}l(dr,"parseMappingBlock");function ua(t,e,n){let i=u(e),r=Yd.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:Wd[r[1]],property:ne(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=Fd.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:ne(o[2]),value:Se(o[3],i,t),location:i});return}let s=Ud.exec(e.content)??ca.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:ne(s[1]),source:Se(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(d.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}l(ua,"pushMapping");var Xd=w("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),ep=w("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),tp=w("^scoped\\s+to\\s+([a-z_]\\w*)$"),np=new Set(["performer"]);function ma(t,e){let n=Xd.exec(e.content);if(n===null)return t.error(d.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,u(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:Te("",u(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:u(e)};let i=n[1],r=Te(n[3],{...u(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 y=t.peekChild(e.indent);y!==void 0;y=t.peekChild(e.indent)){t.reader.takeSignificant();let f=D(y.content);if(f==="description")a=_(t,y,a,`Query '${i}'`);else if(f==="by"){let m=fa(t,y,"by");m!==void 0&&(o!==null&&t.error(d.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,u(y)),o=m)}else if(f==="filter"){let m=fa(t,y,"filter");m!==void 0&&s.push(m)}else f==="authorize"?p=Fe(p,st(t,y)):f==="scoped"?c=ip(t,y,c,i)??c:np.has(f)?t.skipOpaqueBlock(y.indent):(t.error(d.UnknownQueryDirective,`Unexpected '${y.content}' in query body - expected description, by, filter, authorize, scoped or performer`,u(y)),t.skipBlock(y.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:c,authorize:p,location:u(e)}}l(ma,"parseQuery");function fa(t,e,n){let i=ep.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>]'`,u(e));return}let r=e.content.indexOf(i[1],n.length),o=Te(i[2],{...u(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:re(i[3],u(e),t.valueContext),location:u(e)}}l(fa,"parseParameter");function ip(t,e,n,i){let r=tp.exec(e.content);if(r===null){t.error(d.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,u(e));return}if(n!==null){t.error(d.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,u(e));return}return r[1]}l(ip,"parseScope");var rp=w("^@?[a-z_]\\w*\\s+[\\w.]+");function fr(t,e){let n=We(t,e);if(n!==void 0){n.isGenerated&&t.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),n.isSubject&&t.error(d.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not trigger or reaction data properties (decision 0008: one data subject per event).",n.location),t.triggerData.push(n);return}rp.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(d.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,u(e)),t.skipOpaqueBlock(e.indent)}l(fr,"parseTriggerData");function ya(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"?_(t,i,null,`Trigger '${e.content}'`):ue(i)||fr(t,i);return t.triggerData.slice(n)}l(ya,"parseTriggerDeclaration");var op=w("^reaction\\s+([A-Za-z_]\\w*)$"),ap=w("^when\\s+([A-Za-z_]\\w*)$"),sp=w("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),lp=w("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),cp=new Set(["when","every","at"]),dp=w("^invokes\\s+([A-Z]\\w*)$"),pp=Q("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),mr=Q("^on\\s+refused\\b(?=$|\\s+by\\b)"),up=Q("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),fp=w("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function ha(t,e){let n=op.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,u(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 y=D(p.content);if(y==="description"){i=_(t,p,i,`Reaction '${n}'`);continue}if(y==="documentation"){r=ve(t,p,r,`Reaction '${n}'`);continue}if(y==="where"){o=Ne(t,p.content.substring(5).trim(),u(p));continue}if(mr.test(p.content)){t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",u(p)),t.skipBlock(p.indent),c=!0;continue}if(!cp.has(y)){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>'`,u(p)),t.skipBlock(p.indent),c=!0;continue}let f=Sp(t,p);if(f===void 0){c=!0;continue}let m=hp(f);if(a.has(m)){t.error(d.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,u(p)),t.skipBlock(p.indent);continue}a.add(m),s.push(mp(t,p,f))}return s.length===0&&!c&&t.error(d.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,u(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,where:o,triggers:s,location:u(e)}}l(ha,"parseReaction");function mp(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 y=D(p.content);if(y==="description")i=_(t,p,i,`Trigger '${p.content}'`);else if(y==="produces"){let f=rn(t,p);f!==void 0&&r.push(f)}else if(y==="invokes"){let f=dp.exec(p.content);if(f===null)t.error(d.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,u(p)),t.skipBlock(p.indent);else{let m=new xe(t.reader.fork(),t.path,t.languages);m.scope=t.scope,m.sourceOptions=t.sourceOptions,Ie(m,p),t.inputUses.push(...m.inputUses);let h=[],g=[];for(let v=t.peekChild(p.indent);v!==void 0;v=t.peekChild(p.indent)){if(t.reader.takeSignificant(),mr.test(v.content)){let C=yp(t,v);C!==void 0&&g.push(C);continue}let $=pp.exec(v.content);$!==null?h.push({kind:"PropertyMappingSyntax",property:$[1].replaceAll("@",""),source:we($[2],u(v),t.valueContext),location:u(v)}):t.error(d.InvalidPropertyMapping,`Invalid property mapping '${v.content}' - expected '<property> = <source>'`,u(v))}o.push({kind:"InvokesSyntax",command:f[1],mappings:h,onRefused:g,location:u(p)})}}else if(mr.test(p.content))t.error(d.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",u(p)),t.skipBlock(p.indent);else if(y==="reads"||y==="file"||p.content==="csharp"||p.content.startsWith("```")){let f=Un(p);f!==void 0&&s.push(f),fp.test(p.content)&&t.error(d.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",u(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let f=t.triggerData.length;fr(t,p);for(let m of t.triggerData.slice(f))a.push({kind:"TriggerDataSyntax",name:m.name,type:m.type,location:m.location})}}let c={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:u(e)};return Je.set(c,{reads:s,data:a}),c}l(mp,"parseTrigger");function yp(t,e){let n=up.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]'.",u(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.",u(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'.",u(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.",u(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.",u(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:u(e)}}l(yp,"parseRefusal");function hp(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(hp,"sourceKey");function Sp(t,e){let n=u(e);switch(D(e.content)){case"when":{let i=ap.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=sp.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:vp(i[2]),location:n}}default:return gp(t,e)}}l(Sp,"parseTriggerSource");function gp(t,e){let n=u(e),i=lp.exec(e.content),r=i===null?void 0:xp(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(gp,"parseSchedule");function xp(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}l(xp,"timeOf");function vp(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}l(vp,"unitOf");var $p=w("^(data|query|component)\\s+(\\S+)(.*)$"),bp=w("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),kp=w("^([A-Za-z_]\\w*)\\.(.+)$"),Ep=w("^mode\\s+(oneWay|twoWay)\\b(.*)$"),Cp=w("^null\\s+(propagate|clear|preserve)\\b(.*)$"),Pp=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"?Sa(t,`from ${i}`,n):Sa(t,i,n)}l(Mt,"parseFromClause");function Sa(t,e,n){let i=e.trim();if(!i.startsWith("from "))return ga(t,vt("DataContext",i,n),"",n);let r=i.substring(5).trim(),o=$p.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=Ap(t,o[1],o[2],i,n);return ga(t,s,o[3],n)}l(Sa,"parseUiBinding");function Ap(t,e,n,i,r){return e==="data"?vt("DataContext",n,r):e==="query"?wp(t,n,i,r):Op(t,n,i,r)}l(Ap,"parseBindingSource");function wp(t,e,n,i){let r=bp.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(wp,"queryBinding");function Op(t,e,n,i){let r=kp.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(Op,"componentBinding");function ga(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=Ep.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=Cp.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let c=Pp.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(ga,"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=`(?:"(${J})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,Ip=w("^screen\\s+([A-Za-z_]\\w*)$"),Tp=w("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),Rp=w("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),xa=w(`^label\\s+${ct}$`),Dp=w(`^action\\s+${ct}$`),Mp=w("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),jp=w(`^route\\s+${ct}$`),va=w("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),Np=w("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),Lp=w("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),qp=w(`^property\\s+([\\w.]+)\\s*=\\s+${ct}$`),Bp=w("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),Yp=w(`^presentation\\s+([A-Za-z_]\\w*)\\s+${ct}$`),Fp=w("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Up=w("^[a-z_]\\w*$"),Wp=w(`^title\\s+${ct}$`),zp=w(`^column\\s+([\\w.]+)(?:\\s+label\\s+${ct})?$`),Vp=w("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),Qp=w(`^field\\s+([\\w.]+)\\s+label\\s+${ct}$`),Xe=l((t,e)=>t[e]!==void 0?ee(t[e]):t[e+1],"operandText"),Gp=l(t=>["on","uses"].includes(D(t.content)),"isInteraction"),Zp=l((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function $a(t,e){let n=Ip.exec(e.content);n===null&&t.error(d.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,u(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),ue(r)||ba(t,r,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,location:u(e)}}l($a,"parseScreen");function ba(t,e,n){let i=_p(t,e);i!==void 0&&n.push(i)}l(ba,"pushDirective");function yr(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),ba(t,i,n);return n}l(yr,"parseDirectives");function _p(t,e){switch(D(e.content)){case"data":return Kp(t,e);case"action":return Hp(t,e);case"template":return Jp(t,e);case"section":return Xp(t,e);case"title":return eu(t,e);case"table":return tu(t,e);case"summary":return nu(t,e);case"component":return iu(t,e);case"toolbar":return su(t,e);case"navigate":return Vn(t,e.content,e);case"on":return Ie(t,e),{kind:"ScreenBehaviorSyntax",location:u(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:u(e)};default:if(Zp(t,e))return du(t,e);t.error(d.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,u(e)),t.skipBlock(e.indent);return}}l(_p,"parseDirective");function Kp(t,e){let n=Tp.exec(e.content);if(n===null){t.error(d.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,u(e));return}return{kind:"ScreenDataSyntax",type:Te(n[1],u(e)),query:n[2],by:n[3]??null,location:u(e)}}l(Kp,"parseData");function Hp(t,e){let n=Dp.exec(e.content);if(n!==null)return vo(t,e,Xe(n,1),Vn);let i=Rp.exec(e.content);if(i===null){t.error(d.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,u(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=xa.exec(s.content);a!==null?r=Xe(a,1):D(s.content)==="navigate"?o=Vn(t,s.content,s)??null:t.error(d.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,u(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:u(e)}}l(Hp,"parseAction");function Vn(t,e,n){let i=Mp.exec(e);if(i===null){t.error(d.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,u(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=va.exec(s.content);if(a!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:a[1],binding:Mt(t,a[2],u(s)),location:u(s)});continue}let c=jp.exec(s.content);if(c!==null){o=Xe(c,1);continue}t.error(d.InvalidNavigation,`Unexpected '${s.content}' in navigation - expected 'route "..."' or 'parameter <name> from <binding>'`,u(s))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,parameters:r,location:u(n)}}l(Vn,"parseNavigate");function Jp(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(),!Up.test(r.content)){t.error(d.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,u(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:yr(t,r),location:u(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:u(e)}}l(Jp,"parseTemplateReference");function Xp(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:yr(t,e),location:u(e)}}l(Xp,"parseSection");function eu(t,e){let n=Wp.exec(e.content);return n===null?(t.error(d.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,u(e)),{kind:"ScreenTitleSyntax",text:"",location:u(e)}):{kind:"ScreenTitleSyntax",text:Xe(n,1),location:u(e)}}l(eu,"parseTitle");function tu(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=zp.exec(o.content),a=Vp.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?Xe(s,2):null,location:u(o)})}else a!==null?r=Vn(t,a[1],o)??null:D(o.content)==="on"?Ie(t,o):Gp(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>'`,u(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:u(e)}}l(tu,"parseTable");function nu(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=Qp.exec(r.content);if(o===null){t.error(d.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,u(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:Xe(o,2),location:u(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:u(e)}}l(nu,"parseSummary");function iu(t,e){let n=Np.exec(e.content);if(n===null){t.error(d.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,u(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=ru(t,p);break;case"property":ou(t,p,o);break;case"icon":r=p.content.substring(4).trim();break;case"presentation":ka(t,p,a);break;case"exposes":au(t,p,s);break;case"outlet":c.push({kind:"ComponentOutletSyntax",name:p.content.substring(6).trim(),directives:yr(t,p),location:u(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`,u(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:u(e)}}l(iu,"parseComponent");function ru(t,e){return cu(t,e.content.substring(7).trim(),e)}l(ru,"parseUiContext");function ou(t,e,n){let i=Lp.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:Mt(t,i[2],u(e)),value:null,location:u(e)});return}let r=qp.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:Xe(r,2),location:u(e)});return}t.error(d.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = "value"'`,u(e))}l(ou,"parseComponentProperty");function au(t,e,n){let i=Bp.exec(e.content);if(i===null){t.error(d.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,u(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:Mt(t,i[2],u(e)),location:u(e)})}l(au,"parseExposedValue");function ka(t,e,n){let i=Yp.exec(e.content);if(i===null){t.error(d.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,u(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:Xe(i,2),location:u(e)})}l(ka,"parsePresentationValue");function su(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=lu(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:u(e)}}l(su,"parseToolbar");function lu(t,e){let n=Fp.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>'`,u(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=xa.exec(c.content);if(p!==null){i=Xe(p,1);continue}let y=va.exec(c.content);if(y!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:y[1],binding:Mt(t,y[2],u(c)),location:u(c)});continue}if(D(c.content)==="icon"){r=c.content.substring(4).trim();continue}ka(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:u(e)}}l(lu,"parseToolbarItem");function cu(t,e,n){return Mt(t,e,u(n))}l(cu,"parseUiBindingValue");function du(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}'`,u(e));return}e.content.startsWith("```")||t.warning(d.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,u(e));let i=Pt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:u(e)},location:u(e)}}l(du,"parseCode");var pu=w("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),uu=new Set(["reducer"]);function Ea(t,e){let n=pu.exec(e.content),i="StateChange",r="";n===null?t.error(d.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,u(e)):(r=n[2],Vo.includes(n[1])?i=n[1]:t.error(d.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,u(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=null,c=[],p=[],y=[],f=[],m=[],h=[],g=[],v=[],$=[],C=[],x=[],P=[],A=[];for(let k=t.peekChild(e.indent);k!==void 0;k=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ue(k))continue;let b=D(k.content);b==="description"?s=_(t,k,s,`Slice '${r}'`):b==="documentation"?a=ve(t,k,a,`Slice '${r}'`):b==="operation"?p.push(Dn(t,k).operation):b==="event"?c.push(_o(t,k)):b==="command"?y.push(sa(t,k)):b==="query"?f.push(ma(t,k)):b==="projection"?m.push(pr(t,k)):b==="capture"?g.push(ar(t,k)):b==="reaction"?h.push(ha(t,k)):b==="constraint"?v.push(la(t,k)):b==="example"?C.push(He(t,k)):b==="specification"?$.push(tr(t,k)):b==="readmodel"?x.push(Ko(t,k)):b==="screen"?P.push($a(t,k)):uu.has(b)?(A.push(na(t,k)),t.skipOpaqueBlock(k.indent)):(t.warning(d.UnknownSliceDirective,`Unknown construct '${b}' in slice '${r}'`,u(k)),t.skipBlock(k.indent))}t.scope=o;let S={kind:"SliceSyntax",type:i,name:r,description:s,documentation:a,examples:C,events:c,operations:p,commands:y,queries:f,projections:m,captures:g,reactions:h,constraints:v,specifications:$,readModels:x,screens:P,location:u(e)};return Je.set(S,{reducers:A}),S}l(Ea,"parseSlice");var fu=w("^feature\\s+([A-Za-z_]\\w*)$"),mu=new Set(["on","uses","contribute"]),hr="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=_(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 Pn(e,n,this.#n,d.UnknownFeatureDirective),!0;case"authorize":return this.#l=Fe(this.#l,st(e,n)),!0;case"import":return At(e,n,this.#r),!0;case"feature":return this.#e.push(Qn(e,n)),!0;case"example":return this.#o.push(He(e,n)),!0;case"slice":return this.#t.push(Ea(e,n)),!0;default:return mu.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 Qn(t,e){let n=fu.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,u(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 ${hr}`,u(o)),t.skipBlock(o.indent));return t.scope=r,i.build(u(e))}l(Qn,"parseFeature");var Sr=w("^module\\s+([A-Za-z_]\\w*)$"),yu=new Set(["on","uses","screen","dialog","form","contribute"]),gr="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=_(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 Pn(e,n,this.#r,d.UnknownModuleDirective),!0;case"authorize":return this.#a=Fe(this.#a,st(e,n)),!0;case"import":return At(e,n,this.#o),!0;case"example":return this.#t.push(He(e,n)),!0;case"feature":return this.#e.push(Qn(e,n)),!0;default:return yu.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 ${gr}`,u(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 xr(t,e){let n=Sr.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,u(e));let i=new an(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(u(e))}l(xr,"parseModule");var gu=new WeakMap,Be=l(t=>JSON.stringify(t),"authoredOrderKey");function sn(t){return gu.get(t)??new Map}l(sn,"authoredOrderOf");function Gn(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 y=[...c,p.name];n(p.examples,y);for(let f of p.slices){let m=[...c,p.name,f.name];n(f.examples,m);for(let h of new Set(se(f).map(g=>g.name)))e.push({name:h,scope:m,kind:"event"});for(let h of f.commands)e.push({name:h.name,scope:m,kind:"command"});for(let h of f.readModels)e.push({name:h.name,scope:m,kind:"readmodel"})}i(p.features,y)}},"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(m=>{let h=m.split("."),g=e.filter($=>$.name===h.at(-1)),v=h.slice(0,-1);if(v.length)return g.filter($=>v.length<=$.scope.length&&v.every((C,x)=>$.scope[$.scope.length-v.length+x]===C));for(let $=c.length;$>=0;$--){let C=g.filter(x=>$<=x.scope.length&&c.slice(0,$).every((P,A)=>x.scope[A]===P));if(C.length)return C}return[]},"candidates"),y=p(a),f=t.imports.filter(m=>m.qualifiedName.split(".").at(-1)===a);return!y.length&&f.length===1&&(y=p(f[0].qualifiedName)),y.length===1?y[0]:void 0},"resolve"),o=l((a,c,p)=>{let y=r(a,p),f=y?.example;if(!f)return null;let m=r(f.type,y.scope);return m?.kind===c?{example:f,name:[...m.scope,m.name].join(".")}:null},"fixture"),s=l((a,c)=>[...a.filter(p=>!c.some(y=>y.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 y=o(a.eventType,"event",p),f=y?.example??null,m=f?.stream??f?.noStream??null,h=a.stream??a.noStream??null,g=h??m,v=y===null?a:{...a,eventType:y.name,values:s(f.values,a.values),for:a.for??f.for,stream:g?.kind==="SpecificationStreamSyntax"?g:null,noStream:g?.kind==="SpecificationNoStreamSyntax"?g:null},$=v.values.map(C=>{let x=f?.values.find(A=>A.property===C.property),P=a.values.includes(C);return{property:C.property,value:C.source,origin:P?x===void 0?"authored":"override":"example",overriddenValue:P?x?.source??null:null}});return v.for!==null&&$.push({property:"for",value:v.for,origin:a.for===null?"example":f?.for==null?"authored":"override",overriddenValue:a.for===null?null:f?.for??null}),{role:c,authored:a,effective:v,example:f,values:$,route:g===null?null:{value:g,origin:h===null?"example":m===null?"authored":"override",overriddenValue:h===null?null:m}}},"eventStep"),command:l((a,c)=>{if(!a)return a;let p=o(a.commandType,"command",c);if(!p)return a;let{example:y,name:f}=p;return{...a,commandType:f,values:s(y.values,a.values),generatedValues:s(y.generatedValues,a.generatedValues??[]),for:a.for??y.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(Gn,"specificationExamples");function Zn(t){return Gn(t).command}l(Zn,"specificationCommandExamples");function $t(t){return _n(t).application}l($t,"expandSpecificationExamples");function _n(t){let e=Gn(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],y={...c,specifications:c.specifications.map(f=>{let m=[],h=l((v,$)=>{let C=e.eventStep(v,$,p);return m.push(C),C.effective},"event"),g={...f,given:f.given.map(v=>h(v,"given")),givenReadModels:f.givenReadModels.map(v=>e.readModel(v,p)),when:e.command(f.when,p),whenAppended:f.whenAppended===null?null:h(f.whenAppended,"when append"),thenEvents:f.thenEvents.map(v=>h(v,"then")),thenReadModels:f.thenReadModels.map(v=>e.readModel(v,p))};return n.push({authored:f,effective:g,steps:m}),g})};return Je.set(y,qe(c)),y})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}l(_n,"expandEffectiveSpecificationExamples");var dt=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var tt=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 xu={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 Hn(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(Hn,"sliceReferences");function Aa(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(Aa,"buildingReadModelReferences");function br(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...br(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?br(e.blocks):[])}l(br,"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=br(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:xu[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 y of[...t.get(a)].sort())e.has(y)?r.has(y)&&n.set(a,Math.min(n.get(a),e.get(y))):(s(y),n.set(a,Math.min(n.get(a),n.get(y))));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 wa=["usesFactsFrom","reactsTo","decidesFrom"],ze=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),kr=l((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),Er=l((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),Pr=l((t,e)=>t.rank-e.rank||ze(t.key,e.key),"compareNodes"),cn=l(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(Pr),"distinctNodes"),Oa=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||ze(t.location.path??"",e.location.path??"")||ze(t.role,e.role)||ze(t.name,e.name),"compareEvidence");function Ar(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...Ar(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?Ar(e.blocks):[])}l(Ar,"variants");var jt=class t{static{l(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=Er("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((x,P)=>x.map((A,S)=>({syntax:A,index:S,rank:n.get(Be([...P.scope,A.name]))??Number.MAX_SAFE_INTEGER})).sort((A,S)=>A.rank-S.rank||A.index-S.index).map(A=>A.syntax),"ordered"),r=l((x,P)=>{let A=this.add("feature",x.name,P);for(let S of i(x.slices,A))this.slices.push({node:this.add("slice",S.name,A),syntax:S});for(let S of i(x.features,A))r(S,A)},"feature");for(let x of i(e.modules,this.root)){let P=this.add("module",x.name,this.root);for(let A of i(x.features,P))r(A,P)}let o=new Map,s=new Map,a=l((x,P,A,S)=>{let k=kr(P,A);x.has(k)||x.set(k,[]);let b=x.get(k);b.includes(S)||b.push(S);let E=kr(P,[...S.scope,A].join("."));x.has(E)||x.set(E,[]);let O=x.get(E);O.includes(S)||O.push(S)},"declare");for(let{node:x,syntax:P}of this.slices){for(let A of se(P))a(o,"Event",A.name,x);for(let A of P.commands)a(o,"Command",A.name,x);for(let A of P.reactions)a(o,"Reaction",A.name,x);for(let A of P.queries)a(o,"Query",A.name,x);for(let A of P.screens)a(o,"Screen",A.name,x);for(let A of P.readModels)a(o,"ReadModel",A.name,x);for(let A of P.projections){let S=Ar(A.blocks);S.length===0&&a(s,"ReadModel",A.readModel??A.name,x);for(let k of S)a(s,"ReadModel",k.name,x)}for(let A of qe(P).reducers??[])a(s,"ReadModel",A.readModel,x)}let c=new Set((e.declaredTriggers??[]).map(x=>x.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map(x=>x.name.toLowerCase())),y=new Set((e.policies??[]).map(x=>x.name.toLowerCase())),f=e.imports.filter(x=>x.qualifiedName.includes(".")).slice().sort((x,P)=>ze(x.location.path??"",P.location.path??"")||x.location.line-P.location.line||x.location.column-P.location.column||ze(x.qualifiedName,P.qualifiedName)),m=new Map,h=[],g=[],v=new Set,$=0;for(let{node:x,syntax:P}of this.slices){let A=Hn(P);$+=A.shared.filter(S=>(S.kind==="type"?p:y).has(S.name.toLowerCase())).length;for(let S of A.references){let k=kr(S.targetKind,S.name),E=(S.targetKind==="ReadModel"&&s.has(k)?s:o).get(k);if(E!==void 0&&E.length>0){let I=E[0];I!==x&&h.push({consumer:x,producer:I,kind:S.kind,role:S.role,name:S.name,ambiguous:E.length>1,alternatives:E.slice(1),location:S.location,testOnly:S.kind==="verifiedWith"});continue}let O=S.targetKind==="Event"?f.filter(I=>I.qualifiedName.slice(I.qualifiedName.lastIndexOf(".")+1).toLowerCase()===S.name.toLowerCase()):[];if(O.length>0){let I=[];for(let R of O){v.add(R.qualifiedName);let j=R.qualifiedName.slice(0,R.qualifiedName.lastIndexOf(".")),N=`context:${j}`;if(!m.has(N)){let L=Er("context",N,[j],this.modelNodes.length);this.modelNodes.push(L),m.set(N,L)}let B=m.get(N);I.includes(B)||I.push(B)}h.push({consumer:x,producer:I[0],kind:"outsideTheModel",role:S.role,name:S.name,ambiguous:I.length>1,alternatives:I.slice(1),location:S.location,testOnly:S.kind==="verifiedWith"});continue}if(S.role==="trigger"&&c.has(S.name.toLowerCase())){$++;continue}g.push({consumer:x,kind:S.kind,role:S.role,name:S.name,location:S.location})}}let C=new Map;for(let x of h.sort(Oa)){let P=JSON.stringify([x.consumer.key,x.producer.key,x.kind]);C.has(P)||C.set(P,[]),C.get(P).push(x)}this.edges=[...C.values()].map(x=>({consumer:x[0].consumer,producer:x[0].producer,kind:x[0].kind,evidence:x})),this.unresolved=g.sort((x,P)=>x.consumer.rank-P.consumer.rank||x.location.line-P.location.line||x.location.column-P.location.column||dt.indexOf(x.kind)-dt.indexOf(P.kind)||ze(x.location.path??"",P.location.path??"")||ze(x.name,P.name)),this.excludedReferences=$,this.unusedImports=[...new Set(f.filter(x=>!v.has(x.qualifiedName)).map(x=>x.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new tt(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new tt(`Unsupported target level '${n}'.`);if(o<0)throw new tt("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(y=>this.disjoint(c,y))){let y=JSON.stringify([c.key,p.key]);s.has(y)||s.set(y,{source:c,target:p,evidence:[]}),s.get(y).evidence.push(a)}return[...s.values()].sort((a,c)=>a.source.rank-c.source.rank||a.target.rank-c.target.rank||ze(a.source.key,c.source.key)||ze(a.target.key,c.target.key)).map(a=>{let c=a.evidence.sort(Oa),p={};for(let y of dt){let f=c.filter(m=>m.kind===y).length;f>0&&(p[y]=f)}return{source:a.source,target:a.target,sliceEdges:new Set(c.map(y=>JSON.stringify([y.consumer.key,y.producer.key]))).size,references:c.length,byKind:p,consumers:cn(c.map(y=>y.consumer)),producers:cn(c.map(y=>y.producer)),evidence:c.slice(0,o),evidenceCount:c.length,evidenceTruncated:c.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new tt(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Ia(n)),r=cn(i.flatMap(o=>[o.source,o.target]));return Ta(Cr(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return Ta(Cr(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($=>$.container===a),y=new Map(c.map($=>[$.key,$])),f=ln(Cr(c,p)).map($=>$.map(C=>y.get(C)).sort(Pr)).sort(($,C)=>$[0].rank-C[0].rank),m=new Map(f.flatMap(($,C)=>$.map(x=>[x.key,C]))),h=new Map(c.map($=>[$.key,new Set]));for(let $ of p)m.get($.source.key)!==m.get($.target.key)&&h.get($.source.key).add($.target.key);for(let $ of f)for(let C=1;C<$.length;C++)h.get($[C].key).add($[C-1].key);let g=new Set(c.map($=>$.key)),v=[];for(;g.size>0;){let $=[...g].filter(C=>h.get(C).size===0).sort((C,x)=>Pr(y.get(C),y.get(x)))[0];v.push(y.get($)),g.delete($);for(let C of g)h.get(C).delete($)}i.push({container:a,children:v,changed:c.some(($,C)=>$!==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,y)=>+(p.kind!=="slice")-+(y.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 tt(`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 y of o.filter(f=>f.source.address===a[p]).sort((f,m)=>f.target.rank-m.target.rank))s.has(y.target.address)||(s.add(y.target.address),c.push(y.target),a.push(y.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=Er(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=Ra(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(Ia(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 Ra(t){let e=new Set(t??dt);if([...e].some(n=>!dt.includes(n)))throw new tt("Unsupported dependency kind.");return e}l(Ra,"selectedKinds");function Ia(t){return[...Ra(t??wa)].filter(e=>wa.includes(e))}l(Ia,"selectedOrderingKinds");function Cr(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(Cr,"adjacency");function Ta(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(Ta,"groupsOf");var vu=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],Ve=l((t,e)=>e===t||e.startsWith(t+"."),"contains"),Nt=l((t,e)=>t<e?-1:t>e?1:0,"ordinal"),$u=l((t,e)=>Nt(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||Nt(t.kind,e.kind)||Nt(t.consumer.address,e.consumer.address)||Nt(t.producer.address,e.producer.address)||Nt(t.role,e.role)||Nt(t.name,e.name),"orderedEvidence"),Lt=class{static{l(this,"DeclaredDependencies")}static for(e){let n=new Map,i=l((f,m)=>{let h=f.join(".");n.has(h)||n.set(h,{location:m.location,dependencies:[]}),n.get(h).dependencies.push(...m.dependsOn??[]),m.features.forEach(g=>i([...f,g.name],g))},"inventory");if(e.modules.forEach(f=>i([f.name],f)),![...n.values()].some(f=>f.dependencies.length))return{containers:[],diagnostics:[]};let r=jt.for(e,new Map),o=r.nodes.filter(f=>f.kind==="module"||f.kind==="feature"),s=Ee.containersOf(e),a=l((f,m)=>{let h=Ee.resolve(f,m,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),c=[],p=[],y=l((f,m,h,g)=>p.push({code:f,severity:m,message:h,location:g}),"finding");for(let f of o.filter(m=>n.get(m.address).dependencies.length)){let m=n.get(f.address),h=m.dependencies.map($=>{let C=a($.target,f.scope),x=C!==void 0&&!Ve(f.address,C)&&!Ve(C,f.address);return{syntax:$,resolved:C,status:x?"unused":"invalid"}}),g=[],v=new Map;for(let $ of r.edges.flatMap(C=>C.evidence).filter(C=>vu.includes(C.kind)&&Ve(f.address,C.consumer.address)).sort($u)){let C=[$.producer,...$.alternatives].filter(A=>!Ve(f.address,A.address)&&!Ve(A.scope.slice(0,-1).join("."),f.address));if(!C.length)continue;let x=h.filter(A=>A.status!=="invalid"&&C.some(S=>Ve(A.resolved,S.address)));for(let A of x)A.status=$.ambiguous&&A.status!=="used"?"provisional":"used";let P=$.ambiguous?"provisional":x.length?"declared":"undeclared";if(g.push({evidence:$,status:P,coveringDeclarations:x.map(A=>A.syntax)}),P==="undeclared"){let A=$.producer.scope[0];v.has(A)||v.set(A,[]),v.get(A).push($)}}for(let $ of v.values()){let C=$[0].producer.scope.slice(0,-1),x=C.findIndex((k,b)=>$.some(E=>b>=E.producer.scope.length-1||E.producer.scope[b]!==k));x>=0&&(C=C.slice(0,x));let P=C.join("."),A=Ve(f.address,P)||Ve(P,f.address)?[...new Set($.map(k=>k.producer.scope.slice(0,-1).map((b,E)=>k.producer.scope.slice(0,E+1).join(".")).find(b=>!Ve(f.address,b)&&!Ve(b,f.address))))]:[P],S=$.map(k=>`${k.kind} ${k.role} '${k.name}' at ${k.location.path??""}:${k.location.line}:${k.location.column}`).join("; ");y(d.UndeclaredDependency,"warning",`Container '${f.address}' depends on '${A.join("', '")}' without declaring ${A.length===1?"it":"them"} - evidence: ${S}`,m.location)}for(let $ of h)$.status==="unused"&&y(d.UnusedDependencyDeclaration,"information",`Dependency '${$.syntax.target}' on '${f.address}' is not used by any counted explicit reference`,$.syntax.location),$.status!=="invalid"&&n.get($.resolved).dependencies.some(C=>a(C.target,$.resolved.split("."))===f.address)&&y(d.MutualDependencyDeclarations,"information",`Containers '${f.address}' and '${$.resolved}' declare each other`,$.syntax.location);c.push({container:f,location:m.location,declarations:h,edges:g})}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 wr=class extends Error{static{l(this,"InvalidExactNumber")}};function Or(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||Ze(t.value)?.value!==t.value)throw new wr("Expected a canonical, bounded ExactNumber value.");return t.value}l(Or,"canonicalExactText");function Da(t){return!Or(t).includes(".")}l(Da,"exactIsIntegral");var bu=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,ku=/^([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 Ir(t,e){let n=(e?ku:bu).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(Ir,"responseDateValue");var Jn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Xn(t,e,n=e.inputUses){let i=Zn(t),r=[],o=l((S,k)=>{let b=[...k,S.name];S.slices.forEach(E=>r.push({slice:E,scope:[...b,E.name]})),S.features.forEach(E=>o(E,b))},"collect");t.modules.forEach(S=>S.features.forEach(k=>o(k,[S.name])));let s=new Map,a=new Map,c=new Map;for(let{slice:S,scope:k}of r)for(let b of S.commands){let E=s.get(b.name)??[];E.push({command:b,scope:k}),s.set(b.name,E),a.set(b,te(b.properties)),b.response?.kind==="RecordCommandResponseSyntax"&&c.set(b,te(b.response.fields))}let p=new Map;for(let S of t.imports){let k=S.qualifiedName.split(".").at(-1);p.set(k,[...p.get(k)??[],S.qualifiedName])}let y=new Map,f=l((S,k)=>{let b=`${k.join(".")}|${S}`;if(y.has(b))return y.get(b);let E=p.get(S)??[],R=((s.get(S.split(".").at(-1))??[]).length===0&&E.length===1?E[0]:S).split("."),j=s.get(R.at(-1))??[];if(R.length>1){let B=R.slice(0,-1);j=j.filter(L=>B.length<=L.scope.length&&B.every((W,z)=>L.scope[L.scope.length-B.length+z]===W))}else for(let B=k.length;B>=0;B--){let L=j.filter(W=>B<=W.scope.length&&k.slice(0,B).every((z,G)=>W.scope[G]===z));if(L.length>0){j=L;break}}let N=j.length===1?j[0].command:null;return y.set(b,N),N},"resolve"),m=te(t.concepts),h=new Set(t.concepts.map(S=>S.name)),g=new Map([...te(t.types)].map(([S,k])=>[S,te(k.properties)])),v=new Set(r.flatMap(S=>S.slice.readModels.map(k=>k.name))),$=new Set([...a.keys()].flatMap(S=>[...S.properties])),C=l(S=>{for(let k of S)k.isGenerated&&!$.has(k)&&e.error(d.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",k.location)},"checkDeclarations"),x=l(S=>{S.features.forEach(x);for(let k of S.slices){for(let b of k.commands)for(let E of b.produces)E.inlineEvent!==null&&C(E.inlineEvent.properties);k.events.forEach(b=>C(b.properties)),k.readModels.forEach(b=>C(b.properties));for(let b of k.reactions)for(let E of b.triggers)for(let O of E.produces)O.inlineEvent!==null&&C(O.inlineEvent.properties)}},"checkFeature");t.types.forEach(S=>C(S.properties)),t.modules.forEach(S=>S.features.forEach(x));let P=l((S,k,b)=>{let E=a.get(b).get(S.property);if(E===void 0){e.error(d.InvalidResponseSource,`Response source '${S.property}' must reference one direct command property.`,S.location);return}let O=E.type;(O.isCollection||v.has(O.name))&&e.error(d.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",S.location),k!==null&&(k.name!==O.name||k.isCollection!==O.isCollection||k.isOptional!==O.isOptional)&&e.error(d.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",k.location)},"validateSource");for(let S of a.keys()){for(let b of S.properties){if(!b.isGenerated)continue;let E=m.get(b.type.name);(b.type.isOptional||b.type.isCollection||(E===void 0?Jn.has(b.type.name)||g.has(b.type.name)||h.has(b.type.name)||v.has(b.type.name):E.type!=="Uuid"))&&e.error(d.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",b.location)}let k=S.response;if(k?.kind==="ScalarCommandResponseSyntax")P(k.source,null,S);else if(k?.kind==="RecordCommandResponseSyntax"){k.fields.length===0&&e.error(d.InvalidCommandResponse,"A response block requires at least one field.",k.location);let b=new Set;for(let E of k.fields)b.has(E.name)&&e.error(d.DuplicateResponseField,`Duplicate response field '${E.name}'.`,E.location),b.add(E.name),P(E.source,E.type,S)}}let A=l((S,k)=>{let b=i(S.when,k),E=b===null?null:f(b.commandType,k);if(b!==null&&E!==null){let j=a.get(E);for(let L of b.values)j.get(L.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${L.property}' cannot be supplied as request or form input.`,L.location);let N=[...j.values()].filter(L=>L.isIdentifier);if(b.for!==null&&N.length===1&&N[0].isGenerated){let L=N[0].type;(Jn.has(L.name)||m.has(L.name)||g.has(L.name))&&(L.isOptional||L.isCollection||m.get(L.name)?.type!=="Uuid"||b.for.kind!=="LiteralExpressionSyntax"||typeof b.for.value!="string"||!Ma(b.for.value))&&e.error(d.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",b.for.location)}let B=new Set;for(let L of b.generatedValues??[]){let W=j.get(L.property);(B.has(L.property)||W===void 0||!W.isGenerated||W.isIdentifier||!Ce(L.source,W.type,m,g))&&e.error(d.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",L.location),B.add(L.property)}}let O=S.thenReturns;if(O==null||((b===null||S.thenErrors.length>0||S.thenDenied!=null)&&e.error(d.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",O.location),E===null))return;let I=E.response,R=a.get(E);if(O.kind==="ScalarSpecificationReturnSyntax"&&I?.kind==="ScalarCommandResponseSyntax"&&R.has(I.source.property))Ce(O.value,R.get(I.source.property).type,m,g)||e.error(d.InvalidReturnExpectation,"The expected return value must match the response source's type.",O.location);else if(O.kind==="RecordSpecificationReturnSyntax"&&I?.kind==="RecordCommandResponseSyntax"){O.fields.length===0&&e.error(d.InvalidReturnExpectation,"A record return expectation requires at least one field.",O.location);let j=c.get(E),N=new Set;for(let B of O.fields){let L=j.get(B.property),W=L===void 0?void 0:R.get(L.source.property);(N.has(B.property)||W===void 0||!Ce(B.source,W.type,m,g))&&e.error(d.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",B.location),N.add(B.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:S,scope:k}of r)S.specifications.forEach(b=>A(b,k));for(let S of n){if(S.isParameter===!0)continue;let k=f(S.command,S.scope);k!==null&&a.get(k).get(S.property.split(".")[0])?.isGenerated&&e.error(d.GeneratedPropertySuppliedAsInput,`Generated property '${S.property}' cannot be supplied as request or form input.`,S.location)}}l(Xn,"validateResponses");function te(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(te,"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"&&Ma(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&&Da(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"&&Ir(t.value,!1);case"DateTime":return typeof t.value=="string"&&Ir(t.value,!0);default:return!Jn.has(s)}return!Jn.has(s)&&o===void 0}l(Ce,"compatibleValue");var Eu=/^(?:[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 Ma(t){return Eu.test(t)}l(Ma,"uuidValue");function ei(t,e,n,i=!1){let r=[],o=[],s=Oe,a=!1,c=!1,p=!1,y=new Map,f=new xe(new _e([]),e,n).languages;for(let h of t){let g=h;if(g.number===1&&g.raw.startsWith("\uFEFF")){let v=g.raw.substring(1),$=v.length-v.trimStart().length,C=Vt(v.substring($),i);g={...g,indent:$,contentOffset:1,content:(C<0?v.substring($):v.substring($,$+C)).trimEnd()}}if(p){_i(g)&&(p=!1),r.push(g);continue}if(g.content.startsWith("```")&&(["```","```text","```markdown"].includes(g.content)||f.has(g.content.substring(3)))&&(p=!0),!p&&g.indent===0&&D(g.content)==="numbers"){let v=g.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:u(g)}),s=Object.freeze({numericMode:"invalid"})):s=wn,a=!0,r.push({...g,content:""});continue}!p&&g.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(g.content)&&y.set(g.number,{severity:"error",code:d.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:u(g)}),c||=g.content.trim().length>0,r.push(g)}let m=new xe(new _e(a?r:t),e,n);return m.sourceOptions=s,m.nestedNumericDirectives=y,o.forEach(h=>m.error(h.code,h.message,h.location)),m}l(ei,"sourceContext");function ja(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}l(ja,"eventProductions");function Tr(t,e){let n=ja(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(Tr,"requiresExplicitDestinations");function Na(t,e,n){let i=ja(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||Tr(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(Na,"implicitDestination");function ti(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(se))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 ae(t);for(let{slice:a,command:c}of n.flatMap(p=>p.commands.map(y=>({slice:p,command:y})))){let p=c.produces.filter(m=>s.isEventProduction(m,a)),y=c.properties.find(m=>m.isIdentifier)?.name,f=Tr(c,{resolver:s,slice:a});for(let m of p){let h=m.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`,m.location),f&&m.for===null&&e.error(d.ExplicitProducesTargetsRequired,`Production '${m.event}' in command '${c.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,m.location);let g=m.for?.kind==="PathExpressionSyntax"?m.for.path:m.for===null&&h!==null?y:void 0;if(!(y===void 0||g!==y))for(let v of m.mappings.filter($=>$.source.kind==="PathExpressionSyntax"&&$.source.path===y)){let $=`Event '${m.event}' copies command identifier '${y}' into payload property '${v.property}' although it already identifies the event source`;h===null?e.information(d.EventSourceIdInPayload,$,v.location):e.warning(d.EventSourceIdInPayload,$,v.location)}}}}l(ti,"validateInlineEvents");function ni(t,e){let n=new ae(t),i=Zn(t),r=te(t.concepts),o=new Map([...te(t.types)].map(([x,P])=>[x,te(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map(x=>x.qualifiedName.split(".").at(-1))),c=new Map;for(let x of t.imports){let P=x.qualifiedName.split(".").at(-1);c.set(P,[...c.get(P)??[],x.qualifiedName])}let p=l(x=>{let P=new Map,A=new Map;for(let S of x){let k=P.get(S.name)??[];k.push(S),P.set(S.name,k)}return(S,k)=>{let b=JSON.stringify([S,k]);if(A.has(b))return A.get(b);let E=l(j=>{let N=j.split("."),B=P.get(N.at(-1))??[],L=N.slice(0,-1);if(L.length>0)return B.filter(W=>L.length<=W.scope.length&&L.every((z,G)=>W.scope[W.scope.length-L.length+G]===z));for(let W=k.length;W>=0;W--){let z=B.filter(G=>W<=G.scope.length&&k.slice(0,W).every((V,Z)=>G.scope[Z]===V));if(z.length>0)return z}return[]},"candidates"),O=E(S),I=c.get(S)??[];O.length===0&&I.length===1&&(O=E(I[0]));let R=O.length===1?O[0].node:null;return A.set(b,R),R}},"scoped"),y=p(n.slices.flatMap(({slice:x,scope:P})=>x.readModels.map(A=>({name:A.name,scope:P,node:A})))),f=p(n.slices.flatMap(({slice:x,scope:P})=>x.commands.map(A=>({name:A.name,scope:P,node:{command:A,slice:x}})))),m=new Map;for(let x of t.systems??[])m.has(x.name)&&e.error(d.InvalidSystemDeclaration,`System '${x.name}' is declared more than once.`,x.location),m.set(x.name,(m.get(x.name)??0)+1);let h=l((x,P,A=!0)=>{let[S,...k]=P.split("."),b=x.filter(R=>R.name===S);if(b.length!==1)return{type:null,missing:b.length===0};let E=b[0].type;if(k.length===0)return{type:E,missing:!1};let O=o.get(E.name);if(O===void 0)return{type:null,missing:s.has(E.name)};let I=h([...O.values()],k.join("."),A);return I.type===null?I:{type:{...I.type,isOptional:A&&E.isOptional||I.type.isOptional,isCollection:E.isCollection||I.type.isCollection},missing:!1}},"pathType"),g=l((x,P,A,S,k=new Set)=>{if(A.has(P)||x.isOptional&&!S.has(P))return!0;if(x.isCollection||k.has(x.name))return!1;let b=o.get(x.name);return b===void 0?S.has(P)&&!s.has(x.name):[...b.values()].every(E=>g(E.type,`${P}.${E.name}`,A,S,new Set([...k,x.name])))},"covered"),v=l((x,P)=>{if(x.kind==="ListExpressionSyntax"&&P.isCollection)return x.items.every(S=>v(S,{...P,isCollection:!1,isOptional:!1}));let A=o.get(P.name);return x.kind!=="ObjectExpressionSyntax"||A===void 0?!0:[...A.values()].every(S=>(S.type.isOptional||x.members.some(k=>k.name===S.name))&&x.members.filter(k=>k.name===S.name).every(k=>v(k.value,S.type)))},"completeValue"),$=l(x=>x.kind==="LiteralExpressionSyntax"?typeof x.value!="number"||Number.isFinite(x.value):x.kind==="ObjectExpressionSyntax"?x.members.every(P=>$(P.value)):x.kind==="ListExpressionSyntax"&&x.items.every($),"concrete"),C=l((x,P,A,S,k)=>{let b=new Set,E=new Set(x.map(I=>I.property)),O=new Set;for(let I of x){let R=I.property.split(".");for(let j=1;j<=R.length;j++)O.add(R.slice(0,j).join("."))}for(let I of x){b.has(I.property)&&e.error(d.InvalidOperationMapping,`Duplicate operation input mapping '${I.property}'.`,I.location),b.add(I.property);let R=h(P.inputs,I.property,!1);if(R.missing&&e.error(d.InvalidOperationMapping,`Operation '${P.name}' declares no input '${I.property}'.`,I.location),R.type===null)continue;let j=I.property.split(".");for(let N=1;N<j.length;N++)E.has(j.slice(0,N).join("."))&&e.error(d.InvalidOperationMapping,`Operation input mapping '${I.property}' overlaps a whole input mapping.`,I.location);if(A!==null&&I.source.kind==="PathExpressionSyntax"){let N=h(A.properties,I.source.path),B=I.source.path.split("."),L=(Fn.get(A)??[]).filter(G=>(G.alias??G.readModel)===B[0]);if(N.missing&&L.length>0){N={type:null,missing:!1};let G=L.length===1?y(L[0].readModel,k):null;B.length>1&&G!==null&&(N=h(G.properties,B.slice(1).join(".")))}N.missing&&e.error(d.InvalidOperationMapping,`Command '${A.name}' declares no source '${I.source.path}'.`,I.source.location);let W=N.type,z=R.type;W!==null&&s.has(W.name)&&s.has(z.name)&&(W.name!==z.name||W.isCollection!==z.isCollection||W.isOptional&&!z.isOptional)&&e.error(d.InvalidOperationMapping,`Source '${I.source.path}' is incompatible with input '${I.property}' of operation '${P.name}'.`,I.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(I.source.kind)&&(!Ce(I.source,R.type,r,o)||S&&!v(I.source,R.type))&&e.error(d.InvalidOperationMapping,`Value is incompatible with input '${I.property}' of operation '${P.name}'.`,I.source.location)}if(S)for(let I of P.inputs)g(I.type,I.name,b,O)||e.error(d.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${I.name}'.`,P.location)},"validateMappings");for(let{slice:x,scope:P}of n.slices){let A=vn(x),S=new Set(se(x).map(k=>k.name));for(let k of A){S.has(k.name)&&e.error(d.ProductionDeclarationCollision,`Operation '${k.name}' collides with another event or operation in slice '${x.name}'.`,k.location),S.add(k.name),k.uses.length>0&&m.get(k.uses)!==1&&e.error(d.InvalidSystemReference,`Operation '${k.name}' must use one declared system; '${k.uses}' does not resolve uniquely.`,k.usesLocation??k.location);for(let b of k.inputs)!s.has(b.type.name)&&!a.has(b.type.name)&&e.warning(d.UnknownType,`Unknown type '${b.type.name}' on input '${b.name}' of operation '${k.name}'.`,b.type.location)}for(let k of x.commands)for(let b of k.produces){let E=n.resolve(b.event,x);E.kind===ie.Ambiguous&&E.candidates.some(O=>O.kind===ie.Operation)&&e.error(d.InvalidProductionReference,`Production '${b.event}' is ambiguous.`,b.location),b.event.includes(".")&&E.kind!==ie.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",b.location),E.declaration?.node.kind==="OperationSyntax"&&((b.for!==null||b.tags.length>0)&&e.error(d.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",b.location),C(b.mappings,E.declaration.node,k,!0,P))}for(let k of x.reactions.flatMap(b=>b.triggers).flatMap(b=>b.produces)){let b=n.resolve(k.event,x);b.kind===ie.Ambiguous&&b.candidates.some(E=>E.kind===ie.Operation)&&e.error(d.InvalidProductionReference,`Production '${k.event}' is ambiguous.`,k.location),k.event.includes(".")&&n.resolve(k.event,x).kind!==ie.Operation&&e.error(d.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",k.location),n.isOperation(k,x)&&e.error(d.OperationOutsideCommand,"Operations can only be produced by commands.",k.location)}for(let k of x.specifications){let b=[...k.givenOperationFailures??[],...k.thenOperations??[],...k.thenCompensated??[]];if(b.length===0)continue;let E=f(i(k.when,P)?.commandType??"",P);(E===null||k.whenAppended!==null||k.whenQuery!==null||k.whenTrigger!==null||k.whenClock!==null||k.whenCapture!==null)&&e.error(d.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",k.location);let O=new Map;for(let I of b){if(I.kind==="SpecificationOperationSyntax")for(let N of I.values)$(N.source)||e.error(d.InvalidOperationSpecification,"Operation assertions require concrete input values.",N.source.location);let R=n.resolve(I.operation,x).declaration?.node;if(R?.kind!=="OperationSyntax"){e.error(d.InvalidOperationSpecification,`'${I.operation}' does not resolve uniquely to a declared operation.`,I.location);continue}let j=O.get(R)??new Set;if(j.has(I.kind)&&e.error(d.InvalidOperationSpecification,`Duplicate operation step '${I.operation}'.`,I.location),j.add(I.kind),O.set(R,j),I.kind==="SpecificationCompensatedSyntax"&&R.compensate===null&&e.error(d.InvalidOperationSpecification,`Operation '${I.operation}' declares no compensation.`,I.location),E!==null&&E.command.handler==null){let N=E.command.produces.map(B=>n.resolve(B.event,E.slice));N.every(B=>B.kind===ie.Event||B.kind===ie.Operation)&&!N.some(B=>B.declaration?.node===R)&&e.error(d.InvalidOperationSpecification,`Command '${E.command.name}' does not produce operation '${I.operation}'.`,I.location)}I.kind==="SpecificationOperationSyntax"&&C(I.values,R,null,!1,P)}}}}l(ni,"validateOperations");var La=["racialOrEthnicOrigin","politicalOpinions","religiousOrPhilosophicalBeliefs","tradeUnionMembership","genetic","biometric","health","sexLifeOrSexualOrientation"],Cu=w("^(@?[a-z_]\\w*)\\s+(reason|scope|special|criminal)(?:\\s+(.*))?$"),Pu=w(`^"(${J})"$`);function Rr(t){let e=t.replace(/^@/,"");return e==="personal"?"pii":e==="secret"?"sensitive":e}l(Rr,"complianceWireName");function Au(t){let e=Rr(t);return e==="sensitive"?"secret":e}l(Au,"canonicalComplianceName");function qa(t,e,n){let i=n.trim().split(/\s+/).filter(r=>r.length>0);return Ya(t,e,i),i.map(r=>{let o=Rr(r);return(!["pii","sensitive"].includes(o)||r==="@personal"||r==="@secret")&&t.error(d.UnknownComplianceMarker,`Unknown concept marker '${r}' - expected pii, personal or secret`,u(e)),{kind:"ConceptAttributeSyntax",name:o,reason:null,scope:null,specialCategory:null,criminal:!1,location:u(e)}})}l(qa,"parseComplianceMarkers");function Ba(t,e,n,i){let r=Cu.exec(e.content);if(r===null)return!1;let[,o,s]=r,a=r[3]??"",c=Rr(o),p=Au(o);if(Ya(t,e,[o]),!["pii","sensitive"].includes(c)||o==="@personal"||o==="@secret")return t.error(d.UnknownComplianceMarker,`Unknown concept marker '${o}' - expected pii, personal or secret`,u(e)),!0;let y=i.findIndex(m=>m.name===c);if(y<0)return t.error(d.AttributeReasonWithoutAttribute,`Concept '${n}' declares '${p} ${s}' without the marker - write 'concept ${n} : <Type> ${p}'`,u(e)),!0;let f=i[y];switch(s){case"reason":{let m=Pu.exec(a);return m===null?(t.error(d.UnknownConceptDirective,`Invalid '${p} reason' - expected '${p} reason "<text>"'`,u(e)),!0):f.reason!==null?(t.error(d.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${p}' - at most one is allowed`,u(e)),!0):(i[y]={...f,reason:ee(m[1])},!0)}case"scope":return c!=="sensitive"||!["subject","namespace","global"].includes(a)?(t.error(d.InvalidSecretScope,`Invalid '${p} scope ${a}' - scope belongs to secret and must be subject, namespace or global`,u(e)),!0):f.scope!=null?(t.error(d.DuplicateSecretScope,`Concept '${n}' already declares secret scope - at most one is allowed`,u(e)),!0):(i[y]={...f,scope:a},i.some(m=>m.name==="pii")&&t.warning(d.SecretScopeIgnoredForPii,`Concept '${n}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`,u(e)),!0);case"special":case"criminal":return c!=="pii"||(s==="special"?!La.includes(a):a.length>0)?(t.error(d.InvalidPersonalDataQualifier,`Invalid '${p} ${s}${a.length>0?` ${a}`:""}' - expected 'pii criminal' or 'pii special <category>' with category ${La.join(", ")}`,u(e)),!0):s==="special"&&f.specialCategory!=null?(t.error(d.DuplicateSpecialCategory,`Concept '${n}' already declares pii special - at most one is allowed`,u(e)),!0):(i[y]=s==="special"?{...f,specialCategory:a}:{...f,criminal:!0},!0);default:return!1}}l(Ba,"parseComplianceDirective");function Ya(t,e,n){n.some(i=>["@pii","sensitive","@sensitive"].includes(i))&&t.information(d.LegacyComplianceMarker,"Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved",u(e))}l(Ya,"reportLegacy");var wu=Q("^policy\\s+([A-Za-z_]\\w*)$");function Fa(t,e){let n=t;t=t.valueContext;let i=wu.exec(e.content)?.[1]??"";i===""&&t.error(d.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,u(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 m=t.peekChild(c.indent);m!==void 0;m=t.peekChild(c.indent))t.reader.takeSignificant(),p+=` ${m.content}`;let y=Ou(t,p);y.includes("not")&&(t=n);let f=Iu(t,y,u(c));a?t.error(d.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,u(c)):r=f,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`,u(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`,u(c))}else t.error(d.UnknownPolicyDirective,`Unexpected '${c.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,u(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`,u(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`,u(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,location:u(e)}}l(Fa,"parsePolicy");function Ou(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(`"${J}"|\\(|\\)|${n}`).source,"gu"))??[]]}l(Ou,"tokenizePolicyCondition");function Iu(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=l(f=>f!==void 0&&f.startsWith('"')&&f.endsWith('"'),"quoted"),s=l(f=>ee(f.substring(1,f.length-1)),"unquote"),a=l(()=>{if(e[r]==="not"){r++;let g=a();return g===null?null:{kind:"NotPolicyConditionSyntax",operand:g,location:n}}if(e[r]==="("){r++;let g=p();return e[r]===")"?r++:i&&t.error(d.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),g}let f=e[r++];if(f==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(f!=="role"&&f!=="claim")return t.error(f===void 0?d.ExpectedPolicyCondition:d.UnexpectedTokenInPolicyCondition,f===void 0?"Expected a policy condition":`Unexpected '${f}' in policy condition`,n),null;let m=e[r++];if(!o(m))return t.error(f==="role"?d.ExpectedRoleName:d.ExpectedClaimName,`Expected a quoted ${f} name after '${f}'`,n),null;if(f==="role")return{kind:"RoleConditionSyntax",role:s(m),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(m),matchesSubject:h==="subject",matches:h==="subject"?null:we(h,n,t),location:n}},"group"),c=l(()=>{let f=a();for(;f!==null&&e[r]==="and";){r++;let m=a();if(m===null)return null;f={kind:"LogicalPolicyConditionSyntax",left:f,operator:"And",right:m,location:n}}return f},"and"),p=l(()=>{let f=c();for(;f!==null&&e[r]==="or";){r++;let m=c();if(m===null)return null;f={kind:"LogicalPolicyConditionSyntax",left:f,operator:"Or",right:m,location:n}}return f},"or"),y=p();return i&&y!==null&&r<e.length&&t.error(d.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),y}l(Iu,"parsePolicyCondition");var Tu=new RegExp(`^for\\s+"(${J})"$`,"u"),Ru=Q("^[A-Z]\\w*$"),Du=Q("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Ua(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(d.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,u(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:u(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=Tu.exec(i.content);if(r===null){t.error(d.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,u(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(),!Ru.test(s.content)){t.error(d.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,u(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=Du.exec(c.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:we(p[2],u(c),t),location:u(c)}):t.error(d.InvalidSeedPropertyAssignment,`Invalid property assignment '${c.content}' - expected '<property> = <value>'`,u(c))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:u(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:ee(r[1]),events:o,location:u(i)})}return{kind:"SeedSyntax",groups:n,location:u(e)}}l(Ua,"parseSeed");var Mu=w("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),Va=w("^import\\s+([\\w.]+)$"),ju=w("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$"),Nu=w("^@?[a-z_]\\w*$"),Lu=w("^persona\\s+([A-Za-z_]\\w*)$"),qu=w("^policy\\s+([A-Za-z_]\\w*)$"),Bu=/^[ ]*\t/,Wa=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Qa=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Yu=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function ii(t,e,n=xt){Vu(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=[],y=[],f=[],m=[],h=[],g=[],v=[],$=[],C=[],x=[],P=!1;for(let S=t.reader.peekSignificant();S!==void 0;S=t.reader.peekSignificant()){t.reader.takeSignificant();let k=D(S.content);if(k==="domain"){t.authoredDeclarations=!0,s=zu(t,S,s,P);continue}if(P||=za(k,S,n),t.authoredDeclarations||=k!=="import"&&za(k,S,n),k==="import"&&po(S.content))o!==void 0?o.tryParse(t,S):At(t,S,c);else if(k==="import"){let b=Va.exec(S.content);b===null?t.error(d.InvalidImportDeclaration,`Invalid import '${S.content}' - expected 'import <Qualified.Name>'`,u(S)):a.push({kind:"ImportSyntax",qualifiedName:b[1],location:u(S)})}else if(k==="example")o!==void 0?o.tryParse(t,S):C.push(He(t,S));else if(k==="eventsource")m.push(Oo(t,S));else if(k==="system")f.push(No(t,S));else if(k==="concept")p.push(Qu(t,S));else if(k==="type")y.push(Zo(t,S));else if(k==="module"&&!Qt(n))Fu(t,S,n,i);else if(k==="module")h.push(xr(t,S));else if(k==="persona")g.push(Gu(t,S));else if(k==="seed")$.push(Ua(t.valueContext,S));else if(k==="policy")v.push(Fa(t,S));else if(k==="trigger"){let b=ya(t,S),E=/^trigger\s+([A-Za-z_]\w*)$/.exec(S.content)?.[1];E!==void 0&&x.push({name:E,data:b})}else Qa.has(k)?k==="behavior"||k==="layout"?Ie(t,S):t.skipOpaqueBlock(S.indent):o?.tryParse(t,S)!==!0&&Uu(t,S,n)}i!==void 0?h.unshift(i.build(t.start,!0)):r!==void 0&&h.unshift(Wu(n,r.build(t.start,!0),t.start));let A={kind:"ApplicationSyntax",sourceOptions:t.sourceOptions,domain:s,imports:a,concepts:p,types:y,systems:f,eventSources:m,examples:C,modules:h,personas:g,policies:v,seeds:$,declaredTriggers:x,fileImports:c,location:t.start};return t.authoredDeclarations&&ko(A),A}l(ii,"parseApplication");function za(t,e,n){return t==="import"?Va.test(e.content):t==="module"?Qt(n):t==="example"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||Qa.has(t)}l(za,"declaresConstruct");function Fu(t,e,n,i){let r=Sr.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 ${Cn(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,u(e)),t.skipBlock(e.indent)}l(Fu,"parseModuleInPlacedFile");function Uu(t,e,n){let i=D(e.content);if(Qt(n)){let r=Yu.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}`,u(e))}else{let r=n.length===1?gr:hr;t.error(d.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${Cn(n)} - expected an application declaration or ${r}`,u(e))}t.skipBlock(e.indent)}l(Uu,"reportUnexpectedTopLevel");function Wu(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(Wu,"place");function zu(t,e,n,i){let r=Mu.exec(e.content);return r===null?(t.error(d.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,u(e)),n):n!==null?(t.error(d.DuplicateDomain,"The document already declares a domain - a document can have at most one",u(e)),n):(i&&t.error(d.DomainNotFirst,"'domain' must be declared before any other construct",u(e)),{kind:"DomainSyntax",name:r[1],location:u(e)})}l(zu,"parseDomain");function Vu(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&Bu.test(i.raw)&&t.warning(d.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",so(i))}}l(Vu,"warnOnTabIndentation");function Qu(t,e){let n=ju.exec(e.content);if(n===null)return t.error(d.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,u(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:u(e)};let[,i,r,o]=n,s=qa(t,e,o);r!=="Enum"&&!Wa.includes(r)&&t.error(d.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${Wa.join(", ")} or Enum`,u(e));let a=[],c=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))if(t.reader.takeSignificant(),!ue(p))if(D(p.content)==="validate"){r==="Enum"&&p.content==="validate"&&t.peekChild(p.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`,u(p));let y=cr(t,p,"concept");y!==void 0&&c.push(y)}else Ba(t,p,i,s)||(r==="Enum"&&Nu.test(p.content)?a.push(ne(p.content)):r==="Enum"?t.error(d.InvalidEnumerationValue,`Invalid enum value '${p.content}' - expected an identifier`,u(p)):(t.error(d.UnknownConceptDirective,`Unexpected '${p.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,u(p)),t.skipBlock(p.indent)));return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:a,validations:c,location:u(e)}}l(Qu,"parseConcept");function Gu(t,e){let n=Lu.exec(e.content)?.[1]??"";n===""&&t.error(d.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,u(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=_(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=qu.exec(o.content);a===null?t.error(d.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,u(o)):r.push(a[1])}else t.error(d.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,u(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:u(e)}}l(Gu,"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=ei(a,a[0]?.path,n);p.scope=c;let y=ii(p,a,c);for(let f of y.types)r.add(f.name);for(let f of y.concepts)r.add(f.name);for(let f of y.imports)o.add(f.qualifiedName);for(let f of y.eventSources??[])i.set(f.name,[...i.get(f.name)??[],f.streams.map(m=>m.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 Qe=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 me;(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"})(me||(me={}));function Ga(t){return t.length===0?{value:null,failure:me.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:me.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:me.NotNfc}:{value:t,failure:null}}l(Ga,"tryFormatText");function Za(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:me.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(Za,"tryFormatUuidText");function ri(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:me.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:me.OutOfRange}:{value:n.toString(),failure:null}}l(ri,"tryFormatInteger");function oi(t){switch(t){case me.Empty:return"A stream id text literal cannot be empty.";case me.NotNfc:return"A stream id text literal must be Unicode NFC.";case me.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case me.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case me.NotIntegral:return"A stream id integer must be a finite integral value.";case me.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case me.Arity:return"A composite stream id must match the declared part count of at least two.";case me.Escape:return"A composite stream id permits only %25 and %7C escapes.";case me.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}l(oi,"streamIdFailureMessage");function Zu(t,e,n){let i=te(n.types),r=t.properties,o=null,s=!1,a=!1;for(let c of e.split(".")){let p=r.filter(f=>f.name===c);if(p.length!==1)return null;let y=p[0].type;s||=y.isOptional,a||=y.isCollection,o={...y,isOptional:s,isCollection:a},r=i.get(y.name)?.properties??[]}return o}l(Zu,"commandPathType");function ai(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:Na(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:Zu(t,r,n)}l(ai,"commandDestinationType");function si(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(y=>!e.some(f=>f.property===y.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let c=new Set;for(let p of e){let y=a.find(f=>f.name===p.property);y===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,y.type))}}l(si,"validateStreamIdParts");function li(t,e,n){let i=te(n.concepts),r=te(n.types),o=new Map([...r].map(([a,c])=>[a,te(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(li,"formatSpecificationStreamId");function _a(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Qe(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,y,f)=>{let m=li(p,f,i),h=li(y,f,i);return m===null||h===null?null:m===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(y=>{let f=t.streamIdParts.filter(h=>h.property===y.name),m=e.streamIdParts.filter(h=>h.property===y.name);return f.length===1&&m.length===1?c(f[0].source,m[0].source,y.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(_a,"matchesSpecificationRoute");function Ka(t,e){let n=Gn(t).resolvedExamples,i=_n(t);t=i.application;let r=new ae(t),o=new Set,s=n.flatMap(x=>{if(x.kind!=="event")return(x.kind==="command"||x.kind==="readmodel")&&(x.example.stream!=null||x.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",(x.example.stream??x.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:x.name,values:x.example.values,for:x.example.for,stream:x.example.stream,noStream:x.example.noStream,location:x.example.location};return o.add(P),[{scope:x.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Qe(t),c=te(t.concepts),p=te(t.types),y=new Map([...p].map(([x,P])=>[x,te(P.properties)])),f=l((x,P)=>Ce(x,P,c,y),"compatible"),m=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...c.keys(),...p.keys()]),h=l((x,P)=>m.has(x.name)&&m.has(P.name)?x.name===P.name&&x.isCollection===P.isCollection&&(!x.isOptional||P.isOptional):null,"nominallyCompatible"),g=l((x,P)=>li(x,P,t),"formatStreamId"),v=l((x,P)=>{let A=r.resolve(x,P).declaration;return A?.node.kind==="EventSyntax"?A.node:null},"eventOf"),$=[];for(let{slice:x}of r.slices){for(let P of x.commands)for(let A of P.produces){if(!r.isEventProduction(A,x))continue;let S=v(A.event,x);if(S===null)continue;let k=ai(P,A,t,{resolver:r,slice:x});$.push({event:S,command:P,type:k})}for(let P of x.reactions.flatMap(A=>A.triggers).flatMap(A=>A.produces)){let A=v(P.event,x);A!==null&&$.push({event:A,command:null,type:null})}for(let P of x.captures)for(let A of[...P.appends,...P.children.flatMap(S=>S.appends),...P.nested.flatMap(S=>S.appends)]){let S=v(A.event,x);S!==null&&$.push({event:S,command:null,type:null})}}let C=[...s.flatMap(x=>r.slices.filter(P=>P.scope.join(".")===x.scope.join(".")).map(({slice:P,scope:A})=>({slice:P,scope:A,specification:x.specification}))),...r.slices.flatMap(({slice:x,scope:P})=>x.specifications.map(A=>({slice:x,scope:P,specification:A})))];for(let{slice:x,scope:P,specification:A}of C){let S=r.slices.flatMap(R=>R.slice.commands.map(j=>({command:j,scope:R.scope}))),k=A.when?.commandType.split(".")??[],b=k.slice(0,-1),E=S.filter(R=>R.command.name===k.at(-1)&&b.every((j,N)=>R.scope[R.scope.length-b.length+N]===j)),O=b.length>0&&E.length===1?E[0].command:null;for(let R=P.length;b.length===0&&R>=0&&O===null;R--){let j=E.filter(N=>P.slice(0,R).every((B,L)=>N.scope[L]===B));if(j.length>0){O=j.length===1?j[0].command:null;break}}let I=[...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:j,expected:N}of I){let B=i.specifications.flatMap(F=>F.steps).find(F=>F.effective===R),L=B?.route?.origin!=="example",W=L||R.for!==B?.example?.for,z=l((F,oe,de)=>{e.error(F,B?.example==null?oe:`${oe} Example '${B.example.name}' is used here.`,B?.example==null?de:B.authored.location)},"contextualError");if(R.stream==null&&R.noStream==null)continue;j&&R.noStream!=null&&z(d.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",R.noStream.location);let G=null,V=v(R.eventType,x),Z=$.filter(F=>F.event===V);if(R.stream!=null){let F=R.stream,oe=a.resolve(F.eventSource,F.stream);if(oe.kind!==ce.Unique){let pe={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[oe.kind];L&&e.error(d.InvalidSpecificationStreamRoute,`Stream '${F.eventSource}.${F.stream}' is ${pe}; routing requires one physical source and stream.`,F.location);continue}let de=oe.sources[0],$e=oe.streams[0],ht=l((pe,ge)=>{let T=pe.source,M=dn(T,ge,t);M?.failure!=null?e.error(d.InvalidSpecificationStreamRoute,oi(M.failure),T.location):(T.kind!=="LiteralExpressionSyntax"||T.value===null||ge!==null&&!f(T,ge))&&e.error(d.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",T.location)},"validateLiteral");if(L&&($e.streamIdParts.length>0?si($e,F.streamIdParts,F.streamId!==null,F.location,d.InvalidSpecificationStreamRoute,e,ht):F.streamIdParts.length>0?e.error(d.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",F.location):($e.streamId===null!=(F.streamId===null)&&e.error(d.InvalidSpecificationStreamRoute,$e.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",F.location),F.streamId!==null&&ht(F.streamId,$e.streamId))),G=de.identifier,G===null){let pe=Z.map(T=>T.type),ge=new Set(pe.filter(T=>T!==null).map(T=>`${T.name}:${T.isOptional}:${T.isCollection}`));pe.length===0||pe.some(T=>T===null)||ge.size!==1?L&&e.error(d.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${de.name}'; the event's producers do not supply one unambiguous destination type.`,F.location):G=pe[0]}let St=!1;if(B?.example?.stream!=null&&R.for!==null&&R.for===B.example.for){let pe=a.resolve(B.example.stream.eventSource,B.example.stream.stream);if(pe.kind===ce.Unique){let ge=Z.map(q=>q.type),T=new Set(ge.filter(q=>q!==null).map(q=>`${q.name}:${q.isOptional}:${q.isCollection}`)),M=pe.sources[0].identifier??(ge.length>0&&!ge.some(q=>q===null)&&T.size===1?ge[0]:null);M!==null&&(St=R.for.kind!=="LiteralExpressionSyntax"||R.for.value===null||M.isCollection||M.isOptional||!f(R.for,M))}}j&&R.for===null?z(d.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",F.location):W&&!St&&R.for!==null&&(R.for.kind!=="LiteralExpressionSyntax"||R.for.value===null||G!==null&&(G.isCollection||G.isOptional||!f(R.for,G)))&&z(d.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",R.for.location)}if(!N||O===null||Z.length===0||Z.some(F=>F.command!==O))continue;let fe=O.stream?.propertyCandidate===null?O.stream:null,Pe=R.noStream!=null?fe!=null:fe==null||fe.eventSource!==R.stream.eventSource||fe.stream!==R.stream.stream;if(!Pe&&R.stream!=null&&fe!=null){let F=a.resolve(R.stream.eventSource,R.stream.stream),oe=F.kind===ce.Unique?F.streams[0]:null;if(oe!==null&&oe.streamIdParts.length>0){if(fe.streamId===null&&R.stream.streamId===null&&fe.streamIdParts.length>0&&R.stream.streamIdParts.length>0)for(let de of oe.streamIdParts){let $e=fe.streamIdParts.filter(ge=>ge.property===de.name),ht=R.stream.streamIdParts.filter(ge=>ge.property===de.name);if($e.length!==1||ht.length!==1)continue;let St=g($e[0].source,de.type),pe=g(ht[0].source,de.type);St!==null&&pe!==null&&St!==pe&&(Pe=!0)}}else if(oe?.streamId!=null&&fe.streamIdParts.length===0&&R.stream.streamIdParts.length===0){let de=g(fe.streamId?.source,oe.streamId),$e=g(R.stream.streamId?.source,oe.streamId);de!==null&&$e!==null&&de!==$e&&(Pe=!0)}}R.for?.kind==="LiteralExpressionSyntax"&&Z.every(F=>F.type!==null&&(G!==null?h(F.type,G)===!1:!f(R.for,F.type)))&&(Pe=!0),Pe&&z(d.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(R.stream??R.noStream).location)}}}l(Ka,"validateSpecificationStreams");var pn=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function Dr(t,e){let n=e.concepts.filter(r=>r.name===t.name),i=n.length===1?n[0].type:n.length===0&&pn.has(t.name)?t.name:null;return i==="String"||i==="Uuid"||i==="Int"&&n.length===1&&n[0].values.length===0}l(Dr,"supportsStreamIdentity");function dn(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:te(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?Za(i):Ga(i):typeof i=="number"?ri(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?ri(NaN):ri(BigInt(i.value),!1):null}l(dn,"formatStreamIdLiteral");function ci(t,e){let n=te(t.concepts),i=te(t.types),r=new Set([...pn,...n.keys(),...i.keys()]),o=new Map([...i].map(([m,h])=>[m,te(h.properties)])),s=l((m,h)=>r.has(m.name)&&r.has(h.name)?m.name===h.name&&m.isCollection===h.isCollection&&(!m.isOptional||h.isOptional):null,"compatible"),a=l((m,h)=>{if(m===null)return;if(m.isOptional||m.isCollection||t.types.some($=>$.name===m.name)){e.error(d.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",m.location);return}let g=t.concepts.filter($=>$.name===m.name),v=g.length===1?g[0].type:g.length===0&&pn.has(m.name)?m.name:null;h&&v!==null&&!Dr(m,t)&&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.",m.location),v===null&&!t.imports.some($=>$.qualifiedName===m.name||$.qualifiedName.split(".").at(-1)===m.name)&&e.warning(d.UnknownType,`Unknown type '${m.name}' in event source declaration.`,m.location)},"validateType"),c=new Set;for(let m of t.eventSources??[]){c.has(m.name)&&e.error(d.InvalidEventSourceDeclaration,`Event source '${m.name}' has multiple physical declarations.`,m.location),c.add(m.name),a(m.identifier,!1);let h=new Set;for(let g of m.streams){h.has(g.name)&&e.error(d.InvalidEventSourceDeclaration,`Stream '${m.name}.${g.name}' has multiple declarations under this source.`,g.location),h.add(g.name),a(g.streamId,!0);let v=g.streamIdParts;if(v.length>0){v.length<2&&e.error(d.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",g.directiveLocations?.streamId??g.location);for(let $ of new Set(v.map(C=>C.name)))for(let C of v.filter(x=>x.name===$).slice(1))e.error(d.InvalidEventSourceDeclaration,`Stream id part '${C.name}' is declared more than once.`,C.location);for(let $ of v)a($.type,!0)}}}let p=l((m,h)=>{let[g,...v]=h.split(".");if(m===null)return{property:null,missing:!1};let $=m.filter(P=>P.name===g);if($.length!==1)return{property:null,missing:$.length===0};let C=$[0];if(v.length===0)return{property:C,missing:!1};if(pn.has(C.type.name)||n.has(C.type.name)&&!i.has(C.type.name))return{property:null,missing:!0};let x=p(i.get(C.type.name)?.properties??null,v.join("."));return x.property===null?x:{property:{...x.property,type:{...x.property.type,isCollection:C.type.isCollection||x.property.type.isCollection,isOptional:C.type.isOptional||x.property.type.isOptional}},missing:!1}},"pathProperty"),y=new Qe(t),f=new ae(t);for(let{slice:m}of f.slices)for(let h of m.commands){let g=h.stream;if(g==null||g.propertyCandidate!==null)continue;let v=y.resolve(g.eventSource,g.stream);if(v.kind!==ce.Unique){let A={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[v.kind];e.error(d.InvalidCommandStream,`Stream '${g.eventSource}.${g.stream}' is ${A}; routing requires one physical source and stream.`,g.location);continue}let $=v.sources[0],C=v.streams[0],x=h.properties.filter(A=>A.isIdentifier);$.identifier!==null&&x.length===1&&s(x[0].type,$.identifier)===!1&&e.error(d.InvalidCommandStream,`Command identifier '${x[0].name}' does not have the source's nominal identifier type '${$.identifier.name}'. The stream does not supply a destination.`,x[0].location);for(let A of h.produces.filter(S=>f.isEventProduction(S,m))){if($.identifier===null)continue;let S=ai(h,A,t,{resolver:f,slice:m});if(S===null||A.for===null&&A.inlineEvent!==null&&x.length===1&&s(x[0].type,$.identifier)===!1)continue;let k=A.for===null&&A.inlineEvent===null&&!h.properties.some(O=>O.isGenerated&&O.isIdentifier),b=n.get($.identifier.name)?.type??(pn.has($.identifier.name)?$.identifier.name:null);(k?b===null?null:b==="Uuid":s(S,$.identifier))===!1&&e.error(d.InvalidCommandStream,`Command production destination does not have the source's nominal identifier type '${$.identifier.name}'. The stream does not supply a destination.`,A.for?.location??A.location)}let P=l((A,S)=>{let k=A.source;if(k.kind==="PathExpressionSyntax"){let b=p(h.properties,k.path);(b.missing||b.property!==null&&s(b.property.type,S)===!1)&&e.error(d.InvalidCommandStream,`Stream id source '${k.path}' is absent or incompatible with nominal type '${S.name}'.`,k.location)}else if(k.kind==="LiteralExpressionSyntax"&&k.value!==null){let b=dn(k,S,t);b?.failure!=null?e.error(d.InvalidCommandStream,oi(b.failure),k.location):Ce(k,S,n,o)||e.error(d.InvalidCommandStream,`Stream id value is incompatible with nominal type '${S.name}'.`,k.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(k.kind)||k.kind==="LiteralExpressionSyntax"&&k.value===null)&&e.error(d.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",k.location)},"validateMapping");if(C.streamIdParts.length>0){si(C,g.streamIdParts,g.streamId!==null,g.location,d.InvalidCommandStream,e,P);continue}if(g.streamIdParts.length>0){e.error(d.InvalidCommandStream,"A streamId part block requires a composite stream.",g.location);continue}(C.streamId===null&&g.streamId!==null||C.streamId!==null&&g.streamId===null)&&e.error(d.InvalidCommandStream,C.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",g.location),!(C.streamId===null||g.streamId===null)&&P(g.streamId,C.streamId)}Ka(t,e)}l(ci,"validateEventSources");function di(t,e){let n=new ae(t),i=n.slices,r=new Set(t.imports.map(v=>v.qualifiedName)),o=new Set([...i.flatMap(({slice:v})=>se(v).map($=>$.name)),...t.imports.map(v=>v.qualifiedName.split(".").at(-1))]),s=te(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,$)=>{let[C,...x]=$.split(".");if(v===null)return{value:null,missing:!1};let P=v.filter(S=>S.name===C);if(P.length!==1)return{value:null,missing:P.length===0};let A=P[0];return x.length===0?{value:A,missing:!1}:a.has(A.type.name)?{value:null,missing:!0}:c(s.get(A.type.name)?.properties??null,x.join("."))},"property"),p=i.flatMap(({slice:v,scope:$})=>v.readModels.map(C=>({node:C,scope:$}))),y=l((v,$)=>{let C=l(A=>{let S=A.split("."),k=p.filter(E=>E.node.name===S.at(-1)),b=S.slice(0,-1);if(b.length>0)return k.filter(E=>b.length<=E.scope.length&&b.every((O,I)=>E.scope[E.scope.length-b.length+I]===O));for(let E=$.length;E>=0;E--){let O=k.filter(I=>E<=I.scope.length&&$.slice(0,E).every((R,j)=>I.scope[j]===R));if(O.length>0)return O}return[]},"candidates"),x=C(v),P=t.imports.filter(A=>A.qualifiedName.split(".").at(-1)===v);return x.length===0&&P.length===1&&(x=C(P[0].qualifiedName)),x.length===1?x[0].node.properties:null},"viewProperties"),f=l((v,$,C)=>{let x=n.resolve(v,C);o.has(v)||r.has(v)||x.declaration?.kind===ie.Event||x.candidates.some(A=>A.kind===ie.Event)||e.warning(d.UnknownEvent,`Unknown event '${v}' - declare it with 'event ${v}'`,$)},"unknownEvent"),m=l((v,$)=>{for(let C of v)(C.kind==="RemoveWithSyntax"||C.kind==="RemoveViaJoinSyntax")&&f(C.event,C.location,$),"blocks"in C&&m(C.blocks,$)},"removals"),h=new Set,g=l((v,$,C=!1,x=!1)=>{let P=l((S,k)=>{let b=c($,S),E=JSON.stringify([k.path,k.line,k.column]);return b.missing&&!h.has(E)&&(h.add(E),e.warning(d.UnknownReadModelProperty,`Projection target '${S}' is not a declared ${C?"element":"read-model"} property`,k)),b.value},"validate"),A=x||v.some(S=>S.kind==="FromSyntax"||S.kind==="JoinSyntax"||S.kind==="AllSyntax");for(let S of v){let k=S.kind==="EverySyntax"&&!A?[]:"mappings"in S?S.mappings:S.kind==="JoinSyntax"?S.events.flatMap(b=>b.mappings):[];for(let b of k)P(b.property,b.location);if(S.kind==="ChildrenSyntax"||S.kind==="NestedSyntax"){let b=P(S.property,S.location);g(S.blocks,b===null?null:s.get(b.type.name)?.properties??null,!0)}}},"walk");for(let{slice:v}of i){for(let $ of v.projections)m($.blocks,v);for(let $ of v.captures)for(let C of[...$.appends,...$.children.flatMap(x=>x.appends),...$.nested.flatMap(x=>x.appends)])f(C.event,C.location,v)}for(let{slice:v,scope:$}of i)for(let C of v.projections){let x=C.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");x.length===0&&g(C.blocks,y(C.readModel??C.name,$));for(let P of x){let A=y(P.name,$);g(C.blocks.filter(k=>k.kind==="ChildrenSyntax"||k.kind==="NestedSyntax"),A);let S=P.entersOn.length>0||C.blocks.some(k=>k.kind==="FromSyntax"||k.kind==="JoinSyntax"||k.kind==="AllSyntax");g(P.blocks,A,!1,S)}}}l(di,"validateProjectionTargets");function pi(t,e){let n=new Set(t.concepts.filter(f=>f.attributes.some(m=>m.name==="pii")).map(f=>f.name)),i=new Set(t.concepts.filter(f=>f.attributes.some(m=>m.name==="sensitive")).map(f=>f.name)),r=te(t.types),o=new ae(t),s=new Set(t.imports.map(f=>f.qualifiedName.split(".").at(-1))),a=new Map;for(let f of t.declaredTriggers??[]){let m=a.get(f.name)??[];m.push(f.data),a.set(f.name,m)}let c=l((f,m,h="an event source identifier")=>{if(n.has(f.name)||i.has(f.name)){let g=n.has(f.name)?"pii":"secret";e.error(d.PiiNotSupportedOnIdentifier,`Concept '${f.name}' is ${g} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${g} value as a property`,m)}},"validate"),p=l((f,m)=>{let[h,...g]=m.split("."),v=f.filter(C=>C.name===h);if(v.length!==1)return null;let $=v[0];return g.length===0?$:p(r.get($.type.name)?.properties??[],g.join("."))},"property");for(let f of t.eventSources??[]){f.identifier!=null&&c(f.identifier,f.identifier.location);for(let m of f.streams){m.streamId!==null&&c(m.streamId,m.streamId.location,"a stream id");for(let h of m.streamIdParts)c(h.type,h.type.location,`a stream id part '${h.name}'`)}}let y=new Qe(t);for(let{slice:f}of o.slices){for(let m of f.commands){for(let h of m.properties.filter(g=>g.isIdentifier))c(h.type,h.location);for(let h of[...m.stream?[m.stream]:[],...m.streamCandidates??[]].filter(g=>g.propertyCandidate===null)){let g=y.resolve(h.eventSource,h.stream),v=g.kind===ce.Unique?g.streams[0]:void 0,$=[...h.streamId===null?[]:[{mapping:h.streamId,target:v?.streamId}],...h.streamIdParts.map(C=>({mapping:C,target:v?.streamIdParts.find(x=>x.name===C.property)?.type}))];for(let{mapping:C,target:x}of $){if(C.source.kind!=="PathExpressionSyntax")continue;let P=p(m.properties,C.source.path);P!==null&&(P.type.name===x?.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 m.produces.filter(g=>o.isEventProduction(g,f))){if(h.for?.kind!=="PathExpressionSyntax")continue;let g=p(m.properties,h.for.path);g!==null&&!g.isIdentifier&&c(g.type,h.for.location)}}for(let m of f.reactions.flatMap(h=>h.triggers)){if(m.source.kind!=="NamedTriggerSourceSyntax")continue;let g=o.resolve(m.source.name,f).declaration?.node,v=(qe(m).data??[]).flatMap(C=>C.type===null?[]:[{kind:"PropertySyntax",name:C.name,type:C.type,isIdentifier:!1,location:C.location}]),$=[g?.kind==="EventSyntax"?g.properties:[],v];g?.kind!=="EventSyntax"&&!s.has(m.source.name)&&$.push(...a.get(m.source.name)??[]);for(let C of m.produces.filter(x=>o.isEventProduction(x,f))){if(C.for?.kind!=="PathExpressionSyntax")continue;let x=C.for.path,P=$.map(A=>p(A,x)).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");function ui(t,e){let n=l((i,r)=>{for(let o of i.filter(s=>s.isSubject))e.error(d.InvalidSubjectOwner,`The subject modifier is only valid on event properties, not ${r} properties (decision 0008: one data subject per event).`,o.location)},"refuse");for(let i of t.types)n(i.properties,"type");for(let{slice:i}of new ae(t).slices){for(let r of i.commands)n(r.properties,"command");for(let r of i.readModels)for(let o of r.properties.filter(s=>s.isSubject))e.error(d.ReadModelSubjectNotSupported,"Read model subject marks are not yet supported. Chronicle resolves read model subjects and reserves _subject, __subject and __subjects; Screenplay support is tracked in #559.",o.location);for(let r of se(i)){let o=r.properties.filter(s=>s.isSubject);for(let s of o.slice(1))e.error(d.DuplicateEventSubject,`Event '${r.name}' has one data subject (decision 0008); '${s.name}' is an extra mark after '${o[0].name}'. Choose one subject; no automatic repair is safe.`,s.location);for(let s of o){let a=s.type;if(a.isOptional){e.error(d.InvalidSubjectType,"A subject must be required: a null value silently falls back to the event source.",s.location);continue}if(a.isCollection||t.types.some(y=>y.name===a.name)){e.error(d.InvalidSubjectType,"A subject must be a scalar identity, not a collection or composite type.",s.location);continue}let c=t.concepts.filter(y=>y.name===a.name);c.some(y=>y.attributes.some(f=>["pii","sensitive"].includes(f.name)))&&e.error(d.ProtectedSubjectType,`Subject concept '${a.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,s.location);let p=c.length===1?c[0].type:c.length===0&&["String","Uuid","Int","Decimal","Bool","Date","DateTime"].includes(a.name)?a.name:null;c.length===0&&p===null&&t.imports.some(y=>y.qualifiedName===a.name||y.qualifiedName.split(".").at(-1)===a.name)&&e.warning(d.UnknownType,`Unknown type shape '${a.name}' for subject property '${s.name}'; imported subject identity rules cannot be verified.`,s.location),(c.some(y=>y.type==="Enum")||p!==null&&!Dr(a,t))&&e.error(d.InvalidSubjectType,"Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.",s.location)}}}}l(ui,"validateEventSubjects");var Ha=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),ut=class{static{l(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new ae(e).slices,this.types=te(e.types),this.concepts=te(e.concepts),this.knownTypes=new Set([...Ha,...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 se(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(y=>({node:y,slice:c,scope:p}))),o=this.slices.find(c=>c.slice===n)?.scope??[],s=l(c=>{let p=c.split("."),y=r.filter(m=>m.node.name===p.at(-1)),f=p.slice(0,-1);if(f.length>0)return y.filter(m=>f.length<=m.scope.length&&f.every((h,g)=>m.scope[m.scope.length-f.length+g]===h));for(let m=o.length;m>=0;m--){let h=y.filter(g=>m<=g.scope.length&&o.slice(0,m).every((v,$)=>g.scope[$]===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(Ha.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 _u(){return!0}l(_u,"invocationHasNoDeclaredIdentity");function Ku(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(Ku,"authorizationGatedSlices");function mi(t,e){let n=new ut($t(t));new fi(n,e).visitApplication(n.application);let i=Ku(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,m=>m.commands),y=p!==null&&(p.node.authorize!==null||i.has(p.slice)),f=[];for(let m of c.onRefused??[]){if(f.some(C=>a(C,m))&&e.warning(d.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",m.location),f.push(m),m.selector==="authorization"&&_u()&&y&&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).`,m.location),m.constraint===null)continue;let h=o(m.constraint);if(h===null){e.error(d.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${m.constraint}'.`,m.location);continue}if(p===null||p.node.handler!==null)continue;let g=[h.node,...h.node.additionalRules];if(g.some(C=>C.kind==="FileConstraintSyntax"))continue;let v=g.map(C=>C.kind==="FileConstraintSyntax"?null:n.event(C.event,h.slice)),$=p.node.produces.map(C=>n.event(C.event,p.slice));v.every(C=>C!==null)&&$.every(C=>C!==null)&&!v.some(C=>$.includes(C))&&e.warning(d.UnreachableRefusalBranch,`Constraint '${m.constraint}' targets none of the events produced by '${c.command}'.`,m.location)}}}}l(mi,"validateReactionRefusals");function yi(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=>yi(c,{...e,isCollection:!1,isOptional:!1},n));return a.some(c=>c===void 0)?void 0:{canonical:`[${a.map(hi).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:yi(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)}:${hi(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(yi,"redeliveryValue");function hi(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:Or(t):JSON.stringify(t)}l(hi,"canonical");function Mr(t,e,n,i){let r=yi(t,n,i),o=yi(e,n,i);return r===void 0||o===void 0?null:hi(r)===hi(o)}l(Mr,"sameRedeliveryValue");function Si(t,e){t=$t(t);let n=new ut(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,y=>y.reactions);if(a===null||s===null||!a.node.triggers.some(y=>y.source.kind==="NamedTriggerSourceSyntax"&&n.event(y.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(y=>n.event(y.eventType,i)===s).map(y=>Hu(y,o,s,n,t)),p=c.filter(y=>y===!0).length;c.some(y=>y===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(Si,"validateSpecificationRedelivery");function Hu(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:Mr(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?Mr(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(_a(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}l(Hu,"matches");var Ja=64;function Xa(t,e){let n=[];for(let i of t.alternatives){let r=jr(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(Xa,"validateGuardedActionShadowing");function jr(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=jr(t.left),n=jr(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>Ja?null:[...e,...n]:e.length*n.length>Ja?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}l(jr,"normalize");var Ju=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function gi(t,e){let n=new ut(t);for(let{slice:i}of n.slices)for(let r of i.screens)Nr(r.directives,[],i,n,e)}l(gi,"validateGuardedActions");function Nr(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":Xu(a,s,n,i,r);break;case"ScreenSectionSyntax":Nr(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let c of a.slots)Nr(c.directives,s,n,i,r);break}}l(Nr,"validateContainer");function ts(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}l(ts,"viewProperties");function Xu(t,e,n,i,r){let o=e.length===1?ts(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 Lr(s.condition))ns(a.left,a.location,o,n,i,r);es(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&es(t.otherwise.command,t.otherwise.arguments,o,n,i,r),Xa(t,r)}l(Xu,"validateAction");function es(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(y=>y.name===a.name);c?.length===0&&o.warning(d.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=ns(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(es,"validateArguments");function ns(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 y=n.filter(m=>m.name===p);if(y.length===0||y.length===1&&y[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(y.length!==1)return null;if(c===a.length-1)return y[0];let f=y[0].type;if(n=r.types.get(f.name)?.properties??ts(f.name,i,r),n===null)return(Ju.has(f.name)||r.application.concepts.some(m=>m.name===f.name)&&!r.application.types.some(m=>m.name===f.name))&&o.warning(d.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}l(ns,"validateItemPath");function Lr(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...Lr(t.left),...Lr(t.right)]}l(Lr,"comparisons");function bt(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(bt,"ordinalIgnoreCaseKey");function qr(t){let e=sn(t),n=l((h,g)=>h.map(v=>({syntax:v,rank:e.get(Be([...g,v.name]))??Number.MAX_SAFE_INTEGER})).sort((v,$)=>v.rank-$.rank).map(v=>v.syntax),"ordered"),i=[],r=l((h,g)=>{let v=[...g,h.name];for(let $ of n(h.slices,v))i.push({syntax:$,scope:[...v,$.name],identity:[...v.map(C=>`container:${C}`),`slice:${$.name}`],index:i.length});for(let $ of n(h.features,v))r($,v)},"feature");for(let h of n(t.modules,[]))for(let g of n(h.features,[h.name]))r(g,[h.name]);let o=new Map(i.map(h=>[h,new Set([...se(h.syntax).map(g=>bt(g.name)),...h.syntax.commands.flatMap(g=>g.produces.map(v=>bt(v.event))),...h.syntax.reactions.flatMap(g=>g.triggers.flatMap(v=>v.produces.map($=>bt($.event))))])])),s=new Map;for(let h of i)for(let g of se(h.syntax)){let v=bt(g.name);s.has(v)||s.set(v,h)}let a=new Map;for(let h of i){let g=Be(h.scope);a.has(g)||a.set(g,h)}let c=new Map;for(let h of jt.for(t,e).edges.filter(g=>g.kind==="decidesFrom"))for(let g of h.evidence){let v=Be([...h.consumer.scope,g.name.toLowerCase()]);c.has(v)||c.set(v,a.get(Be(h.producer.scope)))}let p=[];for(let h of i){let g=new Set,v=Hn(h.syntax).references.filter($=>$.timeline).map($=>({event:$.name,location:$.location,readModel:$.targetKind==="ReadModel"}));for(let $ of v){let C=bt($.event),x=`${$.readModel?"ReadModel":"Event"}:${C}`;if(g.has(x))continue;g.add(x);let P=$.readModel?c.get(Be([...h.scope,$.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($.readModel){let S=h.identity.slice(0,A+1),k=new Set(i.filter(b=>S.every((E,O)=>b.identity[O]===E)).flatMap(b=>[...o.get(b)]));if(Aa(P.syntax,$.event).some(b=>b.timeline&&b.kind==="usesFactsFrom"&&b.targetKind==="Event"&&k.has(bt(b.name))))continue}p.push({...$,consumer:h,producer:P,container:Be(h.identity.slice(0,A)),left:h.identity[A],right:P.identity[A]})}}}let y=l((h,g)=>h.consumer.index-g.consumer.index||h.location.line-g.location.line||h.location.column-g.location.column,"compare"),f=new Set,m=[];for(let h of new Set(p.map(g=>g.container))){let g=p.filter($=>$.container===h),v=new Map;for(let $ of g)v.has($.left)||v.set($.left,new Set),v.has($.right)||v.set($.right,new Set),v.get($.left).add($.right);for(let $ of ln(v).filter(C=>C.length>1)){let C=new Set($),x=g.filter(S=>C.has(S.left)&&C.has(S.right));x.forEach(S=>f.add(S));let P=x.filter(S=>S.consumer.index<S.producer.index).sort(y)[0];if(P===void 0)continue;let A=l(S=>Math.min(...x.flatMap(k=>[k.consumer,k.producer]).filter(k=>{let b=JSON.parse(h);return k.identity[b.length]===S}).map(k=>k.index)),"memberIndex");$.sort((S,k)=>A(S)-A(k)),m.push({edge:P,diagnostic:{severity:"information",code:d.TimelineCycleGroup,message:`Timeline group ${$.map(S=>`${S.startsWith("slice:")?"slice":h===Be([])?"module":"feature"} '${S.slice(S.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||f.has(h))continue;let g=h.consumer.scope.slice(0,-1),$=h.producer.scope.length>h.consumer.scope.length&&g.every((x,P)=>h.producer.scope[P]===x)?" 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`;m.push({edge:h,diagnostic:{severity:"information",code:d.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${C} slice '${h.producer.syntax.name}' drawn after it.${$}`,location:h.location}})}return m.sort((h,g)=>y(h.edge,g.edge)).map(h=>h.diagnostic)}l(qr,"timelineOrderDiagnostics");function et(t,e,n=xt,i=!0,r,o){let s=Et(t,!1,e),a=ei(s,e,o);a.scope=n,a.streamCandidates=r??qt.capture([s],n,o);let c=ii(a,s,n);if(i){ti(c,a),bn(c,a),ni(c,a),Xn(c,a),ci(c,a),di(c,a),pi(c,a),ui(c,a),mi(c,a),Si(c,a),gi(c,a),c=En(c,a),Lt.validate(c,a);for(let p of $n(c))a.information(p.code,p.message,p.location);for(let p of qr(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(et,"parseForAuthoring");function rP(t){return t===d.LegacyOptionalSuffix||t===d.LegacyComplianceMarker||t===d.RedundantEventId}l(rP,"isQuickFixDiagnostic");function Br(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(Br,"legacyOptionalTypeLength");function oP(t,e={}){let n=et(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 x=i[C.location.line-1],P=Br(x.raw,C);if(P>0)a.set(x.number,{line:x.number,fix:{diagnosticCode:C.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:x.startOffset+C.location.column+P-2,length:1,text:" optional"}]}});else if(C.code===d.LegacyComplianceMarker){let A=ef(x.raw,x.startOffset);A!==void 0&&a.set(x.number,{line:x.number,fix:{diagnosticCode:C.code,title:"Use bare pii and secret compliance markers",scope:"occurrence",edits:[A]}})}else if(C.code===d.RedundantEventId&&Vt(x.raw)<0){let A=c.get(x.number);if(A?.id!==A?.name||A===void 0)continue;a.set(x.number,{line:x.number,fix:{diagnosticCode:C.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:x.startOffset,length:(i[x.number]?.startOffset??t.length)-x.startOffset,text:""}]},change:{node:A,replacement:{...A,id:null}}})}}let y=[d.LegacyOptionalSuffix,d.LegacyComplianceMarker],f=un(n),m=new Map,h,g=new Set,v=new Map,$=l((C,x)=>{let P=is(t,C.edits);if(P===void 0)return;let A=et(P,void 0,e.placement);if(!(!A.success||un(A)!==(x===void 0?f:un(n,[x]))))return A.diagnostics.filter(S=>S.code===C.diagnosticCode).length===(s.get(C.diagnosticCode)??0)-C.edits.length?C:void 0},"verify");return(C,x)=>{let P=typeof C=="number"||C===void 0?void 0:C,A=y.filter(O=>P===void 0?x===void 0||x===O:P.some(I=>I.diagnosticCode===O));for(let O of A.filter(I=>!g.has(I))){let I=[...a.values()].filter(R=>R.fix.diagnosticCode===O);if(I.length>0){let R=$({diagnosticCode:O,title:O===d.LegacyOptionalSuffix?"Use 'optional' throughout this document":"Use bare pii and secret throughout this document",scope:"document",edits:I.flatMap(j=>j.fix.edits)});R!==void 0&&v.set(O,R)}g.add(O)}let S=A.flatMap(O=>v.has(O)?[v.get(O)]:[]);if(P!==void 0){if(h===void 0){h=new Map;let I=i.flatMap(N=>a.has(N.number)?[a.get(N.number)]:[]),R=I.flatMap(N=>N.fix.edits),j=is(t,R);if(R.length>0&&j!==void 0){let N=et(j,void 0,e.placement),B=I.flatMap(L=>L.change===void 0?[]:[L.change]);if(N.success&&un(N)===un(n,B)){let L=new Map,W=new Map;for(let z of N.diagnostics)L.set(z.code,(L.get(z.code)??0)+1);for(let z of I)W.set(z.fix.diagnosticCode,(W.get(z.fix.diagnosticCode)??0)+z.fix.edits.length);if([...W].every(([z,G])=>(L.get(z)??0)===(s.get(z)??0)-G))for(let z of I)h.set(z.line,z.fix)}}}let O=new Map;for(let I of P){let R=h.get(I.line);R?.diagnosticCode===I.diagnosticCode&&O.set(I.line,R)}return[...O.values(),...S]}let k=typeof C=="number"?C:void 0,b=k===void 0?void 0:a.get(k),E;return b!==void 0&&k!==void 0&&(x===void 0||b.fix.diagnosticCode===x)&&(m.has(k)||(m.size===32&&m.delete(m.keys().next().value),m.set(k,$(b.fix,b.change))),E=m.get(k)),[...E===void 0?[]:[E],...S]}}l(oP,"prepareQuickFixes");function ef(t,e){let n=w("^(\\s*concept\\s+\\w+\\s*:\\s*\\w+)((?:[^\\S\\r\\n]+@?\\w+)*)").exec(t);if(n!==null){let r=n[2],o=r.replace(/@pii\b|@?sensitive\b/g,s=>s==="@pii"?"pii":"secret");return o===r?void 0:{start:e+n[1].length,length:r.length,text:o}}let i=w("^(\\s*)(@pii|@?sensitive)\\b").exec(t);return i===null?void 0:{start:e+i[1].length,length:i[2].length,text:i[2]==="@pii"?"pii":"secret"}}l(ef,"complianceMarkerEdit");function un(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(un,"verificationShape");function is(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(is,"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 tf=ye("^[A-Za-z_]\\w*$"),Ge=l((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),K=l(t=>{throw new le(t)},"refuse"),ft=l((t,e,n)=>{if(!Array.isArray(t))return K(n);for(let i=0;i<t.length;i++)Ge(t[i],e)||K(n)},"collection");function Yt(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&&(Ge(e.implementation,"ImplementationSyntax")||K("A named rule requires an ImplementationSyntax wrapper."),(e.rule!=="Rule"||e.value?.kind!=="PathExpressionSyntax"||!Ge(e.value,"PathExpressionSyntax")||typeof e.value.path!="string"||tf.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&&(!Ge(e.file,"FileReferenceSyntax")||typeof e.file.path!="string")&&K("A named rule file requires a FileReferenceSyntax payload with a string path."),e.code!=null&&(!Ge(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."),Yt(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."),ft(n.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),ft(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&&Yt(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;ft(e.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let n=0;n<e.hints.length;n++)Yt(e.hints[n])}if(t.kind==="ImplementationHintSyntax"){let e=t;(typeof e.text!="string"||Rn(e.text))&&K("An implementation hint must be nonblank.")}Yr(t)}l(Yt,"validateSyntaxInvariants");function Yr(t){let e=l(i=>{Gi(i)||K("Event source and stream names must be identifiers.")},"name"),n=l((i,r)=>{ft(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&&ft(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&&!Ge(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&&!On(r.name)&&K("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?ft(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):(ft(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=>Yr(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),Ge(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."),On(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&&!Ge(i.stream,"CommandStreamSyntax")&&K("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&&ft(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(Yr(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&&!Ge(i.stream,"SpecificationStreamSyntax")&&K("A specification stream requires a specification stream node."),i.noStream!=null&&!Ge(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(Yr,"validateSourceStream");var nt={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","criminal","reason","scope","specialCategory","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","isSubject","filters","isObservable","performer","returnType","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",[[96,65,!1],[33,0,!0],[97,63,!1],[98,63,!1],[99,63,!1]]],["ref",41],["array",181],["union",170,8],["object",[[100,182,!1],[44,90,!1],[33,0,!0],[41,0,!0],[87,183,!1],[101,116,!1]]],["object",[[88,65,!0],[102,63,!1],[103,63,!1],[104,63,!1],[105,116,!1]]],["object",[[70,137,!1],[106,0,!0],[107,65,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["object",[[108,0,!0]]],["ref",160],["union",188,8],["object",[[109,0,!0],[110,63,!1],[111,189,!1],[45,60,!1]]],["ref",146],["array",191],["union",192,8],["ref",219],["array",194],["object",[[112,193,!1],[113,195,!1]]],["ref",7],["union",197,8],["ref",176],["array",199],["ref",177],["array",201],["ref",180],["array",203],["ref",218],["array",205],["object",[[114,198,!1],[5,11,!1],[115,63,!1],[116,200,!1],[33,0,!0],[117,202,!1],[118,204,!1],[119,63,!1],[120,206,!1]]],["object",[[33,0,!0]]],["object",[[121,0,!0]]],["ref",58],["array",210],["object",[[43,63,!1],[122,63,!1],[123,85,!1],[33,0,!0],[124,211,!1]]],["object",[[33,0,!0],[41,84,!0]]],["ref",57],["array",214],["object",[[43,63,!1],[122,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],[125,218,!1],[126,65,!1],[122,63,!1],[33,0,!0],[64,160,!1],[48,100,!1]]],["object",[[2,3,!0],[127,65,!0],[3,5,!1]]],["object",[[70,137,!1],[128,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],[129,225,!1],[130,227,!1],[43,63,!1],[80,63,!1],[9,19,!1],[131,229,!1],[10,21,!1],[132,65,!0],[33,0,!0],[133,231,!1],[20,42,!1],[120,206,!1]]],["ref",65,215,216],["array",233],["object",[[134,234,!1],[44,89,!0],[135,65,!0],[106,63,!1],[33,0,!0],[136,116,!1]]],["object",[[137,0,!0]]],["object",[[110,63,!1],[0,0,!0]]],["object",[[138,63,!1],[60,63,!1],[110,63,!1],[0,0,!0]]],["object",[[139,63,!1],[140,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",68],["array",241],["ref",69],["array",243],["ref",70,71],["union",245,8],["object",[[5,11,!1],[141,240,!0],[142,242,!1],[143,244,!1],[144,0,!0],[33,0,!0],[145,189,!1],[146,246,!1],[120,206,!1]]],["ref",59],["array",248],["ref",40,63],["union",250,8],["object",[[147,249,!1],[58,251,!1],[3,5,!1],[148,132,!1]]],["union",149,8],["ref",75],["union",254,8],["object",[[74,253,!1],[44,90,!1],[149,255,!1]]],["ref",76],["array",257],["object",[[150,258,!1]]],["object",[[151,0,!0]]],["object",[[43,63,!1],[33,0,!0]]],["ref",79],["union",262,8],["object",[[152,263,!1],[43,63,!1],[153,263,!1],[154,160,!1],[33,0,!0],[155,0,!0]]],["object",[[74,253,!1],[43,63,!1],[44,90,!1],[149,255,!1]]],["ref",193],["union",266,8],["ref",192],["union",268,8],["object",[[43,63,!1],[144,132,!1],[156,97,!1],[33,0,!0],[157,267,!1],[85,269,!1],[41,0,!0],[101,97,!1]]],["object",[[158,0,!0]]],["object",[[158,0,!0],[101,97,!1]]],["object",[[159,0,!0]]],["ref",39,100],["object",[[160,139,!1],[161,274,!0]]],["object",[[160,139,!1]]],["object",[[76,0,!0],[33,0,!0]]],["ref",86],["array",278],["ref",87],["union",280,8],["ref",3,15,54,90],["object",[[160,139,!1],[162,279,!1],[161,63,!1],[163,281,!1],[164,282,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[165,59,!0],[166,284,!0]]],["ref",93],["array",286],["object",[[128,0,!0],[3,97,!1],[167,287,!1]]],["object",[[168,65,!0],[169,63,!1],[82,158,!1],[170,0,!0]]],["object",[[2,3,!0],[47,0,!0],[3,5,!1]]],["ref",94],["array",291],["object",[[147,292,!1],[171,0,!0],[0,0,!0]]],["object",[[62,1,!0],[0,0,!0]]],["array",1],["object",[[172,295,!1]]],["union",0,65,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[173,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",[[173,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],[129,225,!1],[130,227,!1],[43,63,!1],[174,314,!1],[80,63,!1],[9,19,!1],[131,229,!1],[10,21,!1],[175,317,!1],[132,65,!0],[33,0,!0],[176,319,!1],[20,42,!1],[120,206,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[177,0,!0]]],["object",[[2,3,!0],[66,130,!1],[0,0,!0]]],["object",[[178,309,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[70,137,!1],[179,324,!0],[106,0,!0],[107,65,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["object",[[70,137,!1],[180,0,!0],[71,139,!1],[72,139,!1],[73,139,!1]]],["ref",112],["array",327],["object",[[181,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",[[182,65,!1],[183,63,!1],[184,63,!1],[185,0,!0],[186,60,!1],[187,60,!1]]],["union",309,8],["object",[[74,253,!1],[161,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],[144,132,!1],[188,337,!1],[189,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],[190,63,!1],[191,63,!1],[17,38,!1]]],["ref",120],["array",343],["object",[[66,130,!1],[192,344,!1],[33,0,!0]]],["object",[[0,0,!0],[53,1,!0]]],["object",[[193,65,!1],[194,65,!1],[195,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",[[143,352,!1]]],["object",[[1,1,!0]]],["object",[[143,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],[139,358,!1],[43,63,!1],[196,359,!1],[197,65,!1],[33,0,!0],[198,361,!1],[199,84,!0],[98,63,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[164,0,!0]]],["ref",137],["array",364],["object",[[43,63,!1],[80,63,!1],[33,0,!0],[22,365,!1],[200,340,!1]]],["ref",209],["array",367],["ref",92],["array",369],["union",370,8],["union",158,8],["ref",91,104,148],["object",[[74,253,!1],[201,368,!1],[43,63,!1],[44,90,!1],[202,371,!1],[82,372,!1],[83,163,!1],[53,373,!0]]],["object",[[203,0,!0]]],["object",[[43,63,!1],[80,63,!1],[44,90,!1],[33,0,!0],[64,160,!1]]],["object",[[38,63,!1],[139,63,!1],[190,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],[190,0,!0],[113,380,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[140,0,!0]]],["object",[[47,0,!0],[58,132,!1],[148,132,!1]]],["enum","Error","Information","Warning"],["object",[[161,274,!0],[106,63,!1],[204,384,!0]]],["object",[[205,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",[[206,60,!1],[207,388,!1],[208,389,!0]]],["object",[[128,0,!0],[110,63,!1],[111,189,!1]]],["ref",152],["array",392],["ref",153],["union",394,8],["object",[[162,393,!1],[110,0,!0],[111,189,!1],[163,395,!1]]],["object",[[70,137,!1],[128,0,!0],[161,274,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[70,137,!1],[128,63,!1],[209,398,!0]]],["object",[[210,10,!0]]],["ref",33],["array",401],["ref",34],["array",403],["ref",123],["array",405],["ref",35],["array",407],["object",[[5,11,!1],[211,0,!0],[212,147,!1],[116,402,!1],[213,63,!1],[33,0,!0],[117,404,!1],[214,406,!1],[64,408,!1],[120,206,!1]]],["object",[[139,63,!1],[140,0,!0],[41,84,!0]]],["object",[[110,0,!0],[0,0,!0]]],["ref",150],["array",412],["object",[[139,63,!1],[46,413,!1],[215,63,!1],[177,0,!0]]],["ref",159],["array",415],["object",[[143,416,!1],[216,0,!0]]],["object",[[77,145,!1],[44,90,!1],[33,0,!0]]],["ref",157],["array",419],["object",[[5,11,!1],[142,420,!1],[217,189,!1],[216,0,!0],[120,206,!1]]],["ref",162],["array",422],["object",[[33,0,!0],[118,423,!1]]],["object",[[114,198,!1],[5,11,!1],[115,63,!1],[116,200,!1],[218,63,!1],[33,0,!0],[117,202,!1],[118,204,!1],[119,63,!1],[120,206,!1]]],["ref",204],["array",426],["object",[[172,427,!1],[33,0,!0]]],["object",[[155,205,!0]]],["object",[[47,0,!0],[64,97,!1]]],["ref",171],["array",431],["object",[[219,0,!0],[147,432,!1]]],["ref",172],["array",434],["object",[[220,435,!1]]],["object",[[70,137,!1],[71,139,!1],[72,139,!1],[73,139,!1],[216,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",[[221,439,!1],[222,441,!1],[223,234,!1],[43,63,!1],[80,63,!1],[147,442,!1],[9,19,!1],[44,90,!1],[33,0,!0],[224,443,!1],[225,445,!1],[226,447,!1],[227,449,!1],[228,452,!1],[229,455,!1],[230,457,!1],[231,459,!1],[20,42,!1],[41,460,!0]]],["object",[[232,63,!1],[33,0,!0]]],["object",[[58,1,!0],[33,0,!0]]],["object",[[41,0,!0],[1,0,!0]]],["ref",183],["array",465],["object",[[233,65,!0],[234,466,!1],[235,116,!1]]],["object",[[236,0,!0],[237,97,!1]]],["object",[[238,0,!0]]],["object",[[239,0,!0],[144,132,!1],[156,97,!1],[240,63,!1],[101,97,!1]]],["object",[[33,63,!1]]],["object",[[241,0,!0],[144,132,!1],[240,63,!1],[157,267,!1],[85,269,!1],[101,97,!1]]],["object",[[88,0,!0],[85,0,!0],[90,173,!1],[91,97,!1]]],["object",[[242,65,!0],[64,97,!1]]],["ref",194],["array",475],["object",[[70,97,!1],[242,65,!0],[140,0,!0],[243,476,!1]]],["object",[[242,65,!0],[240,63,!1],[33,0,!0],[64,97,!1]]],["object",[[241,0,!0],[144,132,!1],[157,267,!1],[244,0,!0],[85,269,!1],[101,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],[245,481,!1],[246,483,!1],[247,485,!1],[248,487,!1],[249,489,!1],[250,492,!1],[33,0,!0],[17,38,!1],[251,494,!1],[252,496,!1],[253,498,!1],[254,500,!1],[255,481,!1],[256,65,!0],[257,65,!1],[258,502,!1],[259,504,!1],[260,506,!1],[261,492,!1],[262,476,!1],[263,508,!1],[49,510,!1],[264,511,!1],[265,512,!1],[266,487,!1],[267,514,!1],[268,516,!1],[269,518,!1]]],["object",[[164,0,!0],[101,97,!1]]],["object",[[70,97,!1],[140,0,!0]]],["object",[[58,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[213,63,!1],[110,63,!1],[33,0,!0],[46,413,!1],[214,406,!1],[28,523,!0],[216,0,!0]]],["ref",206,207],["array",525],["object",[[95,526,!1]]],["object",[[270,116,!1],[33,0,!0]]],["object",[[201,368,!1],[43,63,!1],[44,90,!1],[33,0,!0]]],["object",[[271,65,!0],[272,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",[[273,532,!0],[274,63,!1],[275,63,!1],[276,63,!1],[35,534,!1],[277,536,!1],[108,0,!0],[140,63,!1],[278,63,!1]]],["object",[[279,63,!1],[280,116,!1],[281,63,!1],[33,0,!0],[282,116,!1],[283,116,!1],[284,63,!1]]],["object",[[134,234,!1],[47,0,!0],[135,65,!0],[106,63,!1],[33,0,!0],[136,116,!1]]],["object",[[285,116,!1],[134,234,!1],[47,0,!0],[135,65,!0],[106,63,!1],[33,0,!0],[0,0,!0],[136,116,!1]]],["object",[[216,0,!0]]],["ref",12],["array",542],["object",[[70,543,!1],[210,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[74,253,!1],[44,90,!1],[149,255,!1],[106,63,!1],[0,0,!0],[286,545,!0],[204,384,!0],[1,132,!1]]],["ref",116],["array",547],["object",[[29,0,!0],[287,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 Fr=nt.rules,nf=new Map(Fr.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),os=new Map(nt.kinds.map((t,e)=>[t,Fr[nt.contracts[e]][1]])),rf=new Map([...os].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>nt.names[n])])])),rs=l(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function Ur(t){let e=os.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!as(t,e))throw new le(`Invalid typed members for syntax kind '${t.kind}'.`)}l(Ur,"validateSyntaxMembers");function xi(t,e){let n=vi(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new le(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}l(xi,"validateClosedSyntaxMembers");function vi(t){let e=rf.get(t);if(e===void 0)throw new le(`Unknown syntax kind '${t}'.`);return e}l(vi,"syntaxMemberNames");function as(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,nt.names[n])?Wr(t[nt.names[n]],i):!r)}l(as,"matchesMembers");function of(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!Wr(t[n],e))return!1;return!0}l(of,"allIndicesMatch");function Wr(t,e){let[n,...i]=Fr[e];switch(n){case"ref":return rs(t)&&typeof t.kind=="string"&&i.some(r=>nt.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(Wr(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)&&of(t,i[0]);case"object":return rs(t)&&Object.keys(t).every(r=>i[0].some(([o])=>nt.names[o]===r))&&as(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||nf.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}l(Wr,"matches");var af=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(","))])),sf=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function lf(t,e){return af[t]?.has(e)===!0||sf.test(t)&&(e==="source"||e==="value")}l(lf,"isExactOnlyMember");function ss(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:lf(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}l(ss,"isLegacyOmittedMember");var bi=l(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),$i=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),ki=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function Ci(t){let e=cf(t);return zr(e,"legacy",0),Ei(e)}l(Ci,"toSyntaxJson");function cf(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=ls();e.set(o,c);let p=o.length;for(let y=p-1;y>=0;y--)n.push(()=>{c[y]=i(Object.hasOwn(o,y)?o[y]: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],y=o[p];p==="sourceOptions"&&n.push(()=>{typeof y=="object"&&y!==null&&(Object.getPrototypeOf(y)!==Object.prototype&&Object.getPrototypeOf(y)!==null||Reflect.ownKeys(y).length!==Object.keys(y).length)&&(s[p]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[p]=i(y)});return s}l(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}l(cf,"snapshot");function ls(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}l(ls,"dataArray");function Ei(t,e="legacy",n=!1){if(Array.isArray(t)){let o=ls();for(let s=0;s<t.length;s++)o.push(Ei(t[s],e,n));return o}if(bi(t)){if(ki.has(t.kind)&&(e=Ot(t.sourceOptions??Oe).numericMode),Yt(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&xi(t,$i),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&xi(p.file,$i),p.code!=null&&xi(p.code,$i))}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"?vi(t.kind):void 0,c=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&ss(t,p))&&!$i.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(df);for(let p of c){let y=s[p];t.kind==="ConceptAttributeSyntax"&&(p==="scope"||p==="specialCategory")&&y==null||t.kind==="ConceptAttributeSyntax"&&p==="criminal"&&y===!1||t.kind==="PropertySyntax"&&p==="isSubject"&&y===!1||p==="documentation"&&t.kind!=="EventSyntax"&&y==null||t.kind==="SpecificationSyntax"&&p==="description"&&y==null||p==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(y)&&y.length===0||p==="sourceOptions"&&y?.numericMode==="legacy"||p==="examples"&&Array.isArray(y)&&y.length===0||p==="inlineProperty"&&y==null||(t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax")&&(p==="stream"||p==="noStream")&&y==null||t.kind==="SpecificationSyntax"&&p==="thenNoEvents"&&y===!1||t.kind==="SpecificationSyntax"&&p==="whenRedelivered"&&y==null||t.kind==="InvokesSyntax"&&p==="onRefused"&&Array.isArray(y)&&y.length===0||(o[p]=Ei(y,e,n))}return o}if(t===void 0)return null;if(typeof t!="object"||t===null)return t;let i=t,r=Object.create(null);if(i.literalType==="ExactNumber")return r.literalType="ExactNumber",r.value=i.value,r;for(let o of Object.keys(i))o!=="toJSON"&&i[o]!==void 0&&(r[o]=Ei(i[o],e,n));return r}l(Ei,"write");function zr(t,e,n){if(n>96&&e==="exact")throw new le("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)zr(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 le("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!ki.has(i.kind))throw new le("Exact syntax requires a complete source root.");if(e==="exact"&&bi(i)&&Ur(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&Gt(i.text))throw new le("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 le("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"||Ze(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new le("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new le("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&bi(i)?vi(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||bi(s)&&ki.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&zr(s,e,n+1)}l(zr,"validateNumbers");function df(t,e){return t<e?-1:t>e?1:0}l(df,"ordinal");function cs(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($){if(!($ instanceof le))throw $;r=!0,e.push(Ai(d.IncompatibleNumericSource,$.message,v.location))}let o=n.filter(v=>i.get(v)?.numericMode==="exact"||pf(v)),s=i.get(o[0])??Oe;for(let v of o.slice(1))i.get(v)?.numericMode!==s.numericMode&&(r=!0,e.push(Ai(d.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",v.location)));r&&(s=$o);let a=new Map,c=Pi(n.flatMap(v=>v.concepts),"declaration of",e,void 0,a),p=Pi(n.flatMap(v=>v.types),"declaration of",e,void 0,a),y=n.map(v=>v.domain).filter(v=>v!==null);for(let v of y.slice(1))e.push(Ai(d.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${fn(y[0].location.path)}' - a folder compiles to one application, which can have at most one`,v.location));let f=uf(n.flatMap(v=>v.modules),e),m=Pi(n.flatMap(v=>v.personas),"persona",e),h={kind:"ApplicationSyntax",sourceOptions:s,domain:y[0]??null,imports:ff(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:f,personas:m,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}},g=[...t.flatMap(v=>v.diagnostics),...e];return{value:h,diagnostics:g,success:!g.some(v=>v.severity==="error")}}l(cs,"mergeDocuments");function pf(t){if(Eo(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(pf,"hasDeclarations");function uf(t,e){return ms(t).map(us).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(Vr)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:hs(n,`module '${n[0].name}'`,e),documentation:ys(n,`module '${n[0].name}'`,e),authorize:fs(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:ps(n),features:ds(n.flatMap(i=>i.features),e)})}l(uf,"mergeModules");function ds(t,e){return ms(t).map(us).map(n=>n.length===1?Vr(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),description:hs(n,`feature '${n[0].name}'`,e),documentation:ys(n,`feature '${n[0].name}'`,e),authorize:fs(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:ps(n),features:ds(n.flatMap(i=>i.features),e),slices:Pi(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}l(ds,"mergeFeatures");function ps(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(ps,"groupDependencies");function us(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}l(us,"placedLast");function Vr(t){return{...t,isPlacement:!1,features:t.features.map(Vr)}}l(Vr,"unplaced");function fs(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(Ci(s))===JSON.stringify(Ci(r)));if(o!==void 0){n.push(Qr(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)=>Fe(r,o),null)}l(fs,"combineAuthorization");function ff(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}l(ff,"firstOfEach");function ms(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}l(ms,"groupByName");function ys(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(Qr(d.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${fn(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}l(ys,"firstDocumentation");function hs(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(Qr(d.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${fn(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}l(hs,"firstDescription");function Pi(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(Ai(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(Pi,"declaredInOneFile");var fn=l(t=>t??"another file","describe"),Ai=l((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),Qr=l((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function gs(t,e){return hf(t,e).result}l(gs,"parsePlacedDocuments");function hf(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=>et(h.source,h.path,h.isPlacementResolved===!1?[]:h.placement,!1,n,e)),r=i.flatMap((h,g)=>(h.value.eventSources??[]).map(v=>({source:v,placementResolved:t[g].isPlacementResolved!==!1}))),o=t.every(h=>h.isPlacementResolved!==!1)&&i.every(h=>!Bt.hasUnknownExtent(h.diagnostics)),s=i.map((h,g)=>t[g].isPlacementResolved===!1?{...h,value:{...h.value,eventSources:[]}}:h),a=cs(s),c=new xe(new _e([]),void 0,e);a.value.sourceOptions!==void 0&&(c.sourceOptions=a.value.sourceOptions),ci(a.value,c),ni(a.value,c),ti(a.value,c),bn(a.value,c),Xn(a.value,c,s.flatMap(h=>h.inputUses)),di(a.value,c),pi(a.value,c),ui(a.value,c),mi(a.value,c),Si(a.value,c),gi(a.value,c);let p=En(a.value,c);Lt.validate(p,c);for(let h of $n(p))c.information(h.code,h.message,h.location);let y=a.diagnostics,f=new Set(y.map(Ss)),m=[...y,...c.diagnostics.filter(h=>!f.has(Ss(h)))];return{result:{...a,value:p,diagnostics:m,success:!m.some(h=>h.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((h,g)=>[t[g].path,h.value]))}}l(hf,"parsePlacedDocumentsWithSyntax");function Ss(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}l(Ss,"diagnosticKey");var xs=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,vs=l(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function Sf(){let t="";for(let e=0;e<=65535;e++){if(!xs.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&xs.test(String.fromCharCode(e+1));)e++;t+=vs(n)+(e>n?`-${vs(e)}`:"")}return t}l(Sf,"ranges");var wi=Sf();var gf=new RegExp(`^\\s*example\\s+[A-Z][${wi}]*\\s*:\\s*([${wi}.]*)$`),xf=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${wi}.]*)$`);function $s(t,e,n,i,r,o){let s=t,a=[],c=o.some(S=>S.severity==="error")?o.some(S=>S.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,y=[],f=l((S,k)=>{if(S.location.path===e&&S.location.line>0)for(let b of i(S.location.line-1))p.set(b,k)},"own"),m=l((S,k)=>{for(let b of S??[])a.push({name:b.name,scope:k,example:b}),f(b,k)},"examples");m(s.examples,[]),a.push(...[...s.concepts,...s.types].map(S=>({name:S.name,scope:[]})));let h=l((S,k)=>{for(let b of S){let E=[...k,b.name];f(b,E),m(b.examples,E);for(let O of b.slices){let I=[...k,b.name,O.name];f(O,I),m(O.examples,I);let R=new Map;for(let j of se(O))R.set(j.name,[...R.get(j.name)??[],j]);for(let j of R.values()){let N=Math.max(...j.map(B=>B.generation));a.push(...j.filter(B=>B.generation===N).map(B=>({name:B.name,scope:I,fixtureKind:"event"})))}a.push(...O.commands.map(j=>({name:j.name,scope:I,fixtureKind:"command"})),...O.readModels.map(j=>({name:j.name,scope:I,fixtureKind:"readmodel"})));for(let j of O.specifications)y.push({node:j,scope:I}),f(j,I),m(j.examples,I)}h(b.features,E)}},"features");for(let S of s.modules)f(S,[S.name]),m(S.examples,[S.name]),h(S.features,[S.name]);let g=l((S,k)=>{let b=S.split("."),E=a.filter(I=>I.name===b.at(-1)),O=b.slice(0,-1);if(O.length)return E.filter(I=>O.length<=I.scope.length&&O.every((R,j)=>I.scope[I.scope.length-O.length+j]===R));for(let I=k.length;I>=0;I--){let R=E.filter(j=>I<=j.scope.length&&k.slice(0,I).every((N,B)=>j.scope[B]===N));if(R.length)return R}return[]},"candidates"),v=l((S,k)=>{let b=g(S,k);return b.length===1?b[0]:void 0},"unique"),$=l(S=>S.example?v(S.example.type,S.scope)?.fixtureKind:S.fixtureKind,"kind"),C=l(S=>[...S.scope.filter(k=>!r.has(k)),S.name].join("."),"display"),x=l((S,k,b=!1,E="")=>a.flatMap(O=>{let I=$(O);if(!I||k&&I!==k||b&&O.example)return[];let R=[...O.scope,O.name].join("."),j=v(O.name,S)===O?O.name:R;if(v(j,S)!==O)return[];let N=E.split(".").slice(0,-1).join(".");return N&&!R.endsWith(`${N}.${O.name}`)?[]:j===R&&O.scope.some(B=>r.has(B))&&v(O.name,S)!==O?[]:[{label:v(O.name,S)===O?O.name:C(O),insertText:N?O.name:j,documentation:O.example?`Example of ${O.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${I}.`}]}),"targets"),P=l((S,k,b,E,O)=>{if(c)return c;let I=l((V,Z,fe="")=>{if(new Set(V.map(F=>F.property)).size!==V.length||new Set(Z.map(F=>F.property)).size!==Z.length)return null;let Pe=new Map(V.map(F=>[F.property,{value:F,origin:"example",replaced:void 0}]));for(let F of Z){let oe=Pe.get(F.property)?.value;Pe.delete(F.property),Pe.set(F.property,{value:F,origin:oe?"override":"authored",replaced:oe})}return[...Pe.values()].map(({value:F,origin:oe,replaced:de})=>`${fe}${F.property} = ${it(F.source)} \u2014 ${oe}${oe==="example"?` ${S.name}`:""}${de?` (replaces ${it(de.source)} from ${S.name})`:""}`)},"merge"),R=I(S?.values??[],k),j=I(S?.generatedValues??[],b,"generated ");if(!R||!j)return"**Invalid duplicate assignments; no effective values selected.**";let N=E??S?.for,B=S?.stream??S?.noStream,L=O?.stream??O?.noStream,W=L??B,z=l(V=>V.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${V.eventSource}.${V.stream}${V.streamId?` streamId = ${it(V.streamId.source)}`:V.streamIdParts.length?` streamId ${V.streamIdParts.map(Z=>`${Z.property} = ${it(Z.source)}`).join(", ")}`:""}`,"routeText"),G=W?[`${z(W)} \u2014 ${L?B?`override (replaces ${z(B)} from ${S.name})`:"authored":`example ${S.name}`}`]:[];return[...R,...j,...G,...N?[`for ${it(N)} \u2014 ${E?S?.for?`override (replaces ${it(S.for)} from ${S.name})`:"authored":`example ${S.name}`}`]:[]].join(`
19
- `)},"effective"),A=new Map;for(let S of a.filter(k=>k.example?.location.path===e)){let k=S.example,b=k.location.line-1,E=Me(n[b]??"").match(/^\s*example\s+/)?.[0];E&&A.set(b,{start:E.length+1,length:k.name.length,content:`**example ${C(S)} : ${k.type}**
20
-
21
- ${$(S)?P(k,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:S,scope:k}of y){let b=[...S.given.map(E=>({step:E,name:E.eventType,expected:"event",values:E.values,generated:[],destination:E.for,prefix:/^\s*given\s+/})),...S.givenReadModels.map(E=>({step:E,name:E.name,expected:"readmodel",values:E.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...S.when?[{step:S.when,name:S.when.commandType,expected:"command",values:S.when.values,generated:S.when.generatedValues??[],destination:S.when.for,prefix:/^\s*when\s+/}]:[],...S.whenAppended?[{step:S.whenAppended,name:S.whenAppended.eventType,expected:"event",values:S.whenAppended.values,generated:[],destination:S.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...S.thenEvents.map(E=>({step:E,name:E.eventType,expected:"event",values:E.values,generated:[],destination:E.for,prefix:/^\s*then\s+/})),...S.thenReadModels.map(E=>({step:E,name:E.name,expected:"readmodel",values:E.properties,generated:[],destination:null,prefix:/^\s*then\s+readmodel\s+/}))];for(let{step:E,name:O,expected:I,values:R,generated:j,destination:N,prefix:B}of b.filter(L=>L.step.location.path===e)){let L=v(O,k),W=g(O,k).some(Z=>Z.example);if(!L?.example&&(L||!W))continue;let z=E.location.line-1,G=Me(n[z]??"").match(B)?.[0].length;if(G===void 0)continue;let V=L?$(L)!==I?"**Example kind mismatch; no effective values selected.**":`**${I} ${L.example?.type??O}${L.example?` \u2014 example ${C(L)}`:""}**
22
-
23
- ${P(L.example,R,j,N,"eventType"in E?E:void 0)}
24
-
25
- Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";A.set(z,{start:G+1,length:O.length,content:V})}}return{eventExamples:a.filter(S=>S.example?.location.path===e&&$(S)==="event").map(S=>S.example),completions(S,k){let b=p.get(S)??[],E=k.match(gf);if(E)return x(b,void 0,!0,E[1]);if(!y.some(({node:N})=>N.location.path===e&&i(N.location.line-1).includes(S)))return null;let I=k.match(xf);if(!I||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(I[3]))return null;let R=I[2]==="readmodel"?"readmodel":I[2]==="append"||I[1]!=="when"?"event":"command",j=x(b,R,!1,I[3]);return j.length?I[2]?j:[...oo[I[1]],...j]:null},hover(S,k,b){let E=A.get(S);return E&&k>=E.start&&b<=E.start+E.length?E.content:null}}}l($s,"exampleAnalysis");function it(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(it).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${it(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:"${"+it(e.expression)+"}").join("")+"`"}}l(it,"expressionText");function bs(t,e,n,i,r){let o=t,s=e,a=Ee.containersOf(o).filter(f=>![...f.scope,f.name].some(m=>r.has(m))),c=new Map,p=new Map,y=l((f,m,h)=>{for(let g of f){let v=[...m,g.name];if(h){if(g.location.path===n&&g.location.line>0)for(let $ of i(g.location.line-1))c.set($,v)}else{let $=v.join(".");p.set($,[...p.get($)??[],...(g.dependsOn??[]).map(C=>({target:C.target,...C.location}))])}y(g.features,v,h)}},"inventory");return y(o.modules,[],!1),y(s.modules,[],!0),{completions(f,m,h){let g=c.get(f)??h;if(!g?.length||g.some($=>r.has($))||!a.some($=>[...$.scope,$.name].join(".")===g.join(".")))return[];let v=new Set((p.get(g.join("."))??[]).filter($=>$.path!==n||$.line!==f+1).map($=>Ee.resolve($.target,g,a).resolved));return Ee.candidates(g,a).flatMap(({container:$,reference:C,tier:x})=>{if(v.has($))return[];let P=[...$.scope,$.name].join(".");if(m&&(C=m+$.name,Ee.resolve(C,g,a).resolved!==$))return[];let A=$.scope.length===0?"module":x===0?"sibling feature":x!=="qualified"?`feature of ${$.scope.join(".")}`:`feature in ${$.scope.join(".")}`,S=a.indexOf($);return[{label:m?$.name:C,insertText:m?$.name:C,documentation:`${P} \u2014 ${A}.`,detail:A,sortText:`${String(x==="qualified"?g.length:x).padStart(6,"0")}:${String(S).padStart(6,"0")}`}]})}}}l(bs,"dependencyTargetAnalysis");var eI="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",mn=new Map;function vf(t,e){let n=be(t),i=t.flatMap((f,m)=>!n[m]&&X(f)===0&&/^\w/.test(f)?[f.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(f=>["feature","slice","command","event","operation","reaction","specification"].includes(f)))return{source:t.join(`
26
- `),locations:t.map((f,m)=>({line:m+1,column:0}))};let r=[],o=[],s=!1;t.forEach((f,m)=>{!n[m]&&X(f)===0&&/^\w/.test(f)&&(s=/^(?:concept|type|import|domain|system|eventsource)\b/.test(f)),(s?r:o).push(m)});let a=i.includes("feature")?1:i.includes("slice")?2:3,c=e.slice(0,a),p=[...r.map(f=>t[f]),...c,...o.map(f=>" ".repeat(a*2)+t[f])].join(`
27
- `),y=[...r.map(f=>({line:f+1,column:0})),...c.map(()=>({line:0,column:0})),...o.map(f=>({line:f+1,column:a*2}))];return{source:p,locations:y}}l(vf,"authoringSource");function $f(t,e,n,i="current.play",r=!0){let o=e.map((T,M)=>typeof T=="string"?{path:`other-${M}.play`,source:T}:T).filter(T=>T.path!==i),s=[{path:i,source:t.join(`
28
- `),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(T=>[...T.source.matchAll(/\w+/g)].map(M=>M[0]).concat(T.placement??[]))),c=l(T=>{let M=T;for(let q=1;a.has(M);q++)M=`${T}${q}`;return a.add(M),M},"fresh"),p=c("EditorAuthoring"),y=c("FragmentFeature"),f=new Set([p,y]),m=s.map((T,M)=>{let q=M===0?t:T.source.split(`
29
- `),Y=c(`Fragment${M}`);f.add(Y);let rt=T.placement?.length?{source:T.source,locations:q.map((kt,gn)=>({line:gn+1,column:0}))}:vf(q,[`module ${p}`,` feature ${y}`,` slice StateChange ${Y}`]);return{...T,...rt,placement:T.placement??[]}}),h=m[0],g=new Map(m.map(T=>[T.path,T.locations])),v=gs([...m.slice(1),h]),$=new Map,C=new Map,x=new WeakSet,P=l(T=>{if(T===null||typeof T!="object"||x.has(T))return;if(x.add(T),Array.isArray(T)){T.forEach(P);return}let M=T;if(typeof M.path=="string"&&typeof M.line=="number"&&typeof M.column=="number"){let q=g.get(M.path)?.[M.line-1];q&&(M.line=q.line,M.column=Math.max(1,M.column-q.column));return}for(let q of Object.values(M))P(q);M.location?.path===i&&(M.kind==="CommandSyntax"&&$.set(M.location.line-1,T),M.kind==="SpecificationSyntax"&&C.set(M.location.line-1,T))},"walk");P(v.value),P(v.physicalEventSources);for(let T of v.diagnostics)P(T.location);let A=v.diagnostics.some(T=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(T.code))return!1;let M=m.find(Y=>Y.path===T.location.path),q=s.find(Y=>Y.path===T.location.path)?.source.split(`
30
- `)[T.location.line-1];return M?.locations.some(Y=>Y.line===0)&&q!==void 0&&X(q)===0}),S=v.diagnostics.filter(T=>T.location.path===i).flatMap(T=>(P(T.location),T.location.line>0?[T]:[])),k=new ae(v.value),b=new Set(k.slices.flatMap(({slice:T})=>[...T.commands.flatMap(M=>M.produces),...T.reactions.flatMap(M=>M.triggers).flatMap(M=>M.produces)].filter(M=>M.location.path===i&&!k.isEventProduction(M,T)).map(M=>M.location.line-1)));for(let T of S)T.code==="PLAY0499"&&b.add(T.location.line-1);let E=k.declarations.filter(T=>T.kind===ie.Operation).map(T=>({...T.node,scope:T.scope.filter(M=>!f.has(M))})),O=new Map,I=be(t),R=l(T=>{let M=[],q=X(t[T]);for(let Y=T;Y<t.length&&!(Y>T&&!I[Y]&&Me(t[Y]).trim()&&X(t[Y])<=q);Y++)M.push(Y);return M},"range");for(let{slice:T,scope:M}of k.slices){if(T.location.path===i&&T.location.line>0)for(let q of R(T.location.line-1))O.set(q,{scope:M});for(let q of T.specifications.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of R(q.location.line-1))O.set(Y,{scope:M});for(let q of T.commands.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of R(q.location.line-1))O.set(Y,{scope:M,commandLine:q.location.line-1})}let j=new Map(k.declarations.map(T=>[T.node.location,T.scope]));for(let T of E.filter(M=>M.location.path===i)){let M=j.get(T.location);for(let q of R(T.location.line-1))O.set(q,{...O.get(q),scope:M,operation:T})}let N=new Map(E.map(T=>[T.location,T])),B=l((T,M)=>{let q=Me(t[T.line-1]??""),Y=q.slice(T.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return Y&&q.slice(T.column-1+Y.length,T.column-1+Y.length+M.length)===M?{...T,column:T.column+Y.length}:T},"referenceLocation"),L=[];for(let{slice:T}of k.slices){for(let M of T.commands)for(let q of M.produces){if(q.location.path!==i)continue;let Y=k.resolve(q.event,T),rt=Y.declaration?N.get(Y.declaration.node.location)??null:null,kt={name:q.event,location:q.location,targetLocation:q.targetLocation??q.location,kind:Y.kind,declaration:rt,mappings:q.mappings};if(L.push(kt),Y.kind===ie.Operation)for(let gn of R(q.location.line-1)){let eo=O.get(gn);eo&&O.set(gn,{...eo,production:kt})}}for(let M of T.specifications)for(let q of[...M.givenOperationFailures??[],...M.thenOperations??[],...M.thenCompensated??[]]){if(q.location.path!==i)continue;let Y=k.resolve(q.operation,T);L.push({name:q.operation,location:q.location,targetLocation:B(q.location,q.operation),kind:Y.kind,declaration:Y.declaration?N.get(Y.declaration.node.location)??null:null,mappings:[]})}}let W={declarations:E,systems:v.value.systems??[],references:L,contexts:O,types:v.value.types,concepts:v.value.concepts,targets:l(T=>{let M=k.slices.find(q=>q.scope.length===T.length&&q.scope.every((Y,rt)=>Y===T[rt]))?.slice;return M?E.flatMap(q=>{let Y=k.resolve(q.name,M).declaration?.node.location===q.location?q.name:[...q.scope,q.name].join(".");return k.resolve(Y,M).kind===ie.Operation&&k.resolve(Y,M).declaration?.node.location===q.location?[{name:Y,declaration:q}]:[]}):[]},"targets")},z=v.physicalEventSources.map(T=>T.source),G=new Bt(v.physicalEventSources,v.sourceInventoryComplete&&!A),V=new Map,Z=l((T,M)=>{let q=JSON.stringify([T,M]),Y=V.get(q);return Y||(Y=G.resolve(T,M),V.set(q,Y)),{...Y,source:Y.state==="unique"?Y.sources[0]:void 0,stream:Y.state==="unique"?Y.streams[0]:void 0}},"resolve"),fe=new Set(v.value.imports.map(T=>T.qualifiedName)),Pe=z.flatMap(T=>T.streams.filter(M=>Z(T.name,M.name).state==="unique"&&!fe.has(`${T.name}.${M.name}`)).map(M=>({name:`${T.name}.${M.name}`,source:T,stream:M}))),F=new Map,oe=[];for(let T of $.values()){for(let M of R(T.location.line-1))F.set(M,{command:T});for(let M of[...T.produces,...T.validations,...T.handler?[T.handler]:[]])for(let q of R(M.location.line-1))F.delete(q);if(T.stream){oe.push(T.stream);for(let M of R(T.stream.location.line-1))F.set(M,{command:T,route:T.stream})}}let de=$s(v.value,i,t,R,f,v.diagnostics),$e=[...[...C.values()].flatMap(T=>[...T.given.map(M=>({event:M,expectation:!1})),...T.whenAppended?[{event:T.whenAppended,expectation:!1}]:[],...T.thenEvents.map(M=>({event:M,expectation:!0})),...T.whenRedelivered?[{event:T.whenRedelivered,expectation:!0}]:[]]),...(de.eventExamples??[]).map(T=>({event:T,expectation:!0}))];for(let T of $e){let M=T.event;for(let q of R(M.location.line-1))F.set(q,T);if(M.stream){oe.push(M.stream);for(let q of R(M.stream.location.line-1))F.set(q,{...T,route:M.stream})}}for(let T of z.filter(M=>M.location.path===i)){for(let M of R(T.location.line-1))F.set(M,{source:T});for(let M of T.streams)for(let q of R(M.location.line-1))F.set(q,{source:T,stream:M})}let ht=[...$.values()].flatMap(T=>T.streamCandidates??[]).filter(T=>T.propertyCandidate!==null),St={declarations:z,routes:oe,ambiguousCandidates:ht,contexts:F,targets:Pe,resolve:Z},pe;return{commands:$,specifications:C,diagnostics:S,operationProductionLines:b,operations:W,eventSources:St,examples:de,dependencies:{completions(T,M,q){if(pe===void 0){let Y=et(h.source,i,h.placement,!1).value,rt=l(kt=>{P(kt.location),kt.features.forEach(rt)},"remapDependencyHeaders");Y.modules.forEach(rt),pe=bs(v.value,Y,i,R,f)}return pe.completions(T,M,q)}}}}l($f,"analyze");function Ft(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=mn.get(o);return s===void 0&&(s=$f(t,e,n,i,r),mn.size>=16&&mn.delete(mn.keys().next().value),mn.set(o,s)),s}l(Ft,"responseAnalysis");var Gr="file",bf=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,kf=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function rI(t){return kf.test(t)}l(rI,"isAbsoluteFileReferencePath");function Ef(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(Ef,"withoutComment");function Zr(t,e){let n=X(t),i=Ef(t.slice(n)).trimEnd();if(ji(i)!==Gr)return;let r=i.slice(Gr.length),o=r.trim();if(o.length===0||bf.test(o))return;let s=r.length-r.trimStart().length,a=n+Gr.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}l(Zr,"fileReferenceOn");function oI(t){let e=be(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=Zr(t[i],i);r&&n.push(r)}return n}l(oI,"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 Cf=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,Pf=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?(\s+subject)?\s*$/,ks=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,Af=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,wf=["authorize","produces","reads"],Of=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,If=tn,Tf=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],Rf=/^\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 _r(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(_r,"sourceTypeAt");function Kr(t,e,n){return e.map(i=>({index:i,match:t[i].match(Pf)})).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:_r(t[i],t[i].match(/^\s*\S+\s+/)[0].length+1),isIdentifier:r[4]!==void 0,...r[3]!==void 0?{isGenerated:!0}:{},...r[5]!==void 0?{isSubject:!0}:{},line:i}))}l(Kr,"propertiesIn");function hn(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(X(s)<=i)break;r.push(o)}}return r}l(hn,"collectBody");function Ut(t,e,n,i){let r=hn(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=X(t[a]),p=t[a].trim();return o!==void 0&&c>o&&(!s||Of.test(p))?!1:(o=p!=="validate csharp"&&Kr(t,[a],wf).length>0||/^description(?:\s|$)/.test(p)?void 0:c,s=/^authorize(?:\s|$)/.test(p),!0)})}l(Ut,"directBody");var yn=new Map;function Sn(t){let e=t.join(`
31
- `),n=yn.get(e);if(n)return n;let i=Ft(t),r={authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=mt(t);let o=be(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 y=t[p],f=y.trim(),m=X(y),h=s[p].trim().match(/^import\s+([\w.]+)\s*$/);if(h&&m===0){let k=h[1],b=k.split(".").pop()??k;r.imports.push({qualifiedName:k,shortName:b,line:p});continue}let g=f.match(Cf);if(g){let k=hn(t,o,p,m).map(O=>t[O].trim()),b={};for(let O of k){let I=O.match(ks);I&&b[I[1]]===void 0&&(b[I[1]]=I[2])}let E=g[2]==="Enum"?k.filter(O=>!ks.test(O)):[];r.concepts.push({name:g[1],primitive:g[2],attributes:g[3].trim().split(/\s+/).filter(Boolean),attributeReasons:b,enumValues:E,line:p});continue}let v=f.match(/^type\s+(\w+)\s*$/);if(v){r.types.push({name:v[1],properties:Kr(t,hn(t,o,p,m),to),line:p});continue}let $=f.match(/^policy\s+(\w+)\s*$/);if($){let k=hn(t,o,p,m).filter(b=>!o[b]).map(b=>t[b].trim());r.policies.push({name:$[1],requires:k,line:p});continue}let C=s[p].trim().match(/^(?:produces\s+)?event\s+(\w+)(?:\s+generation\s+(\d+))?\s*$/);if(C){let k=f.startsWith("produces "),b=Ut(s,a,p,m),E=k?b:b.filter(O=>Zr(s[O],O)===void 0);r.events.push({name:C[1],...C[2]?{generation:Number(C[2])}:{},inline:k,properties:Kr(k?c:s,E,k?Tf:If),line:p});continue}let x=i.commands.get(p);if(x){let k=Ut(t,o,p,m),b=k.filter(E=>/^\s*produces\b/.test(t[E])&&!i.operationProductionLines?.has(E));r.commands.push({name:x.name,properties:x.properties.map(E=>({name:E.name,type:`${E.type.name}${E.type.isCollection?"[]":""}${E.type.isOptional?" optional":""}`,typeReference:{name:E.type.name,isCollection:E.type.isCollection,isOptional:E.type.isOptional},sourceType:_r(t[E.type.location.line-1],E.type.location.column),isIdentifier:E.isIdentifier||/\sidentifier\s*$/.test(t[E.location.line-1]),...E.isGenerated?{isGenerated:!0}:{},line:E.location.line-1})),response:x.response,productionHeaders:b,produces:b.flatMap(E=>{let O=s[E].trim(),I=/^produces\s+event\b/.test(O),R=/^produces\s+when\b/.test(O),j=R?Ut(s,a,E,X(s[E]))[0]:E;if(j===void 0)return[];let N=R?s[j].trim():O.match(I?/^produces\s+event\s+([A-Za-z_]\w*)(?:\s+generation\s+\d+)?\s*$/:/^produces\s+([A-Z]\w*)\s*$/)?.[1];if(N===void 0||!/^[A-Za-z_]\w*$/.test(N))return[];let B=Ut(s,a,j,X(s[j])),L=B.map(G=>s[G].trim().match(/^for(?:\s+(.*))?$/)).filter(G=>G!==null),W=L.length===0?void 0:L.length===1?L[0][1]??"":"",z=B.flatMap(G=>{let V=s[G].trim().match(I?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return V===null?[]:[{name:V[1].replace(/^@/,""),source:V[2],line:G}]});return[{name:N,inline:I,conditional:R,line:E,target:W,mappings:z}]}),reads:k.filter(E=>!o[E]).map(E=>({line:E,match:t[E].match(Af)})).filter(E=>E.match!==null).map(({line:E,match:O})=>({view:O[1],...O[2]?{alias:O[2]}:{},...O[3]?{by:O[3]}:{},line:E})),line:p});continue}let P=f.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let k=hn(t,o,p,m).map(b=>({index:b,match:t[b].match(Rf)})).filter(b=>b.match!==null).map(({index:b,match:E})=>({name:E[1],type:E[2],typeReference:Wt(E[2]),sourceType:_r(t[b],t[b].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:b}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:Wt(P[2]),parameters:k,line:p});continue}let A=f.match(/^screen\s+(\w+)\s*$/);if(A){r.screens.push({name:A[1],line:p});continue}let S=f.match(/^trigger\s+(\w+)\s*$/);S&&m===0&&r.triggers.push({name:S[1],line:p})}return yn.size>=16&&yn.delete(yn.keys().next().value),yn.set(e,r),r}l(Sn,"scanDocument");function Oi(...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(Oi,"mergeSymbols");function Es(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...Oi(Sn(t),e??Oi()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}l(Es,"symbolsForBuffer");function Ii(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}l(Ii,"knownEventNames");var Df=["Startup","Shutdown"];function vI(t){return[...Ii(t),...t.triggers.map(e=>e.name),...Df]}l(vI,"knownTriggerNames");function Hr(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}l(Hr,"knownTypeNames");function Jr(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(Jr,"productionDestinations");function wI(t,e){let n=Ft(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=mt(t);return Sn(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}=Jr(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(wI,"destinationHints");var H={unknownConceptDirective:"PLAY0010",attributeReasonWithoutAttribute:"PLAY0012",duplicateAttributeReason:"PLAY0013",legacyComplianceMarker:"PLAY0565",unknownComplianceMarker:"PLAY0566",invalidSecretScope:"PLAY0567",duplicateSecretScope:"PLAY0568",secretScopeIgnoredForPii:"PLAY0569",invalidPersonalDataQualifier:"PLAY0570",duplicateSpecialCategory:"PLAY0571",duplicateEventSubject:"PLAY0590",invalidSubjectType:"PLAY0591",protectedSubjectType:"PLAY0592",invalidSubjectOwner:"PLAY0593",readModelSubjectNotSupported:"PLAY0594",invalidSubjectModifierOrder:"PLAY0595",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 Mf=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,jf=/^import\s+"/;function Ps(t){return jf.test(t.trim())}l(Ps,"isFileImportLine");function Xr(t,e){let n=X(t),i=t.slice(n).match(Mf);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(Xr,"fileImportOn");function DI(t){let e=be(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=Xr(t[i],i);r&&n.push(r)}return n}l(DI,"fileImports");var Cs=l(t=>t.split("/").slice(0,-1),"folderOf");function Nf(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(Nf,"relativeTo");function MI(t,e){let n=Cs(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=Nf(n,r),s=Cs(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(MI,"importablePaths");var Lf=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),qf=/^id\s+"((?:[^"\\]|\\.)*)"$/;function As(t,e,n,i=new Set){t=mt(t);let r=[],o=be(t),s=Bf(t,o),a=new Set(e.commands.flatMap(m=>m.productionHeaders??[])),c=new Map,p=new Set;for(let m of[e,n]){for(let h of m.events)c.set(h.name,(c.get(h.name)??0)+1);for(let h of m.imports)p.add(h.shortName)}let y=l((m,h,g,v="error")=>{r.push({line:m,startColumn:X(t[m])+1,endColumn:t[m].length+1,code:h,message:g,severity:v})},"report");for(let m of e.events){let h=Ut(t,o,m.line,X(t[m.line]));if(m.inline){let $=new Set;for(let C of m.properties)$.has(C.name)&&y(C.line,H.duplicateDeclaration,`Event '${m.name}' already declares property '${C.name}'.`),$.add(C.name);a.has(m.line)||y(m.line,H.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),m.generation!==void 0&&y(m.line,H.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((c.get(m.name)??0)>1||p.has(m.name))&&y(m.line,H.inlineEventCollision,`Inline event '${m.name}' collides with another declaration or import.`)}let g=!1,v=!1;for(let $ of h){let C=t[$].trim(),x=C.split(/\s+/)[0];if(m.inline&&x==="generation"&&y($,H.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),m.inline&&x==="origin"&&y($,H.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test(C)){if(x==="id"){let P=C.match(qf);g||P===null||P[1].trim().length===0?y($,H.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===m.name&&y($,H.redundantEventId,"This id repeats the event name; remove it.","information"),g=!0}if(x==="documentation"){let P=$+1;for(;P<t.length&&t[P].trim().length===0;)P++;(v||C!=="documentation"||t[P]?.trim()!=="```markdown"||X(t[P])<=X(t[$])||!s.has(P))&&y($,H.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),v=!0}}}}let f=[];for(let m=0;m<t.length;m++){if(o[m]||t[m].trim().length===0)continue;let h=X(t[m]);for(;f.length>0&&f[f.length-1].indent>=h;)f.pop();let g=t[m].trim().split(/\s+/)[0];Lf.has(g)&&f.at(-1)?.event&&y(m,H.reservedProductionMetadata,`'${g}' is system-assigned production metadata.`),g==="produces"&&f.push({indent:h,event:!i.has(m)&&!/^\s*produces\s+operation\b/.test(t[m])})}for(let m of e.commands){let{identifier:h,mixed:g}=Jr(m);for(let v of m.produces??[]){g&&v.target===void 0&&y(v.line,H.explicitProducesTargetsRequired,`Production '${v.name}' must state for explicitly when destinations differ.`);let $=v.target??(v.inline?h:void 0);if(!(h===void 0||$!==h))for(let C of v.mappings.filter(x=>x.source===h))y(C.line,H.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,v.inline?"warning":"information")}}return r}l(As,"validateInlineEvents");function Bf(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(Bf,"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 Ye(t,e,n,i,r,o){let s=n.indexOf(i)+1;return De(t,e,s,i.length,r,o)}l(Ye,"tokenIssue");function Yf(t,e,n){let i=[],r=new Set([...Hr(e,xn),...Hr(n,[])]),o=l((a,c)=>{for(let p of a.filter(y=>!r.has(yt(y).name))){let y=yt(p).name;i.push(De("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,y==="optional"?`Unknown type 'optional' on '${p.name}' of ${c} \u2014 did you forget the type before 'optional'?`:`Unknown type '${y}' on '${p.name}' of ${c} \u2014 declare it with 'concept ${y} : <Primitive>' or 'type ${y}'.`,H.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(Ye("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.`,H.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(Ye("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,H.duplicateDeclaration))}return i}l(Yf,"validateDeclarations");function aT(t,e={}){let n=be(t),i=Sn(t),r=e.application??Oi(),o=Es(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=Ft(t,o.authoringDocuments??o.authoringSources?.filter(b=>b!==t.join(`
32
- `)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(b=>b.location.line-1)),c={...i,commands:i.commands.map(b=>({...b,properties:b.properties.filter(E=>!a.has(E.line)),produces:b.produces?.filter(E=>!s.operationProductionLines?.has(E.line)),productionHeaders:b.productionHeaders?.filter(E=>!s.operationProductionLines?.has(E))}))},p=new Set([...Ii(c),...Ii(r)]),y=new Set([...c.policies,...r.policies].map(b=>b.name)),f=Yf(t,c,r);f.push(...Ff(t,c));let m=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]),g=new Set([d.UnknownEvent,d.UnknownReadModelProperty,d.PiiNotSupportedOnIdentifier]),v=new Set([d.EventFromLaterSlice,d.TimelineCycleGroup]),$=new Set([d.UndeclaredDependency,d.UnusedDependencyDeclaration,d.InvalidDependencyTarget,d.RepeatedDependencyDeclaration,d.MutualDependencyDeclarations,d.AmbiguousReference]),C=new Set([d.DuplicateEventSubject,d.InvalidSubjectType,d.ProtectedSubjectType,d.InvalidSubjectOwner,d.ReadModelSubjectNotSupported,d.InvalidSubjectModifierOrder,d.UnsupportedInteractionAlternatives,d.MixedInteractionAlternatives,d.InteractionAlternativeWithoutActions,d.InlineInteractionAlternative,d.LegacyInteractionWhere,d.InvalidDocumentation,d.ConflictingDocumentationAcrossFiles,d.InvalidAbsentReadModelStep,d.UnknownConstraintProperty,d.OmittedProductionDestination,d.InvalidSpecificationExample,d.DuplicateSpecificationAssignment]),x=new Set([d.UnknownConceptDirective,d.AttributeReasonWithoutAttribute,d.DuplicateAttributeReason,d.LegacyComplianceMarker,d.UnknownComplianceMarker,d.InvalidSecretScope,d.DuplicateSecretScope,d.SecretScopeIgnoredForPii,d.InvalidPersonalDataQualifier,d.DuplicateSpecialCategory]),P=new Set;for(let b of e.compilerDiagnostics??s.diagnostics){if(!x.has(b.code)&&!m.has(b.code)&&!h.has(b.code)&&!g.has(b.code)&&!v.has(b.code)&&!$.has(b.code)&&!C.has(b.code)&&b.code!==d.InvalidSpecificationExampleBody&&b.code!==d.UnknownRuleImplementationDirective&&b.code!==d.InvalidValidationRule&&b.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(b.code))continue;let E=b.location.line-1;if(b.code===d.OmittedProductionDestination&&f.some(I=>I.code===b.code&&I.line===E))continue;b.code===d.UnknownEvent&&P.add(E);let O=Br(t[E],b)||t[E].length-b.location.column+1;f.push(De(b.severity,E,b.location.column,O,b.message,b.code))}let A=l((b,E,O)=>{!p.has(O)&&!P.has(b)&&f.push(Ye("warning",b,E,O,`Unknown event type '${O}' \u2014 declare it in a slice or import it.`,H.unknownEvent))},"checkEvent"),S=-1;for(let b=0;b<t.length;b++){let E=t[b],O=E.trim();if(n[b]||O.length===0)continue;let I=E.match(/^[ ]*(\t+)/);if(I&&f.push(De("warning",b,I[0].length-I[1].length+1,I[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",H.tabIndentation)),S>=0){if(X(E)>S&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(O)){for(let V of O.split(/\s+/).filter(Z=>Z!=="or"))y.has(V)||f.push(Ye("warning",b,E,V,`Unknown policy '${V}' \u2014 declare it with 'policy ${V}'.`,H.unknownPolicy));continue}S=-1}let R=Uf(t,n,b);R&&f.push(R);let j=O.match(/^slice\s+(\w+)/);j&&!Mi.includes(j[1])&&f.push(Ye("error",b,E,j[1],`Unknown slice type '${j[1]}' \u2014 expected ${Mi.join(", ")}.`,H.unknownSliceType));let N=O.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!xn.includes(N[1])&&f.push(Ye("error",b,E,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${xn.join(", ")} or Enum.`,H.unknownPrimitiveType));let B=O.match(/^authorize\s+(.*)$/);if(B){S=X(E);for(let V of B[1].split(/\s+/).filter(Z=>Z!=="or"&&Z.length>0))y.has(V)||f.push(Ye("warning",b,E,V,`Unknown policy '${V}' \u2014 declare it with 'policy ${V}'.`,H.unknownPolicy))}let L=O.match(/^on\s+([A-Z]\w*)\s*$/);L&&A(b,E,L[1]);let W=O.match(/^produces\s+([A-Z]\w*)\s*$/);if(W&&!s.operationProductionLines?.has(b)&&A(b,E,W[1]),/^produces\s+when\b/.test(O)&&!s.operationProductionLines?.has(b))for(let V=b+1;V<t.length;V++){let Z=t[V];if(!(n[V]||Z.trim().length===0)){if(X(Z)>X(E)){let fe=Z.trim().match(/^([A-Z]\w*)\s*$/);fe&&A(V,Z,fe[1])}break}}let z=O.match(/^unique\s+event\s+([A-Z]\w*)/);z&&A(b,E,z[1]);let G=O.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);G&&A(b,E,G[1]);for(let V of E.match(/\$context\.[\w.]+/g)??[]){let Z=V.substring(9).split(".");Ti.includes(Z[0])?Z[0]==="causedBy"&&Z.length>1&&!Ri.includes(Z[1])?f.push(Ye("warning",b,E,V,`Unknown $context.causedBy property '${Z[1]}' \u2014 expected ${Ri.join(", ")}.`,H.unknownContextCausedByProperty)):Z[0]==="identity"&&Z.length>1&&!Di.includes(Z[1])&&f.push(Ye("warning",b,E,V,`Unknown $context.identity property '${Z[1]}' \u2014 expected ${Di.join(", ")}.`,H.unknownContextIdentityProperty)):f.push(Ye("warning",b,E,V,`Unknown $context path '${Z.join(".")}' \u2014 expected one of ${Ti.join(", ")}.`,H.unknownContextPath))}}f.push(...zf(t,n)),f.push(...As(t,c,r,s.operationProductionLines));let k=t.map((b,E)=>({line:b,index:E})).filter(({line:b})=>/^\s*```(?:[a-z]+)?\s*$/.test(b));if(k.length%2===1){let b=k[k.length-1];f.push(De("error",b.index,1,b.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",H.unclosedCodeBlock))}return f}l(aT,"validateLines");function Ff(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,X(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.`,H.omittedProductionDestination))}}return n}l(Ff,"validateProductionDestinations");function Uf(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||Xr(i,n))return;let o=X(i);if(!(!(o>0&&["module","feature"].includes(no(t,e,n,o)[0]))&&!Ps(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>"'.`,H.invalidFileImport)}l(Uf,"validateImport");var Wf=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function zf(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),y=c[2];if(y.length===0){c[1]&&n.push(De("error",r,(c.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(Bi("").expected)}.`,H.missingEventContextPath));continue}let f=y.substring(1),m=Bi(f),h=(c.index??0)+(c[1]?.length??0)+1;switch(m.status){case"missing":n.push(De("error",r,h,p.length,`'$eventContext.${f}' names no member - expected one of ${i(m.expected)}.`,H.missingEventContextPath));break;case"unknownMember":n.push(De("warning",r,h,p.length,`Unknown event context member '${m.segment}' in '$eventContext.${f}' - expected one of ${i(m.expected)}.`,H.unknownEventContextMember));break;case"unknownSubPath":{let g=m.expected.length===0?"no members to address":`members ${i(m.expected)}`;n.push(De("warning",r,h,p.length,`Unknown event context path '$eventContext.${f}' - '${m.member?.name}' (${m.member?.type}) has ${g}.`,H.unknownEventContextPath));break}case"belowCollection":n.push(De("error",r,h,p.length,`'$eventContext.${f}' cannot resolve - '${m.member?.name}' is a collection (${m.member?.type}) and cannot be addressed below.`,H.eventContextPathBelowCollection));break}}let s=o.trim().match(Wf)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(Ye("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.`,H.unresolvedDynamicKeySource))}return n}l(zf,"validateEventContextPaths");export{ws as a,Vf as b,Qf as c,to as d,Gf as e,Ti as f,Ri as g,Mi as h,xn as i,Zf as j,Os as k,_f as l,wi as m,Wt as n,Hf as o,d as p,ye as q,Gi as r,On as s,rP as t,oP as u,Me as v,X as w,ji as x,be as y,no as z,em as A,tm as B,mt as C,Ni as D,Li as E,qi as F,Is as G,am as H,sm as I,lm as J,Ts as K,Rs as L,ym as M,hm as N,Sm as O,gm as P,xm as Q,vm as R,$m as S,bm as T,km as U,Em as V,Cm as W,Ms as X,Pm as Y,Rm as Z,Dm as _,Mm as $,js as aa,jm as ba,Nm as ca,Lm as da,qm as ea,Ns as fa,Bm as ga,Ym as ha,Fm as ia,Um as ja,Wm as ka,zm as la,Vm as ma,Qm as na,Gm as oa,Zm as pa,_m as qa,Km as ra,Hm as sa,oo as ta,Ls as ua,Jm as va,Xm as wa,ey as xa,ty as ya,ny as za,qs as Aa,iy as Ba,Bs as Ca,ry as Da,oy as Ea,ay as Fa,sy as Ga,ly as Ha,eI as Ia,Ft as Ja,Gr as Ka,rI as La,Zr as Ma,oI as Na,yt as Oa,Ut as Pa,Sn as Qa,Oi as Ra,Es as Sa,Ii as Ta,Df as Ua,vI as Va,Hr as Wa,Jr as Xa,wI as Ya,H as Za,Ps as _a,Xr as $a,DI as ab,MI as bb,aT as cb,zf as db};
33
- //# sourceMappingURL=chunk-LLNOSA4X.js.map