@cratis/screenplay-language 4.123.0 → 4.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/chunk-7GSRLVHB.js +42 -0
- package/dist/bundles/chunk-7GSRLVHB.js.map +7 -0
- package/dist/bundles/index.js +2 -2
- package/dist/bundles/index.js.map +2 -2
- package/dist/bundles/sub-languages/projection/index.js +1 -1
- package/dist/completion-items.d.ts.map +1 -1
- package/dist/diagnostic-codes.d.ts +6 -0
- package/dist/diagnostic-codes.d.ts.map +1 -1
- package/dist/keyword-docs.d.ts.map +1 -1
- package/dist/language.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/bundles/chunk-4CLLEMBX.js +0 -42
- package/dist/bundles/chunk-4CLLEMBX.js.map +0 -7
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import{a as c}from"./chunk-AYDF3IFZ.js";var Rl="screenplay",Fy={id:Rl,extensions:[".play"],aliases:["Screenplay","screenplay","play"],mimetypes:["text/x-screenplay"]},Uy=["domain","import","concept","type","policy","purpose","persona","authentication","identity","module","layout","theme","ui","feature","slice","event","public","system","eventsource","operation","command","query","projection","capture","reaction","reducer","readmodel","trigger","screen","dialog","form","contribute","constraint","specification","case","parameter","example","seed","behavior","exposure","instance"];var Wo=["depends","direction","inbound","outbound","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","display","scopes","reexposes","operations","items","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"],Wy=["csharp","typescript","react","html","sql"],rr=["command","arguments","tenant","causedBy","causation","occurred","identity"],or=["subject","name","userName"],Pt=["id","name","userName","isAuthenticated","roles","claims"],ar=["StateChange","StateView","Automation","Translate"],Un=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Vy=["pii","personal","secret"],Dl=/^\s*(?:module|feature|slice\s+\w+|type|command|event|readmodel|reducer|projection|capture|reaction|screen|dialog|form|contribute|specification|case|constraint|persona|policy|behavior|layout|theme|ui\s+profile|trigger|authentication|identity|seed|system|eventsource|operation|screen\s+template|dialog\s+template|produces\s+event|validate|handler|on)\b[^=]*$/,zy={comments:{lineComment:"//"},brackets:[["(",")"],["[","]"]],autoClosingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],surroundingPairs:[{open:"(",close:")"},{open:"[",close:"]"},{open:'"',close:'"'}],folding:{offSide:!0},onEnterRules:[{beforeText:Dl,action:{indentAction:1}}],indentationRules:{increaseIndentPattern:/^\s*(module|feature|slice|policy|persona|authentication|identity|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 ln(t){let e=/^([\w.]+)(\[\])?(\?|\s+optional)?$/.exec(t);return{name:e?.[1]??t,isCollection:e?.[2]!==void 0,isOptional:e?.[3]!==void 0}}c(ln,"typeReferenceSymbol");function Gy(t){return`${t.name}${t.isCollection?"[]":""}${t.isOptional?" optional":""}`}c(Gy,"typeReferenceText");function Ae(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(Ae,"withoutComment");function ne(t){return t.length-t.trimStart().length}c(ne,"indentOf");function sr(t){return t.trim().split(/\s+/)[0]??""}c(sr,"firstWord");function Re(t){let e=new Array(t.length).fill(!1),n=!1;for(let i=0;i<t.length;i++){if(/^\s*```(?:[a-z]+)?\s*$/.test(t[i])&&(!n||/^\s*```\s*$/.test(t[i]))){e[i]=!0,n=!n;continue}e[i]=n}return e}c(Re,"fenceMap");function Vo(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ae(t[s]);if(a.trim().length===0)continue;let d=ne(a);d<o&&(r.push(sr(a)),o=d)}return r}c(Vo,"enclosingChain");function Ky(t,e,n,i){for(let r=n-1;r>=0&&i>0;r--){if(e[r])continue;let o=Ae(t[r]);if(o.trim().length!==0&&ne(o)<i)return o.trim()}}c(Ky,"nearestEnclosingLine");function Jy(t,e,n,i){let r=[],o=i;for(let s=n-1;s>=0&&o>0;s--){if(e[s])continue;let a=Ae(t[s]);if(a.trim().length===0)continue;let d=ne(a);d<o&&(r.push(a.trim()),o=d)}return r}c(Jy,"enclosingHeaders");var zo="EventContext",cn={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."}]},lr=[{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 cr(t,e){if(t.kind==="function")return e===t.name||e===`${t.name}()`;let n=t.name[0].toUpperCase()+t.name.slice(1);return e===n||e.length>0&&e[0].toUpperCase()+e.slice(1)===n}c(cr,"namesEventContextMember");var dr=cn[zo];function Ml(t){let e=dr;for(let n of t){let i=e.find(r=>cr(r,n));if(!i||i.kind==="collection"||i.kind==="function")return;e=cn[i.type]??[]}return e}c(Ml,"eventContextMembersAfter");function nh(t){return t.length===0?void 0:Ml(t.slice(0,-1))?.find(n=>cr(n,t[t.length-1]))}c(nh,"eventContextMemberAt");function pr(t){let e,n=dr;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=>cr(o,i));if(!r)return{status:e?"unknownSubPath":"unknownMember",member:e,segment:i,expected:n};e=r,n=r.kind==="function"?[]:cn[r.type]??[]}return{status:"known",member:e,expected:[]}}c(pr,"resolveEventContextPath");function ih(){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:**",...dr.map(t=>`- \`${t.name}\` (${t.type}) - ${t.description}`)].join(`
|
|
2
|
-
`)}c(ih,"describeEventContext");function rh(t,e){let n=e.kind==="collection"||e.kind==="function"?[]:cn[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
|
-
`)}c(rh,"describeEventContextMember");var yt={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 dn={label:"purpose",insertText:"purpose ${1:Name}",documentation:"Adds a declared processing purpose to the union covering this slice and its enclosing containers."},lh=[{label:"description",insertText:'description "${1:processing intent}"',documentation:"Describes the processing, not a legal verdict."},{label:"basis",insertText:"basis ${1|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}",documentation:"One Art. 6(1) lawful basis, with an optional quoted reference."},{label:"interest",insertText:'interest "${1:legitimate interests pursued}"',documentation:"Statement accompanying basis legitimateInterests."},{label:"condition",insertText:"condition ${1|explicitConsent,employmentLaw,vitalInterests,notForProfit,madePublic,legalClaims,substantialPublicInterest,healthCare,publicHealth,research|}",documentation:"Art. 9(2) condition for special-category data."},{label:"authorization",insertText:'authorization "${1:authorization in law}"',documentation:"Art. 10 authorization for criminal-offence data."},{label:"subjects",insertText:"subjects ${1:customer}",documentation:"Comma-separated open identifiers for categories of data subjects."},{label:"retention",insertText:'retention "${1:period or criteria}"',documentation:"Declared retention, not enforced."},{label:"recipient",insertText:'recipient "${1:recipient category}"',documentation:"Repeatable recipient category."},{label:"transfer",insertText:'transfer "${1:destination}" safeguard "${2:safeguard}"',documentation:"Repeatable destination and safeguards."},{label:"erasure exception",insertText:"erasure exception ${1|expression,legalObligation,publicTask,publicHealth,archiving,legalClaims|}",documentation:"Declared Art. 17(3) exception; does not change Chronicle per-subject erasure."}];var At=[{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 ur=[{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."}],Ll=[dn,yt,...At,{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."},...ur],jl=[dn,yt,...At,{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."},...ur],mh=[yt,{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."}],yh=[{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."}],hh=[{label:"description",insertText:'description "${1:input surface intent}"',documentation:"Report-only description of the form."},{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."},...ur],Sh=[{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."}],gh=[{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."}],Qe=c((t,e,n)=>({label:t,insertText:e,documentation:n}),"step"),Nl=[Qe("execute","execute ${1:command}","Runs a command."),Qe("navigate to","navigate to ${1:Screen}","Opens a screen."),Qe("open","open ${1:Dialog}","Opens a dialog."),Qe("close","close","Closes the dialog."),Qe("refresh","refresh ${1:query}","Reloads a query."),Qe("set","set ${1:name} ${2:value}","Sets a value."),Qe("notify",'notify ${1|info,warning,error|} "${2:message}"',"Shows a notification."),Qe("confirm","confirm ${1:message}\n on success\n ${2:execute command}","Asks before continuing."),Qe("raise","raise ${1:Trigger}","Raises a trigger.")],xh=[Qe("on success",'on success\n ${1:notify info "Done"}',"What happens when it succeeds."),Qe("on failure",'on failure\n ${1:notify error "Failed"}',"What happens when it fails."),...Nl],vh=[{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."}],$h=[{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."}],bh=[{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."}],kh=[{label:"compatible with",insertText:"compatible with ${1:Package}",documentation:"A component package the theme is compatible with."}],Eh=[{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."}],ql=[{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."}],Ch=[{label:"fits slot",insertText:"fits slot ${1:content}",documentation:"The slot of the shell the template fits."},...ql,{label:"on",insertText:"on ${1|enter,leave,load,unload|}\n ${2:refresh query}",documentation:"Wires what happens on an interaction."}];var Dh=[{label:"optional",insertText:"optional",documentation:"Allows the complete value, including a collection, to be absent."}],De=c(t=>`\`\`\`${t}
|
|
6
|
-
\${1}
|
|
7
|
-
\`\`\``,"fenced"),Mh=[{label:"description",insertText:'description "${1:caller details}"',documentation:"Describes the caller metadata."},{label:"detail from claim",insertText:'${1:detail} ${2:Type} from claim "${3:claim}"',documentation:"One typed detail sourced from a token claim."},{label:"detail from query",insertText:"${1:detail} ${2:Type} from query ${3:Query} by \\$identity.id",documentation:"A keyed, single-result query authorized without additional caller details."},{label:"detail from code",insertText:"${1:detail} ${2:Type}\n ```csharp\n ${3:return value;}\n ```",documentation:"An opaque inline source; authoring metadata, not executable."},{label:"detail from file",insertText:"${1:detail} ${2:Type}\n file ${3:Path}",documentation:"One file source; no refresh or cache directives."}];function Lh(t){let e=[...new Map((t.identityDetails??[]).map(n=>[n.name,n])).values()];return[...Vl,...e.filter(n=>!Pt.includes(n.name)).map(n=>({label:`$identity.${n.name}`,insertText:`\\$identity.${n.name}`,detail:n.type,documentation:"Declared caller detail. Authoring metadata only; executable reads report PLAY0268 until admitted (#600)."}))]}c(Lh,"contextVariableEntries");var jh=[{label:"identity",insertText:'identity\n ${1:detail} ${2:Type} from claim "${3:claim}"',documentation:"Typed additional caller details; authoring metadata only, at most one block per application."},{label:"purpose",insertText:'purpose ${1:Name}\n description "${2:processing intent}"\n basis ${3|consent,contract,legalObligation,vitalInterests,publicTask,legitimateInterests|}',documentation:"Report-only processing metadata. Not legal advice; referenced by module, feature and slice."},...At,{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 from",insertText:'import ${1:Module}.${2:Event} from "${3:origin}"',documentation:"Imports a public event contract with a nonblank opaque origin, not a file path. An import has no local shape, so executable binding still refuses it with PLAY0268."},{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."}],Nh=[{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."}],Bl=[{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:De(t),documentation:"Selects the phase\u2019s sole inline source; not admitted by any supported executable model (ESM) version yet."}))],qh=[{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."},...Bl.filter(t=>t.label!=="hint")],Bh=[{label:"description",insertText:'description "${1:what this value represents}"',documentation:"Report-only authoring description; not a validation or compliance note."},{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."}],Yh=[{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."}],Qo=[dn,yt,...At,{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:"public event",insertText:"public event ${1:Name}\n ${2:property} ${3:Type}",documentation:"Declares a public event: a contract this application publishes. Admitted by ESM v9; an outbound Translate slice produces it through a projection that targets it."},{label:"event from",insertText:'event ${1:Name} from "${2:origin}"\n ${3:property} ${4:Type}',documentation:"An event with an opaque origin naming the application that owns it, not a path or declaration reference. It is a public event admitted by ESM v9; consume it with a capture over source events."},{label:"direction",insertText:"direction ${1|inbound,outbound|}",documentation:"Translate direction, inbound or outbound, admitted by ESM v9. No transport or delivery guarantee is implied."},{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."}],Fh=[yt,{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
|
-
${De("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."}],Yl=[{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."}],Uh=[...Yl,{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."}],Wh=[{label:"when",insertText:"when ${1:condition}",documentation:"Guards the produced event with a condition."}],Vh=[{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:De(t),documentation:"Selects one inline payload. Handler execution remains unsupported."}))],zh=[{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:De("csharp"),documentation:"Inline C# returning the events to append."}],Qh=[{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."}],Gh=[{label:"file",insertText:"file ${1:Path}",documentation:"Delegates the query implementation to an external file."},{label:"csharp",insertText:De("csharp"),documentation:"Inline C# returning the query result, with the QueryContext in scope as context."},{label:"sql",insertText:De("sql"),documentation:"Inline SQL returning the query result."}],_h=[{label:"description",insertText:'description "${1:invariant intent}"',documentation:"Report-only description, distinct from the violation message."},{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."}],Zh=[yt,{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."}],Kh=[{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:De("csharp"),documentation:"Inline C# returning event side effects."}],ht="Syntax-only; reaction refusal handling and redelivery are not yet executable (PLAY0268).",Jh=[{label:"on refused",insertText:`on refused
|
|
11
|
-
acknowledge`,documentation:`Handles validation and constraint refusals, not authorization. ${ht}`},{label:"on refused by validation",insertText:`on refused by validation
|
|
12
|
-
acknowledge`,documentation:`Handles validation refusals. ${ht}`},{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. ${ht}`},{label:"on refused by authorization",insertText:`on refused by authorization
|
|
13
|
-
acknowledge`,documentation:`Explicitly handles unauthorized results, never Unsupported. ${ht}`}],Hh=[{label:"acknowledge",insertText:"acknowledge",documentation:`Acknowledges alone, without productions. ${ht}`},{label:"produces",insertText:"produces ${1:Event}\n ${2:reason} = \\$refusal.reason",documentation:`Records the refusal with ordinary event productions. ${ht}`}],Xh=[{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."}],eS=[{label:"parameter",insertText:"parameter ${1:name} ${2:Type}",documentation:"One typed value, supplied exactly once by every case."},{label:"case",insertText:"case ${1:Name}\n ${2:parameter} = ${3:value}",documentation:"One named complete set of concrete parameter values."},{label:"given caller as",insertText:"given caller as ${1:Persona}",documentation:"An authenticated deterministic witness of a top-level persona; no body. Use explicit callers for negation, ownership claims and implementations."},{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. ${ht}`},{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."}],Go={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. ${ht}`},{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."}]},Fl=[{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:De("csharp"),documentation:"Opaque named-rule predicate returning a bool. Requires an admitting target."}],tS=[{label:"implementation",insertText:'implementation\n hint "${1:predicate guidance}"',documentation:"Command named-rule intent with optional file or tagged fence. Pending intent cannot bind."},...Fl.filter(t=>t.label!=="hint")],nS=[{label:"file",insertText:"file ${1:Path}",documentation:"Gives the named predicate its implementation in an external C# file."},{label:"csharp",insertText:De("csharp"),documentation:"Gives the named predicate its implementation as inline C# returning a bool."}],iS=[{label:"description",insertText:'description "${1:authorization intent}"',documentation:"Report-only description; does not supply an implementation."},{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:De("csharp"),documentation:"Fully custom policy logic in C#, returning a bool."}],rS=[{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."}],oS=[{label:"description",insertText:'description "${1:screen intent}"',documentation:"Report-only description, not a localizable screen title."},{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:De("react"),documentation:"Inline React/TSX component receiving the data contract as Props."},{label:"typescript",insertText:De("typescript"),documentation:"Inline plain TypeScript."},{label:"html",insertText:De("html"),documentation:"Inline static HTML."}],Ul=[{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."}],aS=[{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."},...Ul.filter(t=>t.label!=="label")],Wl=[{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."}],sS=[{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."},...Wl],lS=[{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."}],cS=[{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."}],Vl=[...Pt.map(t=>({label:`$identity.${t}${t==="claims"?".":""}`,insertText:`$identity.${t}${t==="claims"?".${1:name}":""}`,documentation:`The caller's ${t}, equivalent to $context.identity.${t}.`})),{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."},...lr.filter(t=>t.name!=="value").map(t=>({label:`$eventContext.${t.path}`,insertText:`$eventContext.${t.path}`,documentation:`${t.description} (PDL)`}))],zl={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 dS(t){let e=t?zl[t]:void 0;return e?Qo.filter(n=>n.label==="purpose"||n.label==="example"||n.label==="documentation"||n.label==="public event"||n.label==="event from"||n.label==="direction"&&t==="Translate"||e.includes(n.label)):Qo}c(dS,"sliceItemsFor");var l={InvalidIdentityDeclaration:"PLAY0633",DuplicateIdentity:"PLAY0634",InvalidIdentityDetail:"PLAY0635",UnknownIdentitySource:"PLAY0636",IdentityDetailWithoutSource:"PLAY0637",IdentitySourceWithBody:"PLAY0638",DuplicateIdentityDetail:"PLAY0639",BuiltInIdentityDetail:"PLAY0640",UnknownIdentityQuery:"PLAY0641",InvalidIdentityQuery:"PLAY0642",IdentityQueryWithoutKey:"PLAY0643",InvalidIdentityQueryKey:"PLAY0644",IdentityQueryAuthorizationDependency:"PLAY0645",IdentityQueryTypeMismatch:"PLAY0646",CommandProducesPublicEvent:"PLAY0607",PublicEventRequiresOutboundTranslation:"PLAY0608",OutboundPublicEventCount:"PLAY0609",ForeignPublicEventConsumer:"PLAY0610",OutboundTranslationInput:"PLAY0611",InboundTranslationOutput:"PLAY0612",ForeignPublicEventProduced:"PLAY0613",PublicTranslationRequiresDirection:"PLAY0614",TranslationConstructDirection:"PLAY0615",InboundTranslationInput:"PLAY0616",OutboundTranslationOutput:"PLAY0617",EventTargetOutsideOutboundTranslation:"PLAY0618",EventsSourceOutsideInboundTranslation:"PLAY0619",InvalidCaptureEventsSource:"PLAY0620",InvalidExposureDeclaration:"PLAY0621",UnknownExposureOwner:"PLAY0622",ReExposureCycle:"PLAY0623",ReExposureBroken:"PLAY0624",InvalidInstanceContribution:"PLAY0625",UnknownContributionInstance:"PLAY0626",ContributionNotExposed:"PLAY0627",ContributionTypeMismatch:"PLAY0628",UnknownTemplateContentSlot:"PLAY0629",UnknownNavigationOutlet:"PLAY0630",TemplateScopeMismatch:"PLAY0631",IncompatibleComponentPackage:"PLAY0632",LegacyComplianceMarker:"PLAY0565",UnknownComplianceMarker:"PLAY0566",InvalidSecretScope:"PLAY0567",DuplicateSecretScope:"PLAY0568",SecretScopeIgnoredForPii:"PLAY0569",InvalidPersonalDataQualifier:"PLAY0570",DuplicateSpecialCategory:"PLAY0571",InvalidPurposeDeclaration:"PLAY0596",InvalidPurposeVocabulary:"PLAY0597",DuplicatePurposeField:"PLAY0598",DuplicatePurposeDeclaration:"PLAY0599",UnknownPurpose:"PLAY0600",PurposeInterestMismatch:"PLAY0601",PersonalDataWithoutPurpose:"PLAY0602",SpecialDataWithoutCondition:"PLAY0603",CriminalDataWithoutAuthorization:"PLAY0604",PurposeWithoutBasis:"PLAY0605",UnusedPurpose:"PLAY0606",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",InvalidSpecificationCallerPersona:"PLAY0572",UnsynthesizablePersonaCaller:"PLAY0573",PersonaWithoutGate:"PLAY0574",GateWithoutPersona:"PLAY0575",AmbiguousPersonaCaller:"PLAY0576",InvalidSpecificationParameter:"PLAY0577",InvalidSpecificationCase:"PLAY0578",DuplicateSpecificationParameter:"PLAY0579",DuplicateSpecificationCase:"PLAY0580",IncompleteSpecificationTable:"PLAY0581",InvalidSpecificationCaseAssignment:"PLAY0582",InvalidSpecificationCaseValue:"PLAY0583",InvalidSpecificationCaseReference:"PLAY0584",OptionalSpecificationParameterTarget:"PLAY0585",SpecificationCaseNameCollision:"PLAY0586",IncompatibleSpecificationParameterType:"PLAY0587",UnusedSpecificationParameter:"PLAY0588",SingularSpecificationTableExpansion:"PLAY0589",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 fr="\\p{L}\\p{Mn}\\p{Nd}\\p{Pc}",W="[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";function Z(t){let e=`(?=[\\u0000-\\uFFFF])[${fr}]`,n=t.replace(/\[([^\]]*\\w[^\]]*)\]/g,(i,r)=>{let o=r.replaceAll("\\w","");return o===""?`(?:${e})`:`(?:${e}|[${o}])`});return new RegExp(n.replaceAll("\\w",`(?:${e})`),"u")}c(Z,"nativePattern");function I(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?fr:`[${fr}]`:o==="d"?e+="\\p{Nd}":e+=`\\${o}`;continue}r==="["&&!n?n=!0:r==="]"&&n&&(n=!1),e+=r}return new RegExp(e,"u")}c(I,"pattern");var Ql=new RegExp(`^depends${W}+on(?:${W}|$)`,"u"),Gl=new RegExp(`${W}+$`,"u");function Lt(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,d=a.length-a.trimStart().length,p=_l(a.substring(d),e),m=Ql.test(p)?p.replace(Gl,""):p.trimEnd();i.push(n===void 0?{number:r,raw:a,indent:d,content:m,startOffset:o}:{number:r,raw:a,indent:d,content:m,path:n,startOffset:o}),o+=s.length+1}return i}c(Lt,"splitLines");function pn(t,e=!1){let n=!1,i=!1;for(let r=0;r<t.length;r++){let o=t[r];if(o==="\\"&&n&&r+1<t.length)r++;else if(o==='"'&&!i)n=!n;else if(o==="`"&&!n)i=!i;else if(!n&&!i&&(o==="/"&&r+1<t.length&&t[r+1]==="/"||e&&o==="#"))return r}return-1}c(pn,"commentStart");function _l(t,e){let n=pn(t,e);return n<0?t:t.substring(0,n)}c(_l,"stripComment");function le(t){return[...t.events,...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineEvent===null?[]:[e.inlineEvent])]}c(le,"eventDeclarations");function Wn(t){return[...t.operations??[],...t.commands.flatMap(e=>e.produces).flatMap(e=>e.inlineOperation==null?[]:[e.inlineOperation])]}c(Wn,"operationDeclarations");var H;(function(t){t.Event="event",t.Operation="operation",t.Unresolved="unresolved",t.Ambiguous="ambiguous"})(H||(H={}));var ie=class{static{c(this,"AuthoringProductionResolver")}declarations=[];slices=[];byName=new Map;scopes=new Map;resolutions=new Map;constructor(e,n){let i=c((r,o)=>{for(let s of r){let a=[...o,s.name];for(let d of s.slices)this.slices.push({slice:d,scope:[...a,d.name]});i(s.features,a)}},"collect");e.modules.forEach(r=>i(r.features,[r.name]));for(let{slice:r,scope:o}of this.slices){this.scopes.set(r,o);let s=new Map;for(let d of le(r)){let p=s.get(d.name)??[];p.push(d),s.set(d.name,p)}let a=[...s.values()].flatMap(d=>new Set(d.map(p=>p.generation)).size!==d.length?d:[d.reduce((p,m)=>p.generation>=m.generation?p:m)]);this.declarations.push(...a.map(d=>({kind:H.Event,name:d.name,node:d,scope:o})),...Wn(r).map(d=>({kind:H.Operation,name:d.name,node:d,scope:o})))}n!==void 0&&this.declarations.splice(0,this.declarations.length,...n);for(let r of this.declarations){let o=this.byName.get(r.name)??[];o.push(r),this.byName.set(r.name,o)}}resolve(e,n){let i=this.scopes.get(n);if(i===void 0)return{kind:H.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.resolveFromScope(e,i);return r.set(e,s),this.resolutions.set(n,r),s}resolveFromScope(e,n){let i=this.candidates(e,n);return i.length===1?{kind:i[0].kind,declaration:i[0],candidates:[]}:{kind:i.length===0?H.Unresolved:H.Ambiguous,declaration:null,candidates:i}}isOperation(e,n){return e.inlineOperation!=null||this.resolve(e.event,n).kind===H.Operation}isEventProduction(e,n){if(e.inlineOperation!=null)return!1;let i=this.resolve(e.event,n);return i.kind!==H.Operation&&!(i.kind===H.Ambiguous&&i.candidates.some(r=>r.kind===H.Operation))}candidates(e,n){let i=e.split(".").filter(s=>s.length>0);if(i.length===0)return[];let 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,d)=>s.scope[s.scope.length-o.length+d]===a));for(let s=n.length;s>=0;s--){let a=r.filter(d=>s<=d.scope.length&&n.slice(0,s).every((p,m)=>d.scope[m]===p));if(a.length>0)return a}return[]}};var ot=new WeakMap,Se=c(t=>ot.get(t)??{},"dependencySourcesOf");var Ce=class{static{c(this,"ScreenplaySyntaxWalker")}visitNode(e){}visitApplication(e){this.visitNode(e),e.domain!==null&&this.visitDomain(e.domain),e.imports.forEach(n=>this.visitImport(n)),e.fileImports.forEach(n=>this.visitFileImport(n)),e.systems?.forEach(n=>this.visitSystem(n)),e.eventSources?.forEach(n=>this.visitEventSource(n)),e.concepts.forEach(n=>this.visitConcept(n)),e.types.forEach(n=>this.visitType(n)),e.personas.forEach(n=>this.visitPersona(n)),e.policies?.forEach(n=>this.visitPolicy(n)),e.exposures?.forEach(n=>{this.visitNode(n),n.properties.forEach(i=>this.visitNode(i))}),e.instanceContributions?.forEach(n=>{this.visitNode(n),n.contributions.forEach(i=>{this.visitNode(i),i.value!==null&&this.visitExpression(i.value),i.items.forEach(r=>{this.visitNode(r),r.values.forEach(o=>{this.visitNode(o),this.visitExpression(o.value)})})})}),e.identity!=null&&this.visitIdentity(e.identity),e.purposes?.forEach(n=>this.visitPurpose(n)),e.seeds?.forEach(n=>this.visitSeed(n)),e.modules.forEach(n=>this.visitModule(n)),e.examples?.forEach(n=>this.visitSpecificationExample(n))}visitIdentity(e){this.visitNode(e),e.details.forEach(n=>this.visitIdentityDetail(n))}visitIdentityDetail(e){this.visitNode(e),this.visitTypeRef(e.type),this.visitIdentitySource(e.source)}visitIdentitySource(e){switch(e.kind){case"ClaimIdentitySourceSyntax":this.visitClaimIdentitySource(e);break;case"QueryIdentitySourceSyntax":this.visitQueryIdentitySource(e);break;case"CodeIdentitySourceSyntax":this.visitCodeIdentitySource(e);break;case"FileIdentitySourceSyntax":this.visitFileIdentitySource(e);break;default:this.visitNode(e);break}}visitClaimIdentitySource(e){this.visitNode(e)}visitQueryIdentitySource(e){this.visitNode(e),this.visitExpression(e.by)}visitCodeIdentitySource(e){this.visitNode(e),this.visitCodeBlock(e.code)}visitFileIdentitySource(e){this.visitNode(e),this.visitFileReference(e.file)}visitPurpose(e){this.visitNode(e),e.transfers.forEach(n=>this.visitPurposeTransfer(n))}visitPurposeReference(e){this.visitNode(e)}visitPurposeTransfer(e){this.visitNode(e)}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.purposes?.forEach(n=>this.visitPurposeReference(n)),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.purposes?.forEach(n=>this.visitPurposeReference(n)),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.purposes?.forEach(n=>this.visitPurposeReference(n)),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.columns?.forEach(n=>this.visitNode(n)),e.layout!==null&&e.layout!==void 0&&(this.visitNode(e.layout),e.layout.columns.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width),n.minWidth!==null&&this.visitNode(n.minWidth),n.maxWidth!==null&&this.visitNode(n.maxWidth)}),e.layout.columnGap!==null&&this.visitNode(e.layout.columnGap),e.layout.rowGap!==null&&this.visitNode(e.layout.rowGap),e.layout.placements.forEach(n=>{this.visitNode(n),n.width!==null&&this.visitNode(n.width)})),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)),e.contributions?.forEach(n=>{this.visitNode(n),n.directives.forEach(i=>this.visitScreenDirective(i))})}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.visitUiBinding(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.visitUiBinding(e.context),e.properties.forEach(n=>{this.visitNode(n),n.binding!==null&&this.visitUiBinding(n.binding),n.value!==null&&this.visitExpression(n.value)}),e.exposes.forEach(n=>{this.visitNode(n),this.visitUiBinding(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.visitUiBinding(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.parameters?.forEach(n=>{this.visitNode(n),this.visitTypeRef(n.type)}),e.cases?.forEach(n=>{this.visitNode(n),n.values.forEach(i=>this.visitPropertyMapping(i))}),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.givenCallerPersona!=null&&this.visitNode(e.givenCallerPersona),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),n.caseValue!=null&&this.visitExpression(n.caseValue)})}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)}visitUiBinding(e){this.visitNode(e),e.literal!==null&&this.visitExpression(e.literal)}visitIdentityExpression(e){this.visitNode(e)}visitExpression(e){if(e.kind==="IdentityExpressionSyntax"){this.visitIdentityExpression(e);return}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 mr="79228162514264337593543950335";function at(t){let e=_o(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>mr.length)return;let a=n.substring(i,r)+"0".repeat(s);if(a.length===mr.length&&a>mr)return;let d=Math.max(0,o),p=d===0?a:a.length>d?`${a.substring(0,a.length-d)}.${a.substring(a.length-d)}`:`0.${"0".repeat(d-a.length)}${a}`;return Object.freeze({literalType:"ExactNumber",value:(e.negative?"-":"")+p})}c(at,"parseExactNumber");function un(t){return _o(t)!==void 0}c(un,"isExactNumberToken");function _o(t){let e=t.startsWith("-"),n=e?1:0,i=n;for(;i<t.length&&yr(t[i]);)i++;if(i===n)return;let r=t.substring(n,i),o="";if(t[i]==="."){let a=++i;for(;i<t.length&&yr(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 d=i,p=t.length+29;for(;i<t.length&&yr(t[i]);)s=Math.min(p,s*10+t.charCodeAt(i++)-48);if(i===d)return;a&&(s=-s)}return i===t.length?{negative:e,integer:r,fraction:o,exponent:s}:void 0}c(_o,"scan");function yr(t){return t>="0"&&t<="9"}c(yr,"isDigit");var z='(?:[^"\\\\]|\\\\.)*',Zl={"\\":"\\",'"':'"',n:`
|
|
15
|
-
`,r:"\r",t:" "};function Q(t){if(!t.includes("\\"))return t;let e="";for(let n=0;n<t.length;n++){let i=n+1<t.length?Zl[t[n+1]]:void 0;t[n]==="\\"&&i!==void 0?(e+=i,n++):e+=t[n]}return e}c(Q,"unescapeString");var Zo=64,qe=class extends Error{static{c(this,"InvalidStructuredValue")}},Vn=class{static{c(this,"StructuredValueParser")}text;start;context;#e=0;constructor(e,n,i){this.text=e,this.start=n,this.context=i}parse(){let e=this.#t(0);if(this.#n(),this.#e<this.text.length)throw new qe(`'${this.text[this.#e]}' is invalid after a single JSON value.`);return e}#t(e){this.#n();let n=this.#a(),i=this.text[this.#e];if(i==="["||i==="{"){if(e>=Zo)throw new qe(`The value nests deeper than ${Zo} levels.`);return i==="["?this.#s(e,n):this.#i(e,n)}if(i==='"')return{kind:"LiteralExpressionSyntax",value:this.#r(),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.#l(n)}#s(e,n){this.#e++;let i=[];if(this.#n(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};for(;;){if(i.push(this.#t(e+1)),this.#n(),this.#c("]"))return{kind:"ListExpressionSyntax",items:i,location:n};this.#d(",")}}#i(e,n){this.#e++;let i=[],r=new Set;if(this.#n(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};for(;;){this.#n();let o=this.#a();if(this.text[this.#e]!=='"')throw new qe("Expected a property name in double quotes.");let s=this.#r();this.#n(),this.#d(":");let a=this.#t(e+1);if(r.has(s)?this.context?.error(l.DuplicateStructuredValueMember,`Duplicate property '${s}' in structured value`,o):(r.add(s),i.push({kind:"ObjectMemberSyntax",name:s,value:a,location:o})),this.#n(),this.#c("}"))return{kind:"ObjectExpressionSyntax",members:i,location:n};this.#d(",")}}#r(){let e=this.#o(this.#e),n=this.text.substring(this.#e,e);this.#e=e;try{return JSON.parse(n)}catch{throw new qe(`${n} is not a valid JSON string.`)}}#o(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 qe("A string is not closed.")}#l(e){let n=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(this.text.substring(this.#e));if(n===null)throw new qe(`'${this.text[this.#e]??""}' is an invalid start of a value.`);if(this.#e+=n[0].length,this.context?.sourceOptions.numericMode==="exact"){let r=at(n[0]);return r===void 0?(this.context.error(l.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:n[0],location:e}):{kind:"LiteralExpressionSyntax",value:r,location:e}}let i=Number(n[0]);if(!Number.isFinite(i))throw new qe("JSON number is outside the finite Double range.");return{kind:"LiteralExpressionSyntax",value:i,location:e}}#a(){return{...this.start,column:this.start.column+this.#e}}#n(){for(;this.#e<this.text.length&&`
|
|
16
|
-
\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 qe(`Expected '${e}' at position ${this.#e}.`)}};var Kl=I("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Jl=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$"),Hl=I("^-?\\d+(\\.\\d+)?$"),Ko=["command","arguments","tenant","causedBy","causation","occurred","identity"],Jo=["subject","name","userName"],Ke=["id","name","userName","isAuthenticated","roles","claims"];function Be(t,e,n){return ae(t,e,n,!0)}c(Be,"parseModeledMappingSource");function ae(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==="$identity"||t==="$identity.")return n?.error(l.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e};if(t.startsWith("$identity.")){let o=t.substring(10);return n?.deferIdentityValidation!==!0&&Ho(o.split(".")[0],"$identity",e,n),{kind:"IdentityExpressionSyntax",path:o,location:e}}if(t.startsWith("$context.")){let o=t.substring(9);return Xl(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 Vn(t,e,n).parse()}catch(o){if(!(o instanceof qe))throw o;return n?.error(l.InvalidStructuredValue,`Invalid inline structured value: ${o.message}`,e),{kind:"RawExpressionSyntax",text:t,location:e}}let r=n===void 0?fn(t,e):fn(t,e,n);return r!==void 0?r:(i||n?.sourceOptions.numericMode==="exact"?Jl:Kl).test(t)?{kind:"PathExpressionSyntax",path:t,location:e}:{kind:"RawExpressionSyntax",text:t,location:e}}c(ae,"parseMappingSource");function Xl(t,e,n){let[i,r]=t.split(".");Ko.includes(i)?r!==void 0&&i==="causedBy"&&!Jo.includes(r)?n?.warning(l.UnknownContextCausedByProperty,`Unknown $context.causedBy property '${r}' - expected ${Jo.join(", ")}`,e):r!==void 0&&i==="identity"&&Ho(r,"$context.identity",e,n):n?.warning(l.UnknownContextPath,`Unknown $context path '${t}' - expected one of ${Ko.join(", ")}`,e)}c(Xl,"warnOnUnknownContextPath");function Ho(t,e,n,i){Ke.includes(t)||i?.warning(l.UnknownContextIdentityProperty,`Unknown ${e} property '${t}' - expected ${Ke.join(", ")}`,n)}c(Ho,"warnOnUnknownIdentityProperty");function fn(t,e,n){let i=c(o=>({kind:"LiteralExpressionSyntax",value:o,location:e}),"literal");switch(t){case"true":return i(!0);case"false":return i(!1);case"null":return i(null)}if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")))return i(Q(t.substring(1,t.length-1)));if(n?.sourceOptions.numericMode==="exact"){if(!un(t))return;let o=at(t);return o!==void 0?i(o):(n.error(l.InexactNumericLiteral,"Numeric literal is not exactly representable in the bounded Decimal domain.",e),{kind:"RawExpressionSyntax",text:t,location:e})}if(Hl.test(t)&&!Number.isNaN(Number(t)))return i(Number(t))}c(fn,"parseLiteral");function zn(t,e){let n=t.identity?.details??[],i=new Set(n.map(a=>a.name)),r=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(a=>a.name),...t.types.map(a=>a.name),...t.imports.map(a=>a.qualifiedName.split(".").at(-1))]),o=new ie(t);for(let{slice:a}of o.slices){for(let d of a.readModels)r.add(d.name);for(let d of a.projections){let p=d.blocks.filter(m=>m.kind==="ProjectionVariantSyntax");for(let m of p.length>0?p.map(u=>u.name):[d.readModel??d.name])r.add(m)}for(let d of Se(a).reducers??[])r.add(d.readModel)}new Sr(i,e).visitApplication(t);let s=new Set;for(let a of n){if(s.has(a.name)&&e.error(l.DuplicateIdentityDetail,`Duplicate identity detail '${a.name}' - detail names must be unique`,a.location),s.add(a.name),Ke.includes(a.name)&&e.error(l.BuiltInIdentityDetail,`Identity detail '${a.name}' redeclares a built-in caller property`,a.location),r.has(a.type.name)||e.warning(l.UnknownType,`Unknown type '${a.type.name}' on identity detail '${a.name}'`,a.type.location),a.source.kind!=="QueryIdentitySourceSyntax")continue;let d=a.source;ec(d.by)||e.error(l.InvalidIdentityQueryKey,`Identity detail '${a.name}' query key may reference only caller built-ins, claims or literals, never another detail`,d.by.location);let p=d.query.split("."),m=p.at(-1),u=p.slice(0,-1),y=o.slices.flatMap(({slice:g,scope:P})=>g.queries.map(w=>({query:w,scope:P}))).filter(g=>g.query.name===m&&u.length<=g.scope.length&&u.every((P,w)=>P===g.scope[g.scope.length-u.length+w]));if(y.length!==1){e.error(l.UnknownIdentityQuery,`Unknown or ambiguous identity query '${d.query}'`,d.location);continue}let{query:h,scope:x}=y[0];(h.by===null||h.returnType.isCollection)&&e.error(l.InvalidIdentityQuery,`Identity query '${d.query}' must be keyed and return a single, possibly optional result`,d.location),(h.returnType.name!==a.type.name||a.type.isCollection||h.returnType.isOptional&&!a.type.isOptional)&&e.error(l.IdentityQueryTypeMismatch,`Identity detail '${a.name}' must match query '${d.query}' result type, including optionality`,a.type.location);let b=h.authorize===null?[]:[h.authorize];for(let g of t.modules.filter(P=>P.name===x[0]))g.authorize!==null&&b.push(g.authorize),Xo(g.features,x.slice(1,-1),b);let S=new Set(b.flatMap(g=>hr(g.requirement))),$=new gr(i);for(let g of(t.policies??[]).filter(P=>S.has(P.name)))$.visitPolicy(g);$.found.length>0&&e.error(l.IdentityQueryAuthorizationDependency,`Identity query '${d.query}' authorization depends on identity detail '${$.found[0].path.split(".")[0]}' - caller details cannot authorize their own resolution`,d.location)}}c(zn,"validateIdentity");function ec(t){return t.kind==="LiteralExpressionSyntax"?!0:t.kind==="IdentityExpressionSyntax"?Ke.includes(t.path.split(".")[0]):t.kind==="ContextExpressionSyntax"&&t.path.startsWith("identity.")&&Ke.includes(t.path.split(".")[1])}c(ec,"isTokenKey");function hr(t){return t.kind==="PolicyReferenceSyntax"?[t.name]:[...hr(t.left),...hr(t.right)]}c(hr,"policyNames");function Xo(t,e,n){for(let i of t.filter(r=>r.name===e[0]))i.authorize!==null&&n.push(i.authorize),Xo(i.features,e.slice(1),n)}c(Xo,"collectFeatureAuthorizations");var Sr=class extends Ce{static{c(this,"IdentityPaths")}details;context;constructor(e,n){super(),this.details=e,this.context=n}visitExpression(e){if(e.kind==="ContextExpressionSyntax"&&e.path.startsWith("identity.")){let n=e.path.split(".")[1];!Ke.includes(n)&&!this.context.diagnostics.some(i=>i.code===l.UnknownContextIdentityProperty&&i.location.line===e.location.line&&i.location.column===e.location.column)&&this.context.warning(l.UnknownContextIdentityProperty,`Unknown $context.identity property '${n}' - expected ${Ke.join(", ")}`,e.location)}super.visitExpression(e)}visitIdentityExpression(e){let n=e.path.split(".")[0];!this.details.has(n)&&!Ke.includes(n)&&this.context.warning(l.UnknownContextIdentityProperty,`Unknown $identity property '${n}' - expected ${[...Ke,...this.details].join(", ")}`,e.location)}},gr=class extends Ce{static{c(this,"DetailReferences")}details;found=[];constructor(e){super(),this.details=e}visitIdentityExpression(e){this.details.has(e.path.split(".")[0])&&this.found.push(e)}};var pe;(function(t){t.Unique="unique",t.Ambiguous="ambiguous",t.NotFound="notFound",t.WrongKind="wrongKind"})(pe||(pe={}));var Ye=class{static{c(this,"EventSourceCatalog")}sources=new Map;otherNames;constructor(e){for(let n of e.eventSources??[])this.sources.set(n.name,[...this.sources.get(n.name)??[],n]);this.otherNames=new Set([...e.concepts,...e.types].map(n=>n.name))}resolve(e,n){let i=this.sources.get(e)??[],r=i.flatMap(s=>s.streams).filter(s=>s.name===n),o;return i.length===0?o=this.otherNames.has(e)?pe.WrongKind:pe.NotFound:i.length>1||r.length>1?o=pe.Ambiguous:o=r.length===1?pe.Unique:pe.NotFound,{kind:o,sources:i,streams:r}}};function ea(t,e){return t.produces.filter(n=>n.inlineOperation==null&&(e===void 0||e.resolver.isEventProduction(n,e.slice)))}c(ea,"eventProductions");function xr(t,e){let n=ea(t,e),i=t.properties.find(r=>r.isIdentifier)?.name;return n.some(r=>r.for!==null&&(r.for.kind!=="PathExpressionSyntax"||r.for.path!==i))||n.some(r=>r.inlineEvent!==null&&r.for===null)&&n.some(r=>r.inlineEvent===null&&r.for===null)}c(xr,"requiresExplicitDestinations");function ta(t,e,n){let i=ea(t,n);if(e.inlineOperation!=null||n!==void 0&&!n.resolver.isEventProduction(e,n.slice)||e.for!==null||xr(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}c(ta,"implicitDestination");var vr=class extends Error{static{c(this,"InvalidExactNumber")}};function $r(t){if(t.literalType!=="ExactNumber"||typeof t.value!="string"||at(t.value)?.value!==t.value)throw new vr("Expected a canonical, bounded ExactNumber value.");return t.value}c($r,"canonicalExactText");function na(t){return!$r(t).includes(".")}c(na,"exactIsIntegral");var tc=/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/,nc=/^([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 br(t,e){let n=(e?nc:tc).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 d=Number(n[7]),p=Number(n[8]);return d<=14&&p<=59&&(d!==14||p===0)}c(br,"responseDateValue");var ic="http://schemas.microsoft.com/ws/2008/06/identity/claims/role",kr=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),St=c(t=>Array.from(t,e=>{let n=e.toUpperCase();return n.length===e.length&&e!=="\u0131"&&e!=="\u017F"?n:e}).join(""),"claimTypeKey");function yn(t,e){let n=[],i=[],r=c(a=>({caller:null,contributions:n,refusal:a}),"refused");if(t.policies.length===0)return r({policy:null,reason:"noPolicies",location:t.location});for(let a of t.policies){let d=(e.policies??[]).find(m=>m.name===a);if(!d)return r({policy:a,reason:"unresolvedPolicy",location:t.location});if(d.condition===null||d.code!==null||d.file!==null)return r({policy:a,reason:"opaqueImplementation",location:d.location});let p=Er(d.condition);if(p)return r({policy:a,reason:"negation",location:p.location});i.push(d)}for(let a of i){let d=Cr(a.condition,a.name,n);if(d)return r(d)}for(let a of i){let d=mn(a.condition,a.name,n);if(d)return r(d)}let o=[...new Set(n.filter(a=>a.kind==="role").map(a=>a.value))].sort(kr),s=[];for(let a of n.filter(d=>d.kind==="claim"))s.some(d=>St(d.type)===St(a.type)&&d.value===a.value)||s.push({kind:"SpecificationCallerClaimSyntax",type:a.type,value:a.value,location:a.location});return s.sort((a,d)=>kr(St(a.type),St(d.type))||kr(a.value,d.value)),{caller:{kind:"SpecificationCallerSyntax",authenticated:!0,roles:o,claims:s,location:t.location},contributions:n,refusal:null}}c(yn,"synthesizePersonaCaller");function Er(t){return t.kind==="NotPolicyConditionSyntax"?t:t.kind==="LogicalPolicyConditionSyntax"?Er(t.left)??Er(t.right):null}c(Er,"negation");function ia(t,e,n){switch(t.kind){case"AuthenticatedConditionSyntax":return n.push({kind:"authenticated",value:"true",type:null,policy:e,location:t.location}),null;case"RoleConditionSyntax":return n.push({kind:"role",value:t.role,type:null,policy:e,location:t.location}),null;case"ClaimConditionSyntax":if(St(t.claim)===St(ic))return{policy:e,reason:"roleClaim",location:t.location};if(!t.matchesSubject&&t.matches?.kind==="LiteralExpressionSyntax"&&typeof t.matches.value=="string")return n.push({kind:"claim",value:t.matches.value,type:t.claim,policy:e,location:t.location}),null}return{policy:e,reason:"nonLiteralClaim",location:t.location}}c(ia,"atom");function Cr(t,e,n){return t.kind!=="LogicalPolicyConditionSyntax"?ia(t,e,n):t.operator==="Or"?null:Cr(t.left,e,n)??Cr(t.right,e,n)}c(Cr,"required");function jt(t,e){switch(t.kind){case"AuthenticatedConditionSyntax":return!0;case"RoleConditionSyntax":return e.some(n=>n.kind==="role"&&n.value===t.role);case"ClaimConditionSyntax":{let n=t.matches;return!t.matchesSubject&&n?.kind==="LiteralExpressionSyntax"&&e.some(i=>i.kind==="claim"&&St(i.type)===St(t.claim)&&i.value===n.value)}case"LogicalPolicyConditionSyntax":return t.operator==="And"?jt(t.left,e)&&jt(t.right,e):jt(t.left,e)||jt(t.right,e);default:return!1}}c(jt,"satisfied");function mn(t,e,n){if(t.kind!=="LogicalPolicyConditionSyntax")return jt(t,n)?null:ia(t,e,n);if(t.operator==="And")return mn(t.left,e,n)??mn(t.right,e,n);if(jt(t,n))return null;let i=[...n],r=mn(t.left,e,i);if(r===null)return n.push(...i.slice(n.length)),null;let o=[...n];return mn(t.right,e,o)!==null?r:(n.push(...o.slice(n.length)),null)}c(mn,"complete");var Pr=new WeakMap;var D=c(t=>{let e=t.indexOf(" ");return e===-1?t:t.substring(0,e)},"firstWord"),re=c(t=>t.replaceAll("@",""),"unescapeIdentifier");function ra(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}c(ra,"splitTopLevel");var Nt=c((t,e,n)=>n===void 0?{line:t,column:e}:{line:t,column:e,path:n},"sourceLocation");var Ar=c(t=>t.content.length===0,"isBlank"),f=c(t=>Nt(t.number,t.indent+(t.contentOffset??0)+1,t.path),"locationOf"),oa=c(t=>Nt(t.number,1,t.path),"startOf");var rc=I("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+(generated))?(?:\\s+(identifier))?(?:\\s+(subject))?$"),aa=I("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\??\\s+((?:optional|generated|identifier|subject)(?:\\s+(?:optional|generated|identifier|subject))*)$"),oc=I("^@?[a-z_]\\w*\\s+[\\w.]+(?:\\[\\])?\\s+identifier\\s+optional(?:\\s*=.*)?$");function Je(t){let e=rc.exec(t.content);if(e===null)return;let n=f(t);return{kind:"PropertySyntax",name:re(e[1]),type:we(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}}c(Je,"tryParseProperty");function we(t,e){let n=t.endsWith("?"),i=/\soptional$/.test(t),r=n||i;r&&(t=t.substring(0,t.length-(n?1:8)).trimEnd());let o=t.endsWith("[]");return o&&(t=t.substring(0,t.length-2)),{kind:"TypeRefSyntax",name:t,isCollection:o,isOptional:r,location:e}}c(we,"parseTypeRef");function Fe(t,e){let n=Je(e);return n!==void 0?Me(t,n.type,e):Qn(t,e),n}c(Fe,"parseProperty");function Me(t,e,n){t.claimField(n);let i=e.name.length+(e.isCollection?2:0),r=e.location.column-n.indent-1+i;if(e.isOptional&&n.content[r]==="?"){let o=e.name+(e.isCollection?"[]":"");t.information(l.LegacyOptionalSuffix,`Write '${o} optional' instead of '${o}?'.`,e.location)}}c(Me,"reportLegacyOptionalSuffix");function Qn(t,e){let n=aa.exec(e.content);if(n!==null&&n[1].split(/\s+/).includes("subject"))return t.error(l.InvalidSubjectModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier subject'.",f(e)),!0;if(oc.test(e.content))return t.error(l.InvalidOptionalModifierOrder,"Write 'optional' before 'identifier': '<name> <Type> optional identifier'.",f(e)),!0;{let i=aa.exec(e.content);if(i!==null&&i[1].split(/\s+/).some(r=>r==="generated"||r==="identifier"))return t.error(l.InvalidGeneratedModifierOrder,"Write each modifier once in order: '<name> <Type> optional generated identifier'.",f(e)),!0}return!1}c(Qn,"reportInvalidModifierOrder");var wr=I("^then\\s+returns\\b"),Gn=I("^generated\\s+(?=\\S)(?![=])"),_n=I("^generated\\s+([a-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$"),ac=I("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),sc=I(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`);function qt(t,e,n,i){if(e.startsWith("case."))return Le(e,n,t);if(Yt(e)&&t.error(l.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",n),(e.startsWith('"')||e.startsWith("'"))&&!sc.test(e))return t.error(i,"Expected exactly one concrete value.",n),null;let r=ae(e,n,t);return!["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(r.kind)||r.kind==="LiteralExpressionSyntax"&&typeof r.value=="number"&&!Number.isFinite(r.value)?(t.error(i,"Expected exactly one concrete literal or structured value, not an expression.",n),null):r}c(qt,"parseConcrete");function Bt(t,e,n,i){let r=n.exec(e.content);if(r===null)return t.error(i,"Expected a named fixture or assertion with exactly one concrete value.",f(e)),t.skipBlock(e.indent),null;let o=f(e),s=qt(t,r[2],{...o,column:o.column+e.content.indexOf(r[2],e.content.indexOf("=")+1)},i),a=t.peekChild(e.indent);return a!==void 0&&(t.error(i,"A fixture or return field cannot have child directives.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"PropertyMappingSyntax",property:r[1],source:s,location:o}}c(Bt,"parseConcreteMapping");function sa(t,e){let n=wr.exec(e.content)[0].length,i=e.content.substring(n).trim(),r=f(e);if(i.length>0){let s=qt(t,i,{...r,column:r.column+e.content.indexOf(i,n)},l.InvalidReturnExpectation),a=t.peekChild(e.indent);return a!==void 0&&(t.error(l.InvalidReturnExpectation,"A scalar return expectation cannot have child assertions.",f(a)),t.skipBlock(e.indent)),s===null?null:{kind:"ScalarSpecificationReturnSyntax",value:s,location:r}}let o=[];for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=Bt(t,s,ac,l.InvalidReturnExpectation);a!==null&&o.push(a)}return{kind:"RecordSpecificationReturnSyntax",fields:o,location:r}}c(sa,"parseReturn");var lc=new RegExp(I("^case\\s+([A-Za-z_]\\w*)(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?$").source,"du"),cc=I("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),dc=I("^case\\.([a-z_]\\w*)$");function Yt(t){return/\bcase\.[a-z_]\w*/.test(t.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g,""))}c(Yt,"containsCaseReference");function Le(t,e,n,i=!1){if(!t.startsWith("case."))return Yt(t)&&n.error(l.InvalidSpecificationCaseReference,"A case reference fills a whole value position; it cannot occur inside a structured value or expression.",e),ae(t,e,n,i);let r=dc.exec(t);return r===null&&n.error(l.InvalidSpecificationCaseReference,"A case reference fills a whole value position: 'case.<parameter>'.",e),{kind:"CaseValueExpressionSyntax",parameter:r?.[1]??t.substring(5),location:e}}c(Le,"parseSpecificationValue");function la(t,e){let n=e.content.indexOf(" ")+1,i=n>0?Fe(t,{...e,content:e.content.substring(n),indent:e.indent+n}):void 0;if(i===void 0||i.isGenerated||i.isIdentifier)return t.error(l.InvalidSpecificationParameter,"Expected 'parameter <name> <Type>', with optional collection and optional modifiers.",f(e)),t.skipOpaqueBlock(e.indent),null;let r=t.peekChild(e.indent);return r!==void 0&&(t.error(l.InvalidSpecificationParameter,"A parameter has no body or default.",f(r)),t.skipOpaqueBlock(e.indent)),{kind:"SpecificationParameterSyntax",name:i.name,type:i.type,location:f(e)}}c(la,"parseParameter");function ca(t,e){let n=lc.exec(e.content);if(n===null)return t.error(l.InvalidSpecificationCase,"Expected 'case <Name>' with at most one inline parameter assignment.",f(e)),t.skipOpaqueBlock(e.indent),null;let i=[],r=c((o,s,a)=>{let d=f(a),p={...d,column:d.column+a.content.indexOf(s,a.content.indexOf("=")+1)};if(s.startsWith("case.")){t.error(l.InvalidSpecificationCaseValue,"A case assigns concrete values, not case references.",p);return}let m=qt(t,s,p,l.InvalidSpecificationCaseValue);m!==null&&i.push({kind:"PropertyMappingSyntax",property:o,source:m,location:a===e?{...d,column:d.column+n.indices.groups.property[0]}:d})},"add");n.groups?.property!==void 0&&r(n.groups.property,n.groups.value,e);for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=cc.exec(o.content);if(s===null){t.error(l.InvalidSpecificationCaseAssignment,"Expected '<parameter> = <concrete value>' in a case.",f(o)),t.skipOpaqueBlock(o.indent);continue}r(s[1],s[2],o);let a=t.peekChild(o.indent);a!==void 0&&(t.error(l.InvalidSpecificationCaseValue,"A case value must fit on one line.",f(a)),t.skipOpaqueBlock(o.indent))}return{kind:"SpecificationCaseSyntax",name:n[1],values:i,location:f(e)}}c(ca,"parseCase");function Ft(t){return Array.isArray(t)?t.flatMap(Ft):t===null||typeof t!="object"?[]:"kind"in t&&t.kind==="CaseValueExpressionSyntax"?[t]:Object.values(t).flatMap(Ft)}c(Ft,"caseReferences");function da(t,e){let n=t.parameters??[],i=t.cases??[];n.length===0!=(i.length===0)&&e.error(l.IncompleteSpecificationTable,"A specification table requires parameters and at least one case.",t.location),n.forEach((o,s)=>{n.slice(0,s).some(a=>a.name===o.name)&&e.error(l.DuplicateSpecificationParameter,`Parameter '${o.name}' is declared more than once.`,o.location)}),i.forEach((o,s)=>{i.slice(0,s).some(a=>a.name===o.name)&&e.error(l.DuplicateSpecificationCase,`Case '${o.name}' is declared more than once.`,o.location);for(let a of o.values.filter(d=>!n.some(p=>p.name===d.property)))e.error(l.InvalidSpecificationCaseAssignment,`Case '${o.name}' assigns undeclared parameter '${a.property}'.`,a.location);for(let a of n.filter(d=>o.values.filter(p=>p.property===d.name).length!==1))e.error(l.InvalidSpecificationCaseAssignment,`Case '${o.name}' must assign parameter '${a.name}' exactly once.`,o.location)});let r=Ft(t);for(let o of r)(i.length===0||!n.some(s=>s.name===o.parameter))&&e.error(l.InvalidSpecificationCaseReference,`Case reference '${o.parameter}' requires a declared parameter in a specification table.`,o.location);for(let o of n.filter(s=>!r.some(a=>a.parameter===s.name)))e.warning(l.UnusedSpecificationParameter,`Parameter '${o.name}' is never referenced.`,o.location);for(let o of Ft(t.whenRedelivered))e.error(l.InvalidSpecificationCaseReference,"Case references are not permitted in redelivery locators.",o.location)}c(da,"validateTable");function wt(t,e,n=new WeakMap){if(t!==null&&typeof t=="object"&&n.has(t))return n.get(t);if(Array.isArray(t)){let r=t.map(o=>wt(o,e,n));return n.set(t,r),r}if(t===null||typeof t!="object"||!("kind"in t))return t;if(t.kind==="CaseValueExpressionSyntax"){let r=t.parameter;return e.values.find(o=>o.property===r)?.source??t}let i=Object.fromEntries(Object.entries(t).map(([r,o])=>[r,wt(o,e,n)]));if(t.kind==="SpecificationErrorSyntax"&&"caseValue"in t&&t.caseValue!==void 0){let r=i.caseValue;i.name=r.kind==="LiteralExpressionSyntax"?r.value:null,delete i.caseValue}return n.set(t,i),i}c(wt,"substituteCase");function Ut(t){let e=[],n=c((a,d)=>{for(let p of a??[])e.push({name:p.name,scope:d,example:p})},"examples"),i=c((a,d)=>{for(let p of a){let m=[...d,p.name];n(p.examples,m);for(let u of p.slices){let y=[...d,p.name,u.name];n(u.examples,y);for(let h of new Set(le(u).map(x=>x.name)))e.push({name:h,scope:y,kind:"event"});for(let h of u.commands)e.push({name:h.name,scope:y,kind:"command"});for(let h of u.readModels)e.push({name:h.name,scope:y,kind:"readmodel"})}i(p.features,m)}},"features");n(t.examples,[]);for(let a of[...t.concepts,...t.types])e.push({name:a.name,scope:[],kind:"type"});for(let a of t.modules)n(a.examples,[a.name]),i(a.features,[a.name]);let r=c((a,d)=>{let p=c(y=>{let h=y.split("."),x=e.filter(S=>S.name===h.at(-1)),b=h.slice(0,-1);if(b.length)return x.filter(S=>b.length<=S.scope.length&&b.every(($,g)=>S.scope[S.scope.length-b.length+g]===$));for(let S=d.length;S>=0;S--){let $=x.filter(g=>S<=g.scope.length&&d.slice(0,S).every((P,w)=>g.scope[w]===P));if($.length)return $}return[]},"candidates"),m=p(a),u=t.imports.filter(y=>y.qualifiedName.split(".").at(-1)===a);return!m.length&&u.length===1&&(m=p(u[0].qualifiedName)),m.length===1?m[0]:void 0},"resolve"),o=c((a,d,p)=>{let m=r(a,p),u=m?.example;if(!u)return null;let y=r(u.type,m.scope);return y?.kind===d?{example:u,name:[...y.scope,y.name].join(".")}:null},"fixture"),s=c((a,d)=>[...a.filter(p=>!d.some(m=>m.property===p.property)),...d],"merge");return{resolvedExamples:e.filter(a=>a.example!==void 0).flatMap(a=>{let d=r(a.example.type,a.scope);return d?.kind===void 0?[]:[{example:a.example,kind:d.kind,name:[...d.scope,d.name].join("."),scope:d.scope}]}),eventStep:c((a,d,p)=>{let m=o(a.eventType,"event",p),u=m?.example??null,y=u?.stream??u?.noStream??null,h=a.stream??a.noStream??null,x=h??y,b=m===null?a:{...a,eventType:m.name,values:s(u.values,a.values),for:a.for??u.for,stream:x?.kind==="SpecificationStreamSyntax"?x:null,noStream:x?.kind==="SpecificationNoStreamSyntax"?x:null},S=b.values.map($=>{let g=u?.values.find(w=>w.property===$.property),P=a.values.includes($);return{property:$.property,value:$.source,origin:P?g===void 0?"authored":"override":"example",overriddenValue:P?g?.source??null:null}});return b.for!==null&&S.push({property:"for",value:b.for,origin:a.for===null?"example":u?.for==null?"authored":"override",overriddenValue:a.for===null?null:u?.for??null}),{role:d,authored:a,effective:b,example:u,values:S,route:x===null?null:{value:x,origin:h===null?"example":y===null?"authored":"override",overriddenValue:h===null?null:y}}},"eventStep"),command:c((a,d)=>{if(!a)return a;let p=o(a.commandType,"command",d);if(!p)return a;let{example:m,name:u}=p;return{...a,commandType:u,values:s(m.values,a.values),generatedValues:s(m.generatedValues,a.generatedValues??[]),for:a.for??m.for}},"command"),readModel:c((a,d)=>{let p=o(a.name,"readmodel",d);return p?{...a,name:p.name,properties:s(p.example.values,a.properties)}:a},"readModel")}}c(Ut,"specificationExamples");function Zn(t){return Ut(t).command}c(Zn,"specificationCommandExamples");function Ge(t){return Kn(t).application}c(Ge,"expandSpecificationExamples");function Kn(t){let e=Ut(t),n=[],i=c((r,o)=>r.map(s=>{let a=[...o,s.name];return{...s,features:i(s.features,a),slices:s.slices.map(d=>{let p=[...o,s.name,d.name],m={...d,specifications:d.specifications.flatMap(u=>{let y=[],h=c((g,P)=>{let w=e.eventStep(g,P,p);return y.push(w),w.effective},"event"),x=t.personas.find(g=>g.name===u.givenCallerPersona?.name),b=x===void 0?null:yn(x,t),S=b?.caller==null?null:{...b.caller,location:u.givenCallerPersona.location};S!==null&&y.push({role:"given caller",authored:u.givenCallerPersona,effective:S,example:null,route:null,values:b.contributions.map(g=>({property:g.type??g.kind,value:{kind:"LiteralExpressionSyntax",value:g.kind==="authenticated"?!0:g.value,location:g.location},origin:"persona",overriddenValue:null,persona:x.name,policy:g.policy}))});let $={...u,...S===null?{}:{givenCaller:S,givenCallerPersona:void 0},given:u.given.map(g=>h(g,"given")),givenReadModels:u.givenReadModels.map(g=>e.readModel(g,p)),when:e.command(u.when,p),whenAppended:u.whenAppended===null?null:h(u.whenAppended,"when append"),thenEvents:u.thenEvents.map(g=>h(g,"then")),thenReadModels:u.thenReadModels.map(g=>e.readModel(g,p))};return(u.cases?.length??0)===0?(n.push({authored:u,effective:$,steps:y}),[$]):u.cases.map(g=>{let P=new WeakMap,w={...wt($,g,P),name:`${u.name}_${g.name}`,parameters:[],cases:[]};return Pr.set(w,{table:u.name,case:g.name}),n.push({authored:u,effective:w,table:u.name,case:g.name,steps:y.map(v=>({...v,effective:wt(v.effective,g,P),values:v.values.map(E=>E.value.kind==="CaseValueExpressionSyntax"?{...E,value:wt(E.value,g,P),origin:"case",caseParameter:E.value.parameter}:E),route:v.route===null?null:{...v.route,value:wt(v.route.value,g,P)}}))}),w})})};return ot.set(m,Se(d)),m})}}),"features");return{application:{...t,modules:t.modules.map(r=>({...r,features:i(r.features,[r.name])}))},specifications:n}}c(Kn,"expandEffectiveSpecificationExamples");var Jn=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Hn(t,e,n=e.inputUses){let i=Zn(t),r=[],o=c((v,E)=>{let C=[...E,v.name];v.slices.forEach(k=>r.push({slice:k,scope:[...C,k.name]})),v.features.forEach(k=>o(k,C))},"collect");t.modules.forEach(v=>v.features.forEach(E=>o(E,[v.name])));let s=new Map,a=new Map,d=new Map;for(let{slice:v,scope:E}of r)for(let C of v.commands){let k=s.get(C.name)??[];k.push({command:C,scope:E}),s.set(C.name,k),a.set(C,oe(C.properties)),C.response?.kind==="RecordCommandResponseSyntax"&&d.set(C,oe(C.response.fields))}let p=new Map;for(let v of t.imports){let E=v.qualifiedName.split(".").at(-1);p.set(E,[...p.get(E)??[],v.qualifiedName])}let m=new Map,u=c((v,E)=>{let C=`${E.join(".")}|${v}`;if(m.has(C))return m.get(C);let k=p.get(v)??[],T=((s.get(v.split(".").at(-1))??[]).length===0&&k.length===1?k[0]:v).split("."),M=s.get(T.at(-1))??[];if(T.length>1){let j=T.slice(0,-1);M=M.filter(q=>j.length<=q.scope.length&&j.every((V,K)=>q.scope[q.scope.length-j.length+K]===V))}else for(let j=E.length;j>=0;j--){let q=M.filter(V=>j<=V.scope.length&&E.slice(0,j).every((K,J)=>V.scope[J]===K));if(q.length>0){M=q;break}}let N=M.length===1?M[0].command:null;return m.set(C,N),N},"resolve"),y=oe(t.concepts),h=new Set(t.concepts.map(v=>v.name)),x=new Map([...oe(t.types)].map(([v,E])=>[v,oe(E.properties)])),b=new Set(r.flatMap(v=>v.slice.readModels.map(E=>E.name))),S=new Set([...a.keys()].flatMap(v=>[...v.properties])),$=c(v=>{for(let E of v)E.isGenerated&&!S.has(E)&&e.error(l.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",E.location)},"checkDeclarations"),g=c(v=>{v.features.forEach(g);for(let E of v.slices){for(let C of E.commands)for(let k of C.produces)k.inlineEvent!==null&&$(k.inlineEvent.properties);E.events.forEach(C=>$(C.properties)),E.readModels.forEach(C=>$(C.properties));for(let C of E.reactions)for(let k of C.triggers)for(let A of k.produces)A.inlineEvent!==null&&$(A.inlineEvent.properties)}},"checkFeature");t.types.forEach(v=>$(v.properties)),t.modules.forEach(v=>v.features.forEach(g));let P=c((v,E,C)=>{let k=a.get(C).get(v.property);if(k===void 0){e.error(l.InvalidResponseSource,`Response source '${v.property}' must reference one direct command property.`,v.location);return}let A=k.type;(A.isCollection||b.has(A.name))&&e.error(l.InvalidResponseShape,"Collection and whole-read-model responses are not supported.",v.location),E!==null&&(E.name!==A.name||E.isCollection!==A.isCollection||E.isOptional!==A.isOptional)&&e.error(l.InvalidResponseShape,"An explicit response field type must match its source's declared type, collection shape and optionality.",E.location)},"validateSource");for(let v of a.keys()){for(let C of v.properties){if(!C.isGenerated)continue;let k=y.get(C.type.name);(C.type.isOptional||C.type.isCollection||(k===void 0?Jn.has(C.type.name)||x.has(C.type.name)||h.has(C.type.name)||b.has(C.type.name):k.type!=="Uuid"))&&e.error(l.InvalidGeneratedType,"A generated property must be a required, noncollection concept backed by Uuid.",C.location)}let E=v.response;if(E?.kind==="ScalarCommandResponseSyntax")P(E.source,null,v);else if(E?.kind==="RecordCommandResponseSyntax"){E.fields.length===0&&e.error(l.InvalidCommandResponse,"A response block requires at least one field.",E.location);let C=new Set;for(let k of E.fields)C.has(k.name)&&e.error(l.DuplicateResponseField,`Duplicate response field '${k.name}'.`,k.location),C.add(k.name),P(k.source,k.type,v)}}let w=c((v,E)=>{let C=i(v.when,E),k=C===null?null:u(C.commandType,E);if(C!==null&&k!==null){let M=a.get(k);for(let q of C.values)M.get(q.property.split(".")[0])?.isGenerated&&e.error(l.GeneratedPropertySuppliedAsInput,`Generated property '${q.property}' cannot be supplied as request or form input.`,q.location);let N=[...M.values()].filter(q=>q.isIdentifier);if(C.for!==null&&N.length===1&&N[0].isGenerated){let q=N[0].type;(Jn.has(q.name)||y.has(q.name)||x.has(q.name))&&(q.isOptional||q.isCollection||y.get(q.name)?.type!=="Uuid"||C.for.kind!=="LiteralExpressionSyntax"||typeof C.for.value!="string"||!pa(C.for.value))&&e.error(l.InvalidGeneratedFixture,"A generated identifier fixture must supply one compatible concrete UUID value through 'for'.",C.for.location)}let j=new Set;for(let q of C.generatedValues??[]){let V=M.get(q.property);(j.has(q.property)||V===void 0||!V.isGenerated||V.isIdentifier||!Pe(q.source,V.type,y,x))&&e.error(l.InvalidGeneratedFixture,"A generated fixture must uniquely supply a compatible value for a nonidentifier generated command property.",q.location),j.add(q.property)}}let A=v.thenReturns;if(A==null||((C===null||v.thenErrors.length>0||v.thenDenied!=null)&&e.error(l.InvalidReturnExpectation,"A return expectation requires a command action and cannot accompany an error or denial.",A.location),k===null))return;let O=k.response,T=a.get(k);if(A.kind==="ScalarSpecificationReturnSyntax"&&O?.kind==="ScalarCommandResponseSyntax"&&T.has(O.source.property))Pe(A.value,T.get(O.source.property).type,y,x)||e.error(l.InvalidReturnExpectation,"The expected return value must match the response source's type.",A.location);else if(A.kind==="RecordSpecificationReturnSyntax"&&O?.kind==="RecordCommandResponseSyntax"){A.fields.length===0&&e.error(l.InvalidReturnExpectation,"A record return expectation requires at least one field.",A.location);let M=d.get(k),N=new Set;for(let j of A.fields){let q=M.get(j.property),V=q===void 0?void 0:T.get(q.source.property);(N.has(j.property)||V===void 0||!Pe(j.source,V.type,y,x))&&e.error(l.InvalidReturnExpectation,"A return assertion must uniquely name a response field and supply a compatible concrete value.",j.location),N.add(j.property)}}else e.error(l.InvalidReturnExpectation,"The return expectation must match the command's scalar or record response shape.",A.location)},"validateSpecification");for(let{slice:v,scope:E}of r)v.specifications.forEach(C=>w(C,E));for(let v of n){if(v.isParameter===!0)continue;let E=u(v.command,v.scope);E!==null&&a.get(E).get(v.property.split(".")[0])?.isGenerated&&e.error(l.GeneratedPropertySuppliedAsInput,`Generated property '${v.property}' cannot be supplied as request or form input.`,v.location)}}c(Hn,"validateResponses");function oe(t){let e=new Map,n=new Set;for(let i of t)e.has(i.name)&&n.add(i.name),e.set(i.name,i);return n.forEach(i=>e.delete(i)),e}c(oe,"uniqueByName");function Pe(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=>Pe(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 d=r.get(a.name);return d!==void 0&&Pe(a.value,d.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"&&pa(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&&na(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"&&br(t.value,!1);case"DateTime":return typeof t.value=="string"&&br(t.value,!0);default:return!Jn.has(s)}return!Jn.has(s)&&o===void 0}c(Pe,"compatibleValue");var pc=/^(?:[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 pa(t){return pc.test(t)}c(pa,"uuidValue");function uc(t,e,n){let i=oe(n.types),r=t.properties,o=null,s=!1,a=!1;for(let d of e.split(".")){let p=r.filter(u=>u.name===d);if(p.length!==1)return null;let m=p[0].type;s||=m.isOptional,a||=m.isCollection,o={...m,isOptional:s,isCollection:a},r=i.get(m.name)?.properties??[]}return o}c(uc,"commandPathType");function Wt(t,e,n,i){let r=e.for?.kind==="PathExpressionSyntax"?e.for.path:ta(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:uc(t,r,n)}c(Wt,"commandDestinationType");var ua=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]),He=class{static{c(this,"RefusalDeclarations")}application;slices;types;concepts;events;knownTypes;constructor(e){this.application=e,this.slices=new ie(e).slices,this.types=oe(e.types),this.concepts=oe(e.concepts),this.knownTypes=new Set([...ua,...e.types.map(n=>n.name),...e.concepts.map(n=>n.name)]),this.events=new Map(this.slices.map(({slice:n})=>{let i=new Map;for(let r of le(n))(!i.has(r.name)||i.get(r.name).generation<r.generation)&&i.set(r.name,r);return[n,[...i.values()]]}))}resolve(e,n,i){let r=this.slices.flatMap(({slice:d,scope:p})=>i(d).map(m=>({node:m,slice:d,scope:p}))),o=this.slices.find(d=>d.slice===n)?.scope??[],s=c(d=>{let p=d.split("."),m=r.filter(y=>y.node.name===p.at(-1)),u=p.slice(0,-1);if(u.length>0)return m.filter(y=>u.length<=y.scope.length&&u.every((h,x)=>y.scope[y.scope.length-u.length+x]===h));for(let y=o.length;y>=0;y--){let h=m.filter(x=>y<=x.scope.length&&o.slice(0,y).every((b,S)=>x.scope[S]===b));if(h.length>0)return h}return[]},"candidates"),a=s(e);if(a.length===0){let d=this.application.imports.filter(p=>p.qualifiedName.split(".").at(-1)===e);d.length===1&&(a=s(d[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(d=>d.name===o)??[];if(s.length!==1)return null;let a=s[0];if(r===i.length-1)return a;if(ua.has(a.type.name)||this.concepts.has(a.type.name)&&!this.application.types.some(d=>d.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 fc=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function ei(t,e,n){let i=new He(t),r=Ut(t),o=c(d=>fc.has(d)||i.concepts.has(d)||i.types.has(d),"knownType"),s=new Map([...i.types].map(([d,p])=>[d,new Map(p.properties.map(m=>[m.name,m]))])),a=n===void 0?i.slices:[{scope:[],slice:{kind:"SliceSyntax",type:"StateChange",name:"",description:null,location:t.location,events:[],commands:[],queries:[],projections:[],captures:[],reactions:[],constraints:[],readModels:[],screens:[],specifications:n}}];for(let{slice:d,scope:p}of a){let m=new Map;for(let u of d.specifications){let y=(u.cases?.length??0)===0?[u.name]:u.cases.map(h=>`${u.name}_${h.name}`);for(let h of y)m.set(h,(m.get(h)??0)+1);(u.cases?.length??0)>0&&m.set(u.name,(m.get(u.name)??0)+1)}for(let u of d.specifications){for(let b of u.cases??[])(m.get(`${u.name}_${b.name}`)??0)>1&&e.error(l.SpecificationCaseNameCollision,`Case '${b.name}' derives specification '${u.name}_${b.name}', which collides in this ${n===void 0?"slice":"document"}.`,b.location);for(let b of u.parameters??[]){n===void 0&&!o(b.type.name)&&e.error(l.IncompatibleSpecificationParameterType,`Parameter '${b.name}' has unknown type '${b.type.name}'.`,b.type.location);for(let S of u.cases??[])for(let $ of S.values.filter(g=>g.property===b.name))Pe($.source,b.type,i.concepts,s)||e.error(l.InvalidSpecificationCaseValue,`Case '${S.name}' parameter '${b.name}' requires a concrete value of type '${b.type.name}'.`,$.source.location)}let y=c((b,S,$)=>{if(b?.kind!=="CaseValueExpressionSyntax"||S===void 0)return;let g=u.parameters?.find(E=>E.name===b.parameter);if(g===void 0||(g.type.isOptional&&!S.isOptional&&e.error(l.OptionalSpecificationParameterTarget,`Optional parameter '${g.name}' cannot supply required target '${$}'.`,b.location),n!==void 0&&(!o(g.type.name)||!o(S.name))))return;let P=i.concepts.get(g.type.name),w=i.concepts.get(S.name);(!(g.type.name===S.name||P?.type!=="Enum"&&P?.type===S.name||w?.type!=="Enum"&&w?.type===g.type.name)||g.type.isCollection!==S.isCollection)&&e.error(l.IncompatibleSpecificationParameterType,`Parameter '${g.name}' type '${g.type.name}' is incompatible with target '${$}' type '${S.name}'.`,b.location)},"check"),h=c((b,S)=>{for(let $ of b)y($.source,i.property(S,$.property)?.type,$.property)},"assignments"),x=r.command(u.when,p);if(x!==null){let b=i.resolve(x.commandType,d,S=>S.commands)?.node.properties??null;h(x.values,b),h(x.generatedValues??[],b),y(x.for,b?.find(S=>S.isIdentifier)?.type,"for")}if(x!==null&&u.thenReturns!=null){let b=i.resolve(x.commandType,d,$=>$.commands)?.node,S=b?.response;if(u.thenReturns.kind==="ScalarSpecificationReturnSyntax"&&S?.kind==="ScalarCommandResponseSyntax"&&y(u.thenReturns.value,b?.properties.find($=>$.name===S.source.property)?.type,"value"),u.thenReturns.kind==="RecordSpecificationReturnSyntax"&&S?.kind==="RecordCommandResponseSyntax")for(let $ of u.thenReturns.fields){let g=S.fields.find(P=>P.name===$.property);y($.source,g?.type??b?.properties.find(P=>P.name===g?.source.property)?.type,$.property)}}for(let b of[...u.given,...u.thenEvents,...u.whenAppended===null?[]:[u.whenAppended]]){let S=r.eventStep(b,"given",p).effective;h(S.values,i.event(S.eventType,d)?.properties??null);let $=S.stream==null?null:new Ye(t).resolve(S.stream.eventSource,S.stream.stream),g=$?.kind===pe.Unique?$.sources[0]:void 0,P=$?.kind===pe.Unique?$.streams[0]:void 0;y(S.for,S.stream!=null&&g===void 0?void 0:g?.identifier??mc(S.eventType,d,t,i),"for"),S.stream?.streamId!=null&&y(S.stream.streamId.source,P?.streamId??void 0,"streamId");for(let w of S.stream?.streamIdParts??[])y(w.source,P?.streamIdParts.find(v=>v.name===w.property)?.type,w.property)}for(let b of[...u.givenReadModels,...u.thenReadModels]){let S=r.readModel(b,p);h(S.properties,i.resolve(S.name,d,$=>$.readModels)?.node.properties??null)}if(u.whenTrigger!=null){let b=(t.declaredTriggers??[]).find(S=>S.name===u.whenTrigger.trigger);for(let S of u.whenTrigger.values)y(S.source,b?.data.find($=>$.name===S.property)?.type,S.property)}for(let b of u.thenErrors)y(b.caseValue??null,{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:b.location},"message");for(let b of u.thenAbsentReadModels??[]){let S=i.resolve(b.name,d,g=>g.readModels)?.node,$=i.slices.flatMap(({slice:g})=>g.queries.filter(P=>P.by!==null&&i.resolve(P.returnType.name,g,w=>w.readModels)?.node===S));y(b.key,S!==void 0&&$.length===1?$[0].by.type:void 0,"for")}for(let b of[...u.thenQueries??[],...u.whenQuery===null?[]:[u.whenQuery]]){let S=i.resolve(b.query,d,w=>w.queries),$=S===null?[]:[...S.node.by===null?[]:[S.node.by],...S.node.filters].map(w=>({...w,kind:"PropertySyntax",isIdentifier:!1}));h(b.arguments,$);let g=S===null?null:i.resolve(S.node.returnType.name,S.slice,w=>w.readModels)?.node.properties??null,P=b.kind==="SpecificationQuerySyntax"?b.results:u.thenResults;for(let w of P)h(w.properties,g)}}}}c(ei,"validateSpecificationCases");function Xn(t){let e=new Map(t.map(n=>[JSON.stringify([n.name,n.isOptional,n.isCollection]),n]));return e.size===1?[...e.values()][0]:void 0}c(Xn,"uniqueDestinationType");function mc(t,e,n,i){let r=new ie(n),o=i.event(t,e);if(o===null)return;let s=c((d,p=i.slices)=>p.flatMap(({slice:m})=>m.commands.flatMap(u=>u.produces.filter(y=>r.isEventProduction(y,m)&&i.event(y.event,m)===d).map(y=>Wt(u,y,n,{resolver:r,slice:m})).filter(y=>y!==null))),"commandTypes"),a=c((d,p)=>{if(p.has(d))return[];p.add(d);let m=s(d);for(let{slice:u}of i.slices){for(let y of u.reactions.flatMap(h=>h.triggers)){let h=y.source.kind==="NamedTriggerSourceSyntax"?y.source.name:void 0,x=h===void 0?null:i.event(h,u);for(let b of y.produces.filter(S=>i.event(S.event,u)===d))if(b.for?.kind==="PathExpressionSyntax"){let S=b.for.path,$=i.property(x?.properties??null,S)?.type??(h===void 0?void 0:(n.declaredTriggers??[]).find(g=>g.name===h)?.data.find(g=>g.name===S)?.type);$!==void 0&&m.push($)}else b.for?.kind==="LiteralExpressionSyntax"?m.push({kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:b.location}):b.for===null&&x!==null&&m.push(...a(x,p))}u.captures.flatMap(y=>[...y.appends,...y.children.flatMap(h=>h.appends),...y.nested.flatMap(h=>h.appends)]).some(y=>i.event(y.event,u)===d)&&m.push(Xn(s(d))??{kind:"TypeRefSyntax",name:"String",isOptional:!1,isCollection:!1,location:d.location})}return m},"producerTypes");return Xn(s(o,i.slices.filter(d=>d.slice===e)))??Xn(s(o))??Xn(a(o,new Set))}c(mc,"eventDestinationType");function ti(t){let e=new ie(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:l.OmittedProductionDestination,message:`Plain 'produces ${o.event}' omits its destination - use 'for ${r[0].name}' to explicitly select the command's identifier.`,location:o.location}))}))}c(ti,"productionDestinationDiagnostics");function ni(t,e){let n=new ie(t).slices.map(r=>r.slice),i=n.flatMap(le);for(let r of n)for(let o of r.constraints.flatMap(s=>[s,...s.additionalRules])){if(o.kind!=="UniquePropertyConstraintSyntax")continue;let s=i.filter(a=>a.name===o.event);if(s.length!==0)for(let a of[o.property,...o.additionalProperties])a.includes(".")||s.some(d=>d.properties.some(p=>p.name===a))||e.error(l.UnknownConstraintProperty,`Constraint '${o.name}' names property '${a}', which event '${o.event}' does not declare.`,o.location)}}c(ni,"validateConstraintProperties");var fa=c((t,e)=>t.length===e.length&&t.every((n,i)=>n===e[i]),"same"),ii=c(t=>[...t.scope,t.name].join("."),"addressOf"),je=class{static{c(this,"DeclaredDependencyTargets")}static containersOf(e){let n=[],i=c((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=>[ii(r),r])).values()]}static candidates(e,n){let i=e.join(".");return n.flatMap(r=>{let o=ii(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 d=s.slice(-a).join(".");if(this.resolve(d,e,n).resolved!==r)continue;let p=a===1?e.length-1-r.scope.length:"qualified";return[{container:r,reference:d,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=>fa([...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&&fa(a.scope,n.slice(0,o)));if(s.length>0)return s.length===1?{resolved:s[0],ambiguous:[]}:{ambiguous:s}}return{ambiguous:[]}}};function ri(t,e){let n=c(a=>(a.dependsOn?.length??0)>0||a.features.some(n),"hasDependencies");if(!t.modules.some(n))return t;let i=je.containersOf(t),r=new Map,o=c((a,d)=>{let p=[],m=d.join(".");r.has(m)||r.set(m,new Set);let u=r.get(m);for(let y of a){let h=je.resolve(y.target,d,i),x=h.resolved===void 0?void 0:ii(h.resolved),b=x===void 0?`text:${y.target}`:`resolved:${x}`;if(u.has(b)){e.warning(l.RepeatedDependencyDeclaration,`Dependency '${y.target}' is already declared on this container - this repeated declaration is ignored`,y.location);continue}u.add(b),p.push(y),h.ambiguous.length>0?e.warning(l.AmbiguousReference,`Ambiguous dependency target '${y.target}' - candidates: ${h.ambiguous.map(ii).join(", ")}`,y.location):(x===void 0||x===m||x.startsWith(m+".")||m.startsWith(x+"."))&&e.warning(l.InvalidDependencyTarget,`Invalid dependency target '${y.target}' on '${m}' - the target must resolve to another module or feature, not self, an ancestor, or a descendant`,y.location)}return p},"keep"),s=c((a,d)=>{let p=[...d,a.name];return{...a,dependsOn:o(a.dependsOn??[],p),features:a.features.map(m=>s(m,p))}},"normalize");return{...t,modules:t.modules.map(a=>({...a,dependsOn:o(a.dependsOn??[],[a.name]),features:a.features.map(d=>s(d,[a.name]))}))}}c(ri,"validateDependencyDeclarations");var It=[],hn=c(t=>t.length===0,"isDocumentPlacement");function oi(t){return t.length===0?"the application":t.length===1?`module '${t[0]}'`:`feature '${t.join(".")}'`}c(oi,"describePlacement");var yc=I("^(?:(?:or|and)\\s+)?[A-Za-z_(][\\w\\s()]*$"),hc=new RegExp(I("\\(|\\)|[A-Za-z_]\\w*").source,"gu"),Sc=I("^[A-Z]\\w*$");function gt(t,e){let n=e.content.substring(9);for(let a=t.peekChild(e.indent);a!==void 0&&yc.test(a.content);a=t.peekChild(e.indent))t.reader.takeSignificant(),n+=` ${a.content}`;let i=gc(n),r=f(e);if(i.length===0)return t.error(l.AuthorizeWithoutPolicy,"Expected at least one policy after 'authorize'",r),null;let s=new Ir(t,i,r).parse();return s===null?null:{kind:"AuthorizeSyntax",requirement:s,location:r}}c(gt,"parseAuthorize");function Xe(t,e){return t===null?e:e===null?t:{kind:"AuthorizeSyntax",requirement:{kind:"LogicalPolicyRequirementSyntax",left:t.requirement,operator:"And",right:e.requirement,location:t.location},location:t.location}}c(Xe,"combineAuthorize");function gc(t){let e=[];for(let n of t.match(hc)??[])e.length>0&&xc(e[e.length-1])&&vc(n)&&e.push("and"),e.push(n);return e}c(gc,"tokenize");var ma=c(t=>t!=="("&&t!==")"&&t!=="and"&&t!=="or","isName"),xc=c(t=>t===")"||ma(t),"isOperandEnd"),vc=c(t=>t==="("||ma(t),"isOperandStart"),Ir=class{static{c(this,"RequirementParser")}context;tokens;location;#e=0;constructor(e,n,i){this.context=e,this.tokens=n,this.location=i}parse(){let e=this.#t();return e!==null&&this.#e<this.tokens.length&&this.context.error(l.UnexpectedTokenInAuthorize,`Unexpected '${this.tokens[this.#e]}' in authorize`,this.location),e}#t(){return this.#i("or","Or",()=>this.#s())}#s(){return this.#i("and","And",()=>this.#r())}#i(e,n,i){let r=i();for(;r!==null&&this.tokens[this.#e]===e;){this.#e++;let o=i();if(o===null)return null;r={kind:"LogicalPolicyRequirementSyntax",left:r,operator:n,right:o,location:this.location}}return r}#r(){if(this.tokens[this.#e]!=="(")return this.#o();this.#e++;let e=this.#t();return this.tokens[this.#e]===")"?this.#e++:this.context.error(l.UnclosedAuthorizeGroup,"Expected ')' in authorize",this.location),e}#o(){if(this.#e>=this.tokens.length)return this.context.error(l.AuthorizeWithoutPolicy,"Expected a policy name",this.location),null;let e=this.tokens[this.#e++];return Sc.test(e)?{kind:"PolicyReferenceSyntax",name:e,location:this.location}:(this.context.error(l.InvalidPolicyReference,`Invalid policy reference '${e}' - policy names are PascalCase identifiers`,this.location),null)}};function Vt(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(l.ExpectedCodeFence,`Expected an opening \`\`\`${e==="description"?"text":e} fence after '${e}'`,f(n)),null;o!==n&&t.reader.takeSignificant(),e==="description"&&o.content==="```"&&t.warning(l.LegacyInlineCodeFence,"A bare description fence is deprecated - use '```text' instead",f(o));let a=[];for(;;){let d=t.reader.takeRaw();if(d===void 0){t.error(l.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(o));break}if(d.raw.trim()==="```")break;let p=0;for(;p<o.indent&&p<d.raw.length&&d.raw[p]===" ";)p++;a.push(d.raw.substring(p))}return a.join(`
|
|
17
|
-
`)}c(Vt,"parseFencedText");var $c=I(`^description\\s+"(${z})"$`);function G(t,e,n,i,r=!1){if(e.content==="description"){let s=Vt(t,"description",e,r);return s===null?n:s.trim().length===0?(t.error(l.EmptyDescription,`${i} declares an empty description - the fenced block must contain text`,f(e)),n):ya(t,e,n,i,s)}let o=$c.exec(e.content);return o===null?(t.error(l.InvalidDescription,`Invalid description '${e.content}' - expected 'description "<text>"'`,f(e)),n):ya(t,e,n,i,Q(o[1]))}c(G,"parseDescription");function ya(t,e,n,i,r){return n!==null?(t.error(l.DuplicateDescription,`${i} already declares a description - at most one is allowed`,f(e)),n):r}c(ya,"keep");var bc=I("^purpose\\s+([A-Za-z_]\\w*)$"),kc=I(`^(basis|condition)\\s+(\\w+)(?:\\s+"(${z})")?$`),Ec=I(`^(interest|authorization|retention|recipient)\\s+"(${z})"$`),Cc=I(`^transfer\\s+"(${z})"\\s+safeguard\\s+"(${z})"$`),Pc=I("^[A-Za-z_]\\w*$"),Ac=I("^erasure\\s+exception\\s+(\\w+)$"),wc=["consent","contract","legalObligation","vitalInterests","publicTask","legitimateInterests"],Ic=["explicitConsent","employmentLaw","vitalInterests","notForProfit","madePublic","legalClaims","substantialPublicInterest","healthCare","publicHealth","research"],ha=["expression","legalObligation","publicTask","publicHealth","archiving","legalClaims"];function Sa(t,e){let n=ga(t,e),i={kind:"PurposeSyntax",name:n,description:null,basis:null,basisReference:null,interest:null,condition:null,conditionReference:null,authorization:null,subjects:[],retention:null,recipients:[],transfers:[],erasureException:null,location:f(e)},r=new Set,o=[],s=[];for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){t.reader.takeSignificant();let d=D(a.content);if(d!=="recipient"&&d!=="transfer"&&r.has(d)){t.error(l.DuplicatePurposeField,`Purpose '${n}' already declares '${d}' - at most one is allowed`,f(a)),t.skipBlock(a.indent);continue}if(r.add(d),d==="description")i={...i,description:G(t,a,i.description,`Purpose '${n}'`)};else if(d==="basis"||d==="condition"){let p=kc.exec(a.content),m=d==="basis"?wc:Ic;if(p===null||!m.includes(p[2]))t.error(l.InvalidPurposeVocabulary,`Invalid ${d} in purpose '${n}' - expected ${m.join(", ")} with an optional quoted reference`,f(a));else{let u=p[3]===void 0?null:Q(p[3]);i=d==="basis"?{...i,basis:p[2],basisReference:u}:{...i,condition:p[2],conditionReference:u}}}else if(d==="interest"||d==="authorization"||d==="retention"||d==="recipient"){let p=Ec.exec(a.content);p===null?t.error(l.InvalidPurposeDeclaration,`Invalid purpose field '${a.content}' - expected '${d} "<text>"'`,f(a)):d==="recipient"?o.push(Q(p[2])):i={...i,[d]:Q(p[2])}}else if(d==="subjects"){let p=a.content.slice(8).split(",").map(m=>m.trim());p.every(m=>Pc.test(m))?i={...i,subjects:[...new Set(p)]}:t.error(l.InvalidPurposeDeclaration,`Invalid purpose subjects '${a.content}' - expected comma-separated identifiers`,f(a))}else if(d==="erasure"){let p=Ac.exec(a.content);p!==null&&ha.includes(p[1])?i={...i,erasureException:p[1]}:t.error(l.InvalidPurposeVocabulary,`Invalid erasure exception '${a.content}' - expected 'erasure exception ${ha.join("|")}'`,f(a))}else if(d==="transfer"){let p=Cc.exec(a.content);p===null?t.error(l.InvalidPurposeDeclaration,`Invalid transfer '${a.content}' - expected 'transfer "<destination>" safeguard "<text>"'`,f(a)):s.push({kind:"PurposeTransferSyntax",destination:Q(p[1]),safeguard:Q(p[2]),location:f(a)})}else t.error(l.InvalidPurposeDeclaration,`Unexpected '${a.content}' in purpose '${n}'`,f(a)),t.skipBlock(a.indent)}return{...i,recipients:o,transfers:s}}c(Sa,"parsePurpose");function zt(t,e,n){let i=ga(t,e);i.length>0&&!n.some(r=>r.name===i)&&n.push({kind:"PurposeReferenceSyntax",name:i,location:f(e)})}c(zt,"parsePurposeReference");function ga(t,e){let n=bc.exec(e.content);return n!==null?n[1]:(t.error(l.InvalidPurposeDeclaration,`Invalid purpose declaration '${e.content}' - expected 'purpose <Name>'`,f(e)),"")}c(ga,"purposeName");function Ie(t,e,n,i,r=l.InvalidDocumentation){if(e.content!=="documentation"||t.peekChild(e.indent)?.content!=="```markdown")return t.error(r,`${i} documentation requires a fenced markdown block`,f(e)),t.skipOpaqueBlock(e.indent),n;let o=Vt(t,"markdown",e);return o===null||o.trim().length===0||n!==null?(t.error(r,`${i} accepts one nonempty documentation block`,f(e)),n):o}c(Ie,"parseDocumentation");var Oc=Z(`^depends${W}+on${W}+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$`);function ai(t,e,n,i){let r=Oc.exec(e.content)?.[1];if(r===void 0){t.error(i,`Invalid dependency declaration '${e.content}' - expected 'depends on <Name>'`,f(e)),t.skipBlock(e.indent);return}if(n.some(o=>o.target===r)){t.warning(l.RepeatedDependencyDeclaration,`Dependency '${r}' is already declared on this container - this repeated declaration is ignored`,f(e));return}n.push({kind:"DependsOnSyntax",target:r,location:f(e)})}c(ai,"parseDependsOn");var Tc=I('^import\\s+"([^"\\\\]+)"$'),Rc=I('^import\\s+"'),xa=c(t=>Rc.test(t),"isFileImport");function va(t){let e=Tc.exec(t.content);return e===null?void 0:{kind:"FileImportSyntax",pattern:e[1],location:f(t)}}c(va,"tryParseFileImport");function Qt(t,e,n){let i=va(e);if(i!==void 0){n.push(i);return}t.error(l.InvalidFileImport,`Invalid import '${e.content}' - inside a module or feature, import names files: 'import "<path or glob>"'`,f(e)),t.skipBlock(e.indent)}c(Qt,"parseFileImport");var Or={"==":"Equal","!=":"NotEqual",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual",contains:"Contains","starts with":"StartsWith"};function _e(t,e,n,i=!1){i||(t=t.valueContext);let r=i?W:"\\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(Z(`"${z}"|==|!=|>=|<=|>|<|\\(|\\)|${o}${s}`).source,"gu");if(i){let x=e.replace(a,"").replace(new RegExp(W,"gu"),"");if(x.length>0)return t.error(l.UnsupportedActionConditionOperand,`Guarded action conditions contain unsupported character '${x[0]}'`,n),null}let d=e.match(a)??[],p=0,m=c(()=>{if(d[p]==="("){p++;let $=y();return d[p]===")"?p++:(i||t.sourceOptions.numericMode==="exact")&&t.error(l.UnclosedConditionGroup,"Expected ')' in condition",n),$}let x=d[p++];if(i&&x===void 0)return t.error(l.ExpectedCondition,"Expected a condition",n),null;let b=d[p++];if(b==="starts"&&d[p]==="with"&&(b+=" with",p++),i&&!Object.hasOwn(Or,b))return t.error(l.ExpectedComparisonOperator,`Expected a comparison operator after '${x}'`,n),null;let S=d[p++];return i&&S===void 0?(t.error(l.ExpectedComparisonValue,"Expected a value to compare against",n),null):x===void 0||S===void 0||Or[b]===void 0?null:{kind:"ComparisonConditionSyntax",left:x,operator:Or[b],right:Be(S,n,t),location:n}},"group"),u=c(()=>{let x=m();for(;x!==null&&d[p]==="and";){p++;let b=m();if(b===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"And",right:b,location:n}}return x},"and"),y=c(()=>{let x=u();for(;x!==null&&d[p]==="or";){p++;let b=u();if(b===null)return null;x={kind:"LogicalConditionSyntax",left:x,operator:"Or",right:b,location:n}}return x},"or"),h=y();return(i||t.sourceOptions.numericMode==="exact")&&(h===null&&!i?t.error(l.ExpectedCondition,"Expected a condition",n):h!==null&&p<d.length&&t.error(l.UnexpectedTokenInCondition,`Unexpected '${d[p]}' in condition`,n)),h}c(_e,"parseCondition");var Dc=I(`^when${W}+([^\\n]+)${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Mc=I(`^otherwise${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Lc=I(`^with${W}+([A-Za-z_]\\w*)${W}+from${W}+([^\\n]+)$`),jc=I("^item\\.[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Nc=new RegExp(`^${W}+|${W}+$`,"gu");function ba(t,e,n,i){let r=[],o=null,s=null,a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let p=Dc.exec(d.content),m=Mc.exec(d.content);if(p!==null){a&&t.error(l.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(d));let u=_e(t,p[1],f(d),!0),y=$a(t,d);u!==null&&(Gt(t,u),r.push({kind:"ScreenActionAlternativeSyntax",condition:u,command:p[2],arguments:y,location:f(d)}))}else if(d.content==="otherwise hidden"||m!==null)if(a&&t.error(l.MisplacedActionOtherwise,"A guarded action permits only one 'otherwise'",f(d)),a=!0,m!==null)o={kind:"ScreenActionOtherwiseSyntax",outcome:"Execute",command:m[1],arguments:$a(t,d),location:f(d)};else{o={kind:"ScreenActionOtherwiseSyntax",outcome:"Hidden",command:null,arguments:[],location:f(d)};for(let u=t.peekChild(d.indent);u!==void 0;u=t.peekChild(d.indent))t.reader.takeSignificant(),t.error(l.InvalidActionAlternative,"'otherwise hidden' cannot declare command arguments",f(u)),t.skipBlock(u.indent)}else if(D(d.content)==="navigate")s!==null&&t.error(l.InvalidActionAlternative,"A guarded action permits only one 'navigate to'",f(d)),s=i(t,d.content,d)??null;else{let u=D(d.content)==="label";t.error(u?l.UnknownActionDirective:l.InvalidActionAlternative,u?"A guarded action's header already supplies its label":`Unexpected '${d.content}' in guarded action - expected 'when <condition> execute <Command>', 'otherwise hidden', 'otherwise execute <Command>' or 'navigate to ...'`,f(d)),t.skipBlock(d.indent)}}return r.length===0&&t.error(l.GuardedActionWithoutAlternatives,"A guarded action must declare at least one 'when' alternative",f(e)),{kind:"ScreenGuardedActionSyntax",label:n,alternatives:r,otherwise:o,navigate:s,location:f(e)}}c(ba,"parseGuardedAction");function $a(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=Lc.exec(i.content);r!==null?n.push({kind:"InteractionArgumentSyntax",name:r[1],binding:r[2].replace(Nc,""),location:f(i)}):(t.error(l.InvalidInteractionArgument,`Invalid argument '${i.content}' - expected 'with <name> from <binding>'`,f(i)),t.skipBlock(i.indent))}return n}c($a,"parseArguments");function Gt(t,e){if(e.kind==="LogicalConditionSyntax"){Gt(t,e.left),Gt(t,e.right);return}let n=e.right.kind==="LiteralExpressionSyntax"?e.right.value:void 0,i=jc.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(l.UnsupportedActionConditionOperand,"Guarded action conditions compare 'item.<field>' with a literal; ordering requires a number and text operators require a string",e.location)}c(Gt,"validateCondition");var Ne=class t{static{c(this,"LineReader")}lines;#e=0;constructor(e){this.lines=e}get atEnd(){return this.lines.slice(this.#e).every(Ar)}fork(){let e=new t(this.lines);return e.#e=this.#e,e}peekSignificant(){for(;this.#e<this.lines.length&&Ar(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 ue=class extends Error{static{c(this,"InvalidSyntaxJson")}};var Ue=Object.freeze({numericMode:"legacy"}),si=Object.freeze({numericMode:"exact"}),ka=Object.freeze({numericMode:"invalid"});function _t(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 ue("Malformed source numeric options.");let e=t.numericMode;if(e!=="legacy"&&e!=="exact")throw new ue("Malformed source numeric options.");return e==="exact"?si:Ue}c(_t,"validatedSourceOptions");var Ea=new WeakSet;function Ca(t){Ea.add(t)}c(Ca,"recordAuthoredDocument");function Pa(t){return Ea.has(t)}c(Pa,"isAuthoredDocument");var me=class t{static{c(this,"ParserContext")}reader;path;#e=[];triggerData=[];inputUses=[];scope=[];languages;sourceOptions=Ue;authoredDeclarations=!1;deferIdentityValidation=!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 Nt(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 qc=I(`^when${W}+([^\\n]+)${W}+execute${W}+([A-Za-z_]\\w*(?:\\.\\w+)*)$`),Bc=I(`^on${W}+([^\\n]+)$`),wa=I(`^where${W}+([^\\n]+)$`),Aa=new Set(["execute","navigate","open","close","refresh","set","notify","confirm","raise"]);function Ia(t,e){for(let n=0;n<e.length;n++){let i=e[n],r=Bc.exec(i.content);if(r===null||r[1].startsWith("row-click "))continue;let o=[];for(let u=n+1;u<e.length&&e[u].indent>i.indent;u++)o.push(e[u]);let s=o.filter(u=>u.indent===o[0]?.indent),a=s.filter(u=>["when","otherwise"].includes(D(u.content))),d=["click","double click","select"].includes(r[1].trim()),p=s.filter(u=>wa.test(u.content)),m=!1;for(let u of a){let y=D(u.content)==="when",h=y?qc.exec(u.content):null;if(y){m&&t.error(l.MisplacedActionOtherwise,"A 'when' alternative must precede 'otherwise'",f(u));let S=_e(t,h?.[1]??u.content.slice(4).trim(),f(u),!0);S!==null&&Gt(t,S),h!==null&&t.error(l.InlineInteractionAlternative,"Interaction alternatives require an indented action list, not 'when <condition> execute <Command>'",f(u))}else(m||u.content!=="otherwise")&&t.error(l.MisplacedActionOtherwise,"An interaction permits one final block-form 'otherwise'",f(u)),m=!0;let x=o.indexOf(u),b=o[x+1];h===null&&(b===void 0||b.indent<=u.indent||!Aa.has(D(b.content)))&&t.error(l.InteractionAlternativeWithoutActions,"An interaction alternative requires a non-empty action list",f(u))}if(a.length>0&&(d||t.error(l.UnsupportedInteractionAlternatives,"Interaction alternatives are only supported on click, double click and select",f(i)),(p.length>0||s.some(u=>Aa.has(D(u.content))))&&t.error(l.MixedInteractionAlternatives,"Interaction alternatives cannot mix with plain actions or 'where'",f(i)),a.some(u=>D(u.content)==="when")||t.error(l.GuardedActionWithoutAlternatives,"A guarded interaction requires at least one 'when' alternative",f(i))),d)for(let u of p)Yc(t,u)}}c(Ia,"validateInteractionBodies");function Yc(t,e){let n=new me(new Ne([]));n.sourceOptions=t.sourceOptions;let i=_e(n,wa.exec(e.content)[1].trim(),f(e),!0);i!==null&&Gt(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(l.LegacyInteractionWhere,r,f(e)):t.information(l.LegacyInteractionWhere,r,f(e))}c(Yc,"deprecateWhere");var Oa=I("^form\\s+[A-Za-z_]\\w*\\s+for\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Fc=I("^(execute|invokes)\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Uc=I("^field\\s+([\\w.]+)(?:\\s|$)"),Wc=I("^with\\s+([A-Za-z_]\\w*)\\s+from\\s+.+$"),Vc=I("^(@?[\\w.]+)\\s*=(?!=|>)\\s*.+$"),zc=I("^parameter\\s+([A-Za-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?))?$"),Qc=new Set(["refresh","navigate","open","close","set","notify","confirm","raise","on","when","otherwise"]);function We(t,e){let n=[],i=new Set,r=[],o=D(e.content)==="behavior",s=null,a=c(p=>{for(;n.length>0&&n[n.length-1].indent>=p.indent;)n.pop();let m=o&&n.length===0?zc.exec(p.content):null;m!==null&&i.add(m[1]);let u=Oa.exec(p.content),y=Fc.exec(p.content);if(u!==null)n.push({command:u[1],kind:"form",indent:p.indent});else if(y!==null)n.push({command:y[2],kind:y[1],indent:p.indent});else if(Qc.has(D(p.content)))n.push({command:"",kind:"other",indent:p.indent});else{let h=n.at(-1);if(h===void 0||h.kind==="other")return;let x=(h.kind==="form"?Uc:h.kind==="execute"?Wc:Vc).exec(p.content);x!==null&&r.push({command:h.command,property:re(x[1]),scope:t.scope,location:f(p)})}},"recognize");a(e);let d=[e];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){for(t.reader.takeSignificant();n.length>0&&n[n.length-1].indent>=p.indent;)n.pop();Oa.test(e.content)&&D(p.content)==="description"&&n.at(-1)?.kind==="form"?s=G(t,p,s,`Form '${e.content.split(I("\\s+"))[1]}'`):p.content.startsWith("```")?t.skipFencedBody():(d.push(p),a(p))}Ia(t,d);for(let p of r)t.inputUses.push(i.has(p.command)?{...p,isParameter:!0}:p)}c(We,"collectInputUses");function ke(t){return I(`(?![\\s\\S]*[\\uD800-\\uDFFF\\u{10000}-\\u{10FFFF}])${t}`)}c(ke,"sourceStreamPattern");var Gc=ke("^[A-Za-z_]\\w*(?![\\s\\S])"),_c=ke("^[\\w.]+(?![\\s\\S])");function Tr(t){return typeof t=="string"&&Gc.test(t)}c(Tr,"isSourceStreamName");function li(t){return typeof t=="string"&&_c.test(t)}c(li,"isSourceStreamTypeName");var Zc=I(`^id\\s+"(${z})"$`),Kc=ke("^(identifier|streamId)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Jc=ke("^eventsource\\s+([A-Za-z_]\\w*)$"),Hc=ke("^stream\\s+([A-Za-z_]\\w*)$");function Ta(t,e){let n=Jc.exec(e.content)?.[1]??"";n===""&&st(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(Xc(t,a));break;case"identifier":r=Ra(t,a,"identifier",r);break;case"description":o=G(t,a,o,`Event source '${n}'`,!0);break;case"id":s=Da(t,a,n,s);break;default:st(t,a,"An event source accepts description, id, identifier and stream declarations."),t.skipBlock(a.indent);break}return{kind:"EventSourceSyntax",name:n,streams:i,identifier:r,description:o,id:s,location:f(e)}}c(Ta,"parseEventSource");function Xc(t,e){let n=Hc.exec(e.content)?.[1]??"";n===""&&st(t,e,"Expected 'stream <Name>'.");let i=null,r=[],o=!1,s={},a=null,d=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?(st(t,p,"Declare either one 'streamId <Type>' or one streamId part block."),t.skipBlock(p.indent)):p.content==="streamId"?(o=!0,s.streamId=f(p),r=ed(t,p)):(i=Ra(t,p,"streamId",i),o=i!==null);break;case"description":a=G(t,p,a,`Stream '${n}'`,!0);break;case"id":d=Da(t,p,n,d);break;default:st(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:d,directiveLocations:s,location:f(e)}}c(Xc,"parseEventStream");function Ra(t,e,n,i){let r=Kc.exec(e.content);return r===null||i!==null?st(t,e,`Declare at most one '${n} <Type>'.`):(i=we(r[2],{...f(e),column:e.indent+1+e.content.indexOf(r[2],n.length)}),Me(t,i,e)),Sn(t,e,l.InvalidEventSourceDeclaration),i}c(Ra,"parseType");function Da(t,e,n,i){let r=Zc.exec(e.content),o=r===null?null:Q(r[1]);return o===null||o.trim()===""||i!==null?st(t,e,`Declare at most one nonempty rename-only 'id "<old-name>"'.`):(i=o,o===n&&t.information(l.RedundantSourceStreamId,"The rename pin repeats the current name; omit it for a new declaration.",f(e))),Sn(t,e,l.InvalidEventSourceDeclaration),i}c(Da,"parsePin");function Ma(t,e,n,i){let[r,o]=n.type.name.split("."),s={kind:"CommandStreamSyntax",eventSource:r,stream:o,streamId:null,streamIdParts:[],propertyCandidate:null,referenceLocation:n.type.location,referenceLength:n.type.name.length,location:f(e)};if(i)return t.error(l.AmbiguousCommandStream,`'${e.content}' has both a property type and a stream route interpretation; neither is selected.`,f(e)),{...s,propertyCandidate:n};let a=null,d=[],p=!1,m={};for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),u.content==="streamId"){a!==null||p?(t.error(l.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent)):(p=!0,m.streamId=f(u),d=Rr(t,u,l.InvalidCommandStream));continue}let y=/^streamId\s*=\s*(.+)$/.exec(u.content);if(y===null||a!==null||p)t.error(l.InvalidCommandStream,"Declare either one 'streamId = <source>' mapping or one streamId part block.",f(u)),t.skipBlock(u.indent);else{let h={...f(u),column:u.indent+1+u.content.indexOf(y[1],u.content.indexOf("=")+1)};a={kind:"PropertyMappingSyntax",property:"streamId",source:ae(y[1],h,t),location:f(u)},Sn(t,u,l.InvalidCommandStream)}}return{...s,streamId:a,streamIdParts:d,directiveLocations:m}}c(Ma,"parseCommandStream");function ed(t,e){let n=[],i=ke("^([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){st(t,r,"Expected '<part> <Type>' without modifiers in a streamId part block."),t.skipBlock(r.indent);continue}let s=we(o[2],{...f(r),column:r.indent+1+r.content.indexOf(o[2],o[1].length)});Me(t,s,r),n.push({kind:"EventStreamIdPartSyntax",name:o[1],type:s,location:f(r)}),Sn(t,r,l.InvalidEventSourceDeclaration)}return n.length===0&&st(t,e,"A streamId part block cannot be empty."),n}c(ed,"parseStreamIdParts");function Rr(t,e,n){let i=[],r=ke("^([A-Za-z_]\\w*)\\s*=(?!=|>)\\s*(.+)$");for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=r.exec(o.content);if(s===null){t.error(n,"Expected '<part> = <source>' in a streamId part block.",f(o)),t.skipBlock(o.indent);continue}let a={...f(o),column:o.indent+1+o.content.indexOf(s[2],o.content.indexOf("=")+1)};i.push({kind:"PropertyMappingSyntax",property:s[1],source:ae(s[2],a,t),location:f(o)}),Sn(t,o,n)}return i.length===0&&t.error(n,"A streamId part block cannot be empty.",f(e)),i}c(Rr,"parseRouteParts");function Sn(t,e,n){let i=t.peekChild(e.indent);i!==void 0&&(t.error(n,"This directive cannot have children.",f(i)),t.skipBlock(e.indent))}c(Sn,"rejectChildren");function st(t,e,n){t.error(l.InvalidEventSourceDeclaration,n,f(e))}c(st,"invalid");var td=I("^[A-Za-z_]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),La=c(t=>D(t.content)==="file"?t.content.substring(4).trim():"","pathOf"),ge=c(t=>La(t).length>0,"isFileDirective"),ci=c(t=>ge(t)&&!td.test(La(t)),"isFileDirectiveAmongProperties");var nd=new Set([32,133,160,5760,8232,8233,8239,8287,12288]);function di(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||nd.has(n)))return!1}return!0}c(di,"isBlankImplementationHint");var ja=new RegExp('^hint[\\u0009-\\u000d\\u0020\\u0085\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+"((?:[^"\\\\\\r\\n]|\\\\[^\\r\\n])*)"$'),xt=c(t=>D(t.content)==="file"&&t.content.substring(4).trim().length>0,"isFile"),Ot=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCode");function et(t,e){let n=e.content.substring(4).trim();return/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/.test(n)&&t.warning(l.AbsoluteFileReference,`'${n}' is an absolute path - a file reference is relative to the repository root, so it means the same thing on every machine`,f(e)),{kind:"FileReferenceSyntax",path:n,location:f(e)}}c(et,"parseFile");var Dr=c(t=>t.raw.trim()==="```","isClosingCodeFence");function Oe(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n))return t.error(l.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e)),null;let i=e;if(!e.content.startsWith("```")){t.warning(l.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let o=t.reader.peekSignificant();if(o===void 0||o.indent<=e.indent||o.content!=="```"&&o.content!==`\`\`\`${n}`)return t.error(l.ExpectedCodeFence,`Expected an opening \`\`\`${n} fence after '${n}'`,f(e)),null;i=t.reader.takeSignificant()}let r=[];for(;;){let o=t.reader.takeRaw();if(o===void 0){t.error(l.UnclosedCodeBlock,"Unclosed inline code block - expected a closing ``` line",f(i));break}if(Dr(o))break;let s=0;for(;s<i.indent&&o.raw[s]===" ";)s++;r.push(o.raw.substring(s))}return{kind:"CodeBlockSyntax",language:n,code:r.join(`
|
|
18
|
-
`),location:f(e)}}c(Oe,"parseCode");function Na(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(l.HandlerWithoutImplementation,"Expected a 'file' directive or an inline code block in the handler",f(e)),null;if(t.reader.takeSignificant(),D(n.content)==="implementation")return id(t,e,n);let i=xt(n)?et(t,n):null,r=i===null&&Ot(t,n)?Oe(t,n):null;if(i!==null||r!==null){let o=t.peekChild(e.indent);return o!==void 0&&D(o.content)==="implementation"&&(t.error(l.ConflictingImplementationSources,"A handler cannot mix wrapped and direct sources.",f(o)),t.skipBlock(e.indent)),{kind:"HandlerSyntax",file:i,code:r,implementation:null,location:f(e)}}return t.error(l.UnknownHandlerDirective,`Unexpected '${n.content}' in handler - expected 'file <path>' or an inline code block`,f(n)),t.skipBlock(e.indent),null}c(Na,"parseHandler");function id(t,e,n){let i=gn(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"?l.InvalidImplementationBlock:l.ConflictingImplementationSources,"A handler has one implementation wrapper and cannot mix wrapped and direct sources.",f(r)),Ot(t,r)?Oe(t,r):t.skipBlock(r.indent);return{kind:"HandlerSyntax",...i,location:f(e)}}c(id,"parseImplementation");function gn(t,e){let n=[],i=null,r=null,o=!1;e.content!=="implementation"&&t.error(l.InvalidImplementationBlock,"Expected 'implementation' with no operand.",f(e));for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="hint"||ja.test(s.content)){let a=ja.exec(s.content),d=a===null?null:Q(a[1]);di(d)?t.error(l.InvalidImplementationHint,"Expected 'hint' followed by one nonblank quoted string.",f(s)):n.push({kind:"ImplementationHintSyntax",text:d,location:f(s)});let p=t.peekChild(s.indent);p!==void 0&&(t.error(l.InvalidImplementationHint,"A hint cannot have children.",f(p)),t.skipBlock(s.indent))}else if(xt(s)||s.content.startsWith("```")){o&&t.error(l.ConflictingImplementationSources,"An implementation has at most one file or inline payload.",f(s));let a=xt(s)?et(t,s):null,d=a===null?Oe(t,s):null;o||(i=a,r=d),o=!0;let p=t.peekChild(s.indent);a!==null&&p!==void 0&&(t.error(l.InvalidImplementationBlock,"A file directive cannot have children.",f(p)),t.skipBlock(s.indent))}else t.error(l.InvalidImplementationBlock,`Unexpected '${s.content}' in implementation - expected hint, file or a tagged fence.`,f(s)),t.skipBlock(s.indent);return{file:i,code:r,implementation:{kind:"ImplementationSyntax",hints:n,location:f(e)}}}c(gn,"parseImplementationWrapper");var rd=I("^system\\s+([A-Za-z_]\\w*)$"),od=I("^operation\\s+([A-Za-z_]\\w*)$"),ad=I("^produces\\s+operation\\s+([A-Za-z_]\\w*)$"),Mr=I("^uses\\s+([A-Za-z_]\\w*)$"),sd=I("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),ld=new Set(["for","tag","generation","origin","documentation","namespace","sequence","correlation","causation","causedBy","occurred"]);function xn(t,e,n,i){let r=t.peekChild(e.indent);r!==void 0&&(t.error(n,i,f(r)),t.skipBlock(e.indent))}c(xn,"rejectOperationChildren");function qa(t,e){let n=rd.exec(e.content);n===null&&t.error(l.InvalidSystemDeclaration,"Expected 'system <Name>'.",f(e));let i=null;for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent))t.reader.takeSignificant(),D(r.content)==="description"?i=G(t,r,i,`System '${n?.[1]??""}'`):(t.error(l.InvalidSystemDeclaration,"A system accepts only a description; abilities are not supported.",f(r)),t.skipBlock(r.indent));return{kind:"SystemSyntax",name:n?.[1]??"",description:i,location:f(e)}}c(qa,"parseSystem");function pi(t,e,n=!1){let i=(n?ad:od).exec(e.content),r=i?.[1]??"";i===null&&t.error(l.InvalidOperationDeclaration,"Expected an operation declaration with one name.",f(e));let o=null,s=null,a=f(e),d=null,p=null,m=[],u=[],y=new Set;for(let h=t.peekChild(e.indent);h!==void 0;h=t.peekChild(e.indent)){t.reader.takeSignificant();let x=sd.exec(h.content),b=n&&x!==null?{...h,content:x[1].trimEnd()}:h;if(x===null&&ld.has(D(h.content))){t.error(l.InvalidOperationDeclaration,"Operations cannot declare event routing or metadata; escape a keyword-named input with @.",f(h)),t.skipBlock(h.indent);continue}if(!Mr.test(h.content)&&Je(b)!==void 0){let S=Fe(t,b);n&&x===null&&t.error(l.InvalidOperationMapping,"An inline operation input requires '<property> <Type> = <source>'.",f(h)),S.isSubject&&t.error(l.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not operation inputs (decision 0008: one data subject per event).",f(h)),(S.isIdentifier||S.isGenerated)&&t.error(l.InvalidOperationDeclaration,"Operation inputs cannot be identifier or generated properties.",f(h)),y.has(S.name)&&t.error(l.DuplicateDeclaration,`Operation '${r}' already declares input '${S.name}'.`,f(h)),y.add(S.name),m.push(S),n&&x!==null&&u.push({kind:"PropertyMappingSyntax",property:S.name,source:ae(x[2],{...f(h),column:h.indent+h.content.length-x[2].length+1},t),location:f(h)}),xn(t,h,l.InvalidOperationDeclaration,"An operation input cannot have children.")}else if(D(h.content)==="description")o=G(t,h,o,`Operation '${r}'`);else if(Mr.test(h.content))s!==null?t.error(l.InvalidSystemReference,"An operation declares exactly one 'uses <System>'.",f(h)):(s=Mr.exec(h.content)[1],a={...f(h),column:f(h).column+h.content.indexOf(s,4)}),xn(t,h,l.InvalidSystemReference,"A system reference cannot have children.");else if(h.content==="execute"||h.content==="compensate"){let S=cd(t,h);h.content==="execute"?d!==null?t.error(l.InvalidOperationDeclaration,"An operation declares execute at most once.",f(h)):d=S:p!==null?t.error(l.InvalidOperationDeclaration,"An operation declares compensate at most once.",f(h)):p=S}else t.error(l.InvalidOperationDeclaration,`Unexpected '${h.content}' in operation - expected uses, an input, description, execute or compensate.`,f(h)),t.skipBlock(h.indent)}return s===null&&t.error(l.InvalidSystemReference,"An operation requires exactly one 'uses <System>'.",f(e)),{operation:{kind:"OperationSyntax",name:r,uses:s??"",usesLocation:a,inputs:m,description:o,execute:d,compensate:p,location:f(e)},mappings:u}}c(pi,"parseOperation");function cd(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=G(t,a,n,`Operation phase '${e.content}'`);continue}if(D(a.content)==="implementation"){s&&t.error(l.ConflictingImplementationSources,"A phase cannot mix wrapped and direct sources or repeat its wrapper.",f(a));let d=gn(t,a);s||(i=d.file,r=d.code,o=d.implementation),s=!0}else if(ge(a)||a.content.startsWith("```")){s&&t.error(l.ConflictingImplementationSources,"A phase has at most one file or inline payload.",f(a));let d=ge(a)?et(t,a):null,p=d===null?Oe(t,a):null;s||(i=d,r=p),s=!0,d!==null&&xn(t,a,l.InvalidImplementationBlock,"A file directive cannot have children.")}else t.error(l.InvalidOperationDeclaration,"A phase accepts description, file, a tagged fence or implementation.",f(a)),t.skipBlock(a.indent)}return{kind:"OperationPhaseSyntax",description:n,file:i,code:r,implementation:o,location:f(e)}}c(cd,"parseOperationPhase");var dd=I("^(?:given\\s+operation|then\\s+(?:operation|compensated))(?:\\s|$)"),pd=I("^(given operation|then operation|then compensated)\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(\\s+fails)?$"),ud=I("^specification\\s+([A-Za-z_]\\w*)$"),fd=I("^given caller as ([A-Za-z_]\\w*)$"),md="([A-Z]\\w*(?:\\.\\w+)*)",yd="(?:\\s+(?<property>[\\w.]+)\\s*=(?!=|>)\\s*(?<value>.+))?",Zt=c((t,e="")=>Z(`^${t}\\s+${md}${e}${yd}$`.replaceAll("\\s",W)),"stepPattern"),hd=Zt("given"),Sd=Zt("when\\s+append"),gd=Zt("when"),xd=Zt("then"),vd=I("^then\\s+query\\b"),Ba=I("^(?:given|then)\\s+readmodel\\b"),$d=Zt("given\\s+readmodel"),bd=Zt("then\\s+readmodel","(?<exactly>\\s+exactly)?"),Ya=I("^then\\s+no\\b"),kd=I(`^then\\s+error\\s+"(${z})"$`),Nr=I("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Ed=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Cd=I("^given\\s+clock\\b"),Pd=I("^given\\s+capture\\b"),Ad=I("^when\\s+clock\\b"),wd=I("^when\\s+trigger\\b"),Id=I("^when\\s+capture\\b"),Od=I("^when\\s+query\\b"),Td=I("^then\\s+result\\b"),Rd=I("^then\\s+no\\s+result\\b"),Dd=Z("^when\\s+redelivered\\b"),Md=Z("^when\\s+redelivered\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)\\s+to\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Ld=I("^then\\s+no\\s+events\\b"),jd=I('^(given|when)\\s+clock\\s+"(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:\\d{2}))"$'),Nd=I("^when\\s+trigger\\s+([A-Za-z_]\\w*)$"),qd=I("^(?:given|when)\\s+capture\\s+([A-Za-z_]\\w*)$"),Bd=I("^when\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),Yd=I("^then\\s+result(\\s+exactly)?$"),Fa=Z("^then\\s+no\\s+readmodel\\s+([A-Z]\\w*)\\s+for\\s+(.+)$"),Fd=Z(`^(?:"${z}"|'(?:[^'\\\\]|\\\\.)*')$`),Ud=Z("^then\\s+query\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)(\\s+exactly)?$");function qr(t,e){let n=ud.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidSpecificationDeclaration,`Invalid specification declaration '${e.content}' - expected 'specification <Name>'`,f(e));let i=null,r=[],o=[],s={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 u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ge(u)||Wd(t,u,s))continue;let y=Ya.test(u.content)?"then":D(u.content);if(y==="parameter"){let h=la(t,u);h!==null&&r.push(h)}else if(y==="case"){let h=ca(t,u);h!==null&&o.push(h)}else y==="description"?i=G(t,u,i,`Specification '${n}'`):y==="given"?Vd(t,u,s):y==="when"?_d(t,u,s,n):y==="then"?Zd(t,u,s):(t.error(l.UnknownSpecificationDirective,`Unexpected '${D(u.content)}' in specification body`,f(u)),t.skipBlock(u.indent))}s.noEventsLine!==void 0&&(s.whenAppended!==null||s.thenEvents.length>0||s.thenEventsInAnyOrder||s.thenErrors.length>0||s.thenDenied!==null)&&t.error(l.InvalidNoEventsExpectation,"'then no events' cannot follow 'when append' or accompany event, event-order, error or denial expectations.",f(s.noEventsLine));let{whenDeclared:a,noEventsLine:d,...p}=s,m={kind:"SpecificationSyntax",sourceOptions:t.sourceOptions,name:n,description:i,...p,...r.length===0?{}:{parameters:r},...o.length===0?{}:{cases:o},location:f(e)};return da(m,t),m}c(qr,"parseSpecification");function Wd(t,e,n){if(!dd.test(e.content))return!1;let i=pd.exec(e.content);if(i===null||i[1]==="given operation"!=(i[3]!==void 0))t.error(l.InvalidOperationSpecification,"Expected 'given operation <Name> fails', 'then operation <Name>' or 'then compensated <Name>'.",f(e)),xe(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=Bt(t,o,Nr,l.InvalidOperationSpecification);s!==null&&r.push(s)}n.thenOperations.push({kind:"SpecificationOperationSyntax",operation:i[2],values:r,location:f(e)})}else xn(t,e,l.InvalidOperationSpecification,"Failure and compensation assertions cannot have children."),i[1]==="given operation"?n.givenOperationFailures.push({kind:"SpecificationOperationFailureSyntax",operation:i[2],location:f(e)}):n.thenCompensated.push({kind:"SpecificationCompensatedSyntax",operation:i[2],location:f(e)});return!0}c(Wd,"parseOperationStep");function Vd(t,e,n){if(Cd.test(e.content))n.givenClock!==null?(t.error(l.InvalidSpecificationClock,"A specification states its clock at most once.",f(e)),xe(t,e.indent)):n.givenClock=Ua(t,e,"given");else if(Pd.test(e.content)){let i=Wa(t,e,"given");i!==null&&n.givenCaptures.push(i)}else if(e.content.startsWith("given caller"))if(n.givenCaller!==null||n.givenCallerPersona!==void 0)t.error(l.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'given caller' block.",f(e)),t.skipBlock(e.indent);else if(e.content.startsWith("given caller as")){let i=fd.exec(e.content);i===null&&t.error(l.InvalidSpecificationCallerPersona,"Expected 'given caller as <Persona>'.",f(e));let r=t.peekChild(e.indent);r!==void 0&&t.error(l.InvalidSpecificationCallerPersona,"'given caller as <Persona>' has no body; use an explicit 'given caller' for refinements.",f(r)),xe(t,e.indent),i!==null&&(n.givenCallerPersona={kind:"SpecificationCallerPersonaSyntax",name:i[1],location:f(e)})}else n.givenCaller=Gd(t,e);else if(Ba.test(e.content)){let i=Va(t,e,$d,"given");i!==void 0&&n.givenReadModels.push(i)}else{let i=Br(t,e,hd,"given");i!==void 0&&n.given.push(i)}}c(Vd,"parseGiven");var zd=I(`^role${W}+"(${z})"$`),Qd=I(`^claim${W}+"(${z})"${W}*=${W}*"(${z})"$`);function Gd(t,e){if(e.content!=="given caller")return t.error(l.InvalidSpecificationCaller,"Expected exactly 'given caller'.",f(e)),t.skipBlock(e.indent),null;let n=!1,i=[],r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=zd.exec(o.content),a=Qd.exec(o.content);o.content==="authenticated"&&!n?n=!0:s!==null?i.push(Q(s[1])):a!==null?r.push({kind:"SpecificationCallerClaimSyntax",type:Q(a[1]),value:Q(a[2]),location:f(o)}):t.error(Yt(o.content)?l.InvalidSpecificationCaseReference:l.InvalidSpecificationCaller,`Invalid caller fixture '${o.content}' - expected authenticated, role "...", or claim "..." = "...".`,f(o))}return{kind:"SpecificationCallerSyntax",authenticated:n,roles:i,claims:r,location:f(e)}}c(Gd,"parseCaller");function _d(t,e,n,i){let r=e.content.startsWith("when append");if(n.whenDeclared){let d=n.whenAppended!==null||r?l.ConflictingSpecificationActions:l.DuplicateSpecificationWhen;t.error(d,`Specification '${i}' already declares a 'when' - a specification can have at most one`,f(e)),xe(t,e.indent);return}if(n.whenDeclared=!0,r){n.whenAppended=Br(t,e,Sd,"when append")??null;return}if(Dd.test(e.content)){let d=Md.exec(e.content);d===null?(t.error(l.UnmatchedRedeliveredOccurrence,"Expected 'when redelivered <Event> to <Reaction>'.",f(e)),xe(t,e.indent)):n.whenRedelivered={kind:"SpecificationRedeliverySyntax",eventType:d[1],reaction:d[2],...jr(t,e,void 0,void 0,"when redelivered"),location:f(e)};return}if(Ad.test(e.content)){n.whenClock=Ua(t,e,"when");return}if(wd.test(e.content)){n.whenTrigger=Lr(t,e,Nd,l.InvalidSpecificationTrigger,"when trigger","when trigger <Trigger>",(d,p)=>({kind:"SpecificationTriggerSyntax",trigger:d,values:p,location:f(e)}));return}if(Id.test(e.content)){n.whenCapture=Wa(t,e,"when");return}if(Od.test(e.content)){n.whenQuery=Lr(t,e,Bd,l.InvalidSpecificationQueryAction,"when query","when query <Query>",(d,p)=>({kind:"SpecificationWhenQuerySyntax",query:d,arguments:p,location:f(e)}));return}let o=gd.exec(e.content);if(o===null){t.error(l.InvalidSpecificationWhen,`Invalid 'when' declaration '${e.content}' - expected 'when <CommandType>' or 'when append <EventType>'`,f(e)),xe(t,e.indent);return}let s=[],a=jr(t,e,s,o);n.when={kind:"SpecificationCommandSyntax",commandType:o[1],...a,generatedValues:s,inlineProperty:o.groups?.property??null,location:f(e)}}c(_d,"parseWhen");function Zd(t,e,n){if(Ld.test(e.content)){e.content!=="then no events"||n.thenNoEvents?t.error(l.InvalidNoEventsExpectation,"Expected one 'then no events' directive.",f(e)):(n.thenNoEvents=!0,n.noEventsLine=e);let o=t.peekChild(e.indent);o!==void 0&&t.error(l.InvalidNoEventsExpectation,"'then no events' cannot have child mappings.",f(o)),xe(t,e.indent);return}if(wr.test(e.content)){let o=sa(t,e);n.thenReturns!==null?t.error(l.InvalidReturnExpectation,"A specification declares at most one return expectation.",f(e)):n.thenReturns=o;return}if(e.content.startsWith("then events")){e.content!=="then events in any order"||n.thenEventsInAnyOrder?t.error(l.InvalidSpecificationEventOrder,"Expected one 'then events in any order' directive.",f(e)):n.thenEventsInAnyOrder=!0,xe(t,e.indent);return}if(Td.test(e.content)){Jd(t,e,n);return}if(Rd.test(e.content)){e.content!=="then no result"||n.thenNoResult!==null?t.error(l.InvalidSpecificationQueryAction,"Expected one 'then no result' directive.",f(e)):n.thenNoResult={kind:"SpecificationNoResultSyntax",location:f(e)},xe(t,e.indent);return}if(e.content.startsWith("then denied")){e.content!=="then denied"?(t.error(l.InvalidSpecificationDenied,"Expected exactly 'then denied'.",f(e)),xe(t,e.indent)):n.thenDenied!==null?t.error(l.DuplicateSpecificationCallerOrDenied,"A specification has at most one 'then denied' outcome.",f(e)):n.thenDenied={kind:"SpecificationDeniedSyntax",location:f(e)};return}if(e.content==="then error"){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,location:f(e)});return}if(e.content.startsWith("then error case.")){let o=Le(e.content.substring(11),{...f(e),column:f(e).column+11},t);o.kind==="CaseValueExpressionSyntax"&&n.thenErrors.push({kind:"SpecificationErrorSyntax",name:null,caseValue:o,location:f(e)});return}let i=kd.exec(e.content);if(i!==null){n.thenErrors.push({kind:"SpecificationErrorSyntax",name:Q(i[1]),location:f(e)});return}if(D(e.content.substring(4).trim())==="error"){t.error(l.InvalidThenError,`Invalid 'then error' declaration '${e.content}' - expected 'then error' or 'then error "<reason>"'`,f(e)),xe(t,e.indent);return}if(Ya.test(e.content)){if(t.sourceOptions.numericMode==="exact"){let s=Kd(t,e);s!==null&&n.thenAbsentReadModels.push(s);return}let o=Fa.exec(e.content);if(o!==null&&!o[2].endsWith(" exactly")){let s=Le(o[2].trim(),f(e),t.valueContext);(s.kind==="LiteralExpressionSyntax"||s.kind==="ObjectExpressionSyntax"||s.kind==="CaseValueExpressionSyntax")&&n.thenAbsentReadModels.push({kind:"SpecificationAbsentReadModelSyntax",name:o[1],key:s,location:f(e)})}t.skipOpaqueBlock(e.indent);return}if(vd.test(e.content)){let o=t.sourceOptions.numericMode==="exact",s=c((u,y,h)=>{if(!o)return t.skipOpaqueBlock(h.indent);t.error(u,y,f(h)),t.skipBlock(h.indent)},"reject"),a=Ud.exec(e.content);if(a===null)return s(l.InvalidSpecificationQuery,`Invalid 'then query' declaration '${e.content}' - expected 'then query <Query> [exactly]'`,e);let d=[],p=[],m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent))t.reader.takeSignificant(),u.content==="arguments"&&!m?d.push(...vn(t.valueContext,u,!0)):u.content==="arguments"?s(l.DuplicateSpecificationQueryArguments,`Query assertion '${a[1]}' already declares arguments`,u):u.content==="result"?p.push({kind:"SpecificationQueryResultSyntax",properties:vn(t.valueContext,u,!0),exactly:!1,location:f(u)}):s(l.UnknownSpecificationQueryDirective,`Unexpected '${D(u.content)}' in 'then query' body - expected arguments or result`,u),m||=u.content==="arguments";n.thenQueries.push({kind:"SpecificationQuerySyntax",query:a[1],arguments:d,results:p,exactly:a[2]!==void 0,location:f(e)});return}if(Ba.test(e.content)){let o=Va(t,e,bd,"then");o!==void 0&&n.thenReadModels.push(o);return}let r=Br(t,e,xd,"then");r!==void 0&&n.thenEvents.push(r)}c(Zd,"parseThen");function Kd(t,e){let n=Fa.exec(e.content);if(n===null||n[2].endsWith(" exactly"))return t.error(l.InvalidAbsentReadModelStep,`Invalid absence assertion '${e.content}' - expected 'then no readmodel <ReadModelType> for <key>'`,f(e)),xe(t,e.indent),null;let i=n[2].trim(),o=!(i.startsWith('"')||i.startsWith("'"))||Fd.test(i)?Le(i,f(e),t.valueContext):null,s=o!==null&&(o.kind==="LiteralExpressionSyntax"||o.kind==="ObjectExpressionSyntax"||o.kind==="CaseValueExpressionSyntax");s||t.error(l.InvalidAbsentReadModelStep,`Invalid absence key '${i}' - expected exactly one concrete value.`,f(e));let a=!1;for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(l.InvalidAbsentReadModelStep,"An absent read model assertion cannot have child mappings.",f(d)),a=!0;return a||!s?null:{kind:"SpecificationAbsentReadModelSyntax",name:n[1],key:o,location:f(e)}}c(Kd,"parseAbsentReadModel");function xe(t,e){if(t.sourceOptions.numericMode!=="exact")return t.skipBlock(e);t.skipOpaqueBlock(e)}c(xe,"skipBody");function Ua(t,e,n){let i=jd.exec(e.content);return xe(t,e.indent),i===null||i[1]!==n?(t.error(Yt(e.content)?l.InvalidSpecificationCaseReference:l.InvalidSpecificationClock,`Invalid '${n} clock' - expected '${n} clock "<ISO 8601 instant>"', such as '${n} clock "2026-10-05T08:00:00Z"'`,f(e)),null):{kind:"SpecificationClockSyntax",instant:i[2],location:f(e)}}c(Ua,"parseClock");function Wa(t,e,n){return Lr(t,e,qd,l.InvalidSpecificationCapture,`${n} capture`,`${n} capture <Capture>`,(i,r)=>({kind:"SpecificationCaptureSyntax",capture:i,record:r,location:f(e)}))}c(Wa,"parseCapture");function Lr(t,e,n,i,r,o,s){let a=n.exec(e.content);return a===null?(t.error(i,`Invalid '${r}' declaration '${e.content}' - expected '${o}'`,f(e)),xe(t,e.indent),null):s(a[1],vn(t,e))}c(Lr,"parseNamedStep");function Jd(t,e,n){let i=Yd.exec(e.content);if(i===null){t.error(l.InvalidSpecificationQueryAction,`Invalid 'then result' declaration '${e.content}' - expected 'then result [exactly]'`,f(e)),xe(t,e.indent);return}n.thenResults.push({kind:"SpecificationQueryResultSyntax",properties:vn(t,e),exactly:i[1]!==void 0,location:f(e)})}c(Jd,"parseResult");function Va(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(l.InvalidReadModelStep,`Invalid '${i} readmodel' declaration '${e.content}' - expected '${i} readmodel <ReadModelType>'`,f(e)),xe(t,e.indent);return}return{kind:"SpecificationReadModelSyntax",name:r[1],properties:vn(t,e,!1,r),exactly:i==="then"&&r.groups?.exactly!==void 0,inlineProperty:r.groups?.property??null,location:f(e)}}c(Va,"parseReadModelStep");function Br(t,e,n,i){let r=n.exec(e.content);if(r===null){t.error(l.InvalidEventStep,`Invalid '${i}' declaration '${e.content}' - expected '${i} <EventType>'`,f(e)),xe(t,e.indent);return}return{kind:"SpecificationEventSyntax",eventType:r[1],...jr(t,e,void 0,r,i),inlineProperty:r.groups?.property??null,location:f(e)}}c(Br,"parseEventStep");var Yr=ke("^stream\\s+([A-Za-z_]\\w*)\\.([A-Za-z_]\\w*)$"),Hd=I("^streamId\\s*=(?!=|>)\\s*(.+)$");function jr(t,e,n,i,r){let o=[];fi(t,e,i,o);let s=null,a,d,p=!1;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n!==void 0&&Gn.test(m.content)){let y=Bt(t,m,_n,l.InvalidGeneratedFixture);y!==null&&n.push(y);continue}let u=Nr.exec(m.content);if(u!==null)$n(t,o,za(t,m,u));else if(D(m.content)==="stream"||m.content.startsWith("no stream")){if(r===void 0){t.error(l.SpecificationStreamOnCommand,"A command occurrence cannot declare a route; assert it on a then event.",f(m)),t.skipBlock(m.indent);continue}if(p){t.error(l.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(m)),t.skipBlock(m.indent);continue}let y=Yr.exec(m.content);m.content==="no stream"&&(r==="then"||r==="when redelivered")?(d={kind:"SpecificationNoStreamSyntax",location:f(m)},p=!0,ui(t,m)):y!==null?(a=Fr(t,m,y),p=!0):(t.error(l.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",f(m)),t.skipBlock(m.indent))}else if(D(m.content)==="for"){let y=m.content.substring(3).trim();y.length===0?t.error(l.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(m)):s!==null?t.error(l.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(m)):s=Le(y,f(m),t)}else t.error(l.InvalidSpecificationValue,`Invalid property mapping '${m.content}' - expected '<property> = <value>'`,f(m))}return{values:o,for:s,...a===void 0?{}:{stream:a},...d===void 0?{}:{noStream:d}}}c(jr,"parseValuesWithEventSource");function Fr(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(l.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent)):(o=!0,s.streamId=f(a),r=Rr(t,a,l.InvalidSpecificationStream).map(m=>m.source.kind==="PathExpressionSyntax"&&m.source.path.startsWith("case.")?{...m,source:Le(m.source.path,m.source.location,t)}:m));continue}let d=Hd.exec(a.content);if(d===null||i!==null||o){t.error(l.InvalidSpecificationStream,"Declare either one 'streamId = <literal>' mapping or one streamId part block.",f(a)),t.skipBlock(a.indent);continue}let p={...f(a),column:a.indent+1+a.content.indexOf(d[1],a.content.indexOf("=")+1)};i={kind:"PropertyMappingSyntax",property:"streamId",source:Le(d[1],p,t),location:f(a)},ui(t,a)}return{kind:"SpecificationStreamSyntax",eventSource:n[1],stream:n[2],streamId:i,streamIdParts:r,directiveLocations:s,referenceLocation:{...f(e),column:e.indent+1+e.content.indexOf(n[1],6)},referenceLength:n[1].length+1+n[2].length,location:f(e)}}c(Fr,"parseSpecificationStream");function ui(t,e){let n=t.peekChild(e.indent);n!==void 0&&(t.error(l.InvalidSpecificationStream,"This directive cannot have children.",f(n)),t.skipBlock(e.indent))}c(ui,"rejectSpecificationRouteChildren");function vn(t,e,n=!1,i){let r=[];fi(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"?Ed:Nr).exec(o.content);if(s===null){t.error(l.InvalidSpecificationValue,`Invalid property mapping '${o.content}' - expected '<property> = <value>'`,f(o));continue}$n(t,r,za(t,o,s,n))}return r}c(vn,"parseValues");function za(t,e,n,i=!1){return{kind:"PropertyMappingSyntax",property:n[1],source:Le(n[2],f(e),t,i),location:f(e)}}c(za,"mappingOf");var Xd=Z("^example\\s+([A-Z]\\w*)\\s*:\\s*([A-Z]\\w*(?:\\.\\w+)*)$".replaceAll("\\s",W)),ep=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$".replaceAll("\\s",W));function lt(t,e){let n=Xd.exec(e.content);if(n===null)return t.error(l.InvalidSpecificationExample,`Invalid example declaration '${e.content}' - expected 'example <Name> : <EventOrCommandOrReadModel>'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SpecificationExampleSyntax",name:"",type:"",values:[],generatedValues:[],for:null,description:null,location:f(e)};let i=tp(t,e,void 0,!0,n[1]);for(let r of Ft(i))t.error(l.InvalidSpecificationCaseReference,"Case references are not permitted in example bodies.",r.location);return{kind:"SpecificationExampleSyntax",name:n[1],type:n[2],...i,location:f(e)}}c(lt,"parseExample");function fi(t,e,n,i){if(n?.groups?.property===void 0)return;let r=n.groups.property,o=n.groups.value,s=e.content.length-o.length,a=f(e),d=qt(t,o,{...a,column:a.column+s},l.InvalidSpecificationValue);d!==null&&i.push({kind:"PropertyMappingSyntax",property:r,source:d,location:{...a,column:a.column+e.content.lastIndexOf(r,e.content.indexOf("="))}})}c(fi,"addInlineValue");function $n(t,e,n,i=[]){if([...e,...i].some(r=>r.property===n.property)){t.error(l.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)}c($n,"addFixtureValue");function tp(t,e,n,i=!1,r){let o=[],s=[],a=null,d=null,p,m;fi(t,e,n,o);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),r!==void 0&&D(u.content)==="description"){d=G(t,u,d,`Example '${r}'`);continue}if(i&&Gn.test(u.content)){let h=Bt(t,u,_n,l.InvalidGeneratedFixture);h!==null&&(r===void 0?s.push(h):$n(t,s,h,o));continue}let y=ep.exec(u.content);if(r!==void 0&&y===null&&(D(u.content)==="stream"||u.content.startsWith("no stream"))){let h=Yr.exec(u.content);p!==void 0||m!==void 0?(t.error(l.InvalidSpecificationStream,"An event occurrence declares at most one stream or no stream directive.",f(u)),t.skipOpaqueBlock(u.indent)):u.content==="no stream"?(m={kind:"SpecificationNoStreamSyntax",location:f(u)},ui(t,u)):h!==null?p=Fr(t,u,h):(t.error(l.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on an event example.",f(u)),t.skipOpaqueBlock(u.indent));continue}if(y!==null)$n(t,o,{kind:"PropertyMappingSyntax",property:y[1],source:Le(y[2],f(u),t),location:f(u)},s);else if(D(u.content)==="for"){let h=u.content.substring(3).trim();h.length===0?t.error(l.InvalidSpecificationEventSource,"Invalid event-source assertion 'for' - expected 'for <value>'",f(u)):a!==null?t.error(l.DuplicateSpecificationEventSource,"A specification step can declare its event-source assertion only once",f(u)):a=Le(h,f(u),t)}else t.error(l.InvalidSpecificationValue,`Invalid property mapping '${u.content}' - expected '<property> = <value>'`,f(u))}return{values:o,for:a,generatedValues:s,description:d,...p===void 0?{}:{stream:p},...m===void 0?{}:{noStream:m}}}c(tp,"parseFixtureBody");var Qa=["StateChange","StateView","Automation","Translate"];var de;(function(t){t.Inbound="Inbound",t.Outbound="Outbound"})(de||(de={}));var Ur="events",Wr="from";function bn(t){return t.syntaxKind===Ur}c(bn,"isEventsSource");function Ga(t){return bn(t)?t.settings.filter(e=>e.name===Wr):[]}c(Ga,"consumedEvents");var se;(function(t){t.Private="Private",t.Public="Public"})(se||(se={}));var np=new RegExp(`^${W}*$`),kn=c(t=>np.test(t),"isBlankPublicEventOrigin");function mi(t){if(t.kind==="EventSyntax"||t.kind==="ImportSyntax"){let e=t,n=e.visibility===void 0?se.Private:e.visibility;if(n!==se.Private&&n!==se.Public)return"Event visibility must be Private or Public.";if(e.origin!=null&&(typeof e.origin!="string"||kn(e.origin)))return"An event or import origin must be a nonblank quoted string.";if(e.origin!=null&&n!==se.Public)return"An event or import with an origin is a public contract.";if(t.kind==="ImportSyntax"&&n===se.Public&&e.origin==null)return"A public contract import requires an origin."}if(t.kind==="SliceSyntax"){let e=t;if(e.direction!=null&&e.type!=="Translate")return"Only a Translate slice may declare a direction.";if(e.direction!=null&&e.direction!==de.Inbound&&e.direction!==de.Outbound)return"A translation direction must be Inbound or Outbound."}}c(mi,"publicEventMetadataError");var En=["tag"];var ip=I(`^id\\s+"(${z})"$`),Kt=class{static{c(this,"EventMetadataParser")}name;value={id:null,description:null,documentation:null};constructor(e){this.name=e}tryParse(e,n){let i=f(n);switch(D(n.content)){case"id":{let r=ip.exec(n.content),o=r===null?"":Q(r[1]);return o.trim().length===0||this.value.id!==null?e.error(l.InvalidEventId,`Event '${this.name}' accepts one nonempty 'id "<old-name>"'`,i):(this.value.id=o,o===this.name&&e.information(l.RedundantEventId,`Event '${this.name}' already has this name as its identity - remove the redundant id`,i)),!0}case"description":return this.value.description=G(e,n,this.value.description,`Event '${this.name}'`,!0),!0;case"documentation":return this.value.documentation=Ie(e,n,this.value.documentation,`Event '${this.name}'`,l.InvalidEventDocumentation),!0;default:return!1}}};var rp=I("^type\\s+([A-Za-z_]\\w*)$"),op=I(`^(?:(?<public>public)\\s+)?event\\s+(?<name>[A-Za-z_]\\w*)(?:\\s+generation\\s+(?<generation>[0-9]+))?(?:\\s+from\\s+"(?<origin>${z})")?$`),ap=I("^readmodel\\s+([A-Za-z_]\\w*)$"),_a=4294967295,sp=I("^[A-Z]\\w*(?:\\[\\])?(?:\\?|\\s+optional)?$"),lp=I("^[A-Za-z_]\\w*$"),Za=c(t=>D(t.content)==="description"&&Je(t)===void 0,"isDescription");function Vr(t,e,n,i,r){return e.isIdentifier?(t.error(i,r,f(n)),{...e,isIdentifier:!1}):e}c(Vr,"withoutIdentifier");function Ka(t,e){let n=rp.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidTypeDeclaration,`Invalid type declaration '${e.content}' - expected 'type <Name>'`,f(e));let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),Za(o)){r=G(t,o,r,`Type '${n}'`);continue}if(ci(o))continue;let s=Fe(t,o);if(s===void 0){t.error(l.InvalidPropertyDeclaration,`Invalid property '${o.content}' - expected '<name> <Type>'`,f(o));continue}i.push(Vr(t,s,o,l.IdentifierOutsideCommand,`Property '${s.name}' of type '${n}' cannot be marked identifier - only a command property can be`))}return i.length===0&&t.error(l.TypeWithoutProperties,`Type '${n}' must declare at least one property`,f(e)),{kind:"TypeSyntax",name:n,properties:i,description:r,location:f(e)}}c(Ka,"parseType");function Ja(t,e){let n=op.exec(e.content),i=n?.groups?.name??"";n===null&&t.error(l.InvalidEventDeclaration,`Invalid event declaration '${e.content}' - expected '[public] event <Name> [generation <N>] [from "<origin>"]'`,f(e));let r=n?.groups?.origin===void 0?null:Q(n.groups.origin),o=n?.groups?.public!==void 0||r!==null?se.Public:se.Private;r!==null&&kn(r)&&t.error(l.InvalidEventDeclaration,"An event origin must be a nonblank quoted string",f(e));let s=n?.groups?.generation!==void 0,a=1;if(s){let u=Number(n.groups.generation);!Number.isSafeInteger(u)||u===0||u>=_a?t.error(l.InvalidEventGeneration,`Event '${i}' must declare a generation between 1 and ${_a-1}`,f(e)):a=u}let d=[],p=[],m=new Kt(i);for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ci(u))continue;if(En.includes(D(u.content))){let h=Cn(t,u);h!==void 0&&p.push(h);continue}let y=Fe(t,u);if(y===void 0){m.tryParse(t,u)||t.error(l.InvalidPropertyDeclaration,`Invalid property '${u.content}' - expected '<name> <Type>'`,f(u));continue}d.push(Vr(t,y,u,l.IdentifierOnEventProperty,`Property '${y.name}' of event '${i}' cannot be marked identifier - an event never carries its event source id`))}return{kind:"EventSyntax",name:i,properties:d,tags:p,visibility:o,origin:r,generation:a,hasGenerationMarker:s,...m.value,location:f(e)}}c(Ja,"parseEvent");function Cn(t,e,n=!0){let i=e.content.substring(3).trim();if(n&&sp.test(i)&&t.warning(l.TagPropertyReadAsTag,`'${e.content}' declares a static tag with the value '${i}', not a property named 'tag' - write 'tag "${i}"' for the tag, or '@${e.content}' for the property`,f(e)),i.length===0){t.error(l.TagWithoutValue,"Expected a value after 'tag' - an identifier, a string literal or a context expression",f(e));return}if(lp.test(i))return{kind:"TagSyntax",value:{kind:"LiteralExpressionSyntax",value:i,location:f(e)},location:f(e)};let r=ae(i,f(e),t);if(r.kind==="RawExpressionSyntax"){t.error(l.InvalidTagValue,`Invalid tag value '${i}' - expected an identifier, a string literal or a context expression`,f(e));return}return{kind:"TagSyntax",value:r,location:f(e)}}c(Cn,"parseTag");function Ha(t,e){let n=ap.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidReadModelDeclaration,`Invalid read model declaration '${e.content}' - expected 'readmodel <Name>'`,f(e));let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),Za(s))r=G(t,s,r,`Read model '${n}'`);else if(D(s.content)==="documentation"&&Je(s)===void 0)o=Ie(t,s,o,`Read model '${n}'`);else{if(ci(s))continue;{let a=Fe(t,s);if(a===void 0){t.error(l.InvalidPropertyDeclaration,`Invalid property '${s.content}' - expected '<name> <Type>'`,f(s));continue}i.push(Vr(t,a,s,l.IdentifierOutsideCommand,`Property '${a.name}' of read model '${n}' cannot be marked identifier - only a command property can be`))}}return{kind:"ReadModelSyntax",name:n,properties:i,description:r,documentation:o,location:f(e)}}c(Ha,"parseReadModel");var cp=Z("^@?[A-Za-z_]\\w*(\\.@?[A-Za-z_$]\\w*)*$");function Ee(t,e,n){if(n=n.valueContext,t=t.trim(),t.startsWith("`")){let o=[];if(!t.endsWith("`")||t.length<2)return n.error(l.UnterminatedTemplateExpression,"Unterminated template expression - expected a closing backtick",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};let s=t.substring(1,t.length-1),a=0;for(let d=0;d<s.length;d++){if(s[d]!=="$"||s[d+1]!=="{")continue;d>a&&o.push({kind:"TemplateTextSyntax",text:s.substring(a,d),location:e});let p=s.indexOf("}",d);if(p<0)return n.error(l.UnterminatedInterpolation,"Unterminated ${...} interpolation in template expression",e),{kind:"TemplateExpressionSyntax",parts:o,location:e};o.push({kind:"TemplateInterpolationSyntax",expression:Ee(s.substring(d+2,p),e,n),location:e}),d=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 Be(i,e,n);if(t.startsWith("literal ")){let o=fn(t.substring(8).trim(),e,n);return o!==void 0?o:(n.error(l.ExpectedLiteralValue,`Expected a literal value after 'literal', got '${t.substring(8).trim()}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}if(t==="$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=fn(t,e,n);return r!==void 0?r:cp.test(t)?{kind:"PathExpressionSyntax",path:t.replaceAll("@",""),location:e}:(n.error(l.InvalidExpression,`Invalid expression '${t}'`,e),{kind:"RawExpressionSyntax",text:t,location:e})}c(Ee,"parseProjectionExpression");var hi=c(t=>({legacy:I(t),native:Z(t)}),"grammar"),dp=hi("^capture\\s+([A-Za-z_]\\w*)$"),pp=/^[A-Za-z_][\w.]*$/,up=hi("^append\\s+([A-Z]\\w*)$"),fp=hi("^children\\s+([a-z_]\\w*)\\s+identified\\s+by\\s+([\\w.]+)$"),mp=hi("^nested\\s+([\\w.]+)$"),yi=c((t,e)=>t.sourceOptions.numericMode==="exact"?e.native:e.legacy,"select"),yp=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),hp=Z("^([a-z_]\\w*)\\s*=\\s*(.+)$"),Sp=Z(`^"(${z})"\\s*=>\\s*(\\w+)$`),gp=Z(`^split\\s+(\\S+)\\s+by\\s+"(${z})"$`),xp=new RegExp(Z(`"${z}"|[\\w.]+`).source,"gu"),vp=Z("^[\\w.]+$");function zr(t,e){let n=t;t=t.valueContext;let i=yi(t,dp).exec(e.content)?.[1]??"";i===""&&t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidCaptureDeclaration,`Invalid capture declaration '${e.content}' - expected 'capture <Name>'`,f(e));let r=null,o=null,s=[],a=[],d=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"source":r=$p(t,m,n);break;case"key":o=m.content.substring(3).trim();break;case"map":s.push(...es(t,m));break;case"append":ts(t,m,a);break;case"children":{let u=yi(t,fp).exec(m.content);if(u===null){t.error(l.InvalidChildrenDeclaration,`Invalid children declaration '${m.content}' - expected 'children <collection> identified by <key>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=Xa(t,m);u!==null&&d.push({kind:"CaptureChildrenSyntax",property:u[1],identifiedBy:u[2],...y,location:f(m)});break}case"nested":{let u=yi(t,mp).exec(m.content);if(u===null){t.error(l.InvalidNestedDeclaration,`Invalid nested declaration '${m.content}' - expected 'nested <Property>'`,f(m)),t.skipOpaqueBlock(m.indent);break}let y=Xa(t,m);u!==null&&p.push({kind:"CaptureNestedSyntax",property:u[1],...y,location:f(m)});break}default:t.error(l.UnknownCaptureDirective,`Unexpected '${m.content}' in capture body`,f(m)),t.skipOpaqueBlock(m.indent)}return{kind:"CaptureSyntax",sourceOptions:t.sourceOptions,name:i,source:r,key:o,map:s,appends:a,children:d,nested:p,location:f(e)}}c(zr,"parseCapture");function $p(t,e,n){let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);i.push({kind:"CaptureSourceSettingSyntax",name:s,value:o.content.substring(s.length).trim(),location:f(o)})}let r=e.content.substring(6).trim();return r===Ur&&bp(n,e,i),{kind:"CaptureSourceSyntax",syntaxKind:r,settings:i,location:f(e)}}c($p,"parseSource");function bp(t,e,n){n.length===0&&t.error(l.InvalidCaptureEventsSource,"'source events' needs at least one 'from <Event>' line naming a public event to consume",f(e));let i=new Set;for(let r of n)r.name!==Wr?t.error(l.InvalidCaptureEventsSource,`'source events' accepts only 'from <Event>' lines, got '${r.name}'`,r.location):pp.test(r.value)?i.has(r.value)?t.error(l.InvalidCaptureEventsSource,`Event '${r.value}' is already consumed by this 'source events'`,r.location):i.add(r.value):t.error(l.InvalidCaptureEventsSource,`Invalid event '${r.value}' - expected 'from <Event>', optionally qualified with dots`,r.location)}c(bp,"validateEventsSource");function es(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=f(i);if(D(i.content)==="split"){let u=gp.exec(i.content);if(u===null){t.error(l.InvalidSplitDeclaration,`Invalid split operation '${i.content}' - expected 'split <property> by "<separator>"'`,r),t.skipOpaqueBlock(i.indent);continue}let y=[];for(let h=t.peekChild(i.indent);h!==void 0;h=t.peekChild(i.indent))t.reader.takeSignificant(),vp.test(h.content)?y.push(h.content):t.error(l.InvalidSplitTarget,`Invalid split target '${h.content}' - expected a property path`,f(h));u!==null&&n.push({kind:"CaptureSplitSyntax",source:Ee(u[1],r,t),separator:Q(u[2]),targets:y,location:r});continue}let o=hp.exec(i.content);if(o===null){t.error(l.InvalidMapEntry,`Invalid map entry '${i.content}' - expected '<property> = <source> [translate]'`,r),t.skipOpaqueBlock(i.indent);continue}let s=o[2].trim(),a=s.startsWith("`")?s.indexOf("`",1):-1,d=s.startsWith("`")?a>=0&&s.substring(a+1).trim()==="translate":s.endsWith(" translate"),p=s.startsWith("`")&&a>=0&&(t.sourceOptions.numericMode!=="exact"||d||s.substring(a+1).trim()==="")?s.substring(0,a+1):d?s.substring(0,s.length-10).trimEnd():s,m=[];if(d)for(let u=t.peekChild(i.indent);u!==void 0;u=t.peekChild(i.indent)){t.reader.takeSignificant();let y=Sp.exec(u.content);y!==null?m.push({kind:"CaptureTranslationSyntax",from:Q(y[1]),to:y[2],location:f(u)}):t.error(l.InvalidTranslation,`Invalid translation '${u.content}' - expected '"<source>" => <target>'`,f(u))}n.push({kind:"CaptureMapEntrySyntax",property:o[1],source:Ee(p,r,t),translations:m,location:r})}return n}c(es,"parseMap");function Xa(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=es(t,r):D(r.content)==="append"?ts(t,r,i):(t.error(l.UnknownCaptureBlockDirective,`Unexpected '${r.content}' in ${D(e.content)} block - expected 'map' or 'append <EventType>'`,f(r)),t.skipOpaqueBlock(r.indent));return{map:n,appends:i}}c(Xa,"mapAndAppends");function ts(t,e,n){let i=yi(t,up).exec(e.content);if(i===null){t.error(l.InvalidAppendDeclaration,`Invalid append declaration '${e.content}' - expected 'append <EventType>'`,f(e)),t.skipOpaqueBlock(e.indent);return}let r=[],o=[],s=null,a=c((d,p=!1)=>{let m=f(d);if(D(d.content)==="tag"){let y=Cn(t.valueContext,d,!1);y!==void 0&&o.push(y);return}let u=yp.exec(d.content);u!==null?r.push({kind:"PropertyMappingSyntax",property:re(u[1]),source:Be(u[2],m,t.valueContext),location:m}):t.error(p?l.InvalidPropertyMapping:l.UnknownAppendDirective,`Unexpected '${d.content}' in append body`,m)},"mapping");for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(d.content)==="when"){s=kp(t,d);for(let p=t.peekChild(d.indent);p!==void 0;p=t.peekChild(d.indent))t.reader.takeSignificant(),a(p,!0)}else a(d);n.push({kind:"CaptureAppendSyntax",event:i[1],when:s,mappings:r,tags:o,location:f(e)})}c(ts,"pushAppend");function kp(t,e){let n=e.content.substring(4).trim(),i=f(e),r=c((d,p=[],m=null,u=null,y=null)=>({kind:"CaptureWhenSyntax",syntaxKind:d,properties:p,fromValue:m,toValue:u,expression:y,location:i}),"value");if(n==="added")return r("Added");if(n==="removed")return r("Removed");if(n.startsWith("`"))return(!n.endsWith("`")||n.length<2)&&t.error(l.UnterminatedTemplateExpression,"Unterminated template expression in 'when' - expected a closing backtick",i),r("Expression",[],null,null,n);if(n.length===0)return t.error(l.WhenWithoutTrigger,"Expected a trigger after 'when'",i),null;let o=[...n.match(t.sourceOptions.numericMode==="exact"?new RegExp(`"${z}"|[^\\s]+`,"gu"):xp)??[]],s=c(d=>d.startsWith('"')&&d.endsWith('"')?Q(d.substring(1,d.length-1)):d,"unquote");if(o.length===0)return t.error(l.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(l.InvalidWhenTransitionClause,`Invalid 'when ... from ... to ...' clause '${e.content}'`,i),null);if(o[1]!=="or"&&o[1]!=="and")return t.error(l.InvalidWhenClause,`Invalid 'when' clause '${e.content}'`,i),null;if(o.length%2===0)return t.error(l.WhenCombinatorWithoutProperty,`Expected a property after '${o[1]}'`,i),null;let a=[s(o[0])];for(let d=1;d<o.length-1;d+=2){if(o[d]!==o[1])return t.error(l.MixedWhenCombinators,`Cannot mix 'and' and 'or' in a single 'when' clause '${e.content}'`,i),null;a.push(s(o[d+1]))}return r(o[1]==="or"?"LogicalOr":"LogicalAnd",a)}c(kp,"parseWhen");var Qr=I("^returns\\s+(@?[A-Za-z_]\\w*)$"),Ep=I("^(@?[a-z_]\\w*)(?:\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?))?\\s*=(?!=|>)\\s*(@?[a-z_]\\w*)$");function Gr(t,e){let n=f(e);if(e.content!=="returns"){let r=Qr.exec(e.content);if(r===null)return t.error(l.InvalidCommandResponse,"Expected 'returns <property>' or an unconditional 'returns' block.",n),t.skipBlock(e.indent),null;let o=t.peekChild(e.indent);o!==void 0&&(t.error(l.InvalidCommandResponse,"A scalar response cannot have child directives.",f(o)),t.skipBlock(e.indent));let s=r.index+r[0].length-r[1].length;return{kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:re(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=Ep.exec(r.content);if(o===null){Je({...r,content:r.content.split("=",1)[0].trimEnd()})?.isSubject?t.error(l.InvalidSubjectOwner,"The subject modifier is only valid on event properties, not response fields (decision 0008: one data subject per event).",f(r)):t.error(l.InvalidCommandResponse,"Expected '<field> [<Type>] = <property>' in a response block.",f(r)),t.skipBlock(r.indent);continue}let s=f(r),a=o[2]===void 0?null:we(o[2],{...s,column:s.column+r.content.indexOf(o[2],o[1].length)});a!==null&&Me(t,a,r),i.push({kind:"ResponseFieldSyntax",name:re(o[1]),type:a,source:{kind:"PropertyResponseSourceSyntax",property:re(o[3]),location:{...s,column:s.column+r.content.lastIndexOf(o[3])}},location:s});let d=t.peekChild(r.indent);d!==void 0&&(t.error(l.InvalidCommandResponse,"A response field cannot have child directives.",f(d)),t.skipBlock(r.indent))}return{kind:"RecordCommandResponseSyntax",fields:i,location:n}}c(Gr,"parseCommandResponse");var Si=new WeakMap;function gi(t){let e=Z(`^reads${W}+([A-Z]\\w*)(?:${W}+as${W}+([a-z_]\\w*))?(?:${W}+by${W}+([a-z_]\\w*))?$`).exec(t.content);if(!(e===null||["as","by","reads"].includes(e[2])))return{kind:"ReadsSyntax",readModel:e[1],alias:e[2]??null,by:e[3]??null,location:f(t)}}c(gi,"captureReads");function ns(t){return new me(t.reader.fork(),t.path,t.languages)}c(ns,"fork");function is(t,e){if(e.content!=="concurrency")return;let n=ns(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=Z(`^(sourceType|streamType|streamId)${W}+([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(d=>d.replace(new RegExp(`^${W}+|${W}+$`,"gu"),"")).filter(Boolean);a.length>0&&a.every(d=>Z("^[A-Z]\\w*$").test(d))&&(o=a);break}default:n.skipBlock(s.indent);break}return{kind:"ConcurrencySyntax",eventSource:i,eventSourceType:r.sourceType??null,eventStreamType:r.streamType??null,eventStreamId:r.streamId??null,eventTypes:o??[],location:f(e)}}c(is,"captureConcurrency");function rs(t,e){let n=Z(`^reducer${W}+([A-Za-z_]\\w*)${W}*=>${W}*([A-Za-z_]\\w*)$`).exec(e.content),i=ns(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"){G(i,o,null,"Reducer");continue}let s=Z(`^on${W}+([A-Z]\\w*)$`).exec(o.content);s!==null&&r.push({kind:"ReducerRuleSyntax",event:s[1],file:null,code:null,description:null,location:f(o)}),i.skipOpaqueBlock(o.indent)}return{kind:"ReducerSyntax",name:n?.[1]??"",readModel:n?.[2]??"",rules:r,description:null,location:f(e)}}c(rs,"captureReducer");var Cp=I("^produces\\s+operation(?:\\s|$)"),Pp=I("^produces\\s+event\\s+([A-Za-z_]\\w*)(?:\\s+(generation)(?:\\s+.*)?)?$"),Ap=I("^produces\\s+([A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),os=I("^produces\\s+when\\s+(.+)$"),wp=I("^[A-Z]\\w*(?:\\.[A-Za-z_]\\w*)*$"),Ip=I("^for\\s+(\\S.*)$"),Op=I("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Tp=I("^(.+?)\\s*=(?!=|>)\\s*(.+)$"),Rp=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]);function Pn(t,e,n=!1){if(Cp.test(e.content)){if(!n){t.error(l.OperationOutsideCommand,"Operations can only be produced by commands.",f(e)),t.skipOpaqueBlock(e.indent);return}let x=pi(t,e,!0);return{kind:"ProducesSyntax",when:null,event:x.operation.name,targetLocation:{...f(e),column:e.indent+e.content.match(/^produces\s+operation(?:\s+|$)/)[0].length+1},inlineEvent:null,inlineOperation:x.operation,mappings:x.mappings,for:null,tags:[],location:f(e)}}let i=Pp.exec(e.content),r=e,o=null,s,a;if(i!==null){if(!n){t.error(l.InlineEventOutsideCommand,"Inline events can only be declared inside commands",f(e)),t.skipOpaqueBlock(e.indent);return}i[2]!==void 0&&t.error(l.InlineEventGeneration,"Inline events are generation 1 - extract the event before declaring generations",f(e)),s=i[1],a=e.indent+e.content.match(/^produces\s+event\s+/)[0].length+1}else if(os.test(e.content)){o=_e(t,os.exec(e.content)[1],f(e));let x=t.peekChild(e.indent);if(x===void 0||!wp.test(x.content)){t.error(l.ProducesWhenWithoutEvent,"Expected an event name on the line after 'produces when'",f(e)),t.skipOpaqueBlock(e.indent);return}t.reader.takeSignificant(),r=x,s=x.content,a=x.indent+1}else{let x=Ap.exec(e.content);if(x===null){t.error(l.InvalidProducesDeclaration,`Invalid produces declaration '${e.content}' - expected 'produces <EventType>' or 'produces when <condition>'`,f(e)),t.skipOpaqueBlock(e.indent);return}s=x[1],a=e.indent+e.content.match(/^produces\s+/)[0].length+1}let d=[],p=new Set,m=[],u=[],y=new Kt(s),h=null;for(let x=t.peekChild(r.indent);x!==void 0;x=t.peekChild(r.indent)){t.reader.takeSignificant();let b=D(x.content),S=f(x);if(Rp.has(b)){t.error(l.ReservedProductionMetadata,`'${b}' is system-assigned production metadata and cannot be supplied here`,S),t.skipOpaqueBlock(x.indent);continue}if(i!==null&&(b==="generation"||b==="origin")){t.error(b==="generation"?l.InlineEventGeneration:l.ReservedProductionMetadata,b==="generation"?"Inline events are generation 1 - extract the event before declaring generations":"An inline event is local to its command and cannot declare origin",S),t.skipOpaqueBlock(x.indent);continue}if(b==="tag"){let w=Cn(t,x,!1);w!==void 0&&u.push(w);continue}let $=Ip.exec(x.content);if($!==null){h!==null?t.error(l.DuplicateProducesTarget,`'${r.content}' already declares where it lands - an event is appended to one event source`,S):h=ae($[1],S,t);continue}let g=(i===null?Op:Tp).exec(x.content),P=g===null||i===null?void 0:Fe(t,{...x,content:g[1].trimEnd()});if(g!==null&&(i===null||P!==void 0)){if(P!==void 0){P.isIdentifier&&(t.error(l.IdentifierOnEventProperty,`Property '${P.name}' of event '${s}' cannot be marked identifier - an event never carries its event source id`,S),P={...P,isIdentifier:!1});let w=P.name;p.has(w)&&t.error(l.DuplicateDeclaration,`Event '${s}' already declares property '${P.name}'`,S),p.add(w),d.push(P)}m.push({kind:"PropertyMappingSyntax",property:P?.name??re(g[1]),source:ae(g[2],{...S,column:x.indent+x.content.length-g[2].length+1},t),location:S})}else(i===null||!y.tryParse(t,x))&&t.error(l.InvalidPropertyMapping,`Invalid ${i===null?"":"inline "}property mapping '${x.content}' - expected '<property>${i===null?"":" <Type>"} = <source>'`,S)}return r!==e&&t.skipBlock(e.indent),{kind:"ProducesSyntax",when:o,event:s,targetLocation:{...f(r),column:a},inlineOperation:null,mappings:m,for:h,tags:i===null?u:[],location:f(e),inlineEvent:i===null?null:{kind:"EventSyntax",name:s,properties:d,tags:u,generation:1,hasGenerationMarker:!1,...y.value,location:f(e)}}}c(Pn,"parseProduces");var Dp=I("^command\\s+([A-Za-z_]\\w*)$"),Mp=ke("^stream\\s+[A-Za-z_]\\w*\\.[A-Za-z_]\\w*$"),Lp=I("\\bseverity\\s+(\\S+)$"),ss=I(`\\bmessage\\s+(?:"(${z})"|(\\$strings\\.\\S*))$`),jp=I("^([\\w.]+)\\s+(.+)$"),Np=I("^(not empty|length ==|all >=|all >|matches|max|min|rule|>=|<=|==|!=|>|<)\\s*(.*)$"),qp=ke("^[A-Za-z_]\\w*$"),Bp=I("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)"),Yp={max:"Max",min:"Min",">":"GreaterThan",">=":"GreaterThanOrEqual","<":"LessThan","<=":"LessThanOrEqual","==":"Equal","!=":"NotEqual","length ==":"Length",matches:"Matches","all >":"AllGreaterThan","all >=":"AllGreaterThanOrEqual"},ls={information:"Information",warning:"Warning",error:"Error"},Fp=new Set(["reads","concurrency"]),Up=new Set(["description","documentation","handler","concurrency"]);function cs(t,e){let n=new Set,i=new me(t.reader.fork(),t.path,t.languages);return i.sourceOptions=t.sourceOptions,i.streamCandidates=t.streamCandidates,as(i,e,void 0,n),as(t,e,n)}c(cs,"parseCommand");function as(t,e,n,i){let r=Dp.exec(e.content)?.[1]??"";r===""&&t.error(l.InvalidCommandDeclaration,`Invalid command declaration '${e.content}' - expected 'command <Name>'`,f(e));let o=[],s=[],a,d=[],p=[],m=[],u=[],y,h=null,x=null,b=null,S=null,$=null,g=[];for(let k=t.peekChild(e.indent);k!==void 0;k=t.peekChild(e.indent)){t.reader.takeSignificant();let A=D(k.content),O=Je(k);if(O!==void 0&&(Up.has(A)||A==="validate"&&k.content!=="validate csharp"))a=xi(t,o,O,r,k,a);else if(A==="returns"){let T=Qr.exec(k.content);T!==null&&!T[1].startsWith("@")&&O!==void 0?n===void 0?(o.push(O),s.push({line:k,candidate:O,response:null})):n.has(O.type.name)?s.push({line:k,candidate:null,response:Gr(t,k)}):a=xi(t,o,O,r,k,a):O!==void 0?a=xi(t,o,O,r,k,a):Qn(t,k)?t.skipBlock(k.indent):s.push({line:k,candidate:null,response:Gr(t,k)})}else if(A==="stream"&&Mp.test(k.content)&&O!==void 0&&t.streamCandidates?.hasSource(O.type.name.split(".")[0])===!0){let[T,M]=O.type.name.split("."),N=t.streamCandidates.hasPropertyType(O.type.name)&&t.streamCandidates.hasUniqueStream(T,M),j=Ma(t,k,O,N);($!==null||g.length>0)&&t.error(l.InvalidCommandStream,"A command declares at most one stream route.",f(k)),N||$!==null?g.push(j):$=j}else if(A==="description")h=G(t,k,h,`Command '${r}'`);else if(A==="documentation")x=Ie(t,k,x,`Command '${r}'`);else if(A==="authorize")b=Xe(b,gt(t,k));else if(A==="validate"){let T=_r(t,k,"command");T!==void 0&&d.push(T)}else if(A==="produces"){let T=Pn(t,k,!0);T!==void 0&&p.push(T)}else if(A==="handler")S=Na(t,k);else if(Fp.has(A)){let T=gi(k);T!==void 0&&u.push(T),A==="concurrency"&&y===void 0&&(y=is(t,k));let M=/^reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?$/.exec(k.content);M!==null&&m.push({readModel:M[1],alias:M[2]??null}),Bp.test(k.content)&&t.error(l.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(k)),t.skipOpaqueBlock(k.indent)}else O!==void 0?a=xi(t,o,O,r,k,a):(Qn(t,k),t.error(l.UnknownCommandDirective,`Unexpected '${k.content}' in command body`,f(k)),t.skipBlock(k.indent))}let P=new Set(s.flatMap(k=>k.candidate===null?[]:[k.candidate])),w=new Set(o.filter(k=>!P.has(k)).map(k=>k.name));s.some(k=>k.candidate!==null&&!w.has(k.candidate.type.name)&&k.candidate.type.name!=="returns")&&w.add("returns");for(let k of w)i?.add(k);let v=null,E=new Set;for(let k of s){let A=k.response;if(k.candidate!==null){if(!w.has(k.candidate.type.name))continue;E.add(k.candidate),A={kind:"ScalarCommandResponseSyntax",source:{kind:"PropertyResponseSourceSyntax",property:k.candidate.type.name,location:k.candidate.type.location},location:f(k.line)}}A!==null&&(v!==null?t.error(l.InvalidCommandResponse,"A command declares at most one unconditional response.",f(k.line)):v=A)}S!==null&&p.length>0&&t.error(l.CommandWithProducesAndHandler,`Command '${r}' cannot declare both 'produces' and 'handler'`,f(e));let C={kind:"CommandSyntax",name:r,description:h,documentation:x,authorize:b,properties:o.filter(k=>!E.has(k)),validations:d,produces:p,handler:S,response:v,stream:$,streamCandidates:g,location:f(e)};return Si.set(C,m),ot.set(C,{reads:u,concurrency:y}),C}c(as,"parseCommandBody");function xi(t,e,n,i,r,o){return Me(t,n.type,r),n.isIdentifier&&o!==void 0&&(t.error(l.DuplicateCommandIdentifier,`Command '${i}' already marks '${o.name}' as identifier - only one property can be the identifier`,n.location),n={...n,isIdentifier:!1}),e.push(n),o??(n.isIdentifier?n:void 0)}c(xi,"addProperty");function _r(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=Oe(t.valueContext,i);return a===null&&t.skipFencedBody(),{kind:"CodeValidateSyntax",code:a,location:f(e)}}let r=[],o=[],s;for(let a=t.peekChild(e.indent);a!==void 0;a=t.peekChild(e.indent)){if(t.reader.takeSignificant(),n==="concept"){if(t.sourceOptions.numericMode==="legacy"&&a.content.startsWith("```")){t.skipFencedBody();continue}if(s!==void 0&&a.indent<=s&&(s=void 0),s!==void 0||D(a.content)==="implementation"){t.error(l.InvalidValidationRule,`Invalid validation rule '${a.content}'`,f(a)),s??=a.indent;continue}}if(D(a.content)==="require"){let p=_e(n==="concept"?t.valueContext:t,a.content.substring(7).trim(),f(a)),m=null,u="Error",y=!1;for(let h=t.peekChild(a.indent);h!==void 0;h=t.peekChild(a.indent)){t.reader.takeSignificant();let x=ss.exec(h.content);x!==null&&x.index===0?m=x[1]!==void 0?Q(x[1]):x[2]:D(h.content)==="severity"?(y||(u=ls[h.content.substring(8).trim()]??"Error"),y=!0):t.skipOpaqueBlock(h.indent)}p!==null&&o.push({kind:"RequirementSyntax",condition:p,message:m,severity:u,location:f(a)});continue}let d=Wp(t,n==="concept"?{...a,content:`value ${a.content}`}:a,n);d!==void 0&&r.push(d)}return{kind:"DeclarativeValidateSyntax",rules:r,requirements:o,location:f(e)}}if(e.content==="validate csharp"){let i=Oe(t.valueContext,{...e,content:"csharp"});return i===null&&t.skipOpaqueBlock(e.indent),{kind:"CodeValidateSyntax",code:i,location:f(e)}}t.error(l.InvalidValidateDeclaration,`Invalid validate declaration '${e.content}' - expected 'validate' or 'validate csharp'`,f(e)),t.skipBlock(e.indent)}c(_r,"parseValidate");function Wp(t,e,n){let i=n==="concept"?t.valueContext:t,{content:r,message:o}=zp(e.content),s=Qp(i,e,r);if(s===void 0)return;let a=jp.exec(s.content);if(a===null){i.error(l.InvalidValidationRule,`Invalid validation rule '${e.content}'`,f(e));return}let d=Gp(i,a[2],e);if(d===void 0)return;let p=d.kind==="Rule"?Vp(t,e,n==="command"):{file:null,code:null,implementation:null};return{kind:"ValidationRuleSyntax",property:a[1],rule:d.kind,value:d.value,message:o,severity:s.severity,...p,location:f(e)}}c(Wp,"parseValidationRule");function Vp(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?gn(t,i):{file:xt(i)?et(t,i):null,code:!xt(i)&&Ot(t,i)?Oe(t,i):null,implementation:null};!r&&o.file===null&&o.code===null&&(t.error(l.UnknownRuleImplementationDirective,`Unexpected '${i.content}' in rule implementation - expected 'file <path>' or an inline code block`,f(i)),t.skipBlock(i.indent));for(let s=t.peekChild(e.indent);s!==void 0&&(r||n&&D(s.content)==="implementation");s=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(r&&D(s.content)==="implementation"?l.InvalidImplementationBlock:l.ConflictingImplementationSources,"A named rule has one implementation wrapper and cannot mix wrapped and direct sources.",f(s)),Ot(t,s)?Oe(t,s):t.skipBlock(s.indent);return o}c(Vp,"parseRuleImplementation");function zp(t){let e=ss.exec(t);if(e===null)return{content:t,message:null};let n=e[1]!==void 0?Q(e[1]):e[2];return{content:t.substring(0,e.index).trimEnd(),message:n}}c(zp,"splitMessage");function Qp(t,e,n){let i=Lp.exec(n);if(i===null)return{content:n,severity:"Error"};let r=ls[i[1]];if(r===void 0){t.error(l.InvalidValidationSeverity,`Unknown validation severity '${i[1]}' - expected information, warning or error`,f(e));return}return{content:n.substring(0,i.index).trimEnd(),severity:r}}c(Qp,"splitSeverity");function Gp(t,e,n){if(e==="not empty")return{kind:"NotEmpty",value:null};let i=Np.exec(e);if(i===null){t.error(l.InvalidValidationRule,`Invalid validation rule '${n.content}'`,f(n));return}if(i[1]==="rule"){let r=i[2].trim();if(!qp.test(r)){t.error(l.InvalidRuleName,`Invalid rule name '${r}' in '${n.content}' - expected 'rule <Name>' with an identifier`,f(n));return}return{kind:"Rule",value:{kind:"PathExpressionSyntax",path:r,location:f(n)}}}return{kind:Yp[i[1]],value:ae(i[2],f(n),t)}}c(Gp,"parseRule");var _p=I("^constraint\\s+([A-Za-z_]\\w*)$"),Zp=I("^unique\\s+event\\s+([A-Z]\\w*)$"),Kp=I("^unique\\s+([a-z_][\\w.]*(?:\\s*,\\s*[a-z_][\\w.]*)*)\\s+on\\s+([A-Z]\\w*)$"),Jp=I("^released\\s+by\\s+([A-Z]\\w*)$"),Hp=I(`^message\\s+"(${z})"$`),Xp=c(t=>t.kind==="FileConstraintSyntax"?void 0:t.event,"targetOf");function ds(t,e){let n=_p.exec(e.content);n===null&&t.error(l.InvalidConstraintDeclaration,`Invalid constraint declaration '${e.content}' - expected 'constraint <Name>'`,f(e));let i=n?.[1]??D(e.content),r=[],o=[],s=new Set,a=new Set,d=null,p=null,m=!1;for(let u=t.peekChild(e.indent);u!==void 0;u=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(u.content)==="description"){p=G(t,u,p,`Constraint '${i}'`);continue}let y=Jp.exec(u.content),h=Hp.exec(u.content);y!==null?s.has(y[1])?t.error(l.DuplicateConstraintBody,`Constraint '${i}' already releases with event '${y[1]}'`,f(u)):(o.push(y[1]),s.add(y[1])):h!==null?d!==null?t.error(l.DuplicateConstraintBody,`Constraint '${i}' already has a message`,f(u)):d=Q(h[1]):u.content==="ignore casing"?(m&&t.error(l.DuplicateConstraintBody,`Constraint '${i}' already ignores casing`,f(u)),m=!0):eu(t,i,u,r,a)}for(let u of o.filter(y=>a.has(y)))t.error(l.DuplicateConstraintBody,`Constraint '${i}' cannot target and release event '${u}'`,f(e));return r.length===0&&(t.error(l.ConstraintWithoutRule,`Constraint '${i}' must declare 'unique ... on ...', 'unique event ...' or 'file ...'`,f(e)),r.push(vi(i,f(e),{kind:"UniqueEventConstraintSyntax",event:""}))),r[0].kind==="FileConstraintSyntax"&&(o.length>0||d!==null||m)&&t.error(l.InvalidConstraintBody,`File constraint '${i}' cannot have declarative options`,f(e)),{...r[0],additionalRules:r.slice(1),releasedBy:o,message:d,ignoreCasing:m,description:p}}c(ds,"parseConstraint");function eu(t,e,n,i,r){let o=tu(t,e,n);if(o===void 0)return;if(i.length>0&&(o.kind==="FileConstraintSyntax"||i[0].kind==="FileConstraintSyntax"||o.kind==="UniqueEventConstraintSyntax"!=(i[0].kind==="UniqueEventConstraintSyntax"))){t.error(l.DuplicateConstraintBody,`Constraint '${e}' cannot mix constraint kinds`,f(n));return}let s=Xp(o);if(s!==void 0&&r.has(s)){t.error(l.DuplicateConstraintBody,`Constraint '${e}' already targets event '${s}'`,f(n));return}s!==void 0&&r.add(s),i.push(o)}c(eu,"addRule");function tu(t,e,n){let i=f(n),r=Zp.exec(n.content);if(r!==null)return vi(e,i,{kind:"UniqueEventConstraintSyntax",event:r[1]});let o=Kp.exec(n.content);if(o!==null){let s=o[1].split(",").map(a=>a.trim());if(new Set(s).size!==s.length){t.error(l.DuplicateConstraintBody,`Constraint '${e}' repeats a property in its composite key`,i);return}return vi(e,i,{kind:"UniquePropertyConstraintSyntax",property:s[0],additionalProperties:s.slice(1),event:o[2]})}if(ge(n)){t.warning(l.FileConstraintOnlySupportsUniqueness,"A file constraint can only declare unique constraints in Chronicle - declare them with 'unique ...' so they are portable; a rule that is not uniqueness belongs in command validation or a 'require' condition",i);let s=n.content.substring(4).trim();return vi(e,i,{kind:"FileConstraintSyntax",file:{kind:"FileReferenceSyntax",path:s,location:i}})}t.error(l.InvalidConstraintBody,`Invalid constraint body '${n.content}'`,i)}c(tu,"parseRule");function vi(t,e,n){return{...n,name:t,additionalRules:[],releasedBy:[],ignoreCasing:!1,message:null,location:e}}c(vi,"rule");var nu=I("^projection\\s+(@?[\\w.]+)\\s*(?:=>\\s*([\\w.]+))?$"),iu=I("^(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),ru=I("^join\\s+(@?[\\w.]+)\\s+on\\s+(@?[\\w.]+)$"),ou=I("^with\\s+(@?[\\w.]+)$"),au=I("^children\\s+(@?[\\w.]+)\\s+identified\\s+by\\s+(.+)$"),su=I("^nested\\s+(@?[\\w.]+)$"),lu=I("^remove\\s+with\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),cu=I("^remove\\s+via\\s+join\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),du=I("^clear\\s+with\\s+(@?[\\w.]+)$"),pu=I("^variant\\s+(@?[\\w.]+)\\s*$"),uu=I("^enters\\s+on\\s+(@?[\\w.]+)(?:\\s+key\\s+(.+))?$"),fu=I("^(increment|decrement|count|clear)\\s+(@?[$\\w.]+)$"),mu=I("^(add|subtract)\\s+(@?[$\\w.]+)\\s+by\\s+(.+)$"),yu=I("^set\\s+(@?[$\\w.]+)\\s+(?:=|to)\\s+(.+)$"),ps=I("^(@?[$\\w.@]+)\\s*=(?!=|>)\\s*(.+)$"),hu={increment:"IncrementMappingSyntax",decrement:"DecrementMappingSyntax",clear:"ClearMappingSyntax",count:"CountMappingSyntax"};function Kr(t,e){let n=nu.exec(e.content);if(n===null)return t.error(l.InvalidProjectionDeclaration,`Invalid projection declaration '${e.content}' - expected 'projection <Name> [=> <ReadModel>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:D(e.content),readModel:null,sequence:null,autoMap:"Inherit",blocks:[],location:f(e)};let i=n[1],r=null,o=null,s="Inherit",a=null,d=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ge(p))continue;let m=D(p.content);if(m==="description")o=G(t,p,o,`Projection '${i}'`);else if(m==="sequence")r=p.content.substring(8).trim();else if(m==="automap")s="Enabled";else if(p.content==="no automap")s="Disabled";else if(m==="key")a=fs(t,p);else if(m==="variant")d.push(Eu(t,p));else{let u=Jr(t,p,!1);u!==void 0&&d.push(u)}}return Su(t,d,i),d.length===0&&t.error(l.EmptyProjection,`Projection '${i}' must contain at least one directive`,f(e)),{kind:"ProjectionSyntax",sourceOptions:t.sourceOptions,name:i,readModel:n[2]??null,sequence:r,autoMap:s,key:a,blocks:d,description:o,location:f(e)}}c(Kr,"parseProjection");function Su(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(l.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(l.DuplicateVariantEnteringEvent,`Entering event '${s.event}' is claimed more than once in projection '${n}'`,s.location),o.add(s.event)}c(Su,"reportVariantConflicts");function Jr(t,e,n){let i=f(e);switch(D(e.content)){case"from":return gu(t,e);case"every":{let r=!0,{autoMap:o,mappings:s}=Zr(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}=Zr(t,e);return{kind:"AllSyntax",autoMap:r,mappings:o,location:i}}case"join":return xu(t,e);case"children":return vu(t,e);case"nested":return $u(t,e);case"remove":return bu(t,e);case"clear":return n||t.error(l.ClearWithOutsideNestedBlock,"'clear with' is only valid inside a nested block",i),ku(t,e);default:t.error(l.UnknownProjectionDirective,`Unexpected '${D(e.content)}' in projection body`,i),t.skipBlock(e.indent);return}}c(Jr,"parseBlock");function gu(t,e){let n=[];for(let s of ra(e.content.substring(4),",")){let a=s.trim();if(a.length===0){t.error(l.FromWithoutEvent,"Expected an event type after 'from'",f(e));continue}let d=iu.exec(a);if(d===null){t.error(l.InvalidEventReference,`Invalid event reference '${a}'`,f(e));continue}n.push({kind:"EventSpecSyntax",event:re(d[1]),key:d[2]===void 0?null:Ee(d[2],f(e),t),location:f(e)})}let i=[],r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=D(s.content);a==="key"?r=fs(t,s):a==="parent"?o=Ee(s.content.substring(6),f(s),t):ms(t,s,i)}return{kind:"FromSyntax",events:n,key:r,parentKey:o,mappings:i,location:f(e)}}c(gu,"parseFrom");function xu(t,e){let n=ru.exec(e.content);if(n===null)return t.error(l.InvalidJoinDeclaration,`Invalid join declaration '${e.content}' - expected 'join <property> on <key>'`,f(e)),t.skipBlock(e.indent),{kind:"JoinSyntax",property:"",on:"",events:[],location:f(e)};let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=ou.exec(r.content);if(o===null){t.error(l.JoinWithoutEvent,`Expected 'with <EventType>' in join block, got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}let{autoMap:s,mappings:a}=Zr(t,r);i.push({kind:"JoinEventSyntax",event:re(o[1]),autoMap:s,mappings:a,location:f(r)})}return{kind:"JoinSyntax",property:re(n[1]),on:re(n[2]),events:i,location:f(e)}}c(xu,"parseJoin");function vu(t,e){let n=au.exec(e.content);if(n===null)return t.error(l.InvalidChildrenDeclaration,`Invalid children declaration '${e.content}' - expected 'children <collection> identified by <key>'`,f(e)),t.skipBlock(e.indent),{kind:"ChildrenSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let{autoMap:i,blocks:r}=us(t,e);return{kind:"ChildrenSyntax",property:re(n[1]),identifiedBy:Ee(n[2],f(e),t),autoMap:i,blocks:r,location:f(e)}}c(vu,"parseChildren");function $u(t,e){let n=su.exec(e.content);if(n===null)return t.error(l.InvalidNestedDeclaration,`Invalid nested declaration '${e.content}' - expected 'nested <property>'`,f(e)),t.skipBlock(e.indent),{kind:"NestedSyntax",property:"",autoMap:"Inherit",blocks:[],location:f(e)};let i=re(n[1]),{autoMap:r,blocks:o}=us(t,e);return o.some(s=>s.kind==="FromSyntax")||t.error(l.NestedBlockWithoutFrom,`Nested block '${i}' must contain at least one 'from' directive`,f(e)),{kind:"NestedSyntax",property:i,autoMap:r,blocks:o,location:f(e)}}c($u,"parseNested");function us(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=Jr(t,r,!0);o!==void 0&&n.push(o)}return{autoMap:i,blocks:n}}c(us,"parseChildBlocks");function bu(t,e){let n=cu.exec(e.content);if(n!==null)return{kind:"RemoveViaJoinSyntax",event:re(n[1]),key:n[2]===void 0?null:Ee(n[2],f(e),t),location:f(e)};let i=lu.exec(e.content);if(i===null){t.error(l.InvalidRemoveDeclaration,`Invalid remove declaration '${e.content}' - expected 'remove with <EventType>' or 'remove via join on <EventType>'`,f(e)),t.skipBlock(e.indent);return}let r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),D(o.content)==="parent"?r=Ee(o.content.substring(6),f(o),t):t.error(l.UnknownRemoveDirective,`Unexpected '${o.content}' in remove block - only 'parent' is allowed`,f(o));return{kind:"RemoveWithSyntax",event:re(i[1]),key:i[2]===void 0?null:Ee(i[2],f(e),t),parentKey:r,location:f(e)}}c(bu,"parseRemove");function ku(t,e){let n=du.exec(e.content);return n===null?(t.error(l.InvalidClearDeclaration,`Invalid clear declaration '${e.content}' - expected 'clear with <EventType>'`,f(e)),{kind:"ClearWithSyntax",event:"",location:f(e)}):{kind:"ClearWithSyntax",event:re(n[1]),location:f(e)}}c(ku,"parseClearWith");function Eu(t,e){let n=pu.exec(e.content);if(n===null)return t.error(l.InvalidProjectionVariantDeclaration,`Invalid variant declaration '${e.content}' - expected 'variant <Name>'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionVariantSyntax",name:D(e.content),entersOn:[],blocks:[],location:f(e)};let i=re(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(Cu(t,s));else if(a==="variant")t.error(l.NestedProjectionVariantNotAllowed,"A variant cannot be declared inside another variant",f(s)),t.skipBlock(s.indent);else{let d=Jr(t,s,!1);d!==void 0&&o.push(d)}}return r.length===0&&t.error(l.VariantRequiresEnteringEvent,`Variant '${i}' must declare at least one 'enters on' event`,f(e)),{kind:"ProjectionVariantSyntax",name:i,entersOn:r,blocks:o,location:f(e)}}c(Eu,"parseVariant");function Cu(t,e){let n=uu.exec(e.content);return n===null?(t.error(l.InvalidEntersOnDeclaration,`Invalid 'enters on' declaration '${e.content}' - expected 'enters on <EventType> [key <expression>]'`,f(e)),t.skipBlock(e.indent),{kind:"ProjectionEntersOnSyntax",event:"",key:null,location:f(e)}):{kind:"ProjectionEntersOnSyntax",event:re(n[1]),key:n[2]===void 0?null:Ee(n[2],f(e),t),location:f(e)}}c(Cu,"parseEntersOn");function fs(t,e){let n=e.content.substring(3).trim();if(t.peekChild(e.indent)===void 0)return{kind:"ExpressionKeySyntax",expression:Ee(n,f(e),t),location:f(e)};let i=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),o.content==="}")continue;let s=ps.exec(o.content);if(s===null){t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidCompositeKeyPart,`Invalid composite key part '${o.content}' - expected '<property> = <expression>'`,f(o));continue}let a=Ee(s[2],f(o),t);t.sourceOptions.numericMode==="exact"&&a.kind==="TemplateExpressionSyntax"&&t.error(l.TemplateInCompositeKey,"Template expressions are not allowed in composite keys",f(o)),i.push({kind:"KeyPartSyntax",property:re(s[1]),expression:a,location:f(o)})}let r=t.reader.peekSignificant();return r!==void 0&&r.indent===e.indent&&r.content==="}"&&t.reader.takeSignificant(),t.sourceOptions.numericMode==="exact"&&i.length===0&&t.error(l.EmptyCompositeKey,"Composite keys must contain at least one part",f(e)),{kind:"CompositeKeySyntax",type:n.replace(/\{$/,"").trim(),parts:i,location:f(e)}}c(fs,"parseKey");function Zr(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)||ms(t,o,r);return{autoMap:i,mappings:r}}c(Zr,"parseMappingBlock");function ms(t,e,n){let i=f(e),r=fu.exec(e.content);if(r!==null){r[1]!=="clear"||r[2]!=="with"?n.push({kind:hu[r[1]],property:re(r[2]),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidProjectionMapping,`Invalid mapping '${e.content}' - 'clear with' is a block directive and needs an event type; to clear a property named 'with', write 'clear @with'`,i);return}let o=mu.exec(e.content);if(o!==null){n.push({kind:o[1]==="add"?"AddMappingSyntax":"SubtractMappingSyntax",property:re(o[2]),value:Ee(o[3],i,t),location:i});return}let s=yu.exec(e.content)??ps.exec(e.content);s!==null?n.push({kind:"SetMappingSyntax",property:re(s[1]),source:Ee(s[2],i,t),location:i}):t.sourceOptions.numericMode==="exact"&&t.error(l.InvalidProjectionMapping,`Invalid mapping '${e.content}'`,i)}c(ms,"pushMapping");var Pu=I("^query\\s+([A-Za-z_]\\w*)\\s*=>\\s*(observable\\s+)?([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)$"),Au=I("^([a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),wu=I("^scoped\\s+to\\s+([a-z_]\\w*)$"),Iu=new Set(["performer"]);function hs(t,e){let n=Pu.exec(e.content);if(n===null)return t.error(l.InvalidQueryDeclaration,`Invalid query declaration '${e.content}' - expected 'query <Name> => [observable] <ReadModel>'`,f(e)),t.skipBlock(e.indent),{kind:"QuerySyntax",name:D(e.content),returnType:we("",f(e)),by:null,filters:[],description:null,isObservable:!1,scope:null,authorize:null,location:f(e)};let i=n[1],r=we(n[3],{...f(e),column:e.indent+1+n[0].length-n[3].length});n[2]===void 0&&r.name==="observable"&&r.isOptional&&!r.isCollection||Me(t,r,e);let o=null,s=[],a=null,d=null,p=null;for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent)){t.reader.takeSignificant();let u=D(m.content);if(u==="description")a=G(t,m,a,`Query '${i}'`);else if(u==="by"){let y=ys(t,m,"by");y!==void 0&&(o!==null&&t.error(l.InvalidQueryParameter,`Query '${i}' already declares 'by' - a query can have at most one key parameter`,f(m)),o=y)}else if(u==="filter"){let y=ys(t,m,"filter");y!==void 0&&s.push(y)}else u==="authorize"?p=Xe(p,gt(t,m)):u==="scoped"?d=Ou(t,m,d,i)??d:Iu.has(u)?t.skipOpaqueBlock(m.indent):(t.error(l.UnknownQueryDirective,`Unexpected '${m.content}' in query body - expected description, by, filter, authorize, scoped or performer`,f(m)),t.skipBlock(m.indent))}return{kind:"QuerySyntax",name:i,returnType:r,by:o,filters:s,description:a,isObservable:n[2]!==void 0,scope:d,authorize:p,location:f(e)}}c(hs,"parseQuery");function ys(t,e,n){let i=Au.exec(e.content.substring(n.length).trim());if(i===null){t.error(l.InvalidQueryParameter,`Invalid '${n}' parameter '${e.content}' - expected '${n} <name> <Type> [from <source>]'`,f(e));return}let r=e.content.indexOf(i[1],n.length),o=we(i[2],{...f(e),column:e.indent+1+e.content.indexOf(i[2],r+i[1].length)});return Me(t,o,e),{kind:"QueryParameterSyntax",name:i[1],type:o,source:i[3]===void 0?null:ae(i[3],f(e),t.valueContext),location:f(e)}}c(ys,"parseParameter");function Ou(t,e,n,i){let r=wu.exec(e.content);if(r===null){t.error(l.InvalidScopeDeclaration,`Invalid scope declaration '${e.content}' - expected 'scoped to <scope>'`,f(e));return}if(n!==null){t.error(l.DuplicateScope,`Query '${i}' already declares a scope - results are narrowed one way`,f(e));return}return r[1]}c(Ou,"parseScope");var Tu=I("^@?[a-z_]\\w*\\s+[\\w.]+");function Hr(t,e){let n=Fe(t,e);if(n!==void 0){n.isGenerated&&t.error(l.GeneratedPropertyOutsideCommand,"Generated properties can only be declared on commands.",n.location),n.isSubject&&t.error(l.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}Tu.test(e.content)&&/\?|\boptional\b/.test(e.content)&&t.error(l.InvalidTriggerData,`Invalid trigger value '${e.content}' - expected '<name>' or '<name> <Type>'`,f(e)),t.skipOpaqueBlock(e.indent)}c(Hr,"parseTriggerData");function Ss(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"?G(t,i,null,`Trigger '${e.content}'`):ge(i)||Hr(t,i);return t.triggerData.slice(n)}c(Ss,"parseTriggerDeclaration");var Ru=I("^reaction\\s+([A-Za-z_]\\w*)$"),Du=I("^when\\s+([A-Za-z_]\\w*)$"),Mu=I("^every\\s+(\\d+)\\s+(seconds?|minutes?|hours?|days?)$"),Lu=I("^at\\s+(\\d{2}:\\d{2})(?:\\s+on\\s+(?:(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)|day\\s+(\\d{1,2})))?$"),ju=new Set(["when","every","at"]),Nu=I("^invokes\\s+([A-Z]\\w*)$"),qu=Z("^(@?[\\w.]+)\\s*=(?!=|>)\\s*(.+)$"),Xr=Z("^on\\s+refused\\b(?=$|\\s+by\\b)"),Bu=Z("^on\\s+refused(?:\\s+by\\s+(validation|constraint|authorization)(?:\\s+([A-Za-z_]\\w*(?:\\.\\w+)*))?)?$"),Yu=I("^reads\\s+[A-Z]\\w*\\s+optional(?:\\s|$)");function gs(t,e){let n=Ru.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidReactionDeclaration,`Invalid reaction declaration '${e.content}' - expected 'reaction <Name>'`,f(e));let i=null,r=null,o=null,s=[],a=new Set,d=!1;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let m=D(p.content);if(m==="description"){i=G(t,p,i,`Reaction '${n}'`);continue}if(m==="documentation"){r=Ie(t,p,r,`Reaction '${n}'`);continue}if(m==="where"){o=_e(t,p.content.substring(5).trim(),f(p));continue}if(Xr.test(p.content)){t.error(l.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent),d=!0;continue}if(!ju.has(m)){t.error(l.InvalidReactionTrigger,`Expected a trigger in reaction body, got '${p.content}' - a reaction is set off by 'when <Name>', 'every <n> <unit>' or 'at <HH:mm>'`,f(p)),t.skipBlock(p.indent),d=!0;continue}let u=Vu(t,p);if(u===void 0){d=!0;continue}let y=Wu(u);if(a.has(y)){t.error(l.DuplicateReactionTrigger,`Reaction '${n}' already declares '${p.content}' - a second says nothing the first did not`,f(p)),t.skipBlock(p.indent);continue}a.add(y),s.push(Fu(t,p,u))}return s.length===0&&!d&&t.error(l.ReactionWithoutTrigger,`Reaction '${n}' must declare at least one trigger - nothing sets it off`,f(e)),{kind:"ReactionSyntax",name:n,description:i,documentation:r,where:o,triggers:s,location:f(e)}}c(gs,"parseReaction");function Fu(t,e,n){let i=null,r=[],o=[],s=[],a=[];for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent)){t.reader.takeSignificant();let m=D(p.content);if(m==="description")i=G(t,p,i,`Trigger '${p.content}'`);else if(m==="produces"){let u=Pn(t,p);u!==void 0&&r.push(u)}else if(m==="invokes"){let u=Nu.exec(p.content);if(u===null)t.error(l.InvalidInvokesDeclaration,`Invalid invokes declaration '${p.content}' - expected 'invokes <Command>'`,f(p)),t.skipBlock(p.indent);else{let y=new me(t.reader.fork(),t.path,t.languages);y.scope=t.scope,y.sourceOptions=t.sourceOptions,We(y,p),t.inputUses.push(...y.inputUses);let h=[],x=[];for(let b=t.peekChild(p.indent);b!==void 0;b=t.peekChild(p.indent)){if(t.reader.takeSignificant(),Xr.test(b.content)){let $=Uu(t,b);$!==void 0&&x.push($);continue}let S=qu.exec(b.content);S!==null?h.push({kind:"PropertyMappingSyntax",property:S[1].replaceAll("@",""),source:Be(S[2],f(b),t.valueContext),location:f(b)}):t.error(l.InvalidPropertyMapping,`Invalid property mapping '${b.content}' - expected '<property> = <source>'`,f(b))}o.push({kind:"InvokesSyntax",command:u[1],mappings:h,onRefused:x,location:f(p)})}}else if(Xr.test(p.content))t.error(l.InvalidRefusalBranch,"A refusal branch belongs inside 'invokes <Command>'.",f(p)),t.skipBlock(p.indent);else if(m==="reads"||m==="file"||p.content==="csharp"||p.content.startsWith("```")){let u=gi(p);u!==void 0&&s.push(u),Yu.test(p.content)&&t.error(l.OptionalReadsNotSupported,"Optional reads are not yet supported (see #308).",f(p)),p.content.startsWith("```")&&t.skipFencedBody(),t.skipOpaqueBlock(p.indent)}else{let u=t.triggerData.length;Hr(t,p);for(let y of t.triggerData.slice(u))a.push({kind:"TriggerDataSyntax",name:y.name,type:y.type,location:y.location})}}let d={kind:"ReactionTriggerSyntax",source:n,description:i,produces:r,invokes:o,location:f(e)};return ot.set(d,{reads:s,data:a}),d}c(Fu,"parseTrigger");function Uu(t,e){let n=Bu.exec(e.content);if(n===null||n[2]!==void 0&&n[1]!=="constraint"){t.error(l.InvalidRefusalBranch,"Expected 'on refused [by validation | by constraint [<Name>] | by authorization]'.",f(e)),t.skipBlock(e.indent);return}let i=[],r=!1,o=!1;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),s.content==="acknowledge")(r||i.length>0||t.peekChild(s.indent)!==void 0)&&(t.error(l.InvalidRefusalBranchBody,"A refusal branch contains 'acknowledge' alone or one or more 'produces' blocks.",f(s)),o=!0),r=!0,t.skipBlock(s.indent);else if(D(s.content)==="produces"){r&&(t.error(l.InvalidRefusalBranchBody,"A refusal branch cannot combine 'acknowledge' and 'produces'.",f(s)),o=!0);let a=Pn(t,s);a!==void 0?i.push(a):o=!0}else t.error(l.InvalidRefusalBranchBody,"Expected 'acknowledge' or 'produces <Event>' in a refusal branch.",f(s)),t.skipBlock(s.indent),o=!0;return!r&&i.length===0&&!o&&t.error(l.InvalidRefusalBranchBody,"A refusal branch must acknowledge or produce an event.",f(e)),{kind:"InvocationRefusalSyntax",selector:n[1]??"any",constraint:n[2]??null,acknowledge:r,produces:i,location:f(e)}}c(Uu,"parseRefusal");function Wu(t){switch(t.kind){case"NamedTriggerSourceSyntax":return JSON.stringify([t.kind,t.name]);case"IntervalTriggerSourceSyntax":return JSON.stringify([t.kind,t.amount,t.unit]);case"ScheduleTriggerSourceSyntax":return JSON.stringify([t.kind,t.time,t.dayOfWeek,t.dayOfMonth])}}c(Wu,"sourceKey");function Vu(t,e){let n=f(e);switch(D(e.content)){case"when":{let i=Du.exec(e.content);if(i===null){t.error(l.InvalidReactionTrigger,`Invalid trigger '${e.content}' - expected 'when <Name>'`,n),t.skipBlock(e.indent);return}return{kind:"NamedTriggerSourceSyntax",name:i[1],location:n}}case"every":{let i=Mu.exec(e.content),r=i===null?NaN:Number(i[1]);if(i===null||!Number.isInteger(r)||r<1||r>2147483647){t.error(l.InvalidIntervalTrigger,`Invalid interval '${e.content}' - expected 'every <n> <seconds|minutes|hours|days>'`,n),t.skipBlock(e.indent);return}return{kind:"IntervalTriggerSourceSyntax",amount:r,unit:Gu(i[2]),location:n}}default:return zu(t,e)}}c(Vu,"parseTriggerSource");function zu(t,e){let n=f(e),i=Lu.exec(e.content),r=i===null?void 0:Qu(i[1]);if(i===null||r===void 0){t.error(l.InvalidScheduleTrigger,`Invalid schedule '${e.content}' - expected 'at <HH:mm>', optionally followed by 'on <Weekday>' or 'on day <n>'`,n),t.skipBlock(e.indent);return}if(i[3]!==void 0){let o=Number(i[3]);if(o<1||o>31){t.error(l.InvalidScheduleTrigger,`Invalid day of month '${o}' in '${e.content}' - a day of the month is between 1 and 31`,n),t.skipBlock(e.indent);return}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:null,dayOfMonth:o,location:n}}return{kind:"ScheduleTriggerSourceSyntax",time:r,dayOfWeek:i[2]??null,dayOfMonth:null,location:n}}c(zu,"parseSchedule");function Qu(t){let[e,n]=t.split(":").map(Number);if(e>=0&&e<=23&&n>=0&&n<=59)return`${t}:00.0000000`}c(Qu,"timeOf");function Gu(t){switch(t.replace(/s+$/,"")){case"second":return"Seconds";case"minute":return"Minutes";case"hour":return"Hours";default:return"Days"}}c(Gu,"unitOf");var _u=I("^(data|query|component)\\s+(\\S+)(.*)$"),Zu=I("^literal\\s+(.+?)(?:\\s+(mode\\s+.+|null\\s+.+|expected\\s+.+))?$"),Ku=I("^([A-Za-z_]\\w*)(?:\\.(.+))?$"),Ju=I('^(?:([A-Za-z_]\\w*)|"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)")\\.(.+)$'),Hu=I("^mode\\s+(oneWay|twoWay)\\b(.*)$"),Xu=I("^null\\s+(propagate|clear|preserve)\\b(.*)$"),ef=I("^expected\\s+(\\w+(?:\\.\\w+)*)(.*)$");function Jt(t,e,n){let i=e.trim(),r=i.split(/\s+/,1)[0];return r==="data"||r==="query"||r==="component"||r==="literal"?xs(t,`from ${i}`,n):xs(t,i,n)}c(Jt,"parseFromClause");function xs(t,e,n){let i=e.trim();if(!i.startsWith("from "))return eo(t,ct("DataContext",i,n),"",n);let r=i.substring(5).trim();if(r.startsWith("literal ")){let a=Zu.exec(r);return a===null?(t.error(l.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from literal <value>'`,n),{...ct("Invalid",r,n),rawText:i}):eo(t,{...ct("Literal","",n),literal:ae(a[1],n,t)},a[2]??"",n)}let o=_u.exec(r);if(o===null)return t.error(l.UnknownScreenDirective,`Invalid UI binding '${i}' - expected 'from data <path>', 'from query <Query>[.<path>]', 'from component <id>.<path>' or 'from literal <value>'`,n),{...ct("Invalid",r,n),rawText:i};let s=tf(t,o[1],o[2],i,n);return eo(t,s,o[3],n)}c(xs,"parseUiBinding");function tf(t,e,n,i,r){return e==="data"?ct("DataContext",n,r):e==="query"?nf(t,n,i,r):rf(t,n,i,r)}c(tf,"parseBindingSource");function nf(t,e,n,i){let r=Ku.exec(e);return r===null?(t.error(l.UnknownScreenDirective,`Invalid query binding '${n}' - expected 'from query <Query>[.<path>]'.`,i),{...ct("Invalid",e,i),rawText:n}):{...ct("QueryResult",r[2]??"",i),query:r[1]}}c(nf,"queryBinding");function rf(t,e,n,i){let r=Ju.exec(e);if(r===null)return t.error(l.UnknownScreenDirective,`Invalid component binding '${n}' - expected 'from component <stableInstanceId>.<outputPath>' or 'from component "<stableInstanceId>".<outputPath>'.`,i),{...ct("Invalid",e,i),rawText:n};let o=r[1]??r[2],s=r[3];return{...ct("ComponentProperty",s,i),componentId:o,componentPropertyPath:s}}c(rf,"componentBinding");function eo(t,e,n,i){let r=e,o=n.trim();for(;o.length>0;){let s=Hu.exec(o);if(s!==null){r={...r,mode:s[1]==="twoWay"?"TwoWay":"OneWay"},o=s[2].trim();continue}let a=Xu.exec(o);if(a!==null){r={...r,nullBehavior:a[1]==="clear"?"Clear":a[1]==="preserve"?"Preserve":"Propagate"},o=a[2].trim();continue}let d=ef.exec(o);if(d!==null){r={...r,expectedValueType:d[1]},o=d[2].trim();continue}return t.error(l.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}c(eo,"withModifiers");function ct(t,e,n){return{kind:"UiBindingSyntax",bindingKind:t,path:e,query:null,componentId:null,componentPropertyPath:null,mode:null,nullBehavior:null,expectedValueType:null,literal:null,rawText:null,location:n}}c(ct,"create");var Tt=`(?:"(${z})"|(\\$strings\\.\\w+(?:\\.\\w+)*))`,of=I("^screen\\s+([A-Za-z_]\\w*)$"),af=I("^data\\s+([\\w.]+(?:\\[\\])?)\\s+via\\s+query\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),sf=I("^action\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),vs=I(`^label\\s+${Tt}$`),lf=I(`^action\\s+${Tt}$`),cf=I("^navigate\\s+to\\s+(\\w+(?:\\.\\w+)*)(?:\\s+by\\s+(\\w+))?$"),df=I(`^route\\s+${Tt}$`),pf=I("^outlet\\s+([A-Za-z_]\\w*)$"),uf=I("^contribute\\s+to\\s+([A-Za-z_]\\w*)(?:\\s+order\\s+(-?\\d+))?$"),$s=I("^parameter\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),ff=I("^component\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)\\s+([A-Za-z_]\\w*)$"),mf=I(`^id\\s+(?:"(${z})"|(\\S+))$`),yf=I("^property\\s+([\\w.]+)\\s+from\\s+(.+)$"),hf=I("^property\\s+([\\w.]+)\\s*=\\s+(.+)$"),Sf=I("^exposes\\s+([A-Za-z_]\\w*)\\s+from\\s+(.+)$"),gf=I(`^presentation\\s+([A-Za-z_]\\w*)\\s+${Tt}$`),xf=I("^item\\s+([A-Za-z_]\\w*)\\s+(action|navigate|dialog)(?:\\s+to)?\\s+([A-Za-z_]\\w*(?:\\.\\w+)*)$"),vf=I("^[a-z_]\\w*$"),$f=I(`^title\\s+${Tt}$`),bf=I(`^column\\s+([\\w.]+)(?:\\s+label\\s+${Tt})?$`),kf=I("^on\\s+row-click\\s+(navigate\\s+to\\s+.+)$"),Ef=I(`^field\\s+([\\w.]+)\\s+label\\s+${Tt}$`),dt=c((t,e)=>t[e]!==void 0?Q(t[e]):t[e+1],"operandText"),Cf=c(t=>["on","uses"].includes(D(t.content)),"isInteraction"),Pf=c((t,e)=>e.content.startsWith("```")||t.languages.has(e.content),"isCodeLine");function bs(t,e){let n=of.exec(e.content);n===null&&t.error(l.InvalidScreenDeclaration,`Invalid screen declaration '${e.content}' - expected 'screen <Name>'`,f(e));let i=[],r=[],o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(s.content)==="contribute"){let a=Af(t,s);a!==void 0&&r.push(a)}else D(s.content)==="description"?o=G(t,s,o,`Screen '${n?.[1]??""}'`):ge(s)||ks(t,s,i);return{kind:"ScreenSyntax",name:n?.[1]??"",directives:i,description:o,...r.length>0?{contributions:r}:{},location:f(e)}}c(bs,"parseScreen");function Af(t,e){let n=uf.exec(e.content);if(n===null){t.error(l.UnknownScreenDirective,`Invalid screen contribution '${e.content}' - expected 'contribute to <Point> [order <n>]'`,f(e)),t.skipBlock(e.indent);return}return{kind:"ScreenContributionSyntax",contributionPoint:n[1],order:n[2]===void 0?null:Number(n[2]),directives:bi(t,e),location:f(e)}}c(Af,"parseScreenContribution");function ks(t,e,n){let i=wf(t,e);i!==void 0&&n.push(i)}c(ks,"pushDirective");function bi(t,e){let n=[];for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),ks(t,i,n);return n}c(bi,"parseDirectives");function wf(t,e){switch(D(e.content)){case"data":return If(t,e);case"action":return Of(t,e);case"template":return Tf(t,e);case"section":return Rf(t,e);case"title":return Df(t,e);case"table":return Mf(t,e);case"summary":return Lf(t,e);case"component":return jf(t,e);case"toolbar":return Ff(t,e);case"navigate":return $i(t,e.content,e);case"on":return We(t,e),{kind:"ScreenBehaviorSyntax",location:f(e)};case"uses":return t.skipOpaqueBlock(e.indent),{kind:"ScreenUsesBehaviorSyntax",location:f(e)};default:if(Pf(t,e))return Vf(t,e);t.error(l.UnknownScreenDirective,`Unexpected '${e.content}' in screen body`,f(e)),t.skipBlock(e.indent);return}}c(wf,"parseDirective");function If(t,e){let n=af.exec(e.content);if(n===null){t.error(l.InvalidDataDirective,`Invalid data directive '${e.content}' - expected 'data <ReadModel> via query <Query> [by <param>]'`,f(e));return}return{kind:"ScreenDataSyntax",type:we(n[1],f(e)),query:n[2],by:n[3]??null,location:f(e)}}c(If,"parseData");function Of(t,e){let n=lf.exec(e.content);if(n!==null)return ba(t,e,dt(n,1),$i);let i=sf.exec(e.content);if(i===null){t.error(l.InvalidActionDirective,`Invalid action directive '${e.content}' - expected 'action <Command>'`,f(e)),t.skipBlock(e.indent);return}let r=null,o=null;for(let s=t.peekChild(e.indent);s!==void 0;s=t.peekChild(e.indent)){t.reader.takeSignificant();let a=vs.exec(s.content);a!==null?r=dt(a,1):D(s.content)==="navigate"?o=$i(t,s.content,s)??null:t.error(l.UnknownActionDirective,`Unexpected '${s.content}' in action - expected 'label "..."' or 'navigate to ...'`,f(s))}return{kind:"ScreenActionSyntax",command:i[1],label:r,navigate:o,location:f(e)}}c(Of,"parseAction");function $i(t,e,n){let i=cf.exec(e);if(i===null){t.error(l.InvalidNavigation,`Invalid navigation '${e}' - expected 'navigate to <Screen> [by <param>]'`,f(n));return}let r=[],o=null,s=null;for(let a=t.peekChild(n.indent);a!==void 0;a=t.peekChild(n.indent)){t.reader.takeSignificant();let d=$s.exec(a.content);if(d!==null){r.push({kind:"ScreenNavigationParameterSyntax",name:d[1],binding:Jt(t,d[2],f(a)),location:f(a)});continue}let p=df.exec(a.content);if(p!==null){o=dt(p,1);continue}let m=pf.exec(a.content);if(m!==null){s=m[1];continue}t.error(l.InvalidNavigation,`Unexpected '${a.content}' in navigation - expected 'route "..."', 'outlet <name>' or 'parameter <name> from <binding>'`,f(a))}return{kind:"ScreenNavigateSyntax",screen:i[1],by:i[2]??null,route:o,...s===null?{}:{outlet:s},parameters:r,location:f(n)}}c($i,"parseNavigate");function Tf(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(),!vf.test(r.content)){t.error(l.InvalidScreenLayoutSlot,`Expected a slot name in template '${n}', got '${r.content}'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ScreenSlotSyntax",name:r.content,directives:bi(t,r),location:f(r)})}return{kind:"ScreenTemplateReferenceSyntax",name:n,slots:i,location:f(e)}}c(Tf,"parseTemplateReference");function Rf(t,e){return{kind:"ScreenSectionSyntax",name:e.content.substring(7).trim(),directives:bi(t,e),location:f(e)}}c(Rf,"parseSection");function Df(t,e){let n=$f.exec(e.content);return n===null?(t.error(l.InvalidTitleDirective,`Invalid title directive '${e.content}' - expected 'title "..."'`,f(e)),{kind:"ScreenTitleSyntax",text:"",location:f(e)}):{kind:"ScreenTitleSyntax",text:dt(n,1),location:f(e)}}c(Df,"parseTitle");function Mf(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=bf.exec(o.content),a=kf.exec(o.content);if(s!==null){let d=s[2]!==void 0||s[3]!==void 0;i.push({kind:"ScreenColumnSyntax",property:s[1],label:d?dt(s,2):null,location:f(o)})}else a!==null?r=$i(t,a[1],o)??null:D(o.content)==="on"?We(t,o):Cf(o)?t.skipOpaqueBlock(o.indent):t.error(l.UnknownTableDirective,`Unexpected '${o.content}' in table - expected 'column ...', 'on row-click navigate to ...', 'on <trigger>' or 'uses <Behavior>'`,f(o))}return{kind:"ScreenTableSyntax",target:n,columns:i,rowClick:r,location:f(e)}}c(Mf,"parseTable");function Lf(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=Ef.exec(r.content);if(o===null){t.error(l.UnknownSummaryDirective,`Unexpected '${r.content}' in summary - expected 'field <property> label "..."'`,f(r));continue}i.push({kind:"ScreenFieldSyntax",property:o[1],label:dt(o,2),location:f(r)})}return{kind:"ScreenSummarySyntax",target:n,fields:i,location:f(e)}}c(Lf,"parseSummary");function jf(t,e){let n=ff.exec(e.content);if(n===null){t.error(l.UnknownScreenDirective,`Invalid component directive '${e.content}' - expected 'component <Package.Component> <name>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=null,s=[],a=[],d=[],p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))switch(t.reader.takeSignificant(),D(m.content)){case"context":i=Nf(t,m);break;case"id":r=Bf(t,m);break;case"property":qf(t,m,s);break;case"icon":o=m.content.substring(4).trim();break;case"presentation":Es(t,m,d);break;case"exposes":Yf(t,m,a);break;case"outlet":p.push({kind:"ComponentOutletSyntax",name:m.content.substring(6).trim(),directives:bi(t,m),location:f(m)});break;case"on":We(t,m);break;case"uses":t.skipOpaqueBlock(m.indent);break;default:t.error(l.UnknownScreenDirective,`Unexpected '${m.content}' in component - expected context, id, property, icon, presentation, exposes, outlet, on or uses`,f(m)),t.skipBlock(m.indent);break}return{kind:"ScreenComponentSyntax",component:n[1],name:n[2],stableId:r,context:i,properties:s,exposes:a,presentation:d,icon:o,outlets:p,location:f(e)}}c(jf,"parseComponent");function Nf(t,e){return Wf(t,e.content.substring(7).trim(),e)}c(Nf,"parseUiContext");function qf(t,e,n){let i=yf.exec(e.content);if(i!==null){n.push({kind:"ComponentPropertySyntax",property:i[1],binding:Jt(t,i[2],f(e)),value:null,location:f(e)});return}let r=hf.exec(e.content);if(r!==null){n.push({kind:"ComponentPropertySyntax",property:r[1],binding:null,value:ae(r[2],f(e),t),location:f(e)});return}t.error(l.UnknownScreenDirective,`Invalid component property '${e.content}' - expected 'property <path> from <binding>' or 'property <path> = <literal|object|array|null>'`,f(e))}c(qf,"parseComponentProperty");function Bf(t,e){let n=mf.exec(e.content);return n===null?(t.error(l.UnknownScreenDirective,`Invalid component id '${e.content}' - expected 'id "stable-id"'`,f(e)),null):dt(n,1)}c(Bf,"parseStableId");function Yf(t,e,n){let i=Sf.exec(e.content);if(i===null){t.error(l.UnknownScreenDirective,`Invalid exposed value '${e.content}' - expected 'exposes <name> from <binding>'`,f(e));return}n.push({kind:"ComponentExposedValueSyntax",name:i[1],binding:Jt(t,i[2],f(e)),location:f(e)})}c(Yf,"parseExposedValue");function Es(t,e,n){let i=gf.exec(e.content);if(i===null){t.error(l.UnknownScreenDirective,`Invalid presentation value '${e.content}' - expected 'presentation <key> "value"'`,f(e));return}n.push({kind:"PresentationValueSyntax",name:i[1],value:dt(i,2),location:f(e)})}c(Es,"parsePresentationValue");function Ff(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=Uf(t,r);o!==void 0&&i.push(o)}return{kind:"ScreenToolbarSyntax",name:n,items:i,location:f(e)}}c(Ff,"parseToolbar");function Uf(t,e){let n=xf.exec(e.content);if(n===null){t.error(l.UnknownScreenDirective,`Invalid toolbar item '${e.content}' - expected 'item <name> action <Command>', 'item <name> navigate to <Screen>' or 'item <name> dialog <DialogTemplate>'`,f(e)),t.skipBlock(e.indent);return}let i=null,r=null,o=[],s=[];for(let d=t.peekChild(e.indent);d!==void 0;d=t.peekChild(e.indent)){t.reader.takeSignificant();let p=vs.exec(d.content);if(p!==null){i=dt(p,1);continue}let m=$s.exec(d.content);if(m!==null){o.push({kind:"ScreenNavigationParameterSyntax",name:m[1],binding:Jt(t,m[2],f(d)),location:f(d)});continue}if(D(d.content)==="icon"){r=d.content.substring(4).trim();continue}Es(t,d,s)}let a=n[2]==="navigate"?"Navigate":n[2]==="dialog"?"Dialog":"Action";return{kind:"ToolbarItemSyntax",name:n[1],syntaxKind:a,target:n[3],label:i,icon:r,parameters:o,presentation:s,location:f(e)}}c(Uf,"parseToolbarItem");function Wf(t,e,n){return Jt(t,e,f(n))}c(Wf,"parseUiBindingValue");function Vf(t,e){let n=e.content.startsWith("```")?e.content.substring(3):e.content;if(!t.languages.has(n)){t.error(l.ExpectedCodeFence,`Expected a registered language on the opening fence, not '${e.content}'`,f(e));return}e.content.startsWith("```")||t.warning(l.LegacyInlineCodeFence,`'${n}' on its own line is deprecated - use '\`\`\`${n}' instead`,f(e));let i=Vt(t,n,e);return i===null?void 0:{kind:"ScreenCodeSyntax",code:{kind:"CodeBlockSyntax",language:n,code:i,location:f(e)},location:f(e)}}c(Vf,"parseCode");var zf=I("^slice\\s+([A-Za-z]\\w*)\\s+([A-Za-z_]\\w*)$"),Qf=new Set(["reducer"]);function Cs(t,e){let n=zf.exec(e.content),i="StateChange",r="";n===null?t.error(l.InvalidSliceDeclaration,`Invalid slice declaration '${e.content}' - expected 'slice <Type> <Name>'`,f(e)):(r=n[2],Qa.includes(n[1])?i=n[1]:t.error(l.UnknownSliceType,`Unknown slice type '${n[1]}' - expected StateChange, StateView, Automation or Translate`,f(e)));let o=t.scope;t.scope=[...o,r];let s=null,a=!1,d=null,p=null,m=[],u=[],y=[],h=[],x=[],b=[],S=[],$=[],g=[],P=[],w=[],v=[],E=[],C=[];for(let A=t.peekChild(e.indent);A!==void 0;A=t.peekChild(e.indent)){if(t.reader.takeSignificant(),ge(A))continue;let O=A.content.split(/[ \t]/,1)[0],T=O==="public"||O==="direction"?O:D(A.content);if(T==="description")d=G(t,A,d,`Slice '${r}'`);else if(T==="documentation")p=Ie(t,A,p,`Slice '${r}'`);else if(T==="purpose")zt(t,A,w);else if(T==="operation")u.push(pi(t,A).operation);else if(T==="direction"){let M=/^direction\s+(inbound|outbound)$/.exec(A.content);a||i!=="Translate"||M===null?t.error(l.InvalidSliceDeclaration,"Declare direction inbound or direction outbound once, inside a Translate slice only",f(A)):s=M[1]==="inbound"?de.Inbound:de.Outbound,a=!0}else T==="event"||T==="public"?m.push(Ja(t,A)):T==="command"?y.push(cs(t,A)):T==="query"?h.push(hs(t,A)):T==="projection"?x.push(Kr(t,A)):T==="capture"?S.push(zr(t,A)):T==="reaction"?b.push(gs(t,A)):T==="constraint"?$.push(ds(t,A)):T==="example"?P.push(lt(t,A)):T==="specification"?g.push(qr(t,A)):T==="readmodel"?v.push(Ha(t,A)):T==="screen"?E.push(bs(t,A)):Qf.has(T)?(C.push(rs(t,A)),t.skipOpaqueBlock(A.indent)):(t.warning(l.UnknownSliceDirective,`Unknown construct '${T}' in slice '${r}'`,f(A)),t.skipBlock(A.indent))}t.scope=o;let k={kind:"SliceSyntax",type:i,name:r,direction:s,description:d,documentation:p,examples:P,purposes:w,events:m,operations:u,commands:y,queries:h,projections:x,captures:S,reactions:b,constraints:$,specifications:g,readModels:v,screens:E,location:f(e)};return ot.set(k,{reducers:C}),k}c(Cs,"parseSlice");var Gf=I("^feature\\s+([A-Za-z_]\\w*)$"),_f=new Set(["on","uses","contribute"]),to="description, documentation, depends on <Name>, authorize, import, feature, slice, contribute, example, 'on <trigger>' or 'uses <Behavior>'",An=class{static{c(this,"FeatureBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=[];#l=null;#a=null;#n=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#l=G(e,n,this.#l,`Feature '${this.name}'`),!0;case"documentation":return this.#a=Ie(e,n,this.#a,`Feature '${this.name}'`),!0;case"depends":return ai(e,n,this.#r,l.UnknownFeatureDirective),!0;case"purpose":return zt(e,n,this.#o),!0;case"authorize":return this.#n=Xe(this.#n,gt(e,n)),!0;case"import":return Qt(e,n,this.#i),!0;case"feature":return this.#e.push(ki(e,n)),!0;case"example":return this.#s.push(lt(e,n)),!0;case"slice":return this.#t.push(Cs(e,n)),!0;default:return _f.has(i)?(We(e,n),!0):!1}}build(e,n=!1){return{kind:"FeatureSyntax",name:this.name,description:this.#l,documentation:this.#a,authorize:this.#n,dependsOn:this.#r,purposes:this.#o,features:this.#e,slices:this.#t,examples:this.#s,fileImports:this.#i,isPlacement:n,location:e}}};function ki(t,e){let n=Gf.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidFeatureDeclaration,`Invalid feature declaration '${e.content}' - expected 'feature <Name>'`,f(e));let i=new An(n),r=t.scope;t.scope=[...r,n];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent))t.reader.takeSignificant(),i.tryParse(t,o)||(t.error(l.UnknownFeatureDirective,`Unexpected '${D(o.content)}' in feature body - expected ${to}`,f(o)),t.skipBlock(o.indent));return t.scope=r,i.build(f(e))}c(ki,"parseFeature");var no=I("^module\\s+([A-Za-z_]\\w*)$"),Zf=new Set(["on","uses","screen","dialog","form","contribute"]),io="description, documentation, depends on <Name>, authorize, import, screen template, dialog template, form, contribute, feature, example, 'on <trigger>' or 'uses <Behavior>'",wn=class{static{c(this,"ModuleBody")}name;#e=[];#t=[];#s=[];#i=[];#r=[];#o=null;#l=null;#a=null;constructor(e){this.name=e}tryParse(e,n){let i=D(n.content);switch(i){case"description":return this.#o=G(e,n,this.#o,`Module '${this.name}'`),!0;case"documentation":return this.#l=Ie(e,n,this.#l,`Module '${this.name}'`),!0;case"depends":return ai(e,n,this.#i,l.UnknownModuleDirective),!0;case"purpose":return zt(e,n,this.#r),!0;case"authorize":return this.#a=Xe(this.#a,gt(e,n)),!0;case"import":return Qt(e,n,this.#s),!0;case"example":return this.#t.push(lt(e,n)),!0;case"feature":return this.#e.push(ki(e,n)),!0;default:return Zf.has(i)?(We(e,n),!0):!1}}parseChildren(e,n){for(let i=e.peekChild(n.indent);i!==void 0;i=e.peekChild(n.indent))e.reader.takeSignificant(),this.tryParse(e,i)||(e.error(l.UnknownModuleDirective,`Unexpected '${D(i.content)}' in module body - expected ${io}`,f(i)),e.skipBlock(i.indent))}build(e,n=!1){return{kind:"ModuleSyntax",name:this.name,description:this.#o,documentation:this.#l,authorize:this.#a,dependsOn:this.#i,purposes:this.#r,features:this.#e,examples:this.#t,fileImports:this.#s,isPlacement:n,location:e}}};function ro(t,e){let n=no.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidModuleDeclaration,`Invalid module declaration '${e.content}' - expected 'module <Name>'`,f(e));let i=new wn(n),r=t.scope;return t.scope=[n],i.parseChildren(t,e),t.scope=r,i.build(f(e))}c(ro,"parseModule");var Hf=new WeakMap,Ze=c(t=>JSON.stringify(t),"authoredOrderKey");function In(t){return Hf.get(t)??new Map}c(In,"authoredOrderOf");var vt=["usesFactsFrom","reactsTo","decidesFrom","asks","shows","verifiedWith","outsideTheModel"];var pt=class extends Error{static{c(this,"InvalidDependencyQuery")}};var Xf={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 Ci(t){let e=new Ei;return e.visitSlice(t),{references:e.references.sort((n,i)=>n.location.line-i.location.line||n.location.column-i.location.column),shared:e.shared}}c(Ci,"sliceReferences");function ws(t,e){let n=new Ei(e);return t.projections.forEach(i=>n.visitProjection(i)),Se(t).reducers?.filter(i=>i.readModel.toLowerCase()===e.toLowerCase()).forEach(i=>n.visitReducer(i)),n.references}c(ws,"buildingReadModelReferences");function so(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...so(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?so(e.blocks):[])}c(so,"variants");var Ei=class extends Ce{static{c(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),Se(e).reducers?.forEach(i=>this.visitReducer(i))}visitCommand(e){let n=Se(e);n.reads?.forEach(i=>this.visitReads(i)),n.concurrency!=null&&this.visitConcurrency(n.concurrency),super.visitCommand(e)}visitReactionTrigger(e){let n=Se(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=so(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=c((i,r,o)=>{this.references.push({name:i,targetKind:r,role:o,kind:Xf[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 On(t){let e=new Map,n=new Map,i=[],r=new Set,o=[],s=c(a=>{e.set(a,e.size),n.set(a,e.get(a)),i.push(a),r.add(a);for(let m of[...t.get(a)].sort())e.has(m)?r.has(m)&&n.set(a,Math.min(n.get(a),e.get(m))):(s(m),n.set(a,Math.min(n.get(a),n.get(m))));if(n.get(a)!==e.get(a))return;let d=[],p;do p=i.pop(),r.delete(p),d.push(p);while(p!==a);o.push(d.sort())},"visit");for(let a of[...t.keys()].sort())e.has(a)||s(a);return o}c(On,"stronglyConnectedGroups");var Is=["usesFactsFrom","reactsTo","decidesFrom"],nt=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),lo=c((t,e)=>JSON.stringify([t,e.toLowerCase()]),"declarationKey"),co=c((t,e,n,i)=>({kind:t,address:e,scope:n,rank:i,key:`${t}:${e}`}),"nodeOf"),uo=c((t,e)=>t.rank-e.rank||nt(t.key,e.key),"compareNodes"),Tn=c(t=>[...new Map([...t].map(e=>[e.key,e])).values()].sort(uo),"distinctNodes"),Os=c((t,e)=>t.consumer.rank-e.consumer.rank||t.location.line-e.location.line||t.location.column-e.location.column||vt.indexOf(t.kind)-vt.indexOf(e.kind)||t.producer.rank-e.producer.rank||nt(t.location.path??"",e.location.path??"")||nt(t.role,e.role)||nt(t.name,e.name),"compareEvidence");function fo(t){return t.flatMap(e=>e.kind==="ProjectionVariantSyntax"?[e,...fo(e.blocks)]:e.kind==="ChildrenSyntax"||e.kind==="NestedSyntax"?fo(e.blocks):[])}c(fo,"variants");var Ht=class t{static{c(this,"DependencyGraph")}orderSource;edges;unresolved;excludedReferences;unusedImports;modelNodes=[];slices=[];children=new Map;byKey=new Map;parents=new Map;root=co("application","",[],-1);static for(e,n=In(e)){return new t(e,n)}get nodes(){return this.modelNodes}constructor(e,n){e=Ge(e),this.orderSource=n.size>0?"authored":"syntax",this.children.set(this.root.key,[]);let i=c((g,P)=>g.map((w,v)=>({syntax:w,index:v,rank:n.get(Ze([...P.scope,w.name]))??Number.MAX_SAFE_INTEGER})).sort((w,v)=>w.rank-v.rank||w.index-v.index).map(w=>w.syntax),"ordered"),r=c((g,P)=>{let w=this.add("feature",g.name,P);for(let v of i(g.slices,w))this.slices.push({node:this.add("slice",v.name,w),syntax:v});for(let v of i(g.features,w))r(v,w)},"feature");for(let g of i(e.modules,this.root)){let P=this.add("module",g.name,this.root);for(let w of i(g.features,P))r(w,P)}let o=new Map,s=new Map,a=c((g,P,w,v)=>{let E=lo(P,w);g.has(E)||g.set(E,[]);let C=g.get(E);C.includes(v)||C.push(v);let k=lo(P,[...v.scope,w].join("."));g.has(k)||g.set(k,[]);let A=g.get(k);A.includes(v)||A.push(v)},"declare");for(let{node:g,syntax:P}of this.slices){for(let w of le(P))a(o,"Event",w.name,g);for(let w of P.commands)a(o,"Command",w.name,g);for(let w of P.reactions)a(o,"Reaction",w.name,g);for(let w of P.queries)a(o,"Query",w.name,g);for(let w of P.screens)a(o,"Screen",w.name,g);for(let w of P.readModels)a(o,"ReadModel",w.name,g);for(let w of P.projections){let v=fo(w.blocks);v.length===0&&a(s,"ReadModel",w.readModel??w.name,g);for(let E of v)a(s,"ReadModel",E.name,g)}for(let w of Se(P).reducers??[])a(s,"ReadModel",w.readModel,g)}let d=new Set((e.declaredTriggers??[]).map(g=>g.name.toLowerCase())),p=new Set([...e.concepts,...e.types].map(g=>g.name.toLowerCase())),m=new Set((e.policies??[]).map(g=>g.name.toLowerCase())),u=e.imports.filter(g=>g.qualifiedName.includes(".")).slice().sort((g,P)=>nt(g.location.path??"",P.location.path??"")||g.location.line-P.location.line||g.location.column-P.location.column||nt(g.qualifiedName,P.qualifiedName)),y=new Map,h=[],x=[],b=new Set,S=0;for(let{node:g,syntax:P}of this.slices){let w=Ci(P);S+=w.shared.filter(v=>(v.kind==="type"?p:m).has(v.name.toLowerCase())).length;for(let v of w.references){let E=lo(v.targetKind,v.name),k=(v.targetKind==="ReadModel"&&s.has(E)?s:o).get(E);if(k!==void 0&&k.length>0){let O=k[0];O!==g&&h.push({consumer:g,producer:O,kind:v.kind,role:v.role,name:v.name,ambiguous:k.length>1,alternatives:k.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}let A=v.targetKind==="Event"?u.filter(O=>O.qualifiedName.slice(O.qualifiedName.lastIndexOf(".")+1).toLowerCase()===v.name.toLowerCase()):[];if(A.length>0){let O=[];for(let T of A){b.add(T.qualifiedName);let M=T.qualifiedName.slice(0,T.qualifiedName.lastIndexOf(".")),N=`context:${M}`;if(!y.has(N)){let q=co("context",N,[M],this.modelNodes.length);this.modelNodes.push(q),y.set(N,q)}let j=y.get(N);O.includes(j)||O.push(j)}h.push({consumer:g,producer:O[0],kind:"outsideTheModel",role:v.role,name:v.name,ambiguous:O.length>1,alternatives:O.slice(1),location:v.location,testOnly:v.kind==="verifiedWith"});continue}if(v.role==="trigger"&&d.has(v.name.toLowerCase())){S++;continue}x.push({consumer:g,kind:v.kind,role:v.role,name:v.name,location:v.location})}}let $=new Map;for(let g of h.sort(Os)){let P=JSON.stringify([g.consumer.key,g.producer.key,g.kind]);$.has(P)||$.set(P,[]),$.get(P).push(g)}this.edges=[...$.values()].map(g=>({consumer:g[0].consumer,producer:g[0].producer,kind:g[0].kind,evidence:g})),this.unresolved=x.sort((g,P)=>g.consumer.rank-P.consumer.rank||g.location.line-P.location.line||g.location.column-P.location.column||vt.indexOf(g.kind)-vt.indexOf(P.kind)||nt(g.location.path??"",P.location.path??"")||nt(g.name,P.name)),this.excludedReferences=S,this.unusedImports=[...new Set(u.filter(g=>!b.has(g.qualifiedName)).map(g=>g.qualifiedName))]}implied(e,n,i,r=!1,o=3){if(!["slice","feature","module"].includes(e))throw new pt(`Unsupported source level '${e}'.`);if(!["slice","feature","module","context"].includes(n))throw new pt(`Unsupported target level '${n}'.`);if(o<0)throw new pt("Evidence limit must not be negative.");let s=new Map;for(let a of this.evidence(i,r))for(let d of this.at(a.consumer,e))for(let p of this.at(a.producer,n).filter(m=>this.disjoint(d,m))){let m=JSON.stringify([d.key,p.key]);s.has(m)||s.set(m,{source:d,target:p,evidence:[]}),s.get(m).evidence.push(a)}return[...s.values()].sort((a,d)=>a.source.rank-d.source.rank||a.target.rank-d.target.rank||nt(a.source.key,d.source.key)||nt(a.target.key,d.target.key)).map(a=>{let d=a.evidence.sort(Os),p={};for(let m of vt){let u=d.filter(y=>y.kind===m).length;u>0&&(p[m]=u)}return{source:a.source,target:a.target,sliceEdges:new Set(d.map(m=>JSON.stringify([m.consumer.key,m.producer.key]))).size,references:d.length,byKind:p,consumers:Tn(d.map(m=>m.consumer)),producers:Tn(d.map(m=>m.producer)),evidence:d.slice(0,o),evidenceCount:d.length,evidenceTruncated:d.length>o}})}cycles(e,n){if(!["slice","feature","module"].includes(e))throw new pt(`Unsupported cycle level '${e}'.`);let i=this.implied(e,e,Ts(n)),r=Tn(i.flatMap(o=>[o.source,o.target]));return Rs(po(r,i),r,null)}siblingGroups(e){let n=this.siblingEdges(e);return this.containers().flatMap(i=>{let r=this.children.get(i.key);return Rs(po(r,n.filter(o=>o.container===i)),r,i)})}suggestedOrder(e){let n=this.siblingEdges(e),i=[];for(let a of this.containers()){let d=this.children.get(a.key),p=n.filter(S=>S.container===a),m=new Map(d.map(S=>[S.key,S])),u=On(po(d,p)).map(S=>S.map($=>m.get($)).sort(uo)).sort((S,$)=>S[0].rank-$[0].rank),y=new Map(u.flatMap((S,$)=>S.map(g=>[g.key,$]))),h=new Map(d.map(S=>[S.key,new Set]));for(let S of p)y.get(S.source.key)!==y.get(S.target.key)&&h.get(S.source.key).add(S.target.key);for(let S of u)for(let $=1;$<S.length;$++)h.get(S[$].key).add(S[$-1].key);let x=new Set(d.map(S=>S.key)),b=[];for(;x.size>0;){let S=[...x].filter($=>h.get($).size===0).sort(($,g)=>uo(m.get($),m.get(g)))[0];b.push(m.get(S)),x.delete(S);for(let $ of x)h.get($).delete(S)}i.push({container:a,children:b,changed:d.some((S,$)=>S!==b[$])})}let r=new Map(i.map(a=>[a.container.key,a.children])),o=[],s=c(a=>{if(a.kind==="slice")o.push(a);else for(let d of[...r.get(a.key)].sort((p,m)=>+(p.kind!=="slice")-+(m.kind!=="slice")))s(d)},"walk");return s(this.root),{containers:i,slices:o}}traverse(e,n,i,r=!1){if(n!=="incoming"&&n!=="outgoing")throw new pt(`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],d=[];for(let p=0;p<a.length;p++)for(let m of o.filter(u=>u.source.address===a[p]).sort((u,y)=>u.target.rank-y.target.rank))s.has(m.target.address)||(s.add(m.target.address),d.push(m.target),a.push(m.target.address));return Tn(d)}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 d=co(e,o,r,this.modelNodes.length);return this.modelNodes.push(d),this.byKey.set(s,d),this.parents.set(s,i),this.children.get(i.key).push(d),e!=="slice"&&this.children.set(s,[]),d}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=Ds(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(Ts(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 Ds(t){let e=new Set(t??vt);if([...e].some(n=>!vt.includes(n)))throw new pt("Unsupported dependency kind.");return e}c(Ds,"selectedKinds");function Ts(t){return[...Ds(t??Is)].filter(e=>Is.includes(e))}c(Ts,"selectedOrderingKinds");function po(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}c(po,"adjacency");function Rs(t,e,n){let i=new Map(e.map(r=>[r.key,r]));return On(t).filter(r=>r.length>1).map(r=>({container:n,members:Tn(r.map(o=>i.get(o)))})).sort((r,o)=>r.members[0].rank-o.members[0].rank)}c(Rs,"groupsOf");var em=["usesFactsFrom","reactsTo","decidesFrom","asks","shows"],it=c((t,e)=>e===t||e.startsWith(t+"."),"contains"),Xt=c((t,e)=>t<e?-1:t>e?1:0,"ordinal"),tm=c((t,e)=>Xt(t.location.path??"",e.location.path??"")||t.location.line-e.location.line||t.location.column-e.location.column||Xt(t.kind,e.kind)||Xt(t.consumer.address,e.consumer.address)||Xt(t.producer.address,e.producer.address)||Xt(t.role,e.role)||Xt(t.name,e.name),"orderedEvidence"),en=class{static{c(this,"DeclaredDependencies")}static for(e){let n=new Map,i=c((u,y)=>{let h=u.join(".");n.has(h)||n.set(h,{location:y.location,dependencies:[]}),n.get(h).dependencies.push(...y.dependsOn??[]),y.features.forEach(x=>i([...u,x.name],x))},"inventory");if(e.modules.forEach(u=>i([u.name],u)),![...n.values()].some(u=>u.dependencies.length))return{containers:[],diagnostics:[]};let r=Ht.for(e,new Map),o=r.nodes.filter(u=>u.kind==="module"||u.kind==="feature"),s=je.containersOf(e),a=c((u,y)=>{let h=je.resolve(u,y,s).resolved;return h&&[...h.scope,h.name].join(".")},"resolve"),d=[],p=[],m=c((u,y,h,x)=>p.push({code:u,severity:y,message:h,location:x}),"finding");for(let u of o.filter(y=>n.get(y.address).dependencies.length)){let y=n.get(u.address),h=y.dependencies.map(S=>{let $=a(S.target,u.scope),g=$!==void 0&&!it(u.address,$)&&!it($,u.address);return{syntax:S,resolved:$,status:g?"unused":"invalid"}}),x=[],b=new Map;for(let S of r.edges.flatMap($=>$.evidence).filter($=>em.includes($.kind)&&it(u.address,$.consumer.address)).sort(tm)){let $=[S.producer,...S.alternatives].filter(w=>!it(u.address,w.address)&&!it(w.scope.slice(0,-1).join("."),u.address));if(!$.length)continue;let g=h.filter(w=>w.status!=="invalid"&&$.some(v=>it(w.resolved,v.address)));for(let w of g)w.status=S.ambiguous&&w.status!=="used"?"provisional":"used";let P=S.ambiguous?"provisional":g.length?"declared":"undeclared";if(x.push({evidence:S,status:P,coveringDeclarations:g.map(w=>w.syntax)}),P==="undeclared"){let w=S.producer.scope[0];b.has(w)||b.set(w,[]),b.get(w).push(S)}}for(let S of b.values()){let $=S[0].producer.scope.slice(0,-1),g=$.findIndex((E,C)=>S.some(k=>C>=k.producer.scope.length-1||k.producer.scope[C]!==E));g>=0&&($=$.slice(0,g));let P=$.join("."),w=it(u.address,P)||it(P,u.address)?[...new Set(S.map(E=>E.producer.scope.slice(0,-1).map((C,k)=>E.producer.scope.slice(0,k+1).join(".")).find(C=>!it(u.address,C)&&!it(C,u.address))))]:[P],v=S.map(E=>`${E.kind} ${E.role} '${E.name}' at ${E.location.path??""}:${E.location.line}:${E.location.column}`).join("; ");m(l.UndeclaredDependency,"warning",`Container '${u.address}' depends on '${w.join("', '")}' without declaring ${w.length===1?"it":"them"} - evidence: ${v}`,y.location)}for(let S of h)S.status==="unused"&&m(l.UnusedDependencyDeclaration,"information",`Dependency '${S.syntax.target}' on '${u.address}' is not used by any counted explicit reference`,S.syntax.location),S.status!=="invalid"&&n.get(S.resolved).dependencies.some($=>a($.target,S.resolved.split("."))===u.address)&&m(l.MutualDependencyDeclarations,"information",`Containers '${u.address}' and '${S.resolved}' declare each other`,S.syntax.location);d.push({container:u,location:y.location,declarations:h,edges:x})}return{containers:d,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 Pi=class extends Ce{static{c(this,"PublicEventUsageCollector")}command=!1;uses=[];allEvents=[];projectionTargets=[];eventSources=[];visitProjection(e){e.readModel!=null&&this.projectionTargets.push({target:e.readModel,node:e}),super.visitProjection(e)}visitReducer(e){this.projectionTargets.push({target:e.readModel,node:e}),super.visitReducer(e)}visitCaptureSource(e){bn(e)&&(this.eventSources.push(e),Ga(e).forEach(n=>this.uses.push({name:n.value,node:n,output:!1,command:!1}))),super.visitCaptureSource(e)}visitSlice(e){super.visitSlice(e),Se(e).reducers?.forEach(n=>this.visitReducer(n))}visitCommand(e){this.command=!0,super.visitCommand(e),this.command=!1}visitProduces(e){e.inlineOperation==null&&this.uses.push({name:e.event,node:e,output:!0,command:this.command})}visitCaptureAppend(e){this.inputOrOutput(e.event,e,!0)}visitJoinEvent(e){this.inputOrOutput(e.event,e)}visitReducerRule(e){this.inputOrOutput(e.event,e)}visitConstraint(e){e.releasedBy.forEach(n=>this.inputOrOutput(n,e)),e.kind!=="FileConstraintSyntax"&&this.inputOrOutput(e.event,e),super.visitConstraint(e)}visitProjectionBlock(e){switch(e.kind){case"FromSyntax":e.events.forEach(n=>this.inputOrOutput(n.event,n));break;case"ClearWithSyntax":case"RemoveWithSyntax":case"RemoveViaJoinSyntax":this.inputOrOutput(e.event,e);break;case"AllSyntax":this.allEvents.push(e);break}super.visitProjectionBlock(e)}visitReactionTrigger(e){e.source.kind==="NamedTriggerSourceSyntax"&&this.inputOrOutput(e.source.name,e.source),super.visitReactionTrigger(e)}visitSpecification(e){}inputOrOutput(e,n,i=!1){this.uses.push({name:e,node:n,output:i,command:!1})}};var mo=class extends Ce{static{c(this,"PublicEventMetadataValidator")}context;constructor(e){super(),this.context=e}visitNode(e){let n=mi(e);if(n===void 0)return;let i=e.kind==="EventSyntax"?l.InvalidEventDeclaration:e.kind==="ImportSyntax"?l.InvalidImportDeclaration:l.InvalidSliceDeclaration;this.context.error(i,n,e.location)}};function Ms(t,e){new mo(e).visitApplication(t)}c(Ms,"validatePublicEventMetadata");function Ai(t,e){Ms(t,e);let n=new ie(t);if(!n.declarations.some(r=>r.node.kind==="EventSyntax"&&(r.node.visibility===se.Public||r.node.origin!=null))&&!t.imports.some(r=>r.visibility===se.Public||r.origin!=null)&&!n.slices.some(({slice:r})=>r.direction!=null||im(r)||rm(r,n)))return;let i=new ie(t,n.declarations.filter(r=>r.kind===H.Event));for(let{slice:r,scope:o}of n.slices)nm(t,r,o,n,i,e);for(let r of t.seeds?.flatMap(o=>o.groups.flatMap(s=>s.events))??[]){let o=ho(t,i,[],r.event,r,!0,e);if(o?.visibility!==se.Public)continue;let s=o.origin==null?l.PublicEventRequiresOutboundTranslation:l.ForeignPublicEventProduced;e.error(s,`Seed cannot append public event '${r.event}'; public production belongs to outbound translation, and foreign contracts cannot be produced locally.`,r.location)}}c(Ai,"validatePublicEventUsage");function nm(t,e,n,i,r,o){let s=new Pi;s.visitSlice(e);let a=[],d=e.type==="Translate"&&e.direction===de.Outbound,p=new Set(e.readModels.map(u=>u.name));for(let{target:u,node:y}of s.projectionTargets){let h=p.has(u)?void 0:ho(t,r,n,u,y,!1,o);if(h!==void 0){if(!d){o.error(l.EventTargetOutsideOutboundTranslation,`'${u}' is an event: a projection or reducer may only target an event in an explicitly outbound Translate slice.`,y.location);continue}a.push({node:h,output:!0}),yo(e,u,y,!0,!1,h,o)}}if(!(e.type==="Translate"&&e.direction===de.Inbound)&&!d)for(let u of s.eventSources)o.error(l.EventsSourceOutsideInboundTranslation,`'source events' reads another application's public events and belongs to a Translate slice with 'direction inbound', not '${e.name}'.`,u.location);for(let u of s.uses){let y=ho(t,u.node.kind==="ProducesSyntax"?i:r,n,u.name,u.node,u.output,o);y!==void 0&&(a.push({node:y,output:u.output}),yo(e,u.name,u.node,u.output,u.command,y,o))}for(let u of s.allEvents){let y=i.declarations.filter(h=>h.kind===H.Event).map(h=>h.node);for(let h of[...y,...t.imports.filter(x=>x.visibility===se.Public)])a.push({node:h,output:!1}),yo(e,h.kind==="ImportSyntax"?h.qualifiedName:h.name,u,!1,!1,h,o)}if(e.type!=="Translate"||(e.direction==null&&(le(e).some(u=>u.visibility===se.Public)||a.some(u=>u.node.visibility===se.Public))&&o.error(l.PublicTranslationRequiresDirection,"A Translate slice using public events requires an explicit 'direction inbound' or 'direction outbound'. Legacy translations without public metadata remain inbound.",e.location),e.direction!==de.Outbound))return;let m=new Set(a.filter(u=>u.output&&u.node.visibility===se.Public&&u.node.origin==null).map(u=>u.node)).size;m!==1&&o.error(l.OutboundPublicEventCount,`Outbound Translate slice '${e.name}' must produce exactly one local public event type; found ${m}.`,e.location);for(let u of e.captures)o.error(l.TranslationConstructDirection,"An outbound translation consumes private local events, not an external-data capture. Capture belongs to inbound translation.",u.location)}c(nm,"validateSlice");function yo(t,e,n,i,r,o,s){let a=o.origin!=null,d=o.visibility===se.Public,p=c((m,u)=>s.error(m,u,n.location),"error");i?(r&&d&&p(l.CommandProducesPublicEvent,`Command cannot produce public event '${e}'; publish through an outbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&!d&&p(l.OutboundTranslationOutput,`Outbound translation must produce its one local public event, not private event '${e}'.`),a&&p(l.ForeignPublicEventProduced,`Foreign public event '${e}' cannot be produced locally; translate it into a private local event.`),d&&!a&&(t.type!=="Translate"||t.direction!==de.Outbound)&&p(l.PublicEventRequiresOutboundTranslation,`Local public event '${e}' may only be produced by an explicitly outbound Translate slice.`),t.type==="Translate"&&(t.direction??de.Inbound)===de.Inbound&&(d||a)&&p(l.InboundTranslationOutput,`Inbound translation must produce private local events, not '${e}'.`)):(a&&(t.type!=="Translate"||t.direction!==de.Inbound)&&p(l.ForeignPublicEventConsumer,`Foreign public event '${e}' may only be consumed by an explicitly inbound Translate slice.`),t.type==="Translate"&&t.direction===de.Outbound&&(d||a)&&p(l.OutboundTranslationInput,`Outbound translation must consume private local events, not '${e}'.`),t.type==="Translate"&&t.direction===de.Inbound&&(!d||!a)&&p(l.InboundTranslationInput,`Explicitly inbound translation must consume foreign public events, not '${e}'.`))}c(yo,"validateUse");function ho(t,e,n,i,r,o,s){let a=e.resolveFromScope(i,n);if(a.declaration?.node.kind==="EventSyntax")return a.declaration.node;if(a.kind===H.Operation)return;if(a.kind===H.Ambiguous){s.warning(l.AmbiguousReference,`Ambiguous event reference '${i}'; qualify it with its owning module, feature and slice.`,r.location);return}let d=t.imports.filter(p=>p.qualifiedName.split(".").at(-1)===i||p.qualifiedName===i);if(d.length===1){let p=d[0],m=e.resolveFromScope(p.qualifiedName,n);if(m.declaration?.node.kind==="EventSyntax")return m.declaration.node;if(m.kind===H.Ambiguous){s.warning(l.AmbiguousReference,`Ambiguous imported event reference '${i}'; qualify its declaration.`,r.location);return}return p.visibility===se.Public?p:void 0}d.length>1?s.warning(l.AmbiguousReference,`Ambiguous imported event reference '${i}'; use its qualified name.`,r.location):(o&&r.kind!=="CaptureAppendSyntax"||r.kind==="CaptureSourceSettingSyntax")&&!s.diagnostics.some(p=>p.code===l.UnknownEvent&&p.location.path===r.location.path&&p.location.line===r.location.line&&p.location.column===r.location.column)&&s.warning(l.UnknownEvent,`Unknown event '${i}' - declare its contract before classifying its usage.`,r.location)}c(ho,"resolve");function im(t){return t.captures.some(e=>e.source!=null&&bn(e.source))}c(im,"usesEventSource");function rm(t,e){return[...t.projections.map(i=>i.readModel),...(Se(t).reducers??[]).map(i=>i.readModel)].some(i=>i!=null&&e.declarations.some(r=>r.kind===H.Event&&r.name===i))}c(rm,"targetsEvent");function wi(t,e,n,i=!1){let r=[],o=[],s=Ue,a=!1,d=!1,p=!1,m=new Map,u=new me(new Ne([]),e,n).languages;for(let h of t){let x=h;if(x.number===1&&x.raw.startsWith("\uFEFF")){let b=x.raw.substring(1),S=b.length-b.trimStart().length,$=pn(b.substring(S),i);x={...x,indent:S,contentOffset:1,content:($<0?b.substring(S):b.substring(S,S+$)).trimEnd()}}if(p){Dr(x)&&(p=!1),r.push(x);continue}if(x.content.startsWith("```")&&(["```","```text","```markdown"].includes(x.content)||u.has(x.content.substring(3)))&&(p=!0),!p&&x.indent===0&&D(x.content)==="numbers"){let b=x.content!=="numbers exact"?l.InvalidNumericDirective:a?l.DuplicateNumericDirective:d?l.LateNumericDirective:void 0;b!==void 0?(o.push({severity:"error",code:b,message:"Expected one 'numbers exact' preamble before domain, imports and declarations.",location:f(x)}),s=Object.freeze({numericMode:"invalid"})):s=si,a=!0,r.push({...x,content:""});continue}!p&&x.indent>0&&/^numbers(\s+(exact|legacy))?$/.test(x.content)&&m.set(x.number,{severity:"error",code:l.InvalidNumericDirective,message:"Expected 'numbers exact' only as the document preamble, not inside a body.",location:f(x)}),d||=x.content.trim().length>0,r.push(x)}let y=new me(new Ne(a?r:t),e,n);return y.sourceOptions=s,y.nestedNumericDirectives=m,o.forEach(h=>y.error(h.code,h.message,h.location)),y}c(wi,"sourceContext");function Ii(t,e){let n=[],i=c(a=>{n.push(...a.slices),a.features.forEach(i)},"inFeature");t.modules.forEach(a=>a.features.forEach(i));let r=new Map;for(let a of n.flatMap(le))r.set(a.name,(r.get(a.name)??0)+1);let o=new Set(t.imports.map(a=>a.qualifiedName.split(".").at(-1))),s=new ie(t);for(let{slice:a,command:d}of n.flatMap(p=>p.commands.map(m=>({slice:p,command:m})))){let p=d.produces.filter(y=>s.isEventProduction(y,a)),m=d.properties.find(y=>y.isIdentifier)?.name,u=xr(d,{resolver:s,slice:a});for(let y of p){let h=y.inlineEvent;h!==null&&((r.get(h.name)??0)>1||o.has(h.name))&&e.error(l.InlineEventCollision,`Inline event '${h.name}' collides with another event declaration or import`,y.location),u&&y.for===null&&e.error(l.ExplicitProducesTargetsRequired,`Production '${y.event}' in command '${d.name}' must state 'for' explicitly - every production must state 'for' when destinations differ`,y.location);let x=y.for?.kind==="PathExpressionSyntax"?y.for.path:y.for===null&&h!==null?m:void 0;if(!(m===void 0||x!==m))for(let b of y.mappings.filter(S=>S.source.kind==="PathExpressionSyntax"&&S.source.path===m)){let S=`Event '${y.event}' copies command identifier '${m}' into payload property '${b.property}' although it already identifies the event source`;h===null?e.information(l.EventSourceIdInPayload,S,b.location):e.warning(l.EventSourceIdInPayload,S,b.location)}}}}c(Ii,"validateInlineEvents");function Oi(t,e){let n=new ie(t),i=Zn(t),r=oe(t.concepts),o=new Map([...oe(t.types)].map(([g,P])=>[g,oe(P.properties)])),s=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...r.keys(),...o.keys()]),a=new Set(t.imports.map(g=>g.qualifiedName.split(".").at(-1))),d=new Map;for(let g of t.imports){let P=g.qualifiedName.split(".").at(-1);d.set(P,[...d.get(P)??[],g.qualifiedName])}let p=c(g=>{let P=new Map,w=new Map;for(let v of g){let E=P.get(v.name)??[];E.push(v),P.set(v.name,E)}return(v,E)=>{let C=JSON.stringify([v,E]);if(w.has(C))return w.get(C);let k=c(M=>{let N=M.split("."),j=P.get(N.at(-1))??[],q=N.slice(0,-1);if(q.length>0)return j.filter(V=>q.length<=V.scope.length&&q.every((K,J)=>V.scope[V.scope.length-q.length+J]===K));for(let V=E.length;V>=0;V--){let K=j.filter(J=>V<=J.scope.length&&E.slice(0,V).every((U,_)=>J.scope[_]===U));if(K.length>0)return K}return[]},"candidates"),A=k(v),O=d.get(v)??[];A.length===0&&O.length===1&&(A=k(O[0]));let T=A.length===1?A[0].node:null;return w.set(C,T),T}},"scoped"),m=p(n.slices.flatMap(({slice:g,scope:P})=>g.readModels.map(w=>({name:w.name,scope:P,node:w})))),u=p(n.slices.flatMap(({slice:g,scope:P})=>g.commands.map(w=>({name:w.name,scope:P,node:{command:w,slice:g}})))),y=new Map;for(let g of t.systems??[])y.has(g.name)&&e.error(l.InvalidSystemDeclaration,`System '${g.name}' is declared more than once.`,g.location),y.set(g.name,(y.get(g.name)??0)+1);let h=c((g,P,w=!0)=>{let[v,...E]=P.split("."),C=g.filter(T=>T.name===v);if(C.length!==1)return{type:null,missing:C.length===0};let k=C[0].type;if(E.length===0)return{type:k,missing:!1};let A=o.get(k.name);if(A===void 0)return{type:null,missing:s.has(k.name)};let O=h([...A.values()],E.join("."),w);return O.type===null?O:{type:{...O.type,isOptional:w&&k.isOptional||O.type.isOptional,isCollection:k.isCollection||O.type.isCollection},missing:!1}},"pathType"),x=c((g,P,w,v,E=new Set)=>{if(w.has(P)||g.isOptional&&!v.has(P))return!0;if(g.isCollection||E.has(g.name))return!1;let C=o.get(g.name);return C===void 0?v.has(P)&&!s.has(g.name):[...C.values()].every(k=>x(k.type,`${P}.${k.name}`,w,v,new Set([...E,g.name])))},"covered"),b=c((g,P)=>{if(g.kind==="ListExpressionSyntax"&&P.isCollection)return g.items.every(v=>b(v,{...P,isCollection:!1,isOptional:!1}));let w=o.get(P.name);return g.kind!=="ObjectExpressionSyntax"||w===void 0?!0:[...w.values()].every(v=>(v.type.isOptional||g.members.some(E=>E.name===v.name))&&g.members.filter(E=>E.name===v.name).every(E=>b(E.value,v.type)))},"completeValue"),S=c(g=>g.kind==="LiteralExpressionSyntax"?typeof g.value!="number"||Number.isFinite(g.value):g.kind==="ObjectExpressionSyntax"?g.members.every(P=>S(P.value)):g.kind==="ListExpressionSyntax"&&g.items.every(S),"concrete"),$=c((g,P,w,v,E)=>{let C=new Set,k=new Set(g.map(O=>O.property)),A=new Set;for(let O of g){let T=O.property.split(".");for(let M=1;M<=T.length;M++)A.add(T.slice(0,M).join("."))}for(let O of g){C.has(O.property)&&e.error(l.InvalidOperationMapping,`Duplicate operation input mapping '${O.property}'.`,O.location),C.add(O.property);let T=h(P.inputs,O.property,!1);if(T.missing&&e.error(l.InvalidOperationMapping,`Operation '${P.name}' declares no input '${O.property}'.`,O.location),T.type===null)continue;let M=O.property.split(".");for(let N=1;N<M.length;N++)k.has(M.slice(0,N).join("."))&&e.error(l.InvalidOperationMapping,`Operation input mapping '${O.property}' overlaps a whole input mapping.`,O.location);if(w!==null&&O.source.kind==="PathExpressionSyntax"){let N=h(w.properties,O.source.path),j=O.source.path.split("."),q=(Si.get(w)??[]).filter(J=>(J.alias??J.readModel)===j[0]);if(N.missing&&q.length>0){N={type:null,missing:!1};let J=q.length===1?m(q[0].readModel,E):null;j.length>1&&J!==null&&(N=h(J.properties,j.slice(1).join(".")))}N.missing&&e.error(l.InvalidOperationMapping,`Command '${w.name}' declares no source '${O.source.path}'.`,O.source.location);let V=N.type,K=T.type;V!==null&&s.has(V.name)&&s.has(K.name)&&(V.name!==K.name||V.isCollection!==K.isCollection||V.isOptional&&!K.isOptional)&&e.error(l.InvalidOperationMapping,`Source '${O.source.path}' is incompatible with input '${O.property}' of operation '${P.name}'.`,O.source.location)}else["LiteralExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(O.source.kind)&&(!Pe(O.source,T.type,r,o)||v&&!b(O.source,T.type))&&e.error(l.InvalidOperationMapping,`Value is incompatible with input '${O.property}' of operation '${P.name}'.`,O.source.location)}if(v)for(let O of P.inputs)x(O.type,O.name,C,A)||e.error(l.InvalidOperationMapping,`Production of operation '${P.name}' supplies no value for required input '${O.name}'.`,P.location)},"validateMappings");for(let{slice:g,scope:P}of n.slices){let w=Wn(g),v=new Set(le(g).map(E=>E.name));for(let E of w){v.has(E.name)&&e.error(l.ProductionDeclarationCollision,`Operation '${E.name}' collides with another event or operation in slice '${g.name}'.`,E.location),v.add(E.name),E.uses.length>0&&y.get(E.uses)!==1&&e.error(l.InvalidSystemReference,`Operation '${E.name}' must use one declared system; '${E.uses}' does not resolve uniquely.`,E.usesLocation??E.location);for(let C of E.inputs)!s.has(C.type.name)&&!a.has(C.type.name)&&e.warning(l.UnknownType,`Unknown type '${C.type.name}' on input '${C.name}' of operation '${E.name}'.`,C.type.location)}for(let E of g.commands)for(let C of E.produces){let k=n.resolve(C.event,g);k.kind===H.Ambiguous&&k.candidates.some(A=>A.kind===H.Operation)&&e.error(l.InvalidProductionReference,`Production '${C.event}' is ambiguous.`,C.location),C.event.includes(".")&&k.kind!==H.Operation&&e.error(l.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",C.location),k.declaration?.node.kind==="OperationSyntax"&&((C.for!==null||C.tags.length>0)&&e.error(l.InvalidOperationDeclaration,"Operation productions cannot declare event destinations or tags.",C.location),$(C.mappings,k.declaration.node,E,!0,P))}for(let E of g.reactions.flatMap(C=>C.triggers).flatMap(C=>C.produces)){let C=n.resolve(E.event,g);C.kind===H.Ambiguous&&C.candidates.some(k=>k.kind===H.Operation)&&e.error(l.InvalidProductionReference,`Production '${E.event}' is ambiguous.`,E.location),E.event.includes(".")&&n.resolve(E.event,g).kind!==H.Operation&&e.error(l.InvalidProductionReference,"Qualified productions are supported only for explicitly declared operations.",E.location),n.isOperation(E,g)&&e.error(l.OperationOutsideCommand,"Operations can only be produced by commands.",E.location)}for(let E of g.specifications){let C=[...E.givenOperationFailures??[],...E.thenOperations??[],...E.thenCompensated??[]];if(C.length===0)continue;let k=u(i(E.when,P)?.commandType??"",P);(k===null||E.whenAppended!==null||E.whenQuery!==null||E.whenTrigger!==null||E.whenClock!==null||E.whenCapture!==null)&&e.error(l.InvalidOperationSpecification,"Operation fixtures and assertions require a declared command action.",E.location);let A=new Map;for(let O of C){if(O.kind==="SpecificationOperationSyntax")for(let N of O.values)S(N.source)||e.error(l.InvalidOperationSpecification,"Operation assertions require concrete input values.",N.source.location);let T=n.resolve(O.operation,g).declaration?.node;if(T?.kind!=="OperationSyntax"){e.error(l.InvalidOperationSpecification,`'${O.operation}' does not resolve uniquely to a declared operation.`,O.location);continue}let M=A.get(T)??new Set;if(M.has(O.kind)&&e.error(l.InvalidOperationSpecification,`Duplicate operation step '${O.operation}'.`,O.location),M.add(O.kind),A.set(T,M),O.kind==="SpecificationCompensatedSyntax"&&T.compensate===null&&e.error(l.InvalidOperationSpecification,`Operation '${O.operation}' declares no compensation.`,O.location),k!==null&&k.command.handler==null){let N=k.command.produces.map(j=>n.resolve(j.event,k.slice));N.every(j=>j.kind===H.Event||j.kind===H.Operation)&&!N.some(j=>j.declaration?.node===T)&&e.error(l.InvalidOperationSpecification,`Command '${k.command.name}' does not produce operation '${O.operation}'.`,O.location)}O.kind==="SpecificationOperationSyntax"&&$(O.values,T,null,!1,P)}}}}c(Oi,"validateOperations");var om=I("^(@?[a-z_]\\w*)\\s+([\\w.]+(?:\\[\\])?(?:\\?|\\s+optional)?)(?:\\s+from\\s+(.+))?$"),am=I(`^claim\\s+"(${z})"$`),sm=I("^query\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)(?:\\s+by\\s+(.+))?$");function Ls(t,e,n){if(e.content!=="identity")return t.error(l.InvalidIdentityDeclaration,`Invalid identity declaration '${e.content}' - expected 'identity'`,f(e)),t.skipBlock(e.indent),n;if(n!==null)return t.error(l.DuplicateIdentity,"The document already declares an identity block - a document can have at most one",f(e)),t.skipBlock(e.indent),n;let i=[],r=null;for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){if(t.reader.takeSignificant(),D(o.content)==="description"){r=G(t,o,r,"Identity");continue}let s=om.exec(o.content);if(s===null){t.error(l.InvalidIdentityDetail,`Invalid identity detail '${o.content}' - expected '<name> <Type> [from claim "<name>" | from query <Query> by <expression>]'`,f(o)),t.skipBlock(o.indent);continue}let a=we(s[2],{...f(o),column:o.indent+1+o.content.indexOf(s[2],s[1].length)});Me(t,a,o);let d=s[3]!==void 0?lm(t,o,s[3]):cm(t,o);d!==null&&i.push({kind:"IdentityDetailSyntax",name:re(s[1]),type:a,source:d,location:f(o)}),js(t,o,s[3]!==void 0?l.IdentitySourceWithBody:l.InvalidIdentityDetail)}return{kind:"IdentitySyntax",details:i,description:r,location:f(e)}}c(Ls,"parseIdentity");function lm(t,e,n){let i=am.exec(n);if(i!==null)return{kind:"ClaimIdentitySourceSyntax",claim:Q(i[1]),location:f(e)};let r=sm.exec(n);if(r!==null)return r[2]===void 0?(t.error(l.IdentityQueryWithoutKey,"An identity query source requires 'by <expression>'",f(e)),null):{kind:"QueryIdentitySourceSyntax",query:r[1],by:ae(r[2],f(e),t),location:f(e)};let o=D(n);return t.error(o==="claim"||o==="query"?l.InvalidIdentityDetail:l.UnknownIdentitySource,`Invalid identity source '${n}' - expected 'claim "<name>"' or 'query <Query> by <expression>'`,f(e)),null}c(lm,"parseSource");function cm(t,e){let n=t.peekChild(e.indent);if(n===void 0)return t.error(l.IdentityDetailWithoutSource,"An identity detail requires a claim, query, inline code block or file source",f(e)),null;if(t.reader.takeSignificant(),xt(n)){let i=et(t,n);return js(t,n,l.InvalidIdentityDetail),{kind:"FileIdentitySourceSyntax",file:i,location:f(n)}}if(Ot(t,n)){let i=Oe(t,n);return i===null?null:{kind:"CodeIdentitySourceSyntax",code:i,location:f(n)}}return t.error(l.InvalidIdentityDetail,`Unexpected '${n.content}' under an identity detail - expected a file reference or inline code block`,f(n)),t.skipBlock(n.indent),null}c(cm,"parseEscape");function js(t,e,n){for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent))t.reader.takeSignificant(),t.error(n,`Unexpected '${i.content}' under an identity source - refresh and caching are the runtime's business; a detail has exactly one source`,f(i)),t.skipBlock(i.indent)}c(js,"rejectBody");var Ns=["racialOrEthnicOrigin","politicalOpinions","religiousOrPhilosophicalBeliefs","tradeUnionMembership","genetic","biometric","health","sexLifeOrSexualOrientation"],dm=I("^(@?[a-z_]\\w*)\\s+(reason|scope|special|criminal)(?:\\s+(.*))?$"),pm=I(`^"(${z})"$`);function So(t){let e=t.replace(/^@/,"");return e==="personal"?"pii":e==="secret"?"sensitive":e}c(So,"complianceWireName");function um(t){let e=So(t);return e==="sensitive"?"secret":e}c(um,"canonicalComplianceName");function qs(t,e,n){let i=n.trim().split(/\s+/).filter(r=>r.length>0);return Ys(t,e,i),i.map(r=>{let o=So(r);return(!["pii","sensitive"].includes(o)||r==="@personal"||r==="@secret")&&t.error(l.UnknownComplianceMarker,`Unknown concept marker '${r}' - expected pii, personal or secret`,f(e)),{kind:"ConceptAttributeSyntax",name:o,reason:null,scope:null,specialCategory:null,criminal:!1,location:f(e)}})}c(qs,"parseComplianceMarkers");function Bs(t,e,n,i){let r=dm.exec(e.content);if(r===null)return!1;let[,o,s]=r,a=r[3]??"",d=So(o),p=um(o);if(Ys(t,e,[o]),!["pii","sensitive"].includes(d)||o==="@personal"||o==="@secret")return t.error(l.UnknownComplianceMarker,`Unknown concept marker '${o}' - expected pii, personal or secret`,f(e)),!0;let m=i.findIndex(y=>y.name===d);if(m<0)return t.error(l.AttributeReasonWithoutAttribute,`Concept '${n}' declares '${p} ${s}' without the marker - write 'concept ${n} : <Type> ${p}'`,f(e)),!0;let u=i[m];switch(s){case"reason":{let y=pm.exec(a);return y===null?(t.error(l.UnknownConceptDirective,`Invalid '${p} reason' - expected '${p} reason "<text>"'`,f(e)),!0):u.reason!==null?(t.error(l.DuplicateAttributeReason,`Concept '${n}' already declares a reason for '${p}' - at most one is allowed`,f(e)),!0):(i[m]={...u,reason:Q(y[1])},!0)}case"scope":return d!=="sensitive"||!["subject","namespace","global"].includes(a)?(t.error(l.InvalidSecretScope,`Invalid '${p} scope ${a}' - scope belongs to secret and must be subject, namespace or global`,f(e)),!0):u.scope!=null?(t.error(l.DuplicateSecretScope,`Concept '${n}' already declares secret scope - at most one is allowed`,f(e)),!0):(i[m]={...u,scope:a},i.some(y=>y.name==="pii")&&t.warning(l.SecretScopeIgnoredForPii,`Concept '${n}' is pii secret - secret scope is ignored because only Chronicle [PII] renders`,f(e)),!0);case"special":case"criminal":return d!=="pii"||(s==="special"?!Ns.includes(a):a.length>0)?(t.error(l.InvalidPersonalDataQualifier,`Invalid '${p} ${s}${a.length>0?` ${a}`:""}' - expected 'pii criminal' or 'pii special <category>' with category ${Ns.join(", ")}`,f(e)),!0):s==="special"&&u.specialCategory!=null?(t.error(l.DuplicateSpecialCategory,`Concept '${n}' already declares pii special - at most one is allowed`,f(e)),!0):(i[m]=s==="special"?{...u,specialCategory:a}:{...u,criminal:!0},!0);default:return!1}}c(Bs,"parseComplianceDirective");function Ys(t,e,n){n.some(i=>["@pii","sensitive","@sensitive"].includes(i))&&t.information(l.LegacyComplianceMarker,"Legacy compliance spelling - use bare pii for personal data and secret for operational secrets; reason text is preserved",f(e))}c(Ys,"reportLegacy");var fm=Z("^policy\\s+([A-Za-z_]\\w*)$");function Fs(t,e){let n=t;t=t.valueContext;let i=fm.exec(e.content)?.[1]??"";i===""&&t.error(l.InvalidPolicyDeclaration,`Invalid policy declaration '${e.content}' - expected 'policy <Name>'`,f(e));let r=null,o=null,s=null,a=!1,d=null;for(let p=t.peekChild(e.indent);p!==void 0;p=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(p.content)==="description")d=G(n,p,d,`Policy '${i}'`);else if(D(p.content)==="require"){let m=p.content.substring(7).trim();for(let h=t.peekChild(p.indent);h!==void 0;h=t.peekChild(p.indent))t.reader.takeSignificant(),m+=` ${h.content}`;let u=mm(t,m);u.includes("not")&&(t=n);let y=ym(t,u,f(p));a?t.error(l.RepeatedPolicyRequirement,`Policy '${i}' has more than one require line; combine the conditions with and/or in one require`,f(p)):r=y,a=!0}else if(D(p.content)==="file"){let m=et(t,p);o===null&&s===null?s=m:t.error(l.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(p))}else if(p.content.startsWith("```")||t.languages.has(p.content)){let m=Oe(t,p);o===null&&s===null?o=m:t.error(l.UnknownPolicyDirective,`Policy '${i}' must have only one implementation - a file reference or an inline code block, not both`,f(p))}else t.error(l.UnknownPolicyDirective,`Unexpected '${p.content}' in policy body - expected 'require ...', 'file <path>' or an inline code block`,f(p)),t.skipOpaqueBlock(p.indent);return r!==null&&(o!==null||s!==null)&&t.error(l.MixedPolicyImplementation,`Policy '${i}' cannot combine 'require' with a file or inline code block`,f(e)),r===null&&o===null&&s===null&&t.error(l.PolicyWithoutRequirement,`Policy '${i}' must declare a 'require' condition, a file reference or an inline code block`,f(e)),{kind:"PolicySyntax",name:i,condition:r,code:o,file:s,description:d,location:f(e)}}c(Fs,"parsePolicy");function mm(t,e){let n=t.sourceOptions.numericMode==="exact"?"-?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?(?=$|[\\s()])|[\\w.$-]+|[^\\s]":"[\\w.$]+";return[...e.match(new RegExp(Z(`"${z}"|\\(|\\)|${n}`).source,"gu"))??[]]}c(mm,"tokenizePolicyCondition");function ym(t,e,n){let i=t.sourceOptions.numericMode==="exact"||e.includes("not"),r=0,o=c(u=>u!==void 0&&u.startsWith('"')&&u.endsWith('"'),"quoted"),s=c(u=>Q(u.substring(1,u.length-1)),"unquote"),a=c(()=>{if(e[r]==="not"){r++;let x=a();return x===null?null:{kind:"NotPolicyConditionSyntax",operand:x,location:n}}if(e[r]==="("){r++;let x=p();return e[r]===")"?r++:i&&t.error(l.UnclosedPolicyConditionGroup,"Expected ')' in policy condition",n),x}let u=e[r++];if(u==="authenticated")return{kind:"AuthenticatedConditionSyntax",location:n};if(u!=="role"&&u!=="claim")return t.error(u===void 0?l.ExpectedPolicyCondition:l.UnexpectedTokenInPolicyCondition,u===void 0?"Expected a policy condition":`Unexpected '${u}' in policy condition`,n),null;let y=e[r++];if(!o(y))return t.error(u==="role"?l.ExpectedRoleName:l.ExpectedClaimName,`Expected a quoted ${u} name after '${u}'`,n),null;if(u==="role")return{kind:"RoleConditionSyntax",role:s(y),location:n};if(e[r++]!=="matches")return t.error(l.ExpectedClaimMatches,"Expected 'matches' after the claim name",n),null;let h=e[r++];return h===void 0?(t.error(l.ExpectedClaimMatchTarget,"Expected 'subject' or a value after 'matches'",n),null):{kind:"ClaimConditionSyntax",claim:s(y),matchesSubject:h==="subject",matches:h==="subject"?null:Be(h,n,t),location:n}},"group"),d=c(()=>{let u=a();for(;u!==null&&e[r]==="and";){r++;let y=a();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"And",right:y,location:n}}return u},"and"),p=c(()=>{let u=d();for(;u!==null&&e[r]==="or";){r++;let y=d();if(y===null)return null;u={kind:"LogicalPolicyConditionSyntax",left:u,operator:"Or",right:y,location:n}}return u},"or"),m=p();return i&&m!==null&&r<e.length&&t.error(l.UnexpectedTokenInPolicyCondition,`Unexpected '${e[r]}' in policy condition`,n),m}c(ym,"parsePolicyCondition");var hm=new RegExp(`^for\\s+"(${z})"$`,"u"),Sm=Z("^[A-Z]\\w*$"),gm=Z("^([\\w.]+)\\s*=(?!=|>)\\s*(.+)$");function Us(t,e){let n=[];if(t=t.valueContext,e.content!=="seed")return t.error(l.InvalidSeedDeclaration,`Invalid seed declaration '${e.content}' - expected 'seed'`,f(e)),t.skipOpaqueBlock(e.indent),{kind:"SeedSyntax",groups:n,location:f(e)};for(let i=t.peekChild(e.indent);i!==void 0;i=t.peekChild(e.indent)){t.reader.takeSignificant();let r=hm.exec(i.content);if(r===null){t.error(l.InvalidSeedGroup,`Invalid seed group '${i.content}' - expected 'for "<event source id>"'`,f(i)),t.skipOpaqueBlock(i.indent);continue}let o=[];for(let s=t.peekChild(i.indent);s!==void 0;s=t.peekChild(i.indent)){if(t.reader.takeSignificant(),!Sm.test(s.content)){t.error(l.InvalidSeedEvent,`Invalid seed event '${s.content}' - expected an event type name`,f(s)),t.skipOpaqueBlock(s.indent);continue}let a=[];for(let d=t.peekChild(s.indent);d!==void 0;d=t.peekChild(s.indent)){t.reader.takeSignificant();let p=gm.exec(d.content);p!==null?a.push({kind:"PropertyMappingSyntax",property:p[1],source:Be(p[2],f(d),t),location:f(d)}):t.error(l.InvalidSeedPropertyAssignment,`Invalid property assignment '${d.content}' - expected '<property> = <value>'`,f(d))}o.push({kind:"SeedEventSyntax",event:s.content,properties:a,location:f(s)})}n.push({kind:"SeedGroupSyntax",eventSourceId:Q(r[1]),events:o,location:f(i)})}return{kind:"SeedSyntax",groups:n,location:f(e)}}c(Us,"parseSeed");var go=`(?:([A-Za-z_]\\w*)|"(${z})")\\.(\\w+(?:\\.\\w+)*)`,xm=I("^exposure\\s+for\\s+([A-Za-z_]\\w*)$"),vm=I("^instance\\s+([A-Za-z_]\\w*)$"),$m=I(`^property\\s+${go}(?:\\s+label\\s+"(${z})")?(?:\\s+operations\\s+([\\w-]+(?:\\s*,\\s*[\\w-]+)*))?(?:\\s+fields\\s+(\\w+(?:\\s*,\\s*\\w+)*))?(?:\\s+reexposes\\s+([A-Za-z_]\\w*))?$`),bm=I(`^set\\s+${go}\\s*=\\s*(.+)$`),km=I(`^items\\s+${go}$`),Em=I(`^item\\s+(?:([A-Za-z_][\\w-]*)|"(${z})")$`),Cm=I("^([A-Za-z_]\\w*)\\s*=\\s*(.+)$"),Pm=["add","remove","reorder","edit-fields"],Am=`'property <component>.<path> [label "<text>"] [operations <add|remove|reorder|edit-fields>, ...] [fields <field>, ...] [reexposes <Owner>]'`,Ti=c((t,e)=>t[e]??Q(t[e+1]),"reference"),Ws=c(t=>t.trim()==="none"?[]:t.split(",").map(e=>e.trim()).filter(e=>e.length>0),"list");function Vs(t,e){let n=xm.exec(e.content);n===null&&t.error(l.InvalidExposureDeclaration,`Invalid exposure declaration '${e.content}' - expected 'exposure for <Owner>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=wm(t,r);o!==void 0&&i.push(o)}return{kind:"ExposureSyntax",owner:n?.[1]??e.content,properties:i,location:f(e)}}c(Vs,"parseExposure");function zs(t,e){let n=vm.exec(e.content);n===null&&t.error(l.InvalidInstanceContribution,`Invalid instance declaration '${e.content}' - expected 'instance <Screen or Template>'`,f(e));let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Im(t,r);o!==void 0&&i.push(o)}return{kind:"InstanceContributionsSyntax",instance:n?.[1]??e.content,contributions:i,location:f(e)}}c(zs,"parseInstance");function wm(t,e){let n=$m.exec(e.content);if(n===null){t.error(l.InvalidExposureDeclaration,`Invalid exposed property '${e.content}' - expected ${Am}`,f(e));return}let i=n[5]===void 0?[]:Ws(n[5]),r=i.find(o=>!Pm.includes(o));if(r!==void 0){t.error(l.InvalidExposureDeclaration,`Unknown collection operation '${r}' - expected add, remove, reorder, edit-fields or none`,f(e));return}return{kind:"ExposedPropertySyntax",component:Ti(n,1),path:n[3],label:n[4]===void 0?null:Q(n[4]),isCollection:n[5]!==void 0,operations:i,restrictsFields:n[6]!==void 0,editableFields:n[6]===void 0?[]:Ws(n[6]),reExposes:n[7]??null,location:f(e)}}c(wm,"parseExposedProperty");function Im(t,e){let n=bm.exec(e.content);if(n!==null)return t.skipBlock(e.indent),{kind:"InstanceContributionSyntax",component:Ti(n,1),path:n[3],value:ae(n[4],f(e),t),items:[],location:f(e)};let i=km.exec(e.content);if(i!==null){let r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=Om(t,o);s!==void 0&&r.push(s)}return{kind:"InstanceContributionSyntax",component:Ti(i,1),path:i[3],value:null,items:r,location:f(e)}}t.error(l.InvalidInstanceContribution,`Invalid instance contribution '${e.content}' - expected 'set <component>.<path> = <value>' or 'items <component>.<path>'`,f(e)),t.skipBlock(e.indent)}c(Im,"parseContribution");function Om(t,e){let n=Em.exec(e.content);if(n===null){t.error(l.InvalidInstanceContribution,`Invalid contributed item '${e.content}' - expected 'item <id>'`,f(e)),t.skipBlock(e.indent);return}let i=[];for(let r=t.peekChild(e.indent);r!==void 0;r=t.peekChild(e.indent)){t.reader.takeSignificant();let o=Cm.exec(r.content);if(o===null){t.error(l.InvalidInstanceContribution,`Invalid item value '${r.content}' - expected '<field> = <value>'`,f(r)),t.skipBlock(r.indent);continue}i.push({kind:"ContributedItemValueSyntax",field:o[1],value:ae(o[2],f(r),t),location:f(r)})}return{kind:"ContributedItemSyntax",id:Ti(n,1),values:i,location:f(e)}}c(Om,"parseItem");var Tm=I("^domain\\s+([A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*)$"),_s=I(`^import\\s+([\\w.]+)(?:\\s+from\\s+"(?<origin>${z})")?$`),Rm=I("^concept\\s+(\\w+)\\s*:\\s*(\\w+)((?:\\s+@?\\w+)*)$"),Dm=I("^@?[a-z_]\\w*$"),Mm=I("^persona\\s+([A-Za-z_]\\w*)$"),Lm=I("^policy\\s+([A-Za-z_]\\w*)$"),jm=/^[ ]*\t/,Qs=["Uuid","String","Int","Decimal","Bool","Date","DateTime"],Zs=new Set(["policy","authentication","seed","ui","theme","trigger","layout","behavior"]),Nm=new Set(["slice","feature","description","documentation","authorize","screen","dialog","form","contribute","on","uses"]);function Ri(t,e,n=It){t.deferIdentityValidation=!0,Um(t,e);let i=n.length===1?new wn(n[0]):void 0,r=n.length>1?new An(n[n.length-1]):void 0,o=i??r,s=null,a=null,d=[],p=[],m=[],u=[],y=[],h=[],x=[],b=[],S=[],$=[],g=[],P=[],w=[],v=[],E=[],C=!1;for(let A=t.reader.peekSignificant();A!==void 0;A=t.reader.peekSignificant()){t.reader.takeSignificant();let O=D(A.content);if(O==="domain"){t.authoredDeclarations=!0,a=Fm(t,A,a,C);continue}if(C||=Gs(O,A,n),t.authoredDeclarations||=O!=="import"&&Gs(O,A,n),O==="import"&&xa(A.content))o!==void 0?o.tryParse(t,A):Qt(t,A,p);else if(O==="import"){let T=_s.exec(A.content);if(T===null)t.error(l.InvalidImportDeclaration,`Invalid import '${A.content}' - expected 'import <Qualified.Name> [from "<origin>"]'`,f(A));else{let M=T.groups?.origin===void 0?null:Q(T.groups.origin);M!==null&&kn(M)&&t.error(l.InvalidImportDeclaration,"An import origin must be a nonblank quoted string",f(A)),d.push({kind:"ImportSyntax",qualifiedName:T[1],origin:M,visibility:M===null?se.Private:se.Public,location:f(A)})}}else if(O==="example")o!==void 0?o.tryParse(t,A):P.push(lt(t,A));else if(O==="eventsource")h.push(Ta(t,A));else if(O==="system")y.push(qa(t,A));else if(O==="concept")m.push(Wm(t,A));else if(O==="type")u.push(Ka(t,A));else if(O==="module"&&!hn(n))qm(t,A,n,i);else if(O==="module")x.push(ro(t,A));else if(O==="persona")b.push(Vm(t,A));else if(O==="seed")g.push(Us(t.valueContext,A));else if(O==="purpose"&&o!==void 0)o.tryParse(t,A);else if(O==="purpose")$.push(Sa(t,A));else if(O==="identity")s=Ls(t,A,s);else if(O==="policy")S.push(Fs(t,A));else if(O==="exposure")v.push(Vs(t,A));else if(O==="instance")E.push(zs(t,A));else if(O==="trigger"){let T=Ss(t,A),M=/^trigger\s+([A-Za-z_]\w*)$/.exec(A.content)?.[1];M!==void 0&&w.push({name:M,data:T})}else Zs.has(O)?O==="behavior"||O==="layout"?We(t,A):t.skipOpaqueBlock(A.indent):o?.tryParse(t,A)!==!0&&Bm(t,A,n)}i!==void 0?x.unshift(i.build(t.start,!0)):r!==void 0&&x.unshift(Ym(n,r.build(t.start,!0),t.start));let k={kind:"ApplicationSyntax",...s===null?{}:{identity:s},sourceOptions:t.sourceOptions,domain:a,imports:d,concepts:m,types:u,systems:y,eventSources:h,examples:P,modules:x,personas:b,policies:S,purposes:$,seeds:g,declaredTriggers:w,fileImports:p,...v.length>0?{exposures:v}:{},...E.length>0?{instanceContributions:E}:{},location:t.start};return t.authoredDeclarations&&Ca(k),k}c(Ri,"parseApplication");function Gs(t,e,n){return t==="import"?_s.test(e.content):t==="module"?hn(n):t==="identity"?e.content==="identity":t==="purpose"||t==="example"||t==="exposure"||t==="instance"||t==="eventsource"||t==="system"||t==="concept"||t==="type"||t==="persona"||Zs.has(t)}c(Gs,"declaresConstruct");function qm(t,e,n,i){let r=no.exec(e.content)?.[1]??"";if(i!==void 0&&r===n[0]){t.authoredDeclarations=!0,i.parseChildren(t,e);return}t.error(l.ModuleInPlacedFile,`This file is imported into ${oi(n)}, so it cannot declare module '${r}' - import it at the top level of a document instead`,f(e)),t.skipBlock(e.indent)}c(qm,"parseModuleInPlacedFile");function Bm(t,e,n){let i=D(e.content);if(hn(n)){let r=Nm.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, identity, module, seed, trigger, behavior, ui profile, theme or layout";t.error(l.UnknownTopLevelConstruct,`Unexpected '${i}' at the top level${r}`,f(e))}else{let r=n.length===1?io:to;t.error(l.UnexpectedInPlacedFile,`Unexpected '${i}' in a file imported into ${oi(n)} - expected an application declaration or ${r}`,f(e))}t.skipBlock(e.indent)}c(Bm,"reportUnexpectedTopLevel");function Ym(t,e,n){let i=e;for(let r=t.length-2;r>=1;r--)i={kind:"FeatureSyntax",name:t[r],description:null,authorize:null,features:[i],slices:[],fileImports:[],isPlacement:!0,location:n};return{kind:"ModuleSyntax",name:t[0],description:null,authorize:null,features:[i],fileImports:[],isPlacement:!0,location:n}}c(Ym,"place");function Fm(t,e,n,i){let r=Tm.exec(e.content);return r===null?(t.error(l.InvalidDomainDeclaration,`Invalid domain declaration '${e.content}' - expected 'domain <Qualified.Name>'`,f(e)),n):n!==null?(t.error(l.DuplicateDomain,"The document already declares a domain - a document can have at most one",f(e)),n):(i&&t.error(l.DomainNotFirst,"'domain' must be declared before any other construct",f(e)),{kind:"DomainSyntax",name:r[1],location:f(e)})}c(Fm,"parseDomain");function Um(t,e){let n=!1;for(let i of e){if(i.raw.trimStart().startsWith("```")){n=!n;continue}!n&&jm.test(i.raw)&&t.warning(l.TabIndentation,"Screenplay is indentation based - use spaces, not tabs",oa(i))}}c(Um,"warnOnTabIndentation");function Wm(t,e){let n=Rm.exec(e.content);if(n===null)return t.error(l.InvalidConceptDeclaration,`Invalid concept declaration '${e.content}' - expected 'concept <Name> : <Type>'`,f(e)),t.skipBlock(e.indent),{kind:"ConceptSyntax",name:D(e.content),type:"",attributes:[],values:[],location:f(e)};let[,i,r,o]=n,s=qs(t,e,o);r!=="Enum"&&!Qs.includes(r)&&t.error(l.UnknownPrimitiveType,`Unknown primitive type '${r}' - expected ${Qs.join(", ")} or Enum`,f(e));let a=[],d=null,p=[];for(let m=t.peekChild(e.indent);m!==void 0;m=t.peekChild(e.indent))if(t.reader.takeSignificant(),D(m.content)==="description"&&(r!=="Enum"||m.content!=="description"||t.peekChild(m.indent)?.content.startsWith("```")===!0))d=G(t,m,d,`Concept '${i}'`);else{if(ge(m))continue;if(D(m.content)==="validate"){r==="Enum"&&m.content==="validate"&&t.peekChild(m.indent)===void 0&&t.warning(l.ValidateReadAsEnumerationBlock,`'validate' in enumeration concept '${i}' declares an empty validate block, not a value named 'validate' - write '@validate' for the value`,f(m));let u=_r(t,m,"concept");u!==void 0&&p.push(u)}else Bs(t,m,i,s)||(r==="Enum"&&Dm.test(m.content)?a.push(re(m.content)):r==="Enum"?t.error(l.InvalidEnumerationValue,`Invalid enum value '${m.content}' - expected an identifier`,f(m)):(t.error(l.UnknownConceptDirective,`Unexpected '${m.content}' in concept body - expected validate, 'file <path>' or '<attribute> reason "<text>"'`,f(m)),t.skipBlock(m.indent)))}return{kind:"ConceptSyntax",name:i,type:r,attributes:s,values:a,validations:p,description:d,location:f(e)}}c(Wm,"parseConcept");function Vm(t,e){let n=Mm.exec(e.content)?.[1]??"";n===""&&t.error(l.InvalidPersonaDeclaration,`Invalid persona declaration '${e.content}' - expected 'persona <Name>'`,f(e));let i=null,r=[];for(let o=t.peekChild(e.indent);o!==void 0;o=t.peekChild(e.indent)){t.reader.takeSignificant();let s=D(o.content);if(s==="description")i=G(t,o,i,`Persona '${n}'`);else if(s==="policy"){let a=Lm.exec(o.content);a===null?t.error(l.InvalidPersonaPolicyReference,`Invalid policy reference '${o.content}' - expected 'policy <Name>'`,f(o)):r.push(a[1])}else t.error(l.UnknownPersonaDirective,`Unexpected '${s}' in persona body - expected description or policy`,f(o)),t.skipBlock(o.indent)}return{kind:"PersonaSyntax",name:n,description:i,policies:r,location:f(e)}}c(Vm,"parsePersona");var tn=class t{static{c(this,"CommandStreamCandidates")}sources;qualifiedTypes;constructor(e,n){this.sources=e,this.qualifiedTypes=n}hasSource(e){return this.sources.has(e)}hasPropertyType(e){return this.qualifiedTypes.has(e)}hasUniqueStream(e,n){let i=this.sources.get(e);return i?.length===1&&i[0].filter(r=>r===n).length===1}static capture(e,n=It,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:d}of e){let p=wi(a,a[0]?.path,n);p.scope=d;let m=Ri(p,a,d);for(let u of m.types)r.add(u.name);for(let u of m.concepts)r.add(u.name);for(let u of m.imports)o.add(u.qualifiedName);for(let u of m.eventSources??[])i.set(u.name,[...i.get(u.name)??[],u.streams.map(y=>y.name)])}let s=new Set([...o].filter(a=>r.has(a.substring(a.lastIndexOf(".")+1))));return new t(i,s)}};var ve;(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"})(ve||(ve={}));function Ks(t){return t.length===0?{value:null,failure:ve.Empty}:/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(t)?{value:null,failure:ve.LoneSurrogate}:t.normalize("NFC")!==t?{value:null,failure:ve.NotNfc}:{value:t,failure:null}}c(Ks,"tryFormatText");function Js(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:ve.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}}c(Js,"tryFormatUuidText");function Di(t,e=typeof t=="number"){if(typeof t=="number"&&!Number.isInteger(t))return{value:null,failure:ve.NotIntegral};let n=BigInt(t);return e&&(n<-9007199254740991n||n>9007199254740991n)?{value:null,failure:ve.OutOfRange}:{value:n.toString(),failure:null}}c(Di,"tryFormatInteger");function Mi(t){switch(t){case ve.Empty:return"A stream id text literal cannot be empty.";case ve.NotNfc:return"A stream id text literal must be Unicode NFC.";case ve.LoneSurrogate:return"A stream id text literal cannot contain lone UTF-16 surrogates.";case ve.OutOfRange:return"A stream id integer literal must be between -9007199254740991 and 9007199254740991 in Double numeric mode.";case ve.NotIntegral:return"A stream id integer must be a finite integral value.";case ve.MalformedUuid:return"A stream id UUID must use N, D, B or P form.";case ve.Arity:return"A composite stream id must match the declared part count of at least two.";case ve.Escape:return"A composite stream id permits only %25 and %7C escapes.";case ve.Noncanonical:return"A composite stream id part must use canonical scalar spelling."}}c(Mi,"streamIdFailureMessage");function Li(t,e,n,i,r,o,s){if(n){o.error(r,"A composite stream requires a streamId part block, not a scalar mapping.",i);return}let a=t.streamIdParts;for(let p of a.filter(m=>!e.some(u=>u.property===m.name)))o.error(r,`Stream id part '${p.name}' requires a mapping.`,i);let d=new Set;for(let p of e){let m=a.find(u=>u.name===p.property);m===void 0?o.error(r,`Unknown stream id part '${p.property}'.`,p.location):d.has(p.property)?o.error(r,`Stream id part '${p.property}' is mapped more than once.`,p.location):(d.add(p.property),s(p,m.type))}}c(Li,"validateStreamIdParts");function ji(t,e,n){let i=oe(n.concepts),r=oe(n.types),o=new Map([...r].map(([a,d])=>[a,oe(d.properties)]));if(t?.kind!=="LiteralExpressionSyntax"||!Pe(t,e,i,o))return null;let s=i.get(e.name)?.type??e.name;return["String","Uuid","Int"].includes(s)?Rn(t,e,n)?.value??null:null}c(ji,"formatSpecificationStreamId");function Hs(t,e,n,i){if(n!=null)return t==null;if(e==null)return!0;if(t==null)return!1;let r=new Ye(i),o=r.resolve(t.eventSource,t.stream),s=r.resolve(e.eventSource,e.stream);if(o.kind!==pe.Unique||s.kind!==pe.Unique)return null;if(o.sources[0]!==s.sources[0]||o.streams[0]!==s.streams[0])return!1;let a=s.streams[0],d=c((p,m,u)=>{let y=ji(p,u,i),h=ji(m,u,i);return y===null||h===null?null:y===h},"compare");if(a.streamIdParts.length>0){if(t.streamId!==null||e.streamId!==null||t.streamIdParts.length!==a.streamIdParts.length||e.streamIdParts.length!==a.streamIdParts.length)return null;let p=a.streamIdParts.map(m=>{let u=t.streamIdParts.filter(h=>h.property===m.name),y=e.streamIdParts.filter(h=>h.property===m.name);return u.length===1&&y.length===1?d(u[0].source,y[0].source,m.type):null});return p.includes(!1)?!1:p.includes(null)?null:!0}return t.streamIdParts.length>0||e.streamIdParts.length>0?null:a.streamId===null?t.streamId===null&&e.streamId===null?!0:null:d(t.streamId?.source,e.streamId?.source,a.streamId)}c(Hs,"matchesSpecificationRoute");function el(t,e){let n=new ie(t).slices.flatMap(({slice:s})=>s.specifications.flatMap(a=>a.cases??[]));if(n.length===0)return Xs(t,e);let i=new me(new Ne([]));Xs(t,i);let r=new Set,o=new Set;for(let s of i.diagnostics){let a=JSON.stringify([s.code,s.location.path,s.location.line,s.location.column,s.message]);if(o.has(a))continue;o.add(a);let d=s.code===l.InvalidSpecificationStreamRoute?n.find(p=>p.values.some(m=>m.source.location.line===s.location.line&&m.source.location.column===s.location.column&&m.source.location.path===s.location.path)):void 0;if(d===void 0)e.error(s.code,s.message,s.location);else{let p=JSON.stringify(s.location);r.has(p)||e.error(s.code,`Case '${d.name}': ${s.message}`,s.location),r.add(p)}}}c(el,"validateSpecificationStreams");function Xs(t,e){let n=Ut(t).resolvedExamples,i=Kn(t);t=i.application;let r=new ie(t),o=new Set,s=n.flatMap(g=>{if(g.kind!=="event")return(g.kind==="command"||g.kind==="readmodel")&&(g.example.stream!=null||g.example.noStream!=null)&&e.error(l.InvalidSpecificationExampleBody,"only event examples carry routes; a command's route comes from its declaration, and read models have none",(g.example.stream??g.example.noStream).location),[];let P={kind:"SpecificationEventSyntax",eventType:g.name,values:g.example.values,for:g.example.for,stream:g.example.stream,noStream:g.example.noStream,location:g.example.location};return o.add(P),[{scope:g.scope,specification:{when:null,given:[],whenAppended:null,thenEvents:[P],whenRedelivered:null}}]}),a=new Ye(t),d=oe(t.concepts),p=oe(t.types),m=new Map([...p].map(([g,P])=>[g,oe(P.properties)])),u=c((g,P)=>Pe(g,P,d,m),"compatible"),y=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime",...d.keys(),...p.keys()]),h=c((g,P)=>y.has(g.name)&&y.has(P.name)?g.name===P.name&&g.isCollection===P.isCollection&&(!g.isOptional||P.isOptional):null,"nominallyCompatible"),x=c((g,P)=>ji(g,P,t),"formatStreamId"),b=c((g,P)=>{let w=r.resolve(g,P).declaration;return w?.node.kind==="EventSyntax"?w.node:null},"eventOf"),S=[];for(let{slice:g}of r.slices){for(let P of g.commands)for(let w of P.produces){if(!r.isEventProduction(w,g))continue;let v=b(w.event,g);if(v===null)continue;let E=Wt(P,w,t,{resolver:r,slice:g});S.push({event:v,command:P,type:E})}for(let P of g.reactions.flatMap(w=>w.triggers).flatMap(w=>w.produces)){let w=b(P.event,g);w!==null&&S.push({event:w,command:null,type:null})}for(let P of g.captures)for(let w of[...P.appends,...P.children.flatMap(v=>v.appends),...P.nested.flatMap(v=>v.appends)]){let v=b(w.event,g);v!==null&&S.push({event:v,command:null,type:null})}}let $=[...s.flatMap(g=>r.slices.filter(P=>P.scope.join(".")===g.scope.join(".")).map(({slice:P,scope:w})=>({slice:P,scope:w,specification:g.specification}))),...r.slices.flatMap(({slice:g,scope:P})=>g.specifications.map(w=>({slice:g,scope:P,specification:w})))];for(let{slice:g,scope:P,specification:w}of $){let v=r.slices.flatMap(T=>T.slice.commands.map(M=>({command:M,scope:T.scope}))),E=w.when?.commandType.split(".")??[],C=E.slice(0,-1),k=v.filter(T=>T.command.name===E.at(-1)&&C.every((M,N)=>T.scope[T.scope.length-C.length+N]===M)),A=C.length>0&&k.length===1?k[0].command:null;for(let T=P.length;C.length===0&&T>=0&&A===null;T--){let M=k.filter(N=>P.slice(0,T).every((j,q)=>N.scope[q]===j));if(M.length>0){A=M.length===1?M[0].command:null;break}}let O=[...w.given.map(T=>({node:T,required:!0,expected:!1})),...w.whenAppended===null?[]:[{node:w.whenAppended,required:!0,expected:!1}],...w.thenEvents.map(T=>({node:T,required:!1,expected:!o.has(T)})),...w.whenRedelivered==null?[]:[{node:{...w.whenRedelivered,kind:"SpecificationEventSyntax"},required:!1,expected:!1}]];for(let{node:T,required:M,expected:N}of O){let j=i.specifications.flatMap(F=>F.steps).find(F=>F.effective===T),q=j?.route?.origin!=="example",V=q||T.for!==j?.example?.for,K=c((F,ce,ye)=>{e.error(F,j?.example==null?ce:`${ce} Example '${j.example.name}' is used here.`,j?.example==null?ye:j.authored.location)},"contextualError");if(T.stream==null&&T.noStream==null)continue;M&&T.noStream!=null&&K(l.InvalidSpecificationStream,"Expected 'stream Source.Stream', or 'no stream' on a then event.",T.noStream.location);let J=null,U=b(T.eventType,g),_=S.filter(F=>F.event===U);if(T.stream!=null){let F=T.stream,ce=a.resolve(F.eventSource,F.stream);if(ce.kind!==pe.Unique){let he={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[ce.kind];q&&e.error(l.InvalidSpecificationStreamRoute,`Stream '${F.eventSource}.${F.stream}' is ${he}; routing requires one physical source and stream.`,F.location);continue}let ye=ce.sources[0],Te=ce.streams[0],Et=c((he,be)=>{let fe=he.source,R=Rn(fe,be,t);R?.failure!=null?e.error(l.InvalidSpecificationStreamRoute,Mi(R.failure),fe.location):(fe.kind!=="LiteralExpressionSyntax"||fe.value===null||be!==null&&!u(fe,be))&&e.error(l.InvalidSpecificationStreamRoute,"A specification stream id needs a nonempty concrete scalar literal compatible with the stream's declared type.",fe.location)},"validateLiteral");if(q&&(Te.streamIdParts.length>0?Li(Te,F.streamIdParts,F.streamId!==null,F.location,l.InvalidSpecificationStreamRoute,e,Et):F.streamIdParts.length>0?e.error(l.InvalidSpecificationStreamRoute,"A streamId part block requires a composite stream.",F.location):(Te.streamId===null!=(F.streamId===null)&&e.error(l.InvalidSpecificationStreamRoute,Te.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",F.location),F.streamId!==null&&Et(F.streamId,Te.streamId))),J=ye.identifier,J===null){let he=_.map(fe=>fe.type),be=new Set(he.filter(fe=>fe!==null).map(fe=>`${fe.name}:${fe.isOptional}:${fe.isCollection}`));he.length===0||he.some(fe=>fe===null)||be.size!==1?q&&e.error(l.InvalidSpecificationStreamEventSource,`Declare an identifier on source '${ye.name}'; the event's producers do not supply one unambiguous destination type.`,F.location):J=he[0]}let Ct=!1;if(j?.example?.stream!=null&&T.for!==null&&T.for===j.example.for){let he=a.resolve(j.example.stream.eventSource,j.example.stream.stream);if(he.kind===pe.Unique){let be=_.map(L=>L.type),fe=new Set(be.filter(L=>L!==null).map(L=>`${L.name}:${L.isOptional}:${L.isCollection}`)),R=he.sources[0].identifier??(be.length>0&&!be.some(L=>L===null)&&fe.size===1?be[0]:null);R!==null&&(Ct=T.for.kind!=="LiteralExpressionSyntax"||T.for.value===null||R.isCollection||R.isOptional||!u(T.for,R))}}M&&T.for===null?K(l.InvalidSpecificationStreamEventSource,"A routed given or when append event requires 'for <literal>'.",F.location):V&&!Ct&&T.for!==null&&(T.for.kind!=="LiteralExpressionSyntax"||T.for.value===null||J!==null&&(J.isCollection||J.isOptional||!u(T.for,J)))&&K(l.InvalidSpecificationStreamEventSource,"A routed event's for value must be a concrete literal compatible with the source's identifier type.",T.for.location)}if(!N||A===null||_.length===0||_.some(F=>F.command!==A))continue;let te=A.stream?.propertyCandidate===null?A.stream:null,$e=T.noStream!=null?te!=null:te==null||te.eventSource!==T.stream.eventSource||te.stream!==T.stream.stream;if(!$e&&T.stream!=null&&te!=null){let F=a.resolve(T.stream.eventSource,T.stream.stream),ce=F.kind===pe.Unique?F.streams[0]:null;if(ce!==null&&ce.streamIdParts.length>0){if(te.streamId===null&&T.stream.streamId===null&&te.streamIdParts.length>0&&T.stream.streamIdParts.length>0)for(let ye of ce.streamIdParts){let Te=te.streamIdParts.filter(be=>be.property===ye.name),Et=T.stream.streamIdParts.filter(be=>be.property===ye.name);if(Te.length!==1||Et.length!==1)continue;let Ct=x(Te[0].source,ye.type),he=x(Et[0].source,ye.type);Ct!==null&&he!==null&&Ct!==he&&($e=!0)}}else if(ce?.streamId!=null&&te.streamIdParts.length===0&&T.stream.streamIdParts.length===0){let ye=x(te.streamId?.source,ce.streamId),Te=x(T.stream.streamId?.source,ce.streamId);ye!==null&&Te!==null&&ye!==Te&&($e=!0)}}T.for?.kind==="LiteralExpressionSyntax"&&_.every(F=>F.type!==null&&(J!==null?h(F.type,J)===!1:!u(T.for,F.type)))&&($e=!0),$e&&K(l.SpecificationStreamContradictsCommand,"The expected event route contradicts its only producer, the command under test.",(T.stream??T.noStream).location)}}}c(Xs,"validateRoutes");var Dn=new Set(["String","Uuid","Int","Decimal","Bool","Date","DateTime"]);function xo(t,e){let n=e.concepts.filter(r=>r.name===t.name),i=n.length===1?n[0].type:n.length===0&&Dn.has(t.name)?t.name:null;return i==="String"||i==="Uuid"||i==="Int"&&n.length===1&&n[0].values.length===0}c(xo,"supportsStreamIdentity");function Rn(t,e,n){if(t?.kind!=="LiteralExpressionSyntax")return null;let i=t.value,r=e===null?null:oe(n.concepts).get(e.name)?.type??e.name;return typeof i=="string"?r==="Uuid"?Js(i):Ks(i):typeof i=="number"?Di(i):typeof i=="object"&&i!==null&&i.literalType==="ExactNumber"?i.value.includes(".")?Di(NaN):Di(BigInt(i.value),!1):null}c(Rn,"formatStreamIdLiteral");function Ni(t,e){let n=oe(t.concepts),i=oe(t.types),r=new Set([...Dn,...n.keys(),...i.keys()]),o=new Map([...i].map(([y,h])=>[y,oe(h.properties)])),s=c((y,h)=>r.has(y.name)&&r.has(h.name)?y.name===h.name&&y.isCollection===h.isCollection&&(!y.isOptional||h.isOptional):null,"compatible"),a=c((y,h)=>{if(y===null)return;if(y.isOptional||y.isCollection||t.types.some(S=>S.name===y.name)){e.error(l.InvalidEventSourceDeclaration,"Identifier and streamId declarations require a nonoptional scalar value type.",y.location);return}let x=t.concepts.filter(S=>S.name===y.name),b=x.length===1?x[0].type:x.length===0&&Dn.has(y.name)?y.name:null;h&&b!==null&&!xo(y,t)&&e.error(l.UnsupportedStreamIdType,"Stream ids support text and UUID values and their nominal concepts, plus integer-backed concepts; other types need a future portable formatter.",y.location),b===null&&!t.imports.some(S=>S.qualifiedName===y.name||S.qualifiedName.split(".").at(-1)===y.name)&&e.warning(l.UnknownType,`Unknown type '${y.name}' in event source declaration.`,y.location)},"validateType"),d=new Set;for(let y of t.eventSources??[]){d.has(y.name)&&e.error(l.InvalidEventSourceDeclaration,`Event source '${y.name}' has multiple physical declarations.`,y.location),d.add(y.name),a(y.identifier,!1);let h=new Set;for(let x of y.streams){h.has(x.name)&&e.error(l.InvalidEventSourceDeclaration,`Stream '${y.name}.${x.name}' has multiple declarations under this source.`,x.location),h.add(x.name),a(x.streamId,!0);let b=x.streamIdParts;if(b.length>0){b.length<2&&e.error(l.InvalidEventSourceDeclaration,"A composite stream id requires at least two named parts.",x.directiveLocations?.streamId??x.location);for(let S of new Set(b.map($=>$.name)))for(let $ of b.filter(g=>g.name===S).slice(1))e.error(l.InvalidEventSourceDeclaration,`Stream id part '${$.name}' is declared more than once.`,$.location);for(let S of b)a(S.type,!0)}}}let p=c((y,h)=>{let[x,...b]=h.split(".");if(y===null)return{property:null,missing:!1};let S=y.filter(P=>P.name===x);if(S.length!==1)return{property:null,missing:S.length===0};let $=S[0];if(b.length===0)return{property:$,missing:!1};if(Dn.has($.type.name)||n.has($.type.name)&&!i.has($.type.name))return{property:null,missing:!0};let g=p(i.get($.type.name)?.properties??null,b.join("."));return g.property===null?g:{property:{...g.property,type:{...g.property.type,isCollection:$.type.isCollection||g.property.type.isCollection,isOptional:$.type.isOptional||g.property.type.isOptional}},missing:!1}},"pathProperty"),m=new Ye(t),u=new ie(t);for(let{slice:y}of u.slices)for(let h of y.commands){let x=h.stream;if(x==null||x.propertyCandidate!==null)continue;let b=m.resolve(x.eventSource,x.stream);if(b.kind!==pe.Unique){let w={ambiguous:"Ambiguous",notFound:"NotFound",wrongKind:"WrongKind"}[b.kind];e.error(l.InvalidCommandStream,`Stream '${x.eventSource}.${x.stream}' is ${w}; routing requires one physical source and stream.`,x.location);continue}let S=b.sources[0],$=b.streams[0],g=h.properties.filter(w=>w.isIdentifier);S.identifier!==null&&g.length===1&&s(g[0].type,S.identifier)===!1&&e.error(l.InvalidCommandStream,`Command identifier '${g[0].name}' does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,g[0].location);for(let w of h.produces.filter(v=>u.isEventProduction(v,y))){if(S.identifier===null)continue;let v=Wt(h,w,t,{resolver:u,slice:y});if(v===null||w.for===null&&w.inlineEvent!==null&&g.length===1&&s(g[0].type,S.identifier)===!1)continue;let E=w.for===null&&w.inlineEvent===null&&!h.properties.some(A=>A.isGenerated&&A.isIdentifier),C=n.get(S.identifier.name)?.type??(Dn.has(S.identifier.name)?S.identifier.name:null);(E?C===null?null:C==="Uuid":s(v,S.identifier))===!1&&e.error(l.InvalidCommandStream,`Command production destination does not have the source's nominal identifier type '${S.identifier.name}'. The stream does not supply a destination.`,w.for?.location??w.location)}let P=c((w,v)=>{let E=w.source;if(E.kind==="PathExpressionSyntax"){let C=p(h.properties,E.path);(C.missing||C.property!==null&&s(C.property.type,v)===!1)&&e.error(l.InvalidCommandStream,`Stream id source '${E.path}' is absent or incompatible with nominal type '${v.name}'.`,E.location)}else if(E.kind==="LiteralExpressionSyntax"&&E.value!==null){let C=Rn(E,v,t);C?.failure!=null?e.error(l.InvalidCommandStream,Mi(C.failure),E.location):Pe(E,v,n,o)||e.error(l.InvalidCommandStream,`Stream id value is incompatible with nominal type '${v.name}'.`,E.location)}else(["RawExpressionSyntax","ObjectExpressionSyntax","ListExpressionSyntax"].includes(E.kind)||E.kind==="LiteralExpressionSyntax"&&E.value===null)&&e.error(l.InvalidCommandStream,"A stream id needs a scalar value source, not a raw expression, collection or absence.",E.location)},"validateMapping");if($.streamIdParts.length>0){Li($,x.streamIdParts,x.streamId!==null,x.location,l.InvalidCommandStream,e,P);continue}if(x.streamIdParts.length>0){e.error(l.InvalidCommandStream,"A streamId part block requires a composite stream.",x.location);continue}($.streamId===null&&x.streamId!==null||$.streamId!==null&&x.streamId===null)&&e.error(l.InvalidCommandStream,$.streamId===null?"An unkeyed stream cannot take a streamId mapping.":"This keyed stream requires a streamId mapping.",x.location),!($.streamId===null||x.streamId===null)&&P(x.streamId,$.streamId)}el(t,e)}c(Ni,"validateEventSources");function qi(t,e){let n=new ie(t),i=n.slices,r=new Set(t.imports.map(b=>b.qualifiedName)),o=new Set([...i.flatMap(({slice:b})=>le(b).map(S=>S.name)),...t.imports.map(b=>b.qualifiedName.split(".").at(-1))]),s=oe(t.types),a=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime",...t.concepts.map(b=>b.name)].filter(b=>!s.has(b))),d=c((b,S)=>{let[$,...g]=S.split(".");if(b===null)return{value:null,missing:!1};let P=b.filter(v=>v.name===$);if(P.length!==1)return{value:null,missing:P.length===0};let w=P[0];return g.length===0?{value:w,missing:!1}:a.has(w.type.name)?{value:null,missing:!0}:d(s.get(w.type.name)?.properties??null,g.join("."))},"property"),p=i.flatMap(({slice:b,scope:S})=>b.readModels.map($=>({node:$,scope:S}))),m=c((b,S)=>{let $=c(w=>{let v=w.split("."),E=p.filter(k=>k.node.name===v.at(-1)),C=v.slice(0,-1);if(C.length>0)return E.filter(k=>C.length<=k.scope.length&&C.every((A,O)=>k.scope[k.scope.length-C.length+O]===A));for(let k=S.length;k>=0;k--){let A=E.filter(O=>k<=O.scope.length&&S.slice(0,k).every((T,M)=>O.scope[M]===T));if(A.length>0)return A}return[]},"candidates"),g=$(b),P=t.imports.filter(w=>w.qualifiedName.split(".").at(-1)===b);return g.length===0&&P.length===1&&(g=$(P[0].qualifiedName)),g.length===1?g[0].node.properties:null},"viewProperties"),u=c((b,S,$)=>{let g=n.resolve(b,$);o.has(b)||r.has(b)||g.declaration?.kind===H.Event||g.candidates.some(w=>w.kind===H.Event)||e.warning(l.UnknownEvent,`Unknown event '${b}' - declare it with 'event ${b}'`,S)},"unknownEvent"),y=c((b,S)=>{for(let $ of b)($.kind==="RemoveWithSyntax"||$.kind==="RemoveViaJoinSyntax")&&u($.event,$.location,S),"blocks"in $&&y($.blocks,S)},"removals"),h=new Set,x=c((b,S,$=!1,g=!1)=>{let P=c((v,E)=>{let C=d(S,v),k=JSON.stringify([E.path,E.line,E.column]);return C.missing&&!h.has(k)&&(h.add(k),e.warning(l.UnknownReadModelProperty,`Projection target '${v}' is not a declared ${$?"element":"read-model"} property`,E)),C.value},"validate"),w=g||b.some(v=>v.kind==="FromSyntax"||v.kind==="JoinSyntax"||v.kind==="AllSyntax");for(let v of b){let E=v.kind==="EverySyntax"&&!w?[]:"mappings"in v?v.mappings:v.kind==="JoinSyntax"?v.events.flatMap(C=>C.mappings):[];for(let C of E)P(C.property,C.location);if(v.kind==="ChildrenSyntax"||v.kind==="NestedSyntax"){let C=P(v.property,v.location);x(v.blocks,C===null?null:s.get(C.type.name)?.properties??null,!0)}}},"walk");for(let{slice:b}of i){for(let S of b.projections)y(S.blocks,b);for(let S of b.captures)for(let $ of[...S.appends,...S.children.flatMap(g=>g.appends),...S.nested.flatMap(g=>g.appends)])u($.event,$.location,b)}for(let{slice:b,scope:S}of i)for(let $ of b.projections){let g=$.blocks.filter(P=>P.kind==="ProjectionVariantSyntax");g.length===0&&x($.blocks,m($.readModel??$.name,S));for(let P of g){let w=m(P.name,S);x($.blocks.filter(E=>E.kind==="ChildrenSyntax"||E.kind==="NestedSyntax"),w);let v=P.entersOn.length>0||$.blocks.some(E=>E.kind==="FromSyntax"||E.kind==="JoinSyntax"||E.kind==="AllSyntax");x(P.blocks,w,!1,v)}}}c(qi,"validateProjectionTargets");function Bi(t,e){let n=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="pii")).map(u=>u.name)),i=new Set(t.concepts.filter(u=>u.attributes.some(y=>y.name==="sensitive")).map(u=>u.name)),r=oe(t.types),o=new ie(t),s=new Set(t.imports.map(u=>u.qualifiedName.split(".").at(-1))),a=new Map;for(let u of t.declaredTriggers??[]){let y=a.get(u.name)??[];y.push(u.data),a.set(u.name,y)}let d=c((u,y,h="an event source identifier")=>{if(n.has(u.name)||i.has(u.name)){let x=n.has(u.name)?"pii":"secret";e.error(l.PiiNotSupportedOnIdentifier,`Concept '${u.name}' is ${x} and cannot be ${h} - use a surrogate Uuid identifier and keep the ${x} value as a property`,y)}},"validate"),p=c((u,y)=>{let[h,...x]=y.split("."),b=u.filter($=>$.name===h);if(b.length!==1)return null;let S=b[0];return x.length===0?S:p(r.get(S.type.name)?.properties??[],x.join("."))},"property");for(let u of t.eventSources??[]){u.identifier!=null&&d(u.identifier,u.identifier.location);for(let y of u.streams){y.streamId!==null&&d(y.streamId,y.streamId.location,"a stream id");for(let h of y.streamIdParts)d(h.type,h.type.location,`a stream id part '${h.name}'`)}}let m=new Ye(t);for(let{slice:u}of o.slices){for(let y of u.commands){for(let h of y.properties.filter(x=>x.isIdentifier))d(h.type,h.location);for(let h of[...y.stream?[y.stream]:[],...y.streamCandidates??[]].filter(x=>x.propertyCandidate===null)){let x=m.resolve(h.eventSource,h.stream),b=x.kind===pe.Unique?x.streams[0]:void 0,S=[...h.streamId===null?[]:[{mapping:h.streamId,target:b?.streamId}],...h.streamIdParts.map($=>({mapping:$,target:b?.streamIdParts.find(g=>g.name===$.property)?.type}))];for(let{mapping:$,target:g}of S){if($.source.kind!=="PathExpressionSyntax")continue;let P=p(y.properties,$.source.path);P!==null&&(P.type.name===g?.name&&(n.has(P.type.name)||i.has(P.type.name))||d(P.type,$.source.location,"a stream id route mapping"))}}for(let h of y.produces.filter(x=>o.isEventProduction(x,u))){if(h.for?.kind!=="PathExpressionSyntax")continue;let x=p(y.properties,h.for.path);x!==null&&!x.isIdentifier&&d(x.type,h.for.location)}}for(let y of u.reactions.flatMap(h=>h.triggers)){if(y.source.kind!=="NamedTriggerSourceSyntax")continue;let x=o.resolve(y.source.name,u).declaration?.node,b=(Se(y).data??[]).flatMap($=>$.type===null?[]:[{kind:"PropertySyntax",name:$.name,type:$.type,isIdentifier:!1,location:$.location}]),S=[x?.kind==="EventSyntax"?x.properties:[],b];x?.kind!=="EventSyntax"&&!s.has(y.source.name)&&S.push(...a.get(y.source.name)??[]);for(let $ of y.produces.filter(g=>o.isEventProduction(g,u))){if($.for?.kind!=="PathExpressionSyntax")continue;let g=$.for.path,P=S.map(w=>p(w,g)).find(w=>w!==null&&(n.has(w.type.name)||i.has(w.type.name)));P!=null&&d(P.type,$.for.location)}}}}c(Bi,"validateIdentifierCompliance");function Yi(t,e){let n=c((i,r)=>{for(let o of i.filter(s=>s.isSubject))e.error(l.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 ie(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(l.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 le(i)){let o=r.properties.filter(s=>s.isSubject);for(let s of o.slice(1))e.error(l.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(l.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(m=>m.name===a.name)){e.error(l.InvalidSubjectType,"A subject must be a scalar identity, not a collection or composite type.",s.location);continue}let d=t.concepts.filter(m=>m.name===a.name);d.some(m=>m.attributes.some(u=>["pii","sensitive"].includes(u.name)))&&e.error(l.ProtectedSubjectType,`Subject concept '${a.name}' is pii or secret. EventContext.Subject is stored in plaintext; use a surrogate Uuid identity.`,s.location);let p=d.length===1?d[0].type:d.length===0&&["String","Uuid","Int","Decimal","Bool","Date","DateTime"].includes(a.name)?a.name:null;d.length===0&&p===null&&t.imports.some(m=>m.qualifiedName===a.name||m.qualifiedName.split(".").at(-1)===a.name)&&e.warning(l.UnknownType,`Unknown type shape '${a.name}' for subject property '${s.name}'; imported subject identity rules cannot be verified.`,s.location),(d.some(m=>m.type==="Enum")||p!==null&&!xo(a,t))&&e.error(l.InvalidSubjectType,"Subjects support String, Uuid and their concepts, plus Int-backed concepts; bare Int, enums, Decimal, Bool, Date and DateTime are refused.",s.location)}}}}c(Yi,"validateEventSubjects");var Fi=class extends Ce{static{c(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(l.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(l.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 zm(){return!0}c(zm,"invocationHasNoDeclaredIdentity");function Qm(t){let e=new Set,n=c((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}c(Qm,"authorizationGatedSlices");function Ui(t,e){let n=new He(Ge(t));new Fi(n,e).visitApplication(n.application);let i=Qm(n.application);for(let{slice:r}of n.slices){let o=c(d=>n.resolve(d,r,p=>p.constraints),"constraintOf"),s=c((d,p)=>d===p||o(d)!==null&&o(d)?.node===o(p)?.node,"sameConstraint"),a=c((d,p)=>d.selector==="any"&&["any","validation","constraint"].includes(p.selector)||d.selector===p.selector&&(d.selector!=="constraint"||d.constraint===null||p.constraint!==null&&s(d.constraint,p.constraint)),"covers");for(let d of r.reactions.flatMap(p=>p.triggers).flatMap(p=>p.invokes)){let p=n.resolve(d.command,r,y=>y.commands),m=p!==null&&(p.node.authorize!==null||i.has(p.slice)),u=[];for(let y of d.onRefused??[]){if(u.some($=>a($,y))&&e.warning(l.UnreachableRefusalBranch,"This refusal selector is covered by an earlier branch; the first matching branch wins.",y.location),u.push(y),y.selector==="authorization"&&zm()&&m&&e.warning(l.AuthorizationRefusalWithoutIdentity,`Command '${d.command}' is authorization-gated, but this invocation has no declared identity. This authorization refusal branch always fires in the reference runner because there is no caller; Arc runs reactor commands as the system. Declare an invoking identity once supported (#383).`,y.location),y.constraint===null)continue;let h=o(y.constraint);if(h===null){e.error(l.UnknownRefusalConstraint,`Unknown or ambiguous refusal constraint '${y.constraint}'.`,y.location);continue}if(p===null||p.node.handler!==null)continue;let x=[h.node,...h.node.additionalRules];if(x.some($=>$.kind==="FileConstraintSyntax"))continue;let b=x.map($=>$.kind==="FileConstraintSyntax"?null:n.event($.event,h.slice)),S=p.node.produces.map($=>n.event($.event,p.slice));b.every($=>$!==null)&&S.every($=>$!==null)&&!b.some($=>S.includes($))&&e.warning(l.UnreachableRefusalBranch,`Constraint '${y.constraint}' targets none of the events produced by '${d.command}'.`,y.location)}}}}c(Ui,"validateReactionRefusals");function Wi(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=c(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(d=>Wi(d,{...e,isCollection:!1,isOptional:!1},n));return a.some(d=>d===void 0)?void 0:{canonical:`[${a.map(Vi).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(d=>{let p=n.property(s,d.name);return{name:d.name,value:p===null?void 0:Wi(d.value,p.type,n)}});return a.some(d=>d.value===void 0)?void 0:{canonical:`{${a.sort((d,p)=>d.name<p.name?-1:d.name>p.name?1:0).map(d=>`${JSON.stringify(d.name)}:${Vi(d.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)}c(Wi,"redeliveryValue");function Vi(t){return typeof t=="object"&&t!==null?"canonical"in t?t.canonical:$r(t):JSON.stringify(t)}c(Vi,"canonical");function vo(t,e,n,i){let r=Wi(t,n,i),o=Wi(e,n,i);return r===void 0||o===void 0?null:Vi(r)===Vi(o)}c(vo,"sameRedeliveryValue");function zi(t,e){t=Ge(t);let n=new He(t);for(let{slice:i}of n.slices)for(let r of i.specifications){let o=r.whenRedelivered;if(o==null)continue;let s=n.event(o.eventType,i),a=n.resolve(o.reaction,i,m=>m.reactions);if(a===null||s===null||!a.node.triggers.some(m=>m.source.kind==="NamedTriggerSourceSyntax"&&n.event(m.source.name,a.slice)===s)){e.error(l.UnknownRedeliveryReaction,`Reaction '${o.reaction}' must resolve unambiguously and observe event '${o.eventType}'.`,o.location);continue}let d=r.given.filter(m=>n.event(m.eventType,i)===s).map(m=>Gm(m,o,s,n,t)),p=d.filter(m=>m===!0).length;d.some(m=>m===null)?e.error(l.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(l.UnmatchedRedeliveredOccurrence,`Redelivery of '${o.eventType}' matches ${p} given occurrences; use 'for', values, 'stream' or 'no stream' to identify exactly one.`,o.location)}}c(zi,"validateSpecificationRedelivery");function Gm(t,e,n,i,r){let o=[];e.for!==null&&o.push(t.for===null?null:vo(e.for,t.for,null,i));for(let s of e.values){let a=t.values.filter(d=>d.property===s.property);o.push(a.length===1?vo(s.source,a[0].source,i.property(n.properties,s.property)?.type??null,i):null)}return o.push(Hs(t.stream,e.stream,e.noStream,r)),o.includes(!1)?!1:o.includes(null)?null:!0}c(Gm,"matches");var tl=64;function nl(t,e){let n=[];for(let i of t.alternatives){let r=$o(i.condition);r!==null&&(r.length>0&&r.every(o=>n.some(s=>[...s].every(a=>o.has(a))))&&e.warning(l.UnreachableActionAlternative,`Alternative executing '${i.command}' is shadowed by earlier alternatives in this action`,i.location),n.push(...r))}}c(nl,"validateGuardedActionShadowing");function $o(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=$o(t.left),n=$o(t.right);return e===null||n===null?null:t.operator==="Or"?e.length+n.length>tl?null:[...e,...n]:e.length*n.length>tl?null:e.flatMap(i=>n.map(r=>new Set([...i,...r])))}c($o,"normalize");var _m=new Set(["Uuid","String","Int","Decimal","Bool","Date","DateTime"]);function Qi(t,e){let n=new He(t);for(let{slice:i}of n.slices)for(let r of i.screens)bo(r.directives,[],i,n,e)}c(Qi,"validateGuardedActions");function bo(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":Zm(a,s,n,i,r);break;case"ScreenSectionSyntax":bo(a.directives,s,n,i,r);break;case"ScreenTemplateReferenceSyntax":for(let d of a.slots)bo(d.directives,s,n,i,r);break}}c(bo,"validateContainer");function rl(t,e,n){return n.resolve(t,e,i=>i.readModels)?.node.properties??null}c(rl,"viewProperties");function Zm(t,e,n,i,r){let o=e.length===1?rl(e[0].type.name,n,i):null;e.length!==1&&r.warning(l.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 ko(s.condition))ol(a.left,a.location,o,n,i,r);il(s.command,s.arguments,o,n,i,r)}t.otherwise?.command!=null&&il(t.otherwise.command,t.otherwise.arguments,o,n,i,r),nl(t,r)}c(Zm,"validateAction");function il(t,e,n,i,r,o){let s=r.resolve(t,i,a=>a.commands)?.node;for(let a of e){let d=s?.properties.filter(m=>m.name===a.name);d?.length===0&&o.warning(l.UnknownActionArgumentProperty,`Command '${t}' has no argument property '${a.name}'`,a.location);let p=ol(a.binding,a.location,n,i,r,o,!0);d?.length===1&&p!==null&&d[0].type.isCollection!==p.type.isCollection&&o.warning(l.UnknownActionArgumentProperty,`Command argument '${t}.${a.name}' and subject field '${a.binding}' must have matching collection cardinality`,a.location)}}c(il,"validateArguments");function ol(t,e,n,i,r,o,s=!1){if(!t.startsWith("item.")||n===null)return null;let a=t.substring(5).split(".");for(let[d,p]of a.entries()){let m=n.filter(y=>y.name===p);if(m.length===0||m.length===1&&m[0].type.isCollection&&(!s||d<a.length-1))return o.warning(l.UnknownActionSubjectField,`Unknown or collection-valued subject field '${t}' - guarded actions require an item field path`,e),null;if(m.length!==1)return null;if(d===a.length-1)return m[0];let u=m[0].type;if(n=r.types.get(u.name)?.properties??rl(u.name,i,r),n===null)return(_m.has(u.name)||r.application.concepts.some(y=>y.name===u.name)&&!r.application.types.some(y=>y.name===u.name))&&o.warning(l.UnknownActionSubjectField,`Subject field '${t}' continues past scalar '${p}'`,e),null}return null}c(ol,"validateItemPath");function ko(t){return t.kind==="ComparisonConditionSyntax"?[t]:[...ko(t.left),...ko(t.right)]}c(ko,"comparisons");function Gi(t,e){let n=t.personas.map(r=>r.name),i=c(r=>{for(let o of r){i(o.features);for(let s of o.slices)for(let a of s.specifications){let d=a.givenCallerPersona;if(d!=null){let p=n.filter(m=>m===d.name).length;p!==1&&e.error(l.InvalidSpecificationCallerPersona,`${p===0?"Unknown":"Ambiguous"} persona '${d.name}' - declared personas: ${n.join(", ")}.`,d.location)}}}},"visit");for(let r of t.modules)i(r.features)}c(Gi,"validatePersonaCallers");function _i(t,e){let n=new Set;for(let o of t.purposes??[])n.has(o.name)&&e.error(l.DuplicatePurposeDeclaration,`Duplicate purpose '${o.name}' - a purpose is declared once`,o.location),n.add(o.name);for(let o of t.purposes??[])o.interest!==null&&o.basis!=="legitimateInterests"?e.warning(l.PurposeInterestMismatch,`Purpose '${o.name}' declares an interest without basis legitimateInterests`,o.location):o.basis==="legitimateInterests"&&!o.interest?.trim()&&e.warning(l.PurposeInterestMismatch,`Purpose '${o.name}' with basis legitimateInterests has no interest statement (Art. 13(1)(d))`,o.location);let i=[],r=c(o=>{i.push(...o.purposes??[],...o.slices.flatMap(s=>s.purposes??[])),o.features.forEach(r)},"collect");for(let o of t.modules)i.push(...o.purposes??[]),o.features.forEach(r);for(let o of i)n.has(o.name)||e.warning(l.UnknownPurpose,`Unknown purpose '${o.name}' - declare it with 'purpose ${o.name}'`,o.location)}c(_i,"validatePurposes");function Rt(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("")}c(Rt,"ordinalIgnoreCaseKey");function Eo(t){let e=In(t),n=c((h,x)=>h.map(b=>({syntax:b,rank:e.get(Ze([...x,b.name]))??Number.MAX_SAFE_INTEGER})).sort((b,S)=>b.rank-S.rank).map(b=>b.syntax),"ordered"),i=[],r=c((h,x)=>{let b=[...x,h.name];for(let S of n(h.slices,b))i.push({syntax:S,scope:[...b,S.name],identity:[...b.map($=>`container:${$}`),`slice:${S.name}`],index:i.length});for(let S of n(h.features,b))r(S,b)},"feature");for(let h of n(t.modules,[]))for(let x of n(h.features,[h.name]))r(x,[h.name]);let o=new Map(i.map(h=>[h,new Set([...le(h.syntax).map(x=>Rt(x.name)),...h.syntax.commands.flatMap(x=>x.produces.map(b=>Rt(b.event))),...h.syntax.reactions.flatMap(x=>x.triggers.flatMap(b=>b.produces.map(S=>Rt(S.event))))])])),s=new Map;for(let h of i)for(let x of le(h.syntax)){let b=Rt(x.name);s.has(b)||s.set(b,h)}let a=new Map;for(let h of i){let x=Ze(h.scope);a.has(x)||a.set(x,h)}let d=new Map;for(let h of Ht.for(t,e).edges.filter(x=>x.kind==="decidesFrom"))for(let x of h.evidence){let b=Ze([...h.consumer.scope,x.name.toLowerCase()]);d.has(b)||d.set(b,a.get(Ze(h.producer.scope)))}let p=[];for(let h of i){let x=new Set,b=Ci(h.syntax).references.filter(S=>S.timeline).map(S=>({event:S.name,location:S.location,readModel:S.targetKind==="ReadModel"}));for(let S of b){let $=Rt(S.event),g=`${S.readModel?"ReadModel":"Event"}:${$}`;if(x.has(g))continue;x.add(g);let P=S.readModel?d.get(Ze([...h.scope,S.event.toLowerCase()])):s.get($);if(P===void 0||P===h)continue;let w=0;for(;w<h.scope.length&&w<P.scope.length&&h.identity[w]===P.identity[w];)w++;if(!(w===h.scope.length||w===P.scope.length)){if(S.readModel){let v=h.identity.slice(0,w+1),E=new Set(i.filter(C=>v.every((k,A)=>C.identity[A]===k)).flatMap(C=>[...o.get(C)]));if(ws(P.syntax,S.event).some(C=>C.timeline&&C.kind==="usesFactsFrom"&&C.targetKind==="Event"&&E.has(Rt(C.name))))continue}p.push({...S,consumer:h,producer:P,container:Ze(h.identity.slice(0,w)),left:h.identity[w],right:P.identity[w]})}}}let m=c((h,x)=>h.consumer.index-x.consumer.index||h.location.line-x.location.line||h.location.column-x.location.column,"compare"),u=new Set,y=[];for(let h of new Set(p.map(x=>x.container))){let x=p.filter(S=>S.container===h),b=new Map;for(let S of x)b.has(S.left)||b.set(S.left,new Set),b.has(S.right)||b.set(S.right,new Set),b.get(S.left).add(S.right);for(let S of On(b).filter($=>$.length>1)){let $=new Set(S),g=x.filter(v=>$.has(v.left)&&$.has(v.right));g.forEach(v=>u.add(v));let P=g.filter(v=>v.consumer.index<v.producer.index).sort(m)[0];if(P===void 0)continue;let w=c(v=>Math.min(...g.flatMap(E=>[E.consumer,E.producer]).filter(E=>{let C=JSON.parse(h);return E.identity[C.length]===v}).map(E=>E.index)),"memberIndex");S.sort((v,E)=>w(v)-w(E)),y.push({edge:P,diagnostic:{severity:"information",code:l.TimelineCycleGroup,message:`Timeline group ${S.map(v=>`${v.startsWith("slice:")?"slice":h===Ze([])?"module":"feature"} '${v.slice(v.indexOf(":")+1)}'`).join(", ")} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:P.location}})}}for(let h of p){if(h.consumer.index>=h.producer.index||u.has(h))continue;let x=h.consumer.scope.slice(0,-1),S=h.producer.scope.length>h.consumer.scope.length&&x.every((g,P)=>h.producer.scope[P]===g)?" The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.":" Consider drawing the producer before the consumer.",$=h.readModel?`reads read model '${h.event}' built by`:`uses event '${h.event}' produced by`;y.push({edge:h,diagnostic:{severity:"information",code:l.EventFromLaterSlice,message:`Slice '${h.consumer.syntax.name}' ${$} slice '${h.producer.syntax.name}' drawn after it.${S}`,location:h.location}})}return y.sort((h,x)=>m(h.edge,x.edge)).map(h=>h.diagnostic)}c(Eo,"timelineOrderDiagnostics");function tt(t,e,n=It,i=!0,r,o){let s=Lt(t,!1,e),a=wi(s,e,o);a.scope=n,a.streamCandidates=r??tn.capture([s],n,o);let d=Ri(a,s,n);if(i){zn(d,a),_i(d,a),Ii(d,a),ni(d,a),Oi(d,a),Ai(d,a),ei(d,a);let p=Ge(d);Hn(p,a),Ni(d,a),qi(d,a),Bi(p,a),Yi(d,a),Ui(d,a),zi(d,a),Qi(d,a),Gi(d,a),d=ri(d,a),en.validate(d,a);for(let m of ti(d))a.information(m.code,m.message,m.location);for(let m of Eo(d))a.information(m.code,m.message,m.location)}return{value:d,diagnostics:a.diagnostics,triggerData:a.triggerData,inputUses:a.inputUses,success:!a.diagnostics.some(p=>p.severity==="error")}}c(tt,"parseForAuthoring");function bO(t){return t===l.LegacyOptionalSuffix||t===l.LegacyComplianceMarker||t===l.RedundantEventId||t===l.PublicTranslationRequiresDirection}c(bO,"isQuickFixDiagnostic");function Po(t,e){return e.code!==l.LegacyOptionalSuffix?0:/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?\?/u.exec(t.slice(e.location.column-1))?.[0].length??0}c(Po,"legacyOptionalTypeLength");function kO(t,e={}){let n=tt(t,void 0,e.placement),i=new Set(Array.from({length:14},(v,E)=>`PLAY0${607+E}`)),r=c(v=>v.success||v.diagnostics.every(E=>E.severity!=="error"||i.has(E.code)),"acceptable"),o=c(v=>new Set(v.diagnostics.filter(E=>E.severity==="error").map(E=>E.code)),"errorCodes");if(!r(n))return()=>[];let s=Lt(t),a=new Map,d=new Map;new class extends Ce{visitEvent(v){a.set(v.location.line,v)}visitSlice(v){d.set(v.location.line,v),super.visitSlice(v)}}().visitApplication(n.value);let m=new Map,u=new Map,y=new Map,h;for(let v of s)h=a.get(v.number)??h,h!==void 0&&y.set(v.number,h);for(let v of n.diagnostics){m.set(v.code,(m.get(v.code)??0)+1);let E=s[v.location.line-1],C=Po(E.raw,v);if(C>0)u.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:"Use 'optional' instead of '?'",scope:"occurrence",edits:[{start:E.startOffset+v.location.column+C-2,length:1,text:" optional"}]}});else if(v.code===l.LegacyComplianceMarker){let k=Km(E.raw,E.startOffset);k!==void 0&&u.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:"Use bare pii and secret compliance markers",scope:"occurrence",edits:[k]}})}else if(v.code===l.PublicTranslationRequiresDirection){let k=d.get(E.number),A=/^\s*/.exec(E.raw)[0],O=t.includes(`\r
|
|
19
|
-
`)?`\r
|
|
20
|
-
`:`
|
|
21
|
-
`,T=[de.Inbound,de.Outbound].map(M=>({direction:M,text:`${O}${A} direction ${M===de.Inbound?"inbound":"outbound"}`})).filter(M=>{let N=Co(t,[{start:E.startOffset+E.raw.length,length:0,text:M.text}]),j=tt(N,void 0,e.placement),q=o(n);return r(j)&&![...o(j)].some(V=>V===l.PublicTranslationRequiresDirection||!q.has(V))});if(T.length===1){let[{direction:M,text:N}]=T;u.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:`Declare 'direction ${M===de.Inbound?"inbound":"outbound"}'`,scope:"occurrence",edits:[{start:E.startOffset+E.raw.length,length:0,text:N}]},change:{node:k,replacement:{...k,direction:M}}})}}else if(v.code===l.RedundantEventId&&pn(E.raw)<0){let k=y.get(E.number);if(k?.id!==k?.name||k===void 0)continue;u.set(E.number,{line:E.number,fix:{diagnosticCode:v.code,title:"Remove the redundant event id",scope:"occurrence",edits:[{start:E.startOffset,length:(s[E.number]?.startOffset??t.length)-E.startOffset,text:""}]},change:{node:k,replacement:{...k,id:null}}})}}let x=[l.LegacyOptionalSuffix,l.LegacyComplianceMarker],b=Mn(n),S=new Map,$,g=new Set,P=new Map,w=c((v,E)=>{let C=Co(t,v.edits);if(C===void 0)return;let k=tt(C,void 0,e.placement);if(!(!r(k)||Mn(k)!==(E===void 0?b:Mn(n,[E]))))return k.diagnostics.filter(A=>A.code===v.diagnosticCode).length===(m.get(v.diagnosticCode)??0)-v.edits.length?v:void 0},"verify");return(v,E)=>{let C=typeof v=="number"||v===void 0?void 0:v,k=x.filter(N=>C===void 0?E===void 0||E===N:C.some(j=>j.diagnosticCode===N));for(let N of k.filter(j=>!g.has(j))){let j=[...u.values()].filter(q=>q.fix.diagnosticCode===N);if(j.length>0){let q=w({diagnosticCode:N,title:N===l.LegacyOptionalSuffix?"Use 'optional' throughout this document":"Use bare pii and secret throughout this document",scope:"document",edits:j.flatMap(V=>V.fix.edits)});q!==void 0&&P.set(N,q)}g.add(N)}let A=k.flatMap(N=>P.has(N)?[P.get(N)]:[]);if(C!==void 0){if($===void 0){$=new Map;let j=s.flatMap(K=>u.has(K.number)?[u.get(K.number)]:[]),q=j.flatMap(K=>K.fix.edits),V=Co(t,q);if(q.length>0&&V!==void 0){let K=tt(V,void 0,e.placement),J=j.flatMap(U=>U.change===void 0?[]:[U.change]);if(r(K)&&Mn(K)===Mn(n,J)){let U=new Map,_=new Map;for(let te of K.diagnostics)U.set(te.code,(U.get(te.code)??0)+1);for(let te of j)_.set(te.fix.diagnosticCode,(_.get(te.fix.diagnosticCode)??0)+te.fix.edits.length);if([..._].every(([te,$e])=>(U.get(te)??0)===(m.get(te)??0)-$e))for(let te of j)$.set(te.line,te.fix)}}}let N=new Map;for(let j of C){let q=$.get(j.line);q?.diagnosticCode===j.diagnosticCode&&N.set(j.line,q)}return[...N.values(),...A]}let O=typeof v=="number"?v:void 0,T=O===void 0?void 0:u.get(O),M;return T!==void 0&&O!==void 0&&(E===void 0||T.fix.diagnosticCode===E)&&(S.has(O)||(S.size===32&&S.delete(S.keys().next().value),S.set(O,w(T.fix,T.change))),M=S.get(O)),[...M===void 0?[]:[M],...A]}}c(kO,"prepareQuickFixes");function Km(t,e){let n=I("^(\\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=I("^(\\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"}}c(Km,"complianceMarkerEdit");function Mn(t,e=[]){let n=new Map(e.map(i=>[i.node,i.replacement]));return JSON.stringify([t.value,t.triggerData],(i,r)=>["location","usesLocation","targetLocation"].includes(i)?void 0:n.get(r)??r)}c(Mn,"verificationShape");function Co(t,e){let n=[],i=0;for(let r of e){if(r.start<i||r.start<0||r.length<0||r.start+r.length>t.length)return;n.push(t.slice(i,r.start),r.text),i=r.start+r.length}return n.push(t.slice(i)),n.join("")}c(Co,"applyQuickFixEdits");var nn=class{static{c(this,"EventSourceReadConfidence")}complete;sources=new Map;constructor(e,n){this.complete=n;for(let i of e)this.sources.set(i.source.name,[...this.sources.get(i.source.name)??[],i])}static hasUnknownExtent(e){return e.some(n=>n.severity==="error"&&["PLAY0001","PLAY0503","PLAY0164"].includes(n.code))}resolve(e,n){let i=this.sources.get(e)??[],r=n===void 0?[]:i.flatMap(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",d=[];return i.length>1&&d.push("Multiple physical parent sources claim the exact name."),r.length>1&&d.push("Multiple physical streams claim the exact parent and local name."),i.some(p=>!p.placementResolved)&&d.push("A physical parent has unresolved import placement."),this.complete||d.push("Physical source extent or placement is incomplete; missing declarations cannot be excluded."),{state:a,sources:i.map(p=>p.source),streams:r,reasons:d}}};var Jm=ke("^[A-Za-z_]\\w*$"),rt=c((t,e)=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&t.kind===e,"hasKind"),X=c(t=>{throw new ue(t)},"refuse"),$t=c((t,e,n)=>{if(!Array.isArray(t))return X(n);for(let i=0;i<t.length;i++)rt(t[i],e)||X(n)},"collection");function rn(t){let e=mi(t);if(e!==void 0&&X(e),t.kind==="ConceptSyntax"){let n=t;for(let i of n.validations??[])i.kind==="DeclarativeValidateSyntax"&&i.rules.some(r=>r.implementation!=null)&&X("Implementation wrappers on named rules are supported only on commands.")}if(t.kind==="ValidationRuleSyntax"){let n=t;n.implementation!=null&&(rt(n.implementation,"ImplementationSyntax")||X("A named rule requires an ImplementationSyntax wrapper."),(n.rule!=="Rule"||n.value?.kind!=="PathExpressionSyntax"||!rt(n.value,"PathExpressionSyntax")||typeof n.value.path!="string"||Jm.exec(n.value.path)?.[0]!==n.value.path)&&X("An implementation wrapper requires a valid named rule."),n.file!=null&&n.code!=null&&X("A named rule has at most one file or inline payload."),n.file!=null&&(!rt(n.file,"FileReferenceSyntax")||typeof n.file.path!="string")&&X("A named rule file requires a FileReferenceSyntax payload with a string path."),n.code!=null&&(!rt(n.code,"CodeBlockSyntax")||typeof n.code.language!="string"||typeof n.code.code!="string")&&X("A named rule inline payload requires a CodeBlockSyntax with string language and code."),rn(n.implementation))}if(t.kind==="ProducesSyntax"){let n=t,i=n.inlineOperation;if(i!=null){n.inlineEvent!=null&&X("A production cannot declare both an event and an operation."),(n.when!=null||n.event!==i.name||n.for!=null||(n.tags??[]).length>0)&&X("An inline operation requires a matching unconditional target without event metadata."),$t(i.inputs,"PropertySyntax","Operation inputs must be a collection of properties."),$t(n.mappings,"PropertyMappingSyntax","Production mappings must be a collection of mappings."),i.inputs.length!==n.mappings.length&&X("Inline operation inputs and mappings must correspond in order.");for(let r=0;r<i.inputs.length;r++)i.inputs[r].name!==n.mappings[r].property&&X("Inline operation inputs and mappings must correspond in order.")}}if(t.kind==="OperationPhaseSyntax"){let n=t;n.file!=null&&n.code!=null&&X("An operation phase has at most one file or inline payload."),n.implementation!=null&&rn(n.implementation)}if(t.kind==="HandlerSyntax"){let n=t;n.implementation!=null&&n.file!=null&&n.code!=null&&X("A handler has at most one file or inline payload.")}if(t.kind==="ImplementationSyntax"){let n=t;$t(n.hints,"ImplementationHintSyntax","Implementation hints must be a collection of nonblank hints.");for(let i=0;i<n.hints.length;i++)rn(n.hints[i])}if(t.kind==="ImplementationHintSyntax"){let n=t;(typeof n.text!="string"||di(n.text))&&X("An implementation hint must be nonblank.")}Ao(t)}c(rn,"validateSyntaxInvariants");function Ao(t){let e=c(i=>{Tr(i)||X("Event source and stream names must be identifiers.")},"name"),n=c((i,r)=>{$t(r,"PropertyMappingSyntax","Stream id part mappings must be a collection."),i!==null&&r.length>0&&X("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&&$t(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()==="")&&X("A rename pin must be nonempty.");let r=i.kind==="EventSourceSyntax"?i.identifier:i.streamId;r!==null&&!rt(r,"TypeRefSyntax")&&X("Source identifiers and stream ids require type reference nodes."),r!==null&&(r.isCollection||r.isOptional)&&X("Source identifiers and stream ids require nonoptional scalar type references."),r!==null&&!li(r.name)&&X("Source identifiers and stream ids require an exact type reference name."),i.kind==="EventSourceSyntax"?$t(i.streams,"EventStreamSyntax","Event streams must contain event stream nodes without null elements."):($t(i.streamIdParts,"EventStreamIdPartSyntax","Stream id parts must be a collection."),i.streamId!==null&&i.streamIdParts.length>0&&X("A stream cannot declare both scalar and composite stream ids."),i.streamIdParts.forEach(o=>Ao(o)))}if(t.kind==="EventStreamIdPartSyntax"){let i=t;e(i.name),rt(i.type,"TypeRefSyntax")||X("A stream id part requires a type."),(i.type.isOptional||i.type.isCollection)&&X("Source identifiers and stream ids require nonoptional scalar type references."),li(i.type.name)||X("Source identifiers and stream ids require an exact type reference name.")}if(t.kind==="CommandSyntax"){let i=t;i.stream?.propertyCandidate!=null&&X("The authoritative command stream cannot contain an ambiguous property candidate."),i.stream!=null&&!rt(i.stream,"CommandStreamSyntax")&&X("The authoritative command stream must be a command stream node."),i.streamCandidates!==void 0&&$t(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(Ao(s),s.propertyCandidate===null&&i.stream==null&&X("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&&X("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&&X("An event occurrence cannot declare both stream and no stream."),i.stream!=null&&!rt(i.stream,"SpecificationStreamSyntax")&&X("A specification stream requires a specification stream node."),i.noStream!=null&&!rt(i.noStream,"SpecificationNoStreamSyntax")&&X("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"&&X("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"&&X("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)&&X("An ambiguous route must retain its exact unmodified property candidate, without selecting nested routing.")}}c(Ao,"validateSourceStream");var ut={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","CaseValueExpressionSyntax","ChildrenSyntax","ClaimConditionSyntax","ClaimIdentitySourceSyntax","CodeIdentitySourceSyntax","FileIdentitySourceSyntax","IdentitySyntax","IdentityDetailSyntax","QueryIdentitySourceSyntax","ClearMappingSyntax","ClearWithSyntax","CloseDialogActionSyntax","CodeBlockSyntax","ComponentExposedValueSyntax","ComponentOutletSyntax","ComponentPropertySyntax","CodeValidateSyntax","CommandSyntax","CommandStreamSyntax","ComparisonConditionSyntax","CompositeKeySyntax","ConceptAttributeSyntax","ConceptSyntax","ConcurrencySyntax","ConfirmActionSyntax","ContextExpressionSyntax","IdentityExpressionSyntax","ContributionSyntax","CountMappingSyntax","DeclarativeValidateSyntax","DecrementMappingSyntax","DialogTemplateSyntax","DomainSyntax","EnvironmentExpressionSyntax","EventContextExpressionSyntax","EventInteractionTriggerSyntax","EventSourceIdExpressionSyntax","EventSourceSyntax","EventStreamIdPartSyntax","EventStreamSyntax","EventSpecSyntax","EventSyntax","EverySyntax","ExecuteCommandActionSyntax","ExpressionKeySyntax","FeatureSyntax","FileConstraintSyntax","FileImportSyntax","FileReferenceSyntax","FormColumnSyntax","ExposureSyntax","ExposedPropertySyntax","InstanceContributionsSyntax","InstanceContributionSyntax","ContributedItemSyntax","ContributedItemValueSyntax","ScreenContributionSyntax","TemplateSlotContentSyntax","CommandFormLayoutSyntax","FormLayoutColumnSyntax","FormFieldPlacementSyntax","FormWidthSyntax","FormFieldSyntax","FormPopulateFromItemSyntax","FormPopulateViaQuerySyntax","FormSyntax","FromSyntax","HandlerSyntax","ImplementationSyntax","ImplementationHintSyntax","SystemSyntax","OperationSyntax","OperationPhaseSyntax","SpecificationExampleSyntax","SpecificationParameterSyntax","SpecificationCaseSyntax","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","PurposeSyntax","PurposeReferenceSyntax","PurposeTransferSyntax","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","SpecificationCallerPersonaSyntax","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","exposures","fileImports","identity","imports","instanceContributions","layouts","modules","personas","policies","purposes","seeds","sourceOptions","numericMode","systems","templates","themes","triggers","types","uiProfiles","triggerName","children","columns","gap","grow","rows","span","syntaxKind","height","root","width","growFactor","name","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","parameter","blocks","claim","matches","matchesSubject","code","details","by","query","arguments","onFailure","onResult","onSuccess","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","content","displayName","exposes","outlets","restrictsScopes","scopes","slots","templateType","usedBehaviors","eventName","id","identifier","streams","generation","hasGenerationMarker","origin","visibility","includeChildren","command","contributions","dependsOn","features","isPlacement","slices","additionalRules","ignoreCasing","releasedBy","pattern","owner","component","editableFields","isCollection","operations","reExposes","restrictsFields","instance","items","field","slot","columnGap","placements","rowGap","index","maxWidth","minWidth","column","columnSpan","row","rowSpan","unit","composeUsing","columnMode","fields","for","generationMode","layout","onSubmit","populate","events","parentKey","implementation","hints","text","compensate","execute","inputs","uses","generatedValues","noStream","operation","qualifiedName","actions","condition","alternatives","otherwise","trigger","amount","onRefused","acknowledge","constraint","selector","on","literalType","dialogTemplates","forms","screenTemplates","screen","operand","level","dialogTemplate","members","hidden","sizeHeight","sizeWidth","slotName","x","y","authorization","basis","basisReference","conditionReference","erasureException","interest","recipients","retention","subjects","transfers","destination","safeguard","inlineEvent","inlineOperation","readModel","sequence","entersOn","isGenerated","isIdentifier","isSubject","filters","isObservable","performer","returnType","where","data","invokes","member","severity","role","dayOfMonth","dayOfWeek","time","outcome","behavior","context","icon","presentation","stableId","outlet","route","target","rowClick","fitsSlot","eventSourceId","groups","captures","commands","constraints","direction","projections","queries","reactions","readModels","reducers","screens","specifications","contributes","authenticated","claims","roles","capture","record","instant","commandType","inlineProperty","caseValue","eventType","exactly","results","reaction","cases","given","givenCaller","givenCallerPersona","givenCaptures","givenClock","givenOperationFailures","givenReadModels","thenAbsentReadModels","thenCompensated","thenDenied","thenErrors","thenEvents","thenEventsInAnyOrder","thenNoEvents","thenNoResult","thenOperations","thenQueries","thenReadModels","thenResults","thenReturns","whenAppended","whenCapture","whenClock","whenQuery","whenRedelivered","whenTrigger","compatibleWith","isOptional","bindingKind","componentId","componentPropertyPath","expectedValueType","literal","nullBehavior","rawText","defaultSizeClass","icons","packages","platforms","theme","additionalProperties","rule","places"],rules:[["string"],["ref",26,27,52,53,60,61,63,120,121,133,135,160,163,206,227,231],["object",[[0,0,!0],[1,1,!0]]],["enum","Inherit","Disabled","Enabled"],["ref",0,36,55,57,107,199,228],["array",4],["object",[[2,3,!0],[3,5,!1]]],["ref",10],["null"],["union",7,8],["ref",14],["array",10],["ref",49],["array",12],["ref",59],["union",14,8],["ref",64],["array",16],["ref",100],["array",18],["ref",77],["array",20],["ref",74],["array",22],["ref",33],["union",24,8],["ref",106],["array",26],["ref",79],["array",28],["ref",119],["array",30],["union",31,8],["ref",125],["array",33],["ref",137],["array",35],["union",36,8],["ref",140],["array",38],["ref",141],["array",40],["ref",198],["array",42],["union",43,8],["enum","legacy","exact"],["object",[[22,45,!0]]],["ref",97],["array",47],["ref",200],["array",49],["ref",234],["array",51],["union",52,8],["ref",236],["array",54],["union",55,8],["ref",238],["array",57],["union",58,8],["ref",240],["array",60],["union",61,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,25,!1],[13,27,!1],[14,29,!1],[15,32,!1],[16,34,!1],[17,37,!1],[18,39,!1],[19,41,!1],[20,44,!1],[21,46,!1],[23,48,!1],[24,50,!1],[25,53,!1],[26,56,!1],[27,59,!1],[28,62,!1]]],["object",[[29,0,!0]]],["ref",4,6],["array",65],["integer",-2147483648,2147483647],["union",67,8],["number"],["union",69,8],["enum","Flat","Row","Column","Grid"],["object",[[30,66,!1],[31,68,!1],[32,68,!1],[33,70,!1],[34,68,!1],[35,68,!1],[36,71,!0]]],["union",0,8],["object",[[37,73,!1],[38,65,!0],[39,73,!1]]],["boolean"],["object",[[33,75,!1],[40,70,!1],[37,68,!1],[41,0,!0],[35,68,!1],[39,68,!1]]],["enum","Flow","Freeform"],["ref",5],["array",78],["union",79,8],["union",65,8],["ref",246],["array",82],["union",83,8],["object",[[42,77,!0],[43,80,!1],[38,81,!1],[44,84,!1]]],["object",[]],["object",[[45,73,!1],[41,0,!0]]],["ref",9],["array",88],["object",[[46,89,!1]]],["ref",124,139],["object",[[47,91,!0]]],["object",[[41,0,!0],[1,0,!0]]],["ref",237],["union",94,8],["object",[[41,0,!0],[48,95,!1]]],["ref",111],["array",97],["ref",75],["union",99,8],["ref",13],["array",101],["object",[[49,98,!1],[50,73,!1],[51,100,!1],[41,73,!1],[52,68,!1],[53,102,!1]]],["enum","Click","DoubleClick","Select","Submit","Change","Load","Unload","Enter","Leave","Unknown"],["object",[[36,104,!0]]],["ref",149],["array",106],["ref",229],["array",108],["union",109,8],["ref",25],["union",111,8],["object",[[54,0,!0],[3,107,!1],[55,110,!1],[56,112,!1]]],["ref",16],["array",114],["ref",18,22],["array",116],["object",[[57,115,!1],[58,0,!0],[59,117,!1],[0,0,!0]]],["ref",24],["array",119],["object",[[0,0,!0],[60,1,!0],[61,120,!1]]],["object",[[57,115,!1],[59,117,!1],[0,0,!0]]],["ref",20],["array",123],["object",[[62,124,!1],[36,0,!0]]],["array",0],["object",[[63,0,!0],[60,1,!0],[64,126,!1]]],["ref",17],["array",128],["ref",19],["array",130],["ref",21],["union",132,8],["object",[[57,115,!1],[30,129,!1],[65,73,!1],[59,117,!1],[41,0,!0],[66,131,!1],[60,133,!1],[21,46,!1]]],["object",[[67,0,!0],[68,0,!0]]],["enum","PropertyChanged","Added","Removed","Changed","LogicalOr","LogicalAnd","ValueTransition","Expression"],["object",[[69,73,!1],[70,73,!1],[71,126,!1],[36,136,!0],[72,73,!1]]],["object",[[0,73,!1]]],["object",[[73,0,!0]]],["ref",1,28,37,69,93,117,129,147,169,170],["array",140],["object",[[2,3,!0],[74,141,!1],[58,1,!0],[0,0,!0]]],["union",1,8],["object",[[75,0,!0],[76,143,!1],[77,75,!0]]],["object",[[75,0,!0]]],["ref",39],["object",[[78,146,!0]]],["object",[[51,99,!0]]],["ref",34],["array",149],["object",[[50,73,!1],[79,150,!1]]],["ref",30,31,32,35],["object",[[41,0,!0],[60,152,!0],[48,94,!0]]],["object",[[80,1,!0],[81,0,!0]]],["object",[[0,0,!0]]],["object",[[54,0,!0]]],["ref",110],["array",157],["ref",38,51,70,127,128,131,132,159,168,203],["array",159],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[78,0,!0],[86,0,!0]]],["ref",239],["object",[[87,163,!0],[41,0,!0]]],["ref",174,176,179,180,181,183,185,186,187,188,190,191,193,194,195],["array",165],["object",[[88,166,!1],[41,0,!0]]],["union",163,8],["object",[[87,168,!1],[0,0,!0],[1,143,!1]]],["ref",11],["union",170,8],["ref",50],["union",172,8],["ref",94],["union",174,8],["ref",144],["array",176],["ref",150],["array",178],["ref",165],["array",180],["union",181,8],["ref",153,154],["union",183,8],["ref",45],["union",185,8],["array",185],["ref",43,56],["array",188],["object",[[89,171,!1],[90,173,!1],[50,73,!1],[91,73,!1],[92,175,!1],[41,0,!0],[93,177,!1],[71,179,!1],[94,182,!1],[95,184,!1],[96,186,!1],[97,187,!1],[98,189,!1]]],["union",178,8],["union",106,8],["object",[[99,0,!0],[100,191,!1],[96,0,!0],[101,192,!1],[102,107,!1]]],["enum","Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Contains","StartsWith"],["object",[[103,0,!0],[104,194,!0],[105,1,!0]]],["ref",118],["array",196],["object",[[106,197,!1],[48,0,!0]]],["object",[[107,75,!1],[41,0,!0],[108,73,!1],[109,73,!1],[110,73,!1]]],["ref",48],["array",200],["union",189,8],["object",[[111,201,!1],[50,73,!1],[51,100,!1],[41,0,!0],[48,0,!0],[98,202,!1],[112,126,!1]]],["object",[[99,75,!0],[113,73,!1],[114,73,!1],[115,73,!1],[116,126,!1]]],["object",[[82,158,!1],[117,0,!0],[118,75,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[119,0,!0]]],["ref",185],["union",207,8],["object",[[120,0,!0],[121,73,!1],[122,208,!1],[52,68,!1]]],["ref",171],["array",210],["union",211,8],["ref",245],["array",213],["object",[[123,212,!1],[124,214,!1]]],["ref",7],["union",216,8],["ref",84],["array",218],["ref",201],["array",220],["ref",202],["array",222],["ref",205],["array",224],["ref",244],["array",226],["object",[[125,217,!1],[5,11,!1],[126,73,!1],[127,219,!1],[50,73,!1],[128,73,!1],[129,221,!1],[41,0,!0],[130,223,!1],[131,75,!1],[132,126,!1],[133,225,!1],[134,73,!1],[135,227,!1]]],["object",[[41,0,!0]]],["object",[[136,0,!0]]],["ref",66],["array",231],["object",[[50,73,!1],[137,73,!1],[138,95,!1],[41,0,!0],[139,232,!1]]],["object",[[41,0,!0],[48,94,!0]]],["ref",65],["array",235],["object",[[50,73,!1],[137,73,!1],[41,0,!0],[101,95,!1],[102,236,!1]]],["object",[[54,0,!0],[65,143,!1]]],["integer",0,4294967295],["enum","Private","Public"],["object",[[50,73,!1],[91,73,!1],[51,100,!1],[140,239,!1],[141,75,!1],[137,73,!1],[41,0,!0],[142,73,!1],[71,179,!1],[55,110,!1],[143,240,!1]]],["object",[[2,3,!0],[144,75,!0],[3,5,!1]]],["object",[[82,158,!1],[145,0,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[69,1,!0]]],["ref",54],["array",245],["union",246,8],["ref",243],["array",248],["ref",72],["array",250],["ref",142],["array",252],["ref",204],["array",254],["object",[[89,171,!1],[5,11,!1],[146,247,!1],[147,249,!1],[50,73,!1],[91,73,!1],[9,19,!1],[148,251,!1],[11,23,!1],[149,75,!0],[41,0,!0],[19,253,!1],[150,255,!1],[24,50,!1],[135,227,!1]]],["ref",73,241,242],["array",257],["object",[[151,258,!1],[50,73,!1],[51,99,!0],[152,75,!0],[117,73,!1],[41,0,!0],[153,126,!1]]],["object",[[154,0,!0]]],["object",[[121,73,!1],[0,0,!0]]],["ref",78],["array",262],["object",[[155,0,!0],[71,263,!1]]],["object",[[156,0,!0],[157,126,!1],[158,75,!0],[121,73,!1],[159,126,!1],[119,0,!0],[160,73,!1],[161,75,!0]]],["ref",80],["array",266],["object",[[146,267,!1],[162,0,!0]]],["ref",81],["array",269],["object",[[156,0,!0],[163,270,!1],[119,0,!0],[1,143,!1]]],["ref",82],["array",272],["object",[[137,0,!0],[112,273,!1]]],["object",[[164,0,!0],[1,1,!0]]],["object",[[120,0,!0],[88,166,!1],[52,68,!1]]],["object",[[88,166,!1],[165,0,!0]]],["ref",88],["union",278,8],["ref",86],["array",280],["ref",87],["array",282],["object",[[166,279,!1],[31,281,!1],[167,283,!1],[168,279,!1]]],["object",[[169,67,!0],[170,279,!1],[171,279,!1],[39,279,!1]]],["object",[[172,67,!0],[173,68,!1],[164,0,!0],[174,67,!0],[175,68,!1],[39,279,!1]]],["enum","Fraction","Pixels","Percent","Auto"],["object",[[176,287,!0],[1,70,!1]]],["object",[[177,73,!1],[67,73,!1],[121,73,!1],[0,0,!0]]],["object",[[80,73,!1],[81,0,!0]]],["enum","Unspecified","Auto","Manual"],["ref",76],["array",292],["ref",89],["array",294],["ref",85],["union",296,8],["ref",90,91],["union",298,8],["object",[[5,11,!1],[178,291,!0],[31,293,!1],[50,73,!1],[179,295,!1],[180,0,!0],[181,291,!0],[182,297,!1],[41,0,!0],[183,208,!1],[184,299,!1],[135,227,!1]]],["ref",67],["array",301],["ref",47,71],["union",303,8],["object",[[185,302,!1],[65,304,!1],[3,5,!1],[186,143,!1]]],["union",146,8],["ref",95],["union",307,8],["object",[[78,306,!1],[51,100,!1],[187,308,!1]]],["ref",96],["array",310],["object",[[188,311,!1]]],["object",[[189,0,!0]]],["object",[[50,73,!1],[41,0,!0]]],["ref",99],["union",315,8],["object",[[190,316,!1],[50,73,!1],[191,316,!1],[192,179,!1],[41,0,!0],[193,0,!0]]],["object",[[78,306,!1],[50,73,!1],[51,100,!1],[187,308,!1]]],["ref",219],["union",319,8],["ref",218],["union",321,8],["object",[[50,73,!1],[180,143,!1],[194,107,!1],[41,0,!0],[195,320,!1],[96,322,!1],[48,0,!0],[112,107,!1]]],["object",[[41,0,!0],[112,107,!1]]],["object",[[196,0,!0]]],["object",[[196,0,!0],[112,107,!1]]],["object",[[142,73,!1],[197,0,!0],[143,240,!1]]],["ref",46,122],["object",[[198,160,!1],[199,328,!0]]],["object",[[198,160,!1]]],["object",[[87,0,!0],[41,0,!0]]],["ref",108],["array",332],["ref",109],["union",334,8],["ref",3,15,62,112],["object",[[198,160,!1],[200,333,!1],[199,73,!1],[201,335,!1],[202,336,!0]]],["enum","Seconds","Minutes","Hours","Days"],["object",[[203,67,!0],[176,338,!0]]],["ref",115],["array",340],["object",[[145,0,!0],[3,107,!1],[204,341,!1]]],["object",[[205,75,!0],[206,73,!1],[93,177,!1],[207,0,!0]]],["object",[[2,3,!0],[54,0,!0],[3,5,!1]]],["ref",116],["array",345],["object",[[185,346,!1],[208,0,!0],[0,0,!0]]],["object",[[69,1,!0],[0,0,!0]]],["object",[[125,217,!1],[5,11,!1],[126,73,!1],[129,221,!1],[41,0,!0],[130,223,!1],[131,75,!1],[132,126,!1],[133,225,!1],[134,73,!1],[135,227,!1]]],["array",1],["object",[[163,350,!1]]],["union",0,75,8],["number",-17976931348623157e292,17976931348623157e292],["enum","Int32","Int64","Decimal","Single"],["string","^-?[0-9]+(\\.[0-9]+)?([Ee][+-]?[0-9]+)?$"],["object",[[209,354,!0],[1,355,!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",[[209,357,!0],[1,358,!0]]],["union",352,353,356,359],["object",[[1,360,!1]]],["enum","And","Or"],["object",[[103,328,!0],[104,362,!0],[105,328,!0]]],["ref",8,29,123,130,172],["object",[[103,364,!0],[104,362,!0],[105,364,!0]]],["object",[[103,91,!0],[104,362,!0],[105,91,!0]]],["ref",58],["array",367],["union",368,8],["ref",92],["array",370],["union",371,8],["ref",192],["array",373],["object",[[89,171,!1],[5,11,!1],[146,247,!1],[147,249,!1],[50,73,!1],[210,369,!1],[91,73,!1],[9,19,!1],[148,251,!1],[11,23,!1],[211,372,!1],[149,75,!0],[41,0,!0],[19,253,!1],[212,374,!1],[24,50,!1],[135,227,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[213,0,!0]]],["object",[[2,3,!0],[74,141,!1],[0,0,!0]]],["object",[[214,364,!0]]],["enum","Info","Warning","Error","Unknown"],["object",[[82,158,!1],[215,379,!0],[117,0,!0],[118,75,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["object",[[82,158,!1],[216,0,!0],[83,160,!1],[84,160,!1],[85,160,!1]]],["ref",134],["array",382],["object",[[217,383,!1]]],["object",[[41,0,!0],[1,1,!0]]],["object",[[78,306,!1],[51,100,!1]]],["object",[[50,73,!1],[41,0,!0],[18,126,!1]]],["object",[[218,75,!1],[219,73,!1],[220,73,!1],[221,0,!0],[222,68,!1],[223,68,!1]]],["union",364,8],["object",[[78,306,!1],[199,389,!1],[50,73,!1],[51,100,!1],[41,0,!0]]],["ref",143],["array",391],["object",[[224,73,!1],[225,73,!1],[226,73,!1],[199,73,!1],[227,73,!1],[50,73,!1],[228,73,!1],[229,73,!1],[41,0,!0],[230,126,!1],[231,73,!1],[232,126,!1],[233,392,!1]]],["object",[[234,0,!0],[235,0,!0]]],["ref",68],["union",395,8],["ref",98],["union",397,8],["union",328,8],["object",[[54,0,!0],[180,143,!1],[236,396,!1],[237,398,!1],[3,107,!1],[55,110,!1],[56,399,!1]]],["object",[[2,3,!0],[74,141,!1],[50,73,!1],[51,100,!1],[65,304,!1],[41,0,!0],[238,73,!1],[239,73,!1],[21,46,!1]]],["ref",145],["array",402],["object",[[74,141,!1],[240,403,!1],[41,0,!0]]],["object",[[0,0,!0],[60,1,!0]]],["object",[[241,75,!1],[242,75,!1],[243,75,!1],[41,0,!0],[48,94,!0]]],["ref",151],["object",[[41,0,!0],[60,407,!0],[48,95,!1]]],["object",[[60,407,!0]]],["ref",152],["array",410],["object",[[179,411,!1]]],["object",[[1,1,!0]]],["object",[[179,107,!1]]],["object",[[41,0,!0],[60,143,!1],[48,94,!0]]],["ref",157],["union",416,8],["array",416],["ref",136],["union",419,8],["object",[[89,171,!1],[80,417,!1],[50,73,!1],[244,418,!1],[245,75,!1],[41,0,!0],[246,420,!1],[247,94,!0],[109,73,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[202,0,!0]]],["ref",162],["array",423],["object",[[50,73,!1],[91,73,!1],[41,0,!0],[26,424,!1],[248,399,!1]]],["ref",235],["array",426],["ref",114],["array",428],["union",429,8],["union",177,8],["ref",113,126,173],["object",[[78,306,!1],[249,427,!1],[50,73,!1],[51,100,!1],[250,430,!1],[93,431,!1],[94,182,!1],[60,432,!0]]],["object",[[251,0,!0]]],["object",[[50,73,!1],[91,73,!1],[51,100,!1],[41,0,!0],[71,179,!1]]],["object",[[45,73,!1],[80,73,!1],[238,0,!0]]],["object",[[78,306,!1],[50,73,!1],[54,0,!0],[51,100,!1]]],["ref",166],["array",438],["object",[[50,73,!1],[41,0,!0],[238,0,!0],[124,439,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[81,0,!0]]],["object",[[54,0,!0],[65,143,!1],[186,143,!1]]],["enum","Error","Information","Warning"],["object",[[199,328,!0],[117,73,!1],[252,443,!0]]],["object",[[253,0,!0]]],["enum","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],["union",446,8],["string","^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]{1,7})?$"],["object",[[254,68,!1],[255,447,!1],[256,448,!0]]],["object",[[145,0,!0],[121,73,!1],[122,208,!1]]],["ref",177],["array",451],["ref",178],["union",453,8],["object",[[200,452,!1],[121,0,!0],[122,208,!1],[201,454,!1]]],["object",[[82,158,!1],[145,0,!0],[199,328,!0]]],["enum","Hidden","Execute","Unknown"],["object",[[82,158,!1],[145,73,!1],[257,457,!0]]],["object",[[258,10,!0]]],["ref",40],["array",460],["ref",41],["array",462],["ref",148],["array",464],["ref",42],["array",466],["object",[[5,11,!1],[156,0,!0],[259,168,!1],[129,461,!1],[260,73,!1],[41,0,!0],[130,463,!1],[261,465,!1],[71,467,!1],[262,73,!1],[135,227,!1]]],["object",[[80,73,!1],[81,0,!0],[48,94,!0]]],["object",[[121,0,!0],[0,0,!0]]],["ref",175],["array",471],["object",[[80,73,!1],[263,73,!1],[53,472,!1],[264,73,!1],[213,0,!0]]],["ref",184],["array",474],["object",[[179,475,!1],[265,0,!0]]],["ref",83],["array",477],["object",[[146,478,!1],[50,73,!1],[88,166,!1],[51,100,!1],[41,0,!0]]],["ref",182],["array",480],["object",[[5,11,!1],[31,481,!1],[266,208,!1],[265,0,!0],[135,227,!1]]],["ref",187],["array",483],["object",[[41,0,!0],[133,484,!1]]],["object",[[125,217,!1],[5,11,!1],[126,73,!1],[127,219,!1],[50,73,!1],[128,73,!1],[129,221,!1],[267,73,!1],[41,0,!0],[130,223,!1],[131,75,!1],[132,126,!1],[133,225,!1],[134,73,!1],[135,227,!1]]],["ref",230],["array",487],["object",[[163,488,!1],[41,0,!0]]],["object",[[193,226,!0]]],["object",[[54,0,!0],[71,107,!1]]],["ref",196],["array",492],["object",[[268,0,!0],[185,493,!1]]],["ref",197],["array",495],["object",[[269,496,!1]]],["object",[[82,158,!1],[83,160,!1],[84,160,!1],[85,160,!1],[265,0,!0],[1,0,!0]]],["ref",23],["array",499],["ref",44],["array",501],["enum","Inbound","Outbound"],["union",503,8],["array",395],["array",397],["ref",146],["array",507],["ref",158],["array",509],["ref",161],["array",511],["ref",164],["array",513],["union",514,8],["ref",167],["array",516],["union",517,8],["ref",189],["array",519],["ref",224],["array",521],["enum","StateChange","StateView","Automation","Translate"],["object",[[270,500,!1],[271,502,!1],[272,258,!1],[50,73,!1],[273,504,!1],[91,73,!1],[185,505,!1],[9,19,!1],[51,100,!1],[41,0,!0],[159,506,!1],[274,508,!1],[19,253,!1],[275,510,!1],[276,512,!1],[277,515,!1],[278,518,!1],[279,520,!1],[280,522,!1],[24,50,!1],[48,523,!0]]],["object",[[281,73,!1],[41,0,!0]]],["object",[[65,1,!0],[41,0,!0]]],["object",[[48,0,!0],[1,0,!0]]],["ref",208],["array",528],["object",[[282,75,!0],[283,529,!1],[284,126,!1]]],["object",[[285,0,!0],[286,107,!1]]],["object",[[287,0,!0]]],["object",[[288,0,!0],[180,143,!1],[194,107,!1],[289,73,!1],[112,107,!1]]],["ref",27],["union",534,8],["object",[[290,535,!1],[41,73,!1]]],["object",[[291,0,!0],[180,143,!1],[289,73,!1],[195,320,!1],[96,322,!1],[112,107,!1]]],["object",[[99,0,!0],[96,0,!0],[101,192,!1],[102,107,!1]]],["object",[[292,75,!0],[71,107,!1]]],["ref",220],["array",540],["object",[[82,107,!1],[292,75,!0],[81,0,!0],[293,541,!1]]],["object",[[292,75,!0],[289,73,!1],[41,0,!0],[71,107,!1]]],["object",[[291,0,!0],[180,143,!1],[195,320,!1],[294,0,!0],[96,322,!1],[112,107,!1]]],["ref",102],["array",545],["ref",216],["array",547],["ref",210],["union",549,8],["ref",209],["union",551,8],["ref",211],["array",553],["ref",212],["union",555,8],["ref",103],["array",557],["ref",222],["array",559],["union",560,8],["ref",101],["array",562],["ref",207],["array",564],["ref",105],["array",566],["ref",214],["union",568,8],["ref",215],["array",570],["ref",217],["union",572,8],["ref",104],["array",574],["ref",221],["array",576],["ref",155,156],["union",578,8],["ref",213],["union",580,8],["union",547,8],["union",553,8],["ref",226],["union",584,8],["ref",223],["union",586,8],["ref",225],["union",588,8],["object",[[295,546,!1],[50,73,!1],[9,19,!1],[51,100,!1],[296,548,!1],[297,550,!1],[298,552,!1],[299,554,!1],[300,556,!1],[301,558,!1],[302,561,!1],[41,0,!0],[53,563,!1],[21,46,!1],[303,565,!1],[304,567,!1],[305,569,!1],[306,571,!1],[307,548,!1],[308,75,!0],[309,75,!1],[310,573,!1],[311,575,!1],[312,577,!1],[313,561,!1],[314,541,!1],[315,579,!1],[56,581,!1],[316,582,!1],[317,583,!1],[318,556,!1],[319,585,!1],[320,587,!1],[321,589,!1]]],["object",[[202,0,!0],[112,107,!1]]],["object",[[82,107,!1],[81,0,!0]]],["object",[[65,0,!0]]],["enum","Unknown","Action","Navigate","Dialog"],["object",[[260,73,!1],[121,73,!1],[41,0,!0],[53,472,!1],[261,465,!1],[36,594,!0],[265,0,!0]]],["ref",232,233],["array",596],["object",[[106,597,!1]]],["object",[[322,126,!1],[41,0,!0]]],["object",[[249,427,!1],[50,73,!1],[51,100,!1],[41,0,!0]]],["object",[[158,75,!0],[323,75,!0],[41,0,!0]]],["object",[[50,73,!1],[51,100,!1],[41,0,!0],[71,179,!1]]],["enum","Invalid","DataContext","QueryResult","ComponentProperty","Literal"],["enum","OneWay","TwoWay"],["union",604,8],["enum","Propagate","Clear","Preserve"],["union",606,8],["object",[[324,603,!0],[325,73,!1],[326,73,!1],[327,73,!1],[328,143,!1],[42,605,!1],[329,607,!1],[119,0,!0],[81,73,!1],[330,73,!1]]],["object",[[331,73,!1],[332,126,!1],[182,73,!1],[41,0,!0],[333,126,!1],[334,126,!1],[335,73,!1]]],["object",[[151,258,!1],[50,73,!1],[54,0,!0],[152,75,!0],[117,73,!1],[41,0,!0],[153,126,!1]]],["object",[[336,126,!1],[151,258,!1],[50,73,!1],[54,0,!0],[152,75,!0],[117,73,!1],[41,0,!0],[0,0,!0],[153,126,!1]]],["object",[[265,0,!0]]],["ref",12],["array",613],["object",[[82,614,!1],[258,0,!0]]],["enum","NotEmpty","Max","Min","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Equal","Length","Matches","AllGreaterThan","AllGreaterThanOrEqual","Rule","NotEqual"],["object",[[78,306,!1],[51,100,!1],[187,308,!1],[117,73,!1],[0,0,!0],[337,616,!0],[252,443,!0],[1,143,!1]]],["ref",138],["array",618],["object",[[37,0,!0],[338,619,!1],[39,0,!0]]]],contracts:[2,6,63,64,72,74,76,85,86,87,90,92,93,96,103,105,113,118,121,122,93,125,127,134,135,137,138,139,142,144,145,147,148,151,153,154,155,156,161,162,164,167,169,147,190,193,195,198,199,203,204,205,206,206,209,155,215,155,228,229,229,206,230,86,233,234,237,238,241,242,243,244,256,259,260,206,261,264,265,268,271,274,275,276,277,284,285,286,288,289,86,290,300,305,309,312,313,314,317,318,323,234,324,325,326,325,327,155,329,330,331,337,339,339,342,343,344,347,348,349,351,361,363,365,366,375,229,376,161,377,378,380,381,384,385,206,386,387,388,229,390,393,229,394,400,238,401,404,93,405,406,155,408,409,412,413,414,415,421,422,313,425,433,434,435,436,437,440,441,238,442,444,445,449,450,164,455,456,458,459,147,468,261,469,470,473,167,167,476,479,482,485,486,313,489,490,491,494,497,405,229,96,229,498,524,525,206,526,527,229,530,531,532,533,86,536,537,86,538,86,539,542,543,544,590,591,592,593,2,413,595,598,244,313,599,96,600,601,602,608,609,610,611,612,615,617,620]};var wo=ut.rules,Hm=new Map(wo.flatMap(([t,e],n)=>t==="string"&&typeof e=="string"?[[n,new RegExp(e,"u")]]:[])),sl=new Map(ut.kinds.map((t,e)=>[t,wo[ut.contracts[e]][1]])),Xm=new Map([...sl].map(([t,e])=>[t,new Set(["kind",...e.map(([n])=>ut.names[n])])])),al=c(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"object");function Io(t){let e=sl.get(t.kind);if(!Object.hasOwn(t,"kind")||e===void 0||!ll(t,e))throw new ue(`Invalid typed members for syntax kind '${t.kind}'.`)}c(Io,"validateSyntaxMembers");function Zi(t,e){let n=Ki(t.kind);for(let i of Object.keys(t))if(!n.has(i)&&!e.has(i))throw new ue(`Unknown member '${i}' for syntax kind '${t.kind}'.`)}c(Zi,"validateClosedSyntaxMembers");function Ki(t){let e=Xm.get(t);if(e===void 0)throw new ue(`Unknown syntax kind '${t}'.`);return e}c(Ki,"syntaxMemberNames");function ll(t,e){return e.every(([n,i,r])=>Object.hasOwn(t,ut.names[n])?Oo(t[ut.names[n]],i):!r)}c(ll,"matchesMembers");function ey(t,e){for(let n=0;n<t.length;n++)if(!Object.hasOwn(t,n)||!Oo(t[n],e))return!1;return!0}c(ey,"allIndicesMatch");function Oo(t,e){let[n,...i]=wo[e];switch(n){case"ref":return al(t)&&typeof t.kind=="string"&&i.some(r=>ut.kinds[r]===t.kind);case"union":case"one":{let r=i.reduce((o,s)=>o+(Oo(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)&&ey(t,i[0]);case"object":return al(t)&&Object.keys(t).every(r=>i[0].some(([o])=>ut.names[o]===r))&&ll(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||Hm.get(e).test(t));default:return n==="boolean"&&typeof t=="boolean"}}c(Oo,"matches");var ty=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(","))])),ny=/^(?:Set|Clear|Increment|Decrement|Count|Add|Subtract)MappingSyntax$/;function iy(t,e){return ty[t]?.has(e)===!0||ny.test(t)&&(e==="source"||e==="value")}c(iy,"isExactOnlyMember");function cl(t,e){return t.kind==="SpecificationSyntax"&&e==="givenCaller"?t.givenCaller==null:iy(t.kind,e)||t.kind==="ValidationRuleSyntax"&&t.implementation==null&&(e==="code"||e==="file"||e==="implementation")}c(cl,"isLegacyOmittedMember");var Hi=c(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string","isNode"),Ji=new Set(["kind","location","targetLocation","referenceLocation","referenceLength","nameWasEscaped","declaredTriggers","directiveLocations"]),Xi=new Set(["ApplicationSyntax","ProjectionSyntax","CaptureSyntax","SpecificationSyntax"]);function tr(t){let e=ry(t);return To(e,"legacy",0),er(e)}c(tr,"toSyntaxJson");function ry(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 d=dl();e.set(o,d);let p=o.length;for(let m=p-1;m>=0;m--)n.push(()=>{d[m]=i(Object.hasOwn(o,m)?o[m]:void 0)});return d}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 d=a.length-1;d>=0;d--)n.push(()=>{let p=a[d],m=o[p];p==="sourceOptions"&&n.push(()=>{typeof m=="object"&&m!==null&&(Object.getPrototypeOf(m)!==Object.prototype&&Object.getPrototypeOf(m)!==null||Reflect.ownKeys(m).length!==Object.keys(m).length)&&(s[p]=Object.assign(Object.create(null),{numericMode:"invalid"}))}),s[p]=i(m)});return s}c(i,"detach");let r=i(t);for(;n.length>0;)n.pop()();return r}c(ry,"snapshot");function dl(){let t=[];return Object.defineProperty(t,"toJSON",{value:void 0}),t}c(dl,"dataArray");function er(t,e="legacy",n=!1){if(Array.isArray(t)){let o=dl();for(let s=0;s<t.length;s++)o.push(er(t[s],e,n));return o}if(Hi(t)){if(Xi.has(t.kind)&&(e=_t(t.sourceOptions??Ue).numericMode),rn(t),(t.kind==="ImplementationSyntax"||t.kind==="ImplementationHintSyntax")&&Zi(t,Ji),t.kind==="ValidationRuleSyntax"){let p=t;p.implementation!=null&&(p.file!=null&&Zi(p.file,Ji),p.code!=null&&Zi(p.code,Ji))}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"?Ki(t.kind):void 0,d=Object.keys(s).filter(p=>(a===void 0||a.has(p))&&!(e==="legacy"&&!n&&cl(t,p))&&!Ji.has(p)&&!(t.kind==="OperationSyntax"&&p==="usesLocation")).sort(oy);for(let p of d){let m=s[p];t.kind==="ApplicationSyntax"&&p==="identity"&&m==null||(t.kind==="EventSyntax"||t.kind==="ImportSyntax")&&(p==="visibility"&&m==="Private"||p==="origin"&&m==null)||t.kind==="SliceSyntax"&&p==="direction"&&m==null||t.kind==="ConceptAttributeSyntax"&&(p==="scope"||p==="specialCategory")&&m==null||t.kind==="ConceptAttributeSyntax"&&p==="criminal"&&m===!1||t.kind==="PropertySyntax"&&p==="isSubject"&&m===!1||p==="description"&&m==null&&["ConceptSyntax","PolicySyntax","FileConstraintSyntax","UniqueEventConstraintSyntax","UniquePropertyConstraintSyntax","ProjectionSyntax","ScreenSyntax","FormSyntax"].includes(t.kind)||p==="documentation"&&t.kind!=="EventSyntax"&&m==null||t.kind==="SpecificationSyntax"&&p==="description"&&m==null||p==="dependsOn"&&(t.kind==="ModuleSyntax"||t.kind==="FeatureSyntax")&&Array.isArray(m)&&m.length===0||p==="sourceOptions"&&m?.numericMode==="legacy"||(p==="examples"||t.kind==="SpecificationSyntax"&&(p==="parameters"||p==="cases"))&&Array.isArray(m)&&m.length===0||t.kind==="SpecificationErrorSyntax"&&p==="caseValue"&&m==null||p==="purposes"&&Array.isArray(m)&&m.length===0||p==="inlineProperty"&&m==null||(t.kind==="SpecificationExampleSyntax"||t.kind==="SpecificationRedeliverySyntax")&&(p==="stream"||p==="noStream")&&m==null||t.kind==="SpecificationSyntax"&&p==="thenNoEvents"&&m===!1||t.kind==="SpecificationSyntax"&&p==="whenRedelivered"&&m==null||t.kind==="InvokesSyntax"&&p==="onRefused"&&Array.isArray(m)&&m.length===0||(o[p]=er(m,e,n))}return o}if(t===void 0)return null;if(typeof t!="object"||t===null)return t;let i=t,r=Object.create(null);if(i.literalType==="ExactNumber")return r.literalType="ExactNumber",r.value=i.value,r;for(let o of Object.keys(i))o!=="toJSON"&&i[o]!==void 0&&(r[o]=er(i[o],e,n));return r}c(er,"write");function To(t,e,n){if(n>96&&e==="exact")throw new ue("Syntax nesting exceeds the supported depth of 96.");if(Array.isArray(t)){for(let o=0;o<t.length;o++)To(t[o],e,n+1);return}if(typeof t!="object"||t===null)return;let i=t;if(Xi.has(i.kind)||Object.hasOwn(i,"sourceOptions")){let o=Object.hasOwn(i,"sourceOptions")?_t(i.sourceOptions):Ue;if(n>0&&e!==o.numericMode)throw new ue("Conflicting source numeric options.");e=o.numericMode}if(n===0&&e==="exact"&&!Xi.has(i.kind))throw new ue("Exact syntax requires a complete source root.");if(e==="exact"&&Hi(i)&&Io(i),i.kind==="RawExpressionSyntax"&&e==="exact"&&typeof i.text=="string"&&un(i.text))throw new ue("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 ue("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"||at(o.value)?.value!==o.value||Object.keys(o).length!==2)throw new ue("Malformed or incompatible ExactNumber literal.")}else if(e==="exact")throw new ue("Exact source refuses old or plain object literal insertion.")}}let r=e==="exact"&&Hi(i)?Ki(i.kind):void 0;for(let[o,s]of Object.entries(i))(r===void 0||r.has(o)||Hi(s)&&Xi.has(s.kind))&&o!=="location"&&o!=="targetLocation"&&o!=="usesLocation"&&To(s,e,n+1)}c(To,"validateNumbers");function oy(t,e){return t<e?-1:t>e?1:0}c(oy,"ordinal");function ul(t){let e=[],n=t.map($=>$.value),i=new Map,r=!1;for(let $ of n)try{i.set($,Object.hasOwn($,"sourceOptions")?_t($.sourceOptions):Ue)}catch(g){if(!(g instanceof ue))throw g;r=!0,e.push(jn(l.IncompatibleNumericSource,g.message,$.location))}let o=n.filter($=>i.get($)?.numericMode==="exact"||ay($)),s=i.get(o[0])??Ue;for(let $ of o.slice(1))i.get($)?.numericMode!==s.numericMode&&(r=!0,e.push(jn(l.MixedNumericModes,"Declaration-bearing documents and marked import barrels must independently select the same numeric mode.",$.location)));r&&(s=ka);let a=new Map,d=Ln(n.flatMap($=>$.concepts),"declaration of",e,void 0,a),p=Ln(n.flatMap($=>$.types),"declaration of",e,void 0,a),m=n.flatMap($=>$.identity==null?[]:[$.identity]);for(let $ of m.slice(1))e.push(jn(l.RepeatedSingularDeclarationAcrossFiles,`The folder already declares an identity block in '${on(m[0].location.path)}' - a folder compiles to one application, which can have at most one`,$.location));let u=n.map($=>$.domain).filter($=>$!==null);for(let $ of u.slice(1))e.push(jn(l.RepeatedSingularDeclarationAcrossFiles,`The folder already declares a domain in '${on(u[0].location.path)}' - a folder compiles to one application, which can have at most one`,$.location));let y=sy(n.flatMap($=>$.modules),e),h=Ln(n.flatMap($=>$.personas),"persona",e),x={kind:"ApplicationSyntax",sourceOptions:s,...m.length===0?{}:{identity:m[0]},domain:u[0]??null,imports:Do(n.flatMap($=>$.imports),$=>$.qualifiedName),concepts:d,types:p,examples:n.flatMap($=>$.examples??[]),systems:n.flatMap($=>$.systems??[]),purposes:Ln(n.flatMap($=>$.purposes??[]),"purpose",e),eventSources:n.flatMap($=>$.eventSources??[]),declaredTriggers:n.flatMap($=>$.declaredTriggers??[]),modules:y,personas:h,policies:n.flatMap($=>$.policies??[]),seeds:n.flatMap($=>$.seeds??[]),fileImports:n.flatMap($=>$.fileImports),...pl("exposures",n.flatMap($=>$.exposures??[])),...pl("instanceContributions",n.flatMap($=>$.instanceContributions??[])),location:n[0]?.location??{line:1,column:1}},b=new me(new Ne([]));zn(x,b),e.push(...b.diagnostics);let S=[...t.flatMap($=>$.diagnostics),...e];return{value:x,diagnostics:S,success:!S.some($=>$.severity==="error")}}c(ul,"mergeDocuments");function ay(t){if(Pa(t)||t.identity!=null||t.domain!==null||t.concepts.length>0||t.types.length>0||t.personas.length>0||(t.policies?.length??0)>0||(t.purposes?.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=c(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))}c(ay,"hasDeclarations");function sy(t,e){return Sl(t).map(yl).map(n=>n.length===1?{...n[0],isPlacement:!1,features:n[0].features.map(Ro)}:{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Do(n.flatMap(i=>i.purposes??[]),i=>i.name),description:xl(n,`module '${n[0].name}'`,e),documentation:gl(n,`module '${n[0].name}'`,e),authorize:hl(n.map(i=>i.authorize),`module '${n[0].name}'`,e),dependsOn:ml(n),features:fl(n.flatMap(i=>i.features),e)})}c(sy,"mergeModules");function fl(t,e){return Sl(t).map(yl).map(n=>n.length===1?Ro(n[0]):{...n[0],isPlacement:!1,fileImports:n.flatMap(i=>i.fileImports),examples:n.flatMap(i=>i.examples??[]),purposes:Do(n.flatMap(i=>i.purposes??[]),i=>i.name),description:xl(n,`feature '${n[0].name}'`,e),documentation:gl(n,`feature '${n[0].name}'`,e),authorize:hl(n.map(i=>i.authorize),`feature '${n[0].name}'`,e),dependsOn:ml(n),features:fl(n.flatMap(i=>i.features),e),slices:Ln(n.flatMap(i=>i.slices),"slice",e,`feature '${n[0].name}'`)})}c(fl,"mergeFeatures");function ml(t){return[...t].sort((e,n)=>(e.location.path??"")<(n.location.path??"")?-1:(e.location.path??"")>(n.location.path??"")?1:0).flatMap(e=>e.dependsOn??[])}c(ml,"groupDependencies");function yl(t){return[...t.filter(e=>!e.isPlacement),...t.filter(e=>e.isPlacement)]}c(yl,"placedLast");function Ro(t){return{...t,isPlacement:!1,features:t.features.map(Ro)}}c(Ro,"unplaced");function hl(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(tr(s))===JSON.stringify(tr(r)));if(o!==void 0){n.push(Mo(l.DuplicateAuthorizationAcrossFiles,`An identical authorization is already declared on the ${e} in '${on(o.location.path)}' - this repeated gate is ignored`,r.location));continue}i.push(r)}return i.reduce((r,o)=>Xe(r,o),null)}c(hl,"combineAuthorization");function Do(t,e){let n=new Set;return t.filter(i=>!n.has(e(i))&&n.add(e(i))!==void 0)}c(Do,"firstOfEach");function Sl(t){let e=new Map;for(let n of t)e.set(n.name,[...e.get(n.name)??[],n]);return[...e.values()]}c(Sl,"groupByName");function gl(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(Mo(l.ConflictingDocumentationAcrossFiles,`The ${e} is already documented in '${on(i[0].location.path)}' - keeping that documentation`,r.location));return i[0]?.documentation??null}c(gl,"firstDocumentation");function xl(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(Mo(l.ConflictingDescriptionAcrossFiles,`The ${e} is already described in '${on(i[0].location.path)}' - keeping that description`,r.location));return i[0]?.description??null}c(xl,"firstDescription");function Ln(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(jn(l.RepeatedDeclarationAcrossFiles,`Duplicate ${e} '${s.name}'${i===void 0?"":` in ${i}`} - already declared in '${on(a.path)}'`,s.location));continue}a===void 0&&r.set(s.name,s.location),o.push(s)}return o}c(Ln,"declaredInOneFile");var on=c(t=>t??"another file","describe"),jn=c((t,e,n)=>({severity:"error",code:t,message:e,location:n}),"error"),Mo=c((t,e,n)=>({severity:"warning",code:t,message:e,location:n}),"warning");function pl(t,e){return e.length===0?{}:{[t]:e}}c(pl,"presentOnly");function $l(t,e){return dy(t,e).result}c($l,"parsePlacedDocuments");function dy(t,e){let n=tn.capturePlaced(t.filter(x=>x.isPlacementResolved!==!1).map(x=>({lines:Lt(x.source,!1,x.path),placement:x.placement})),e),i=t.map(x=>tt(x.source,x.path,x.isPlacementResolved===!1?[]:x.placement,!1,n,e)),r=i.flatMap((x,b)=>(x.value.eventSources??[]).map(S=>({source:S,placementResolved:t[b].isPlacementResolved!==!1}))),o=t.every(x=>x.isPlacementResolved!==!1)&&i.every(x=>!nn.hasUnknownExtent(x.diagnostics)),s=i.map((x,b)=>t[b].isPlacementResolved===!1?{...x,value:{...x.value,eventSources:[]}}:x),a=ul(s),d=new me(new Ne([]),void 0,e);a.value.sourceOptions!==void 0&&(d.sourceOptions=a.value.sourceOptions),ei(a.value,d);let p=Ge(a.value);Ni(a.value,d),Oi(a.value,d),Ai(a.value,d),Ii(a.value,d),ni(a.value,d),Hn(p,d,s.flatMap(x=>x.inputUses)),qi(a.value,d),Bi(p,d),Yi(a.value,d),Ui(a.value,d),zi(a.value,d),Qi(a.value,d),Gi(a.value,d),_i(a.value,d);let m=ri(a.value,d);en.validate(m,d);for(let x of ti(m))d.information(x.code,x.message,x.location);let u=a.diagnostics,y=new Set(u.map(vl)),h=[...u,...d.diagnostics.filter(x=>!y.has(vl(x)))];return{result:{...a,value:m,diagnostics:h,success:!h.some(x=>x.severity==="error"),physicalEventSources:r,sourceInventoryComplete:o},syntax:new Map(s.map((x,b)=>[t[b].path,x.value]))}}c(dy,"parsePlacedDocumentsWithSyntax");function vl(t){return JSON.stringify([t.code,t.location.path,t.location.line,t.location.column])}c(vl,"diagnosticKey");var bl=/[\p{L}\p{Mn}\p{Nd}\p{Pc}]/u,kl=c(t=>`\\u${t.toString(16).padStart(4,"0")}`,"escape");function py(){let t="";for(let e=0;e<=65535;e++){if(!bl.test(String.fromCharCode(e)))continue;let n=e;for(;e<65535&&bl.test(String.fromCharCode(e+1));)e++;t+=kl(n)+(e>n?`-${kl(e)}`:"")}return t}c(py,"ranges");var Dt=py();var uy=new RegExp(`^\\s*example\\s+[A-Z][${Dt}]*\\s*:\\s*([${Dt}.]*)$`),fy=new RegExp(`^\\s*(given|when|then)\\s+(?:(readmodel|append)\\s+)?([${Dt}.]*)$`);function El(t,e,n,i,r,o){let s=t,a=[],d=o.some(v=>v.severity==="error")?o.some(v=>v.code==="PLAY0519")?"**Invalid duplicate assignments; no effective values selected.**":"**Invalid source; no effective values selected.**":null,p=new Map,m=[],u=c((v,E)=>{if(v.location.path===e&&v.location.line>0)for(let C of i(v.location.line-1))p.set(C,E)},"own"),y=c((v,E)=>{for(let C of v??[])a.push({name:C.name,scope:E,example:C}),u(C,E)},"examples");y(s.examples,[]),a.push(...[...s.concepts,...s.types].map(v=>({name:v.name,scope:[]})));let h=c((v,E)=>{for(let C of v){let k=[...E,C.name];u(C,k),y(C.examples,k);for(let A of C.slices){let O=[...E,C.name,A.name];u(A,O),y(A.examples,O);let T=new Map;for(let M of le(A))T.set(M.name,[...T.get(M.name)??[],M]);for(let M of T.values()){let N=Math.max(...M.map(j=>j.generation));a.push(...M.filter(j=>j.generation===N).map(j=>({name:j.name,scope:O,fixtureKind:"event"})))}a.push(...A.commands.map(M=>({name:M.name,scope:O,fixtureKind:"command"})),...A.readModels.map(M=>({name:M.name,scope:O,fixtureKind:"readmodel"})));for(let M of A.specifications)m.push({node:M,scope:O}),u(M,O),y(M.examples,O)}h(C.features,k)}},"features");for(let v of s.modules)u(v,[v.name]),y(v.examples,[v.name]),h(v.features,[v.name]);let x=c((v,E)=>{let C=v.split("."),k=a.filter(O=>O.name===C.at(-1)),A=C.slice(0,-1);if(A.length)return k.filter(O=>A.length<=O.scope.length&&A.every((T,M)=>O.scope[O.scope.length-A.length+M]===T));for(let O=E.length;O>=0;O--){let T=k.filter(M=>O<=M.scope.length&&E.slice(0,O).every((N,j)=>M.scope[j]===N));if(T.length)return T}return[]},"candidates"),b=c((v,E)=>{let C=x(v,E);return C.length===1?C[0]:void 0},"unique"),S=c(v=>v.example?b(v.example.type,v.scope)?.fixtureKind:v.fixtureKind,"kind"),$=c(v=>[...v.scope.filter(E=>!r.has(E)),v.name].join("."),"display"),g=c((v,E,C=!1,k="")=>a.flatMap(A=>{let O=S(A);if(!O||E&&O!==E||C&&A.example)return[];let T=[...A.scope,A.name].join("."),M=b(A.name,v)===A?A.name:T;if(b(M,v)!==A)return[];let N=k.split(".").slice(0,-1).join(".");return N&&!T.endsWith(`${N}.${A.name}`)?[]:M===T&&A.scope.some(j=>r.has(j))&&b(A.name,v)!==A?[]:[{label:b(A.name,v)===A?A.name:$(A),insertText:N?A.name:M,documentation:A.example?`Example of ${A.example.type}. Step assignments override example values; no implicit defaults.`:`Declared ${O}.`}]}),"targets"),P=c((v,E,C,k,A)=>{if(d)return d;let O=c((U,_,te="")=>{if(new Set(U.map(F=>F.property)).size!==U.length||new Set(_.map(F=>F.property)).size!==_.length)return null;let $e=new Map(U.map(F=>[F.property,{value:F,origin:"example",replaced:void 0}]));for(let F of _){let ce=$e.get(F.property)?.value;$e.delete(F.property),$e.set(F.property,{value:F,origin:ce?"override":"authored",replaced:ce})}return[...$e.values()].map(({value:F,origin:ce,replaced:ye})=>`${te}${F.property} = ${ft(F.source)} \u2014 ${ce}${ce==="example"?` ${v.name}`:""}${ye?` (replaces ${ft(ye.source)} from ${v.name})`:""}`)},"merge"),T=O(v?.values??[],E),M=O(v?.generatedValues??[],C,"generated ");if(!T||!M)return"**Invalid duplicate assignments; no effective values selected.**";let N=k??v?.for,j=v?.stream??v?.noStream,q=A?.stream??A?.noStream,V=q??j,K=c(U=>U.kind==="SpecificationNoStreamSyntax"?"no stream":`stream ${U.eventSource}.${U.stream}${U.streamId?` streamId = ${ft(U.streamId.source)}`:U.streamIdParts.length?` streamId ${U.streamIdParts.map(_=>`${_.property} = ${ft(_.source)}`).join(", ")}`:""}`,"routeText"),J=V?[`${K(V)} \u2014 ${q?j?`override (replaces ${K(j)} from ${v.name})`:"authored":`example ${v.name}`}`]:[];return[...T,...M,...J,...N?[`for ${ft(N)} \u2014 ${k?v?.for?`override (replaces ${ft(v.for)} from ${v.name})`:"authored":`example ${v.name}`}`]:[]].join(`
|
|
22
|
-
`)},"effective"),w=new Map;for(let v of a.filter(E=>E.example?.location.path===e)){let E=v.example,C=E.location.line-1,k=Ae(n[C]??"").match(/^\s*example\s+/)?.[0];k&&w.set(C,{start:k.length+1,length:E.name.length,content:`**example ${$(v)} : ${E.type}**
|
|
23
|
-
|
|
24
|
-
${S(v)?P(E,[],[],null):"Unresolved or ambiguous type; no effective values selected."}`})}for(let{node:v,scope:E}of m){let C=[...v.given.map(k=>({step:k,name:k.eventType,expected:"event",values:k.values,generated:[],destination:k.for,prefix:/^\s*given\s+/})),...v.givenReadModels.map(k=>({step:k,name:k.name,expected:"readmodel",values:k.properties,generated:[],destination:null,prefix:/^\s*given\s+readmodel\s+/})),...v.when?[{step:v.when,name:v.when.commandType,expected:"command",values:v.when.values,generated:v.when.generatedValues??[],destination:v.when.for,prefix:/^\s*when\s+/}]:[],...v.whenAppended?[{step:v.whenAppended,name:v.whenAppended.eventType,expected:"event",values:v.whenAppended.values,generated:[],destination:v.whenAppended.for,prefix:/^\s*when\s+append\s+/}]:[],...v.thenEvents.map(k=>({step:k,name:k.eventType,expected:"event",values:k.values,generated:[],destination:k.for,prefix:/^\s*then\s+/})),...v.thenReadModels.map(k=>({step:k,name:k.name,expected:"readmodel",values:k.properties,generated:[],destination:null,prefix:/^\s*then\s+readmodel\s+/}))];for(let{step:k,name:A,expected:O,values:T,generated:M,destination:N,prefix:j}of C.filter(q=>q.step.location.path===e)){let q=b(A,E),V=x(A,E).some(_=>_.example);if(!q?.example&&(q||!V))continue;let K=k.location.line-1,J=Ae(n[K]??"").match(j)?.[0].length;if(J===void 0)continue;let U=q?S(q)!==O?"**Example kind mismatch; no effective values selected.**":`**${O} ${q.example?.type??A}${q.example?` \u2014 example ${$(q)}`:""}**
|
|
25
|
-
|
|
26
|
-
${P(q.example,T,M,N,"eventType"in k?k:void 0)}
|
|
27
|
-
|
|
28
|
-
Authored fixture values, not execution results. Matching is unchanged.`:"**Ambiguous example; no effective values selected.**";w.set(K,{start:J+1,length:A.length,content:U})}}return{eventExamples:a.filter(v=>v.example?.location.path===e&&S(v)==="event").map(v=>v.example),completions(v,E){let C=p.get(v)??[],k=E.match(uy);if(k)return g(C,void 0,!0,k[1]);if(!m.some(({node:N})=>N.location.path===e&&i(N.location.line-1).includes(v)))return null;let O=E.match(fy);if(!O||["clock","caller","capture","trigger","query","result","error","denied","returns","no","operation","compensated"].includes(O[3]))return null;let T=O[2]==="readmodel"?"readmodel":O[2]==="append"||O[1]!=="when"?"event":"command",M=g(C,T,!1,O[3]);return M.length?O[2]?M:[...Go[O[1]],...M]:null},hover(v,E,C){let k=w.get(v);return k&&E>=k.start&&C<=k.start+k.length?k.content:null}}}c(El,"exampleAnalysis");function ft(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(ft).join(", ")}]`;case"ObjectExpressionSyntax":return`{ ${t.members.map(e=>`${JSON.stringify(e.name)}: ${ft(e.value)}`).join(", ")} }`;case"RawExpressionSyntax":return t.text;case"CaseValueExpressionSyntax":return`case.${t.parameter}`;case"PathExpressionSyntax":return t.path;case"ContextExpressionSyntax":return`$context.${t.path}`;case"IdentityExpressionSyntax":return`$identity.${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:"${"+ft(e.expression)+"}").join("")+"`"}}c(ft,"expressionText");var my=new RegExp(`^\\s*given caller as\\s+[${Dt}]*$`),yy=new RegExp(`^\\s*(?:given caller as|persona)\\s+([A-Za-z_][${Dt}]*)\\s*$`);function Cl(t,e){let n=t,i=new Map(n.personas.map(r=>[r.name,yn(r,n)]));return{completions(r,o){return Ae(o).length<o.length||!my.test(o)?null:n.personas.map(s=>({label:s.name,insertText:s.name,documentation:"Authenticated deterministic witness of this persona. Negation, needed nonliteral claims, role-URI claims, implementations and policyless personas require an explicit caller."}))},hover(r,o,s){let a=Ae(e[r]??""),d=yy.exec(a);if(!d||a.slice(o-1,s-1)!==d[1])return null;let p=i.get(d[1]);return p?p.refusal?`**${d[1]} caller** \u2014 ${p.refusal.reason}${p.refusal.policy?` in policy ${p.refusal.policy}`:""}. Use an explicit \`given caller\`.`:`**${d[1]} caller** \u2014 authenticated.
|
|
29
|
-
|
|
30
|
-
Roles: ${p.caller.roles.map(m=>JSON.stringify(m)).join(", ")||"(none)"}.
|
|
31
|
-
|
|
32
|
-
Claims: ${p.caller.claims.map(m=>`${JSON.stringify(m.type)} = ${JSON.stringify(m.value)}`).join(", ")||"(none)"}.
|
|
33
|
-
|
|
34
|
-
Contributions: ${p.contributions.map(m=>`${m.policy}: ${m.kind}${m.type?` ${JSON.stringify(m.type)}`:""} ${JSON.stringify(m.value)}`).join("; ")}. This witnesses one deterministic minimal caller, not every caller fitting the persona.`:null}}}c(Cl,"personaAnalysis");function Pl(t,e,n,i,r){let o=t,s=e,a=je.containersOf(o).filter(u=>![...u.scope,u.name].some(y=>r.has(y))),d=new Map,p=new Map,m=c((u,y,h)=>{for(let x of u){let b=[...y,x.name];if(h){if(x.location.path===n&&x.location.line>0)for(let S of i(x.location.line-1))d.set(S,b)}else{let S=b.join(".");p.set(S,[...p.get(S)??[],...(x.dependsOn??[]).map($=>({target:$.target,...$.location}))])}m(x.features,b,h)}},"inventory");return m(o.modules,[],!1),m(s.modules,[],!0),{completions(u,y,h){let x=d.get(u)??h;if(!x?.length||x.some(S=>r.has(S))||!a.some(S=>[...S.scope,S.name].join(".")===x.join(".")))return[];let b=new Set((p.get(x.join("."))??[]).filter(S=>S.path!==n||S.line!==u+1).map(S=>je.resolve(S.target,x,a).resolved));return je.candidates(x,a).flatMap(({container:S,reference:$,tier:g})=>{if(b.has(S))return[];let P=[...S.scope,S.name].join(".");if(y&&($=y+S.name,je.resolve($,x,a).resolved!==S))return[];let w=S.scope.length===0?"module":g===0?"sibling feature":g!=="qualified"?`feature of ${S.scope.join(".")}`:`feature in ${S.scope.join(".")}`,v=a.indexOf(S);return[{label:y?S.name:$,insertText:y?S.name:$,documentation:`${P} \u2014 ${w}.`,detail:w,sortText:`${String(g==="qualified"?x.length:g).padStart(6,"0")}:${String(v).padStart(6,"0")}`}]})}}}c(Pl,"dependencyTargetAnalysis");var HD="Executable as ESM v7. Generated values require fixtures in reference execution; other unadmitted constructs still prevent binding.",Nn=new Map;function hy(t,e){let n=Re(t),i=t.flatMap((u,y)=>!n[y]&&ne(u)===0&&/^\w/.test(u)?[u.split(/\s+/)[0]]:[]);if(i.includes("module")||!i.some(u=>["feature","slice","command","event","operation","reaction","specification"].includes(u)))return{source:t.join(`
|
|
35
|
-
`),locations:t.map((u,y)=>({line:y+1,column:0}))};let r=[],o=[],s=!1;t.forEach((u,y)=>{!n[y]&&ne(u)===0&&/^\w/.test(u)&&(s=/^(?:concept|type|import|domain|system|eventsource|policy|persona|identity)\b/.test(u)),(s?r:o).push(y)});let a=i.includes("feature")?1:i.includes("slice")?2:3,d=e.slice(0,a),p=[...r.map(u=>t[u]),...d,...o.map(u=>" ".repeat(a*2)+t[u])].join(`
|
|
36
|
-
`),m=[...r.map(u=>({line:u+1,column:0})),...d.map(()=>({line:0,column:0})),...o.map(u=>({line:u+1,column:a*2}))];return{source:p,locations:m}}c(hy,"authoringSource");function Sy(t,e,n,i="current.play",r=!0){let o=e.map((R,L)=>typeof R=="string"?{path:`other-${L}.play`,source:R}:R).filter(R=>R.path!==i),s=[{path:i,source:t.join(`
|
|
37
|
-
`),placement:n,isPlacementResolved:r},...o],a=new Set(s.flatMap(R=>[...R.source.matchAll(/\w+/g)].map(L=>L[0]).concat(R.placement??[]))),d=c(R=>{let L=R;for(let B=1;a.has(L);B++)L=`${R}${B}`;return a.add(L),L},"fresh"),p=d("EditorAuthoring"),m=d("FragmentFeature"),u=new Set([p,m]),y=s.map((R,L)=>{let B=L===0?t:R.source.split(`
|
|
38
|
-
`),Y=d(`Fragment${L}`);u.add(Y);let mt=R.placement?.length?{source:R.source,locations:B.map((Mt,Fn)=>({line:Fn+1,column:0}))}:hy(B,[`module ${p}`,` feature ${m}`,` slice StateChange ${Y}`]);return{...R,...mt,placement:R.placement??[]}}),h=y[0],x=new Map(y.map(R=>[R.path,R.locations])),b=$l([...y.slice(1),h]),S=new Map,$=new Map,g=new WeakSet,P=c(R=>{if(R===null||typeof R!="object"||g.has(R))return;if(g.add(R),Array.isArray(R)){R.forEach(P);return}let L=R;if(typeof L.path=="string"&&typeof L.line=="number"&&typeof L.column=="number"){let B=x.get(L.path)?.[L.line-1];B&&(L.line=B.line,L.column=Math.max(1,L.column-B.column));return}for(let B of Object.values(L))P(B);L.location?.path===i&&(L.kind==="CommandSyntax"&&S.set(L.location.line-1,R),L.kind==="SpecificationSyntax"&&$.set(L.location.line-1,R))},"walk");P(b.value),P(b.physicalEventSources);for(let R of b.diagnostics)P(R.location);let w=b.diagnostics.some(R=>{if(!["PLAY0022","PLAY0024","PLAY0029"].includes(R.code))return!1;let L=y.find(Y=>Y.path===R.location.path),B=s.find(Y=>Y.path===R.location.path)?.source.split(`
|
|
39
|
-
`)[R.location.line-1];return L?.locations.some(Y=>Y.line===0)&&B!==void 0&&ne(B)===0}),v=b.diagnostics.filter(R=>R.location.path===i).flatMap(R=>(P(R.location),R.location.line>0?[R]:[])),E=new ie(b.value),C=new Set(E.slices.flatMap(({slice:R})=>[...R.commands.flatMap(L=>L.produces),...R.reactions.flatMap(L=>L.triggers).flatMap(L=>L.produces)].filter(L=>L.location.path===i&&!E.isEventProduction(L,R)).map(L=>L.location.line-1)));for(let R of v)R.code==="PLAY0499"&&C.add(R.location.line-1);let k=E.declarations.filter(R=>R.kind===H.Operation).map(R=>({...R.node,scope:R.scope.filter(L=>!u.has(L))})),A=new Map,O=Re(t),T=c(R=>{let L=[],B=ne(t[R]);for(let Y=R;Y<t.length&&!(Y>R&&!O[Y]&&Ae(t[Y]).trim()&&ne(t[Y])<=B);Y++)L.push(Y);return L},"range");for(let{slice:R,scope:L}of E.slices){if(R.location.path===i&&R.location.line>0)for(let B of T(R.location.line-1))A.set(B,{scope:L});for(let B of R.specifications.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of T(B.location.line-1))A.set(Y,{scope:L});for(let B of R.commands.filter(Y=>Y.location.path===i&&Y.location.line>0))for(let Y of T(B.location.line-1))A.set(Y,{scope:L,commandLine:B.location.line-1})}let M=new Map(E.declarations.map(R=>[R.node.location,R.scope]));for(let R of k.filter(L=>L.location.path===i)){let L=M.get(R.location);for(let B of T(R.location.line-1))A.set(B,{...A.get(B),scope:L,operation:R})}let N=new Map(k.map(R=>[R.location,R])),j=c((R,L)=>{let B=Ae(t[R.line-1]??""),Y=B.slice(R.column-1).match(/^(?:given\s+operation|then\s+(?:operation|compensated))\s+/)?.[0];return Y&&B.slice(R.column-1+Y.length,R.column-1+Y.length+L.length)===L?{...R,column:R.column+Y.length}:R},"referenceLocation"),q=[];for(let{slice:R}of E.slices){for(let L of R.commands)for(let B of L.produces){if(B.location.path!==i)continue;let Y=E.resolve(B.event,R),mt=Y.declaration?N.get(Y.declaration.node.location)??null:null,Mt={name:B.event,location:B.location,targetLocation:B.targetLocation??B.location,kind:Y.kind,declaration:mt,mappings:B.mappings};if(q.push(Mt),Y.kind===H.Operation)for(let Fn of T(B.location.line-1)){let Uo=A.get(Fn);Uo&&A.set(Fn,{...Uo,production:Mt})}}for(let L of R.specifications)for(let B of[...L.givenOperationFailures??[],...L.thenOperations??[],...L.thenCompensated??[]]){if(B.location.path!==i)continue;let Y=E.resolve(B.operation,R);q.push({name:B.operation,location:B.location,targetLocation:j(B.location,B.operation),kind:Y.kind,declaration:Y.declaration?N.get(Y.declaration.node.location)??null:null,mappings:[]})}}let V={declarations:k,systems:b.value.systems??[],references:q,contexts:A,types:b.value.types,concepts:b.value.concepts,targets:c(R=>{let L=E.slices.find(B=>B.scope.length===R.length&&B.scope.every((Y,mt)=>Y===R[mt]))?.slice;return L?k.flatMap(B=>{let Y=E.resolve(B.name,L).declaration?.node.location===B.location?B.name:[...B.scope,B.name].join(".");return E.resolve(Y,L).kind===H.Operation&&E.resolve(Y,L).declaration?.node.location===B.location?[{name:Y,declaration:B}]:[]}):[]},"targets")},K=b.physicalEventSources.map(R=>R.source),J=new nn(b.physicalEventSources,b.sourceInventoryComplete&&!w),U=new Map,_=c((R,L)=>{let B=JSON.stringify([R,L]),Y=U.get(B);return Y||(Y=J.resolve(R,L),U.set(B,Y)),{...Y,source:Y.state==="unique"?Y.sources[0]:void 0,stream:Y.state==="unique"?Y.streams[0]:void 0}},"resolve"),te=new Set(b.value.imports.map(R=>R.qualifiedName)),$e=K.flatMap(R=>R.streams.filter(L=>_(R.name,L.name).state==="unique"&&!te.has(`${R.name}.${L.name}`)).map(L=>({name:`${R.name}.${L.name}`,source:R,stream:L}))),F=new Map,ce=[];for(let R of S.values()){for(let L of T(R.location.line-1))F.set(L,{command:R});for(let L of[...R.produces,...R.validations,...R.handler?[R.handler]:[]])for(let B of T(L.location.line-1))F.delete(B);if(R.stream){ce.push(R.stream);for(let L of T(R.stream.location.line-1))F.set(L,{command:R,route:R.stream})}}let ye=El(b.value,i,t,T,u,b.diagnostics),Te=[...[...$.values()].flatMap(R=>[...R.given.map(L=>({event:L,expectation:!1})),...R.whenAppended?[{event:R.whenAppended,expectation:!1}]:[],...R.thenEvents.map(L=>({event:L,expectation:!0})),...R.whenRedelivered?[{event:R.whenRedelivered,expectation:!0}]:[]]),...(ye.eventExamples??[]).map(R=>({event:R,expectation:!0}))];for(let R of Te){let L=R.event;for(let B of T(L.location.line-1))F.set(B,R);if(L.stream){ce.push(L.stream);for(let B of T(L.stream.location.line-1))F.set(B,{...R,route:L.stream})}}for(let R of K.filter(L=>L.location.path===i)){for(let L of T(R.location.line-1))F.set(L,{source:R});for(let L of R.streams)for(let B of T(L.location.line-1))F.set(B,{source:R,stream:L})}let Et=[...S.values()].flatMap(R=>R.streamCandidates??[]).filter(R=>R.propertyCandidate!==null),Ct={declarations:K,routes:ce,ambiguousCandidates:Et,contexts:F,targets:$e,resolve:_},he,be={completions(R,L,B){if(he===void 0){let Y=tt(h.source,i,h.placement,!1).value,mt=c(Mt=>{P(Mt.location),Mt.features.forEach(mt)},"remapDependencyHeaders");Y.modules.forEach(mt),he=Pl(b.value,Y,i,T,u)}return he.completions(R,L,B)}};return{identityDetails:(b.value.identity?.details??[]).map(R=>({name:R.name,type:`${R.type.name}${R.type.isCollection?"[]":""}${R.type.isOptional?" optional":""}`,line:R.location.line-1})),commands:S,specifications:$,diagnostics:v,operationProductionLines:C,operations:V,eventSources:Ct,examples:ye,personas:Cl(b.value,t),dependencies:be}}c(Sy,"analyze");function an(t,e=[],n,i="current.play",r=!0){let o=JSON.stringify([t,e,n,i,r]),s=Nn.get(o);return s===void 0&&(s=Sy(t,e,n,i,r),Nn.size>=16&&Nn.delete(Nn.keys().next().value),Nn.set(o,s)),s}c(an,"responseAnalysis");var Lo="file",gy=/^[A-Za-z_]\w*(?:\[\])?(?:\?|\s+optional)?$/,xy=/^(?:[/\\]|[A-Za-z]:[/\\]|~[/\\])/;function nM(t){return xy.test(t)}c(nM,"isAbsoluteFileReferencePath");function vy(t){let e=!1,n=!1;for(let i=0;i<t.length;i++){let r=t[i];if(r==="\\"&&e&&i+1<t.length)i++;else if(r==='"'&&!n)e=!e;else if(r==="`"&&!e)n=!n;else if(!e&&!n&&r==="/"&&t[i+1]==="/")return t.slice(0,i)}return t}c(vy,"withoutComment");function jo(t,e){let n=ne(t),i=vy(t.slice(n)).trimEnd();if(sr(i)!==Lo)return;let r=i.slice(Lo.length),o=r.trim();if(o.length===0||gy.test(o))return;let s=r.length-r.trimStart().length,a=n+Lo.length+s+1;return{path:o,line:e,startColumn:a,endColumn:a+o.length}}c(jo,"fileReferenceOn");function iM(t){let e=Re(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=jo(t[i],i);r&&n.push(r)}return n}c(iM,"fileReferences");function bt(t){let e=!1;return t.map(n=>{if(e)return n.trim()==="```"&&(e=!1),n;let i=Ae(n);return/^\s*```(?:[a-z]+)?\s*$/.test(i)&&(e=!0),i.trimEnd()})}c(bt,"eventAnalysisSource");var $y=/^concept\s+(\w+)\s*:\s*(\w+)((?:\s+@\w+)*)\s*$/,by=/^\s*(@?[a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(\s+generated)?(\s+identifier)?(\s+subject)?\s*$/,Al=/^([a-z_]\w*)\s+reason\s+"((?:[^"\\]|\\.)*)"\s*$/,ky=/^\s*reads\s+([A-Z]\w*)(?:\s+as\s+([a-z_]\w*))?(?:\s+by\s+([a-z_]\w*))?\s*$/,Ey=["authorize","produces","reads"],Cy=/^(?:(?:or|and)\s+)?[A-Za-z_(][\p{L}\p{Mn}\p{Nd}\p{Pc}\s()]*$/u,Py=En,Ay=["tag","for","generation","origin","namespace","sequence","correlation","causation","causedBy","occurred"],wy=/^\s*(?:by|filter)\s+([a-z_]\w*)\s+([\w.]+(?:\[\])?(?:\?|\s+optional)?)(?:\s+from\s+.+)?\s*$/;function kt(t){return t.typeReference??ln(t.type)}c(kt,"propertyTypeReference");function No(t,e){let n=t.slice(e-1).match(/^[\p{L}\p{Mn}\p{Nd}\p{Pc}.]+(?:\[\])?(?:\?|\s+optional\b)?/u)?.[0]??"";return{text:n,startColumn:e,endColumn:e+n.length}}c(No,"sourceTypeAt");function qo(t,e,n){return e.map(i=>({index:i,match:t[i].match(by)})).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:ln(r[2]),sourceType:No(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}))}c(qo,"propertiesIn");function Bn(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(ne(s)<=i)break;r.push(o)}}return r}c(Bn,"collectBody");function sn(t,e,n,i){let r=Bn(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 d=ne(t[a]),p=t[a].trim();return o!==void 0&&d>o&&(!s||Cy.test(p))?!1:(o=p!=="validate csharp"&&qo(t,[a],Ey).length>0||/^description(?:\s|$)/.test(p)?void 0:d,s=/^authorize(?:\s|$)/.test(p),!0)})}c(sn,"directBody");var qn=new Map;function Yn(t){let e=t.join(`
|
|
40
|
-
`),n=qn.get(e);if(n)return n;let i=an(t),r={...i.identityDetails?.length?{identityDetails:i.identityDetails}:{},authoringSources:[e],eventSources:i.eventSources.declarations,imports:[],concepts:[],types:[],policies:[],events:[],commands:[],queries:[],screens:[],triggers:[]};t=bt(t);let o=Re(t),s=t,a=o,d=t.map(p=>p.replace(/\s*=(?!=|>).*/,""));for(let p=0;p<t.length;p++){if(o[p])continue;let m=t[p],u=m.trim(),y=ne(m),h=s[p].trim().match(/^import\s+([\w.]+)(?:\s+from\s+"(?:[^"\\]|\\.)*")?\s*$/);if(h&&y===0){let E=h[1],C=E.split(".").pop()??E;r.imports.push({qualifiedName:E,shortName:C,line:p});continue}let x=u.match($y);if(x){let E=Bn(t,o,p,y).map(A=>t[A].trim()),C={};for(let A of E){let O=A.match(Al);O&&C[O[1]]===void 0&&(C[O[1]]=O[2])}let k=x[2]==="Enum"?E.filter(A=>!Al.test(A)):[];r.concepts.push({name:x[1],primitive:x[2],attributes:x[3].trim().split(/\s+/).filter(Boolean),attributeReasons:C,enumValues:k,line:p});continue}let b=u.match(/^type\s+(\w+)\s*$/);if(b){r.types.push({name:b[1],properties:qo(t,Bn(t,o,p,y),Wo),line:p});continue}let S=u.match(/^policy\s+(\w+)\s*$/);if(S){let E=Bn(t,o,p,y).filter(C=>!o[C]).map(C=>t[C].trim());r.policies.push({name:S[1],requires:E,line:p});continue}let $=s[p].trim().match(/^(?:(?:produces|(?<public>public))\s+)?event\s+(?<name>\w+)(?:\s+generation\s+(?<generation>\d+))?(?:\s+from\s+(?<origin>"(?:[^"\\]|\\.)*"))?\s*$/);if($){let E=u.startsWith("produces "),C=sn(s,a,p,y),k=E?C:C.filter(A=>jo(s[A],A)===void 0);r.events.push({name:$.groups.name,...$.groups.generation?{generation:Number($.groups.generation)}:{},...$.groups.public||$.groups.origin?{visibility:se.Public}:{},...$.groups.origin?{origin:Q($.groups.origin.slice(1,-1))}:{},inline:E,properties:qo(E?d:s,k,E?Ay:Py),line:p});continue}let g=i.commands.get(p);if(g){let E=sn(t,o,p,y),C=E.filter(k=>/^\s*produces\b/.test(t[k])&&!i.operationProductionLines?.has(k));r.commands.push({name:g.name,properties:g.properties.map(k=>({name:k.name,type:`${k.type.name}${k.type.isCollection?"[]":""}${k.type.isOptional?" optional":""}`,typeReference:{name:k.type.name,isCollection:k.type.isCollection,isOptional:k.type.isOptional},sourceType:No(t[k.type.location.line-1],k.type.location.column),isIdentifier:k.isIdentifier||/\sidentifier\s*$/.test(t[k.location.line-1]),...k.isGenerated?{isGenerated:!0}:{},line:k.location.line-1})),response:g.response,productionHeaders:C,produces:C.flatMap(k=>{let A=s[k].trim(),O=/^produces\s+event\b/.test(A),T=/^produces\s+when\b/.test(A),M=T?sn(s,a,k,ne(s[k]))[0]:k;if(M===void 0)return[];let N=T?s[M].trim():A.match(O?/^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 j=sn(s,a,M,ne(s[M])),q=j.map(J=>s[J].trim().match(/^for(?:\s+(.*))?$/)).filter(J=>J!==null),V=q.length===0?void 0:q.length===1?q[0][1]??"":"",K=j.flatMap(J=>{let U=s[J].trim().match(O?/^(@?[a-z_]\w*)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?\s*=(?!=|>)\s*(.+)$/:/^(@?[\w.]+)\s*=(?!=|>)\s*(.+)$/);return U===null?[]:[{name:U[1].replace(/^@/,""),source:U[2],line:J}]});return[{name:N,inline:O,conditional:T,line:k,target:V,mappings:K}]}),reads:E.filter(k=>!o[k]).map(k=>({line:k,match:t[k].match(ky)})).filter(k=>k.match!==null).map(({line:k,match:A})=>({view:A[1],...A[2]?{alias:A[2]}:{},...A[3]?{by:A[3]}:{},line:k})),line:p});continue}let P=u.match(/^query\s+(\w+)\s*=>\s*(?:observable\s+)?([\w.]+(?:\[\])?(?:\?|\s+optional)?)\s*$/);if(P){let E=Bn(t,o,p,y).map(C=>({index:C,match:t[C].match(wy)})).filter(C=>C.match!==null).map(({index:C,match:k})=>({name:k[1],type:k[2],typeReference:ln(k[2]),sourceType:No(t[C],t[C].match(/^\s*(?:by|filter)\s+\S+\s+/)[0].length+1),isIdentifier:!1,line:C}));r.queries.push({name:P[1],returnType:P[2],returnTypeReference:ln(P[2]),parameters:E,line:p});continue}let w=u.match(/^screen\s+(\w+)\s*$/);if(w){r.screens.push({name:w[1],line:p});continue}let v=u.match(/^trigger\s+(\w+)\s*$/);v&&y===0&&r.triggers.push({name:v[1],line:p})}return qn.size>=16&&qn.delete(qn.keys().next().value),qn.set(e,r),r}c(Yn,"scanDocument");function nr(...t){return{...t.some(e=>e.identityDetails?.length)?{identityDetails:t.flatMap(e=>e.identityDetails??[])}:{},authoringSources:t.flatMap(e=>e.authoringSources??[]),...t.some(e=>e.authoringDocuments)?{authoringDocuments:t.flatMap(e=>e.authoringDocuments??[])}:{},eventSources:t.flatMap(e=>e.eventSources??[]),imports:t.flatMap(e=>e.imports),concepts:t.flatMap(e=>e.concepts),types:t.flatMap(e=>e.types),policies:t.flatMap(e=>e.policies),events:t.flatMap(e=>e.events),commands:t.flatMap(e=>e.commands),queries:t.flatMap(e=>e.queries),screens:t.flatMap(e=>e.screens),triggers:t.flatMap(e=>e.triggers)}}c(nr,"mergeSymbols");function wl(t,e){let n=e?.authoringPath??"current.play",i=e?.authoringDocuments?.find(r=>r.path===n);return{...nr(Yn(t),e??nr()),authoringDocuments:e?.authoringDocuments,authoringPath:n,authoringPlacement:e?.authoringPlacement??i?.placement,authoringPlacementResolved:e?.authoringPlacementResolved??i?.isPlacementResolved}}c(wl,"symbolsForBuffer");function ir(t){return[...t.events.map(e=>e.name),...t.imports.map(e=>e.shortName)]}c(ir,"knownEventNames");var Iy=["Startup","Shutdown"];function gM(t){return[...ir(t),...t.triggers.map(e=>e.name),...Iy]}c(gM,"knownTriggerNames");function Bo(t,e){return[...e,...t.concepts.map(n=>n.name),...t.types.map(n=>n.name),...t.imports.map(n=>n.shortName)]}c(Bo,"knownTypeNames");function Yo(t){let e=t.properties.filter(o=>o.isIdentifier&&!kt(o).isOptional&&!kt(o).isCollection),n=e.length===1?e[0].name:void 0,i=t.produces??[],r=i.some(o=>o.target!==void 0&&o.target!==n)||i.some(o=>o.inline&&o.target===void 0)&&i.some(o=>!o.inline&&o.target===void 0);return{identifier:n,mixed:r}}c(Yo,"productionDestinations");function PM(t,e){let n=an(t,e?.authoringDocuments??e?.authoringSources,e?.authoringPlacement,e?.authoringPath),i=bt(t);return Yn(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}=Yo(r);if(s||r.productionHeaders?.length!==r.produces?.length)return[];let a=r.produces?.some(d=>d.target!==void 0||d.inline);return(r.produces??[]).flatMap(d=>d.target!==void 0||d.inline&&(o===void 0||/\bgeneration\b/.test(i[d.line]))?[]:!d.inline&&a?[]:[{line:d.line,column:i[d.line].length+1,label:d.inline?`for ${o}`:"for <new event source>"}])})}c(PM,"destinationHints");var ee={repeatedSingularDeclarationAcrossFiles:"PLAY0172",invalidIdentityDeclaration:"PLAY0633",duplicateIdentity:"PLAY0634",invalidIdentityDetail:"PLAY0635",unknownIdentitySource:"PLAY0636",identityDetailWithoutSource:"PLAY0637",identitySourceWithBody:"PLAY0638",duplicateIdentityDetail:"PLAY0639",builtInIdentityDetail:"PLAY0640",unknownIdentityQuery:"PLAY0641",invalidIdentityQuery:"PLAY0642",identityQueryWithoutKey:"PLAY0643",invalidIdentityQueryKey:"PLAY0644",identityQueryAuthorizationDependency:"PLAY0645",identityQueryTypeMismatch:"PLAY0646",commandProducesPublicEvent:"PLAY0607",publicEventRequiresOutboundTranslation:"PLAY0608",outboundPublicEventCount:"PLAY0609",foreignPublicEventConsumer:"PLAY0610",outboundTranslationInput:"PLAY0611",inboundTranslationOutput:"PLAY0612",foreignPublicEventProduced:"PLAY0613",publicTranslationRequiresDirection:"PLAY0614",translationConstructDirection:"PLAY0615",inboundTranslationInput:"PLAY0616",outboundTranslationOutput:"PLAY0617",eventTargetOutsideOutboundTranslation:"PLAY0618",eventsSourceOutsideInboundTranslation:"PLAY0619",invalidCaptureEventsSource:"PLAY0620",invalidDescription:"PLAY0145",emptyDescription:"PLAY0146",duplicateDescription:"PLAY0147",unknownConceptDirective:"PLAY0010",attributeReasonWithoutAttribute:"PLAY0012",duplicateAttributeReason:"PLAY0013",legacyComplianceMarker:"PLAY0565",unknownComplianceMarker:"PLAY0566",invalidSecretScope:"PLAY0567",duplicateSecretScope:"PLAY0568",secretScopeIgnoredForPii:"PLAY0569",invalidPersonalDataQualifier:"PLAY0570",duplicateSpecialCategory:"PLAY0571",invalidPurposeDeclaration:"PLAY0596",invalidPurposeVocabulary:"PLAY0597",duplicatePurposeField:"PLAY0598",duplicatePurposeDeclaration:"PLAY0599",unknownPurpose:"PLAY0600",purposeInterestMismatch:"PLAY0601",personalDataWithoutPurpose:"PLAY0602",specialDataWithoutCondition:"PLAY0603",criminalDataWithoutAuthorization:"PLAY0604",purposeWithoutBasis:"PLAY0605",unusedPurpose:"PLAY0606",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",invalidSpecificationCallerPersona:"PLAY0572",unsynthesizablePersonaCaller:"PLAY0573",personaWithoutGate:"PLAY0574",gateWithoutPersona:"PLAY0575",ambiguousPersonaCaller:"PLAY0576",invalidSpecificationParameter:"PLAY0577",invalidSpecificationCase:"PLAY0578",duplicateSpecificationParameter:"PLAY0579",duplicateSpecificationCase:"PLAY0580",incompleteSpecificationTable:"PLAY0581",invalidSpecificationCaseAssignment:"PLAY0582",invalidSpecificationCaseValue:"PLAY0583",invalidSpecificationCaseReference:"PLAY0584",optionalSpecificationParameterTarget:"PLAY0585",specificationCaseNameCollision:"PLAY0586",incompatibleSpecificationParameterType:"PLAY0587",unusedSpecificationParameter:"PLAY0588",singularSpecificationTableExpansion:"PLAY0589",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 Oy=/^import(\s+)"([^"\\]+)"\s*(?:\/\/.*)?$/,Ty=/^import\s+"/;function Ol(t){return Ty.test(t.trim())}c(Ol,"isFileImportLine");function Fo(t,e){let n=ne(t),i=t.slice(n).match(Oy);if(!i)return;let r=n+6+i[1].length+2;return{pattern:i[2],line:e,startColumn:r,endColumn:r+i[2].length}}c(Fo,"fileImportOn");function TM(t){let e=Re(t),n=[];for(let i=0;i<t.length;i++){if(e[i])continue;let r=Fo(t[i],i);r&&n.push(r)}return n}c(TM,"fileImports");var Il=c(t=>t.split("/").slice(0,-1),"folderOf");function Ry(t,e){let n=e.split("/"),i=0;for(;i<t.length&&i<n.length-1&&t[i]===n[i];)i++;return[...t.slice(i).map(()=>".."),...n.slice(i)].join("/")}c(Ry,"relativeTo");function RM(t,e){let n=Il(t),i=new Set;for(let r of e.filter(o=>o!==t&&o.toLowerCase().endsWith(".play"))){let o=Ry(n,r),s=Il(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()}c(RM,"importablePaths");var Dy=new Set(["namespace","sequence","correlation","causation","causedBy","occurred"]),My=/^id\s+"((?:[^"\\]|\\.)*)"$/;function Tl(t,e,n,i=new Set){t=bt(t);let r=[],o=Re(t),s=Ly(t,o),a=new Set(e.commands.flatMap(y=>y.productionHeaders??[])),d=new Map,p=new Set;for(let y of[e,n]){for(let h of y.events)d.set(h.name,(d.get(h.name)??0)+1);for(let h of y.imports)p.add(h.shortName)}let m=c((y,h,x,b="error")=>{r.push({line:y,startColumn:ne(t[y])+1,endColumn:t[y].length+1,code:h,message:x,severity:b})},"report");for(let y of e.events){let h=sn(t,o,y.line,ne(t[y.line]));if(y.inline){let S=new Set;for(let $ of y.properties)S.has($.name)&&m($.line,ee.duplicateDeclaration,`Event '${y.name}' already declares property '${$.name}'.`),S.add($.name);a.has(y.line)||m(y.line,ee.inlineEventOutsideCommand,"Inline events can only be declared inside commands."),y.generation!==void 0&&m(y.line,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),((d.get(y.name)??0)>1||p.has(y.name))&&m(y.line,ee.inlineEventCollision,`Inline event '${y.name}' collides with another declaration or import.`)}let x=!1,b=!1;for(let S of h){let $=t[S].trim(),g=$.split(/\s+/)[0];if(y.inline&&g==="generation"&&m(S,ee.inlineEventGeneration,"Inline events are generation 1; extract the event before declaring generations."),y.inline&&g==="origin"&&m(S,ee.reservedProductionMetadata,"An inline event is local to its command and cannot declare origin."),!/^(?:id|description|documentation)\s+[\w.]+(?:\[\])?(?:\?|\s+optional)?(?:\s*=.*)?$/.test($)){if(g==="id"){let P=$.match(My);x||P===null||P[1].trim().length===0?m(S,ee.invalidEventId,'Expected one nonempty id "<old-name>".'):P[1]===y.name&&m(S,ee.redundantEventId,"This id repeats the event name; remove it.","information"),x=!0}if(g==="documentation"){let P=S+1;for(;P<t.length&&t[P].trim().length===0;)P++;(b||$!=="documentation"||t[P]?.trim()!=="```markdown"||ne(t[P])<=ne(t[S])||!s.has(P))&&m(S,ee.invalidEventDocumentation,"Expected one nonempty fenced markdown documentation block."),b=!0}}}}let u=[];for(let y=0;y<t.length;y++){if(o[y]||t[y].trim().length===0)continue;let h=ne(t[y]);for(;u.length>0&&u[u.length-1].indent>=h;)u.pop();let x=t[y].trim().split(/\s+/)[0];Dy.has(x)&&u.at(-1)?.event&&m(y,ee.reservedProductionMetadata,`'${x}' is system-assigned production metadata.`),x==="produces"&&u.push({indent:h,event:!i.has(y)&&!/^\s*produces\s+operation\b/.test(t[y])})}for(let y of e.commands){let{identifier:h,mixed:x}=Yo(y);for(let b of y.produces??[]){x&&b.target===void 0&&m(b.line,ee.explicitProducesTargetsRequired,`Production '${b.name}' must state for explicitly when destinations differ.`);let S=b.target??(b.inline?h:void 0);if(!(h===void 0||S!==h))for(let $ of b.mappings.filter(g=>g.source===h))m($.line,ee.eventSourceIdInPayload,`The payload copies '${h}', which already identifies the event source.`,b.inline?"warning":"information")}}return r}c(Tl,"validateInlineEvents");function Ly(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}c(Ly,"nonemptyMarkdownBlocks");function ze(t,e,n,i,r,o){return{severity:t,message:r,line:e,startColumn:n,endColumn:n+i,code:o}}c(ze,"issue");function Ve(t,e,n,i,r,o){let s=n.indexOf(i)+1;return ze(t,e,s,i.length,r,o)}c(Ve,"tokenIssue");function jy(t,e,n){let i=[],r=new Set([...Bo(e,Un),...Bo(n,[])]),o=c((a,d)=>{for(let p of a.filter(m=>!r.has(kt(m).name))){let m=kt(p).name;i.push(ze("warning",p.line,p.sourceType.startColumn,p.sourceType.text.length,m==="optional"?`Unknown type 'optional' on '${p.name}' of ${d} \u2014 did you forget the type before 'optional'?`:`Unknown type '${m}' on '${p.name}' of ${d} \u2014 declare it with 'concept ${m} : <Primitive>' or 'type ${m}'.`,ee.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 d=a.properties.filter(p=>p.isIdentifier);for(let p of d.slice(1))i.push(Ve("error",p.line,t[p.line],"identifier",`Command '${a.name}' already marks '${d[0].name}' as identifier \u2014 only one property can be the identifier.`,ee.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(Ve("error",a.line,t[a.line],a.name,`Duplicate declaration of '${a.name}' \u2014 concept and type names must be unique.`,ee.duplicateDeclaration))}return i}c(jy,"validateDeclarations");function r3(t,e={}){let n=Re(t),i=Yn(t),r=e.application??nr(),o=wl(t,{...r,authoringPath:e.path??r.authoringPath,authoringPlacement:e.placement??r.authoringPlacement}),s=an(t,o.authoringDocuments??o.authoringSources?.filter(C=>C!==t.join(`
|
|
41
|
-
`)),o.authoringPlacement,o.authoringPath,o.authoringPlacementResolved),a=new Set(s.eventSources.routes.map(C=>C.location.line-1)),d={...i,commands:i.commands.map(C=>({...C,properties:C.properties.filter(k=>!a.has(k.line)),produces:C.produces?.filter(k=>!s.operationProductionLines?.has(k.line)),productionHeaders:C.productionHeaders?.filter(k=>!s.operationProductionLines?.has(k))}))},p=new Set([...ir(d),...ir(r)]),m=new Set([...d.policies,...r.policies].map(C=>C.name)),u=jy(t,d,r);u.push(...Ny(t,d));let y=new Set([l.LegacyOptionalSuffix,l.InvalidOptionalModifierOrder,l.OptionalReadsNotSupported]),h=new Set([l.UnexpectedTokenInPolicyCondition,l.ExpectedPolicyCondition,l.UnclosedPolicyConditionGroup,l.ExpectedRoleName,l.ExpectedClaimName,l.ExpectedClaimMatches,l.ExpectedClaimMatchTarget]),x=new Set([l.UnknownEvent,l.UnknownReadModelProperty,l.PiiNotSupportedOnIdentifier]),b=new Set([l.EventFromLaterSlice,l.TimelineCycleGroup]),S=new Set([l.UndeclaredDependency,l.UnusedDependencyDeclaration,l.InvalidDependencyTarget,l.RepeatedDependencyDeclaration,l.MutualDependencyDeclarations,l.AmbiguousReference]),$=new Set([l.InvalidEventDeclaration,l.InvalidImportDeclaration,l.InvalidSliceDeclaration,l.InvalidDescription,l.DuplicateDescription,l.EmptyDescription,l.DuplicateEventSubject,l.InvalidSubjectType,l.ProtectedSubjectType,l.InvalidSubjectOwner,l.ReadModelSubjectNotSupported,l.InvalidSubjectModifierOrder,l.UnsupportedInteractionAlternatives,l.MixedInteractionAlternatives,l.InteractionAlternativeWithoutActions,l.InlineInteractionAlternative,l.LegacyInteractionWhere,l.InvalidSpecificationParameter,l.InvalidSpecificationCase,l.DuplicateSpecificationParameter,l.DuplicateSpecificationCase,l.IncompleteSpecificationTable,l.InvalidSpecificationCaseAssignment,l.InvalidSpecificationCaseValue,l.InvalidSpecificationCaseReference,l.OptionalSpecificationParameterTarget,l.SpecificationCaseNameCollision,l.IncompatibleSpecificationParameterType,l.UnusedSpecificationParameter,l.SingularSpecificationTableExpansion,l.InvalidSpecificationCallerPersona,l.UnsynthesizablePersonaCaller,l.PersonaWithoutGate,l.GateWithoutPersona,l.AmbiguousPersonaCaller,l.InvalidDocumentation,l.ConflictingDocumentationAcrossFiles,l.InvalidAbsentReadModelStep,l.UnknownConstraintProperty,l.OmittedProductionDestination,l.InvalidSpecificationExample,l.DuplicateSpecificationAssignment]),g=new Set([l.InvalidPurposeDeclaration,l.InvalidPurposeVocabulary,l.DuplicatePurposeField,l.DuplicatePurposeDeclaration,l.UnknownPurpose,l.PurposeInterestMismatch,l.PersonalDataWithoutPurpose,l.SpecialDataWithoutCondition,l.CriminalDataWithoutAuthorization,l.PurposeWithoutBasis,l.UnusedPurpose,l.UnknownConceptDirective,l.AttributeReasonWithoutAttribute,l.DuplicateAttributeReason,l.LegacyComplianceMarker,l.UnknownComplianceMarker,l.InvalidSecretScope,l.DuplicateSecretScope,l.SecretScopeIgnoredForPii,l.InvalidPersonalDataQualifier,l.DuplicateSpecialCategory]),P=new Set;for(let C of e.compilerDiagnostics??s.diagnostics){let k=C.code===l.UnknownType&&(s.identityDetails??[]).some(M=>M.line===C.location.line-1),A=C.code===l.RepeatedSingularDeclarationAcrossFiles&&C.message.includes("identity block");if(!k&&!A&&!g.has(C.code)&&!y.has(C.code)&&!h.has(C.code)&&!x.has(C.code)&&!b.has(C.code)&&!S.has(C.code)&&!$.has(C.code)&&C.code!==l.InvalidSpecificationExampleBody&&C.code!==l.UnknownRuleImplementationDirective&&C.code!==l.InvalidValidationRule&&C.code!==l.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$|^PLAY060[7-9]$|^PLAY061[0-9]$|^PLAY0620$|^PLAY063[3-9]$|^PLAY064[0-6]$/.test(C.code))continue;let O=C.location.line-1;if(C.code===l.OmittedProductionDestination&&u.some(M=>M.code===C.code&&M.line===O))continue;if(C.code===l.UnknownEvent){if(P.has(O))continue;P.add(O)}let T=Po(t[O],C)||t[O].length-C.location.column+1;u.push(ze(C.severity,O,C.location.column,T,C.message,C.code))}let w=c((C,k,A)=>{!p.has(A)&&!P.has(C)&&u.push(Ve("warning",C,k,A,`Unknown event type '${A}' \u2014 declare it in a slice or import it.`,ee.unknownEvent))},"checkEvent"),v=-1;for(let C=0;C<t.length;C++){let k=t[C],A=k.trim();if(n[C]||A.length===0)continue;let O=k.match(/^[ ]*(\t+)/);if(O&&u.push(ze("warning",C,O[0].length-O[1].length+1,O[1].length,"Screenplay is indentation-based \u2014 use spaces, not tabs.",ee.tabIndentation)),v>=0){if(ne(k)>v&&/^(?:or\s+)?[A-Z]\w*(?:\s+or\s+[A-Z]\w*)*$/.test(A)){for(let U of A.split(/\s+/).filter(_=>_!=="or"))m.has(U)||u.push(Ve("warning",C,k,U,`Unknown policy '${U}' \u2014 declare it with 'policy ${U}'.`,ee.unknownPolicy));continue}v=-1}let T=qy(t,n,C);T&&u.push(T);let M=A.match(/^slice\s+(\w+)/);M&&!ar.includes(M[1])&&u.push(Ve("error",C,k,M[1],`Unknown slice type '${M[1]}' \u2014 expected ${ar.join(", ")}.`,ee.unknownSliceType));let N=A.match(/^concept\s+\w+\s*:\s*(\w+)/);N&&N[1]!=="Enum"&&!Un.includes(N[1])&&u.push(Ve("error",C,k,N[1],`Unknown primitive type '${N[1]}' \u2014 expected ${Un.join(", ")} or Enum.`,ee.unknownPrimitiveType));let j=A.match(/^authorize\s+(.*)$/);if(j){v=ne(k);for(let U of j[1].split(/\s+/).filter(_=>_!=="or"&&_.length>0))m.has(U)||u.push(Ve("warning",C,k,U,`Unknown policy '${U}' \u2014 declare it with 'policy ${U}'.`,ee.unknownPolicy))}let q=A.match(/^on\s+([A-Z]\w*)\s*$/);q&&w(C,k,q[1]);let V=A.match(/^produces\s+([A-Z]\w*)\s*$/);if(V&&!s.operationProductionLines?.has(C)&&w(C,k,V[1]),/^produces\s+when\b/.test(A)&&!s.operationProductionLines?.has(C))for(let U=C+1;U<t.length;U++){let _=t[U];if(!(n[U]||_.trim().length===0)){if(ne(_)>ne(k)){let te=_.trim().match(/^([A-Z]\w*)\s*$/);te&&w(U,_,te[1])}break}}let K=A.match(/^unique\s+event\s+([A-Z]\w*)/);K&&w(C,k,K[1]);let J=A.match(/^unique\s+[a-z_]\w*\s+on\s+([A-Z]\w*)/);J&&w(C,k,J[1]);for(let U of k.match(/\$identity\.[\w.]+/g)??[]){let _=U.substring(10).split(".")[0],te=[...Pt,...(s.identityDetails??[]).map($e=>$e.name)];te.includes(_)||u.push(Ve("warning",C,k,U,`Unknown $identity property '${_}' \u2014 expected ${te.join(", ")}.`,ee.unknownContextIdentityProperty))}for(let U of k.match(/\$context\.[\w.]+/g)??[]){let _=U.substring(9).split(".");rr.includes(_[0])?_[0]==="causedBy"&&_.length>1&&!or.includes(_[1])?u.push(Ve("warning",C,k,U,`Unknown $context.causedBy property '${_[1]}' \u2014 expected ${or.join(", ")}.`,ee.unknownContextCausedByProperty)):_[0]==="identity"&&_.length>1&&!Pt.includes(_[1])&&u.push(Ve("warning",C,k,U,`Unknown $context.identity property '${_[1]}' \u2014 expected ${Pt.join(", ")}.`,ee.unknownContextIdentityProperty)):u.push(Ve("warning",C,k,U,`Unknown $context path '${_.join(".")}' \u2014 expected one of ${rr.join(", ")}.`,ee.unknownContextPath))}}u.push(...Yy(t,n)),u.push(...Tl(t,d,r,s.operationProductionLines));let E=t.map((C,k)=>({line:C,index:k})).filter(({line:C})=>/^\s*```(?:[a-z]+)?\s*$/.test(C));if(E.length%2===1){let C=E[E.length-1];u.push(ze("error",C.index,1,C.line.length+1,"Unclosed inline code block \u2014 expected a closing ``` line.",ee.unclosedCodeBlock))}return u}c(r3,"validateLines");function Ny(t,e){let n=[];t=bt(t);for(let i of e.commands){let r=i.properties.filter(o=>o.isIdentifier&&!kt(o).isOptional&&!kt(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(ze("information",s,ne(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.`,ee.omittedProductionDestination))}}return n}c(Ny,"validateProductionDestinations");function qy(t,e,n){let i=t[n],r=i.trim().replace(/\s*\/\/.*$/,"");if(!/^import\b/.test(r)||Fo(i,n))return;let o=ne(i);if(!(!(o>0&&["module","feature"].includes(Vo(t,e,n,o)[0]))&&!Ol(i)))return ze("error",n,o+1,r.length,`Invalid import '${r}' \u2014 inside a module or feature, import names files: 'import "<path or glob>"'.`,ee.invalidFileImport)}c(qy,"validateImport");var By=/^(?:(?:increment|decrement|count|clear|add|subtract|set)\s+)?@?([$\w.]+)(?=\s|=|$)/;function Yy(t,e){let n=[],i=c(r=>r.map(o=>o.name).join(", "),"names");for(let r=0;r<t.length;r++){let o=t[r];if(e[r])continue;for(let d of o.matchAll(/(\.)?\$eventContext((?:\.(?:\w+(?:\(\))?)?)*)/g)){let p=d[0].substring(d[1]?.length??0),m=d[2];if(m.length===0){d[1]&&n.push(ze("error",r,(d.index??0)+2,p.length,`'$eventContext' names no member - expected one of ${i(pr("").expected)}.`,ee.missingEventContextPath));continue}let u=m.substring(1),y=pr(u),h=(d.index??0)+(d[1]?.length??0)+1;switch(y.status){case"missing":n.push(ze("error",r,h,p.length,`'$eventContext.${u}' names no member - expected one of ${i(y.expected)}.`,ee.missingEventContextPath));break;case"unknownMember":n.push(ze("warning",r,h,p.length,`Unknown event context member '${y.segment}' in '$eventContext.${u}' - expected one of ${i(y.expected)}.`,ee.unknownEventContextMember));break;case"unknownSubPath":{let x=y.expected.length===0?"no members to address":`members ${i(y.expected)}`;n.push(ze("warning",r,h,p.length,`Unknown event context path '$eventContext.${u}' - '${y.member?.name}' (${y.member?.type}) has ${x}.`,ee.unknownEventContextPath));break}case"belowCollection":n.push(ze("error",r,h,p.length,`'$eventContext.${u}' cannot resolve - '${y.member?.name}' is a collection (${y.member?.type}) and cannot be addressed below.`,ee.eventContextPathBelowCollection));break}}let s=o.trim().match(By)?.[1],a=s?.match(/\.\$(\w+)/)?.[1];s&&a&&a!=="eventContext"&&n.push(Ve("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.`,ee.unresolvedDynamicKeySource))}return n}c(Yy,"validateEventContextPaths");export{Rl as a,Fy as b,Uy as c,Wo as d,Wy as e,rr as f,or as g,ar as h,Un as i,Vy as j,Dl as k,zy as l,Dt as m,ln as n,Gy as o,l as p,ke as q,Tr as r,li as s,bO as t,kO as u,Ae as v,ne as w,sr as x,Re as y,Vo as z,Ky as A,Jy as B,bt as C,lh as D,lr as E,cr as F,dr as G,Ml as H,nh as I,ih as J,rh as K,Ll as L,jl as M,mh as N,yh as O,hh as P,Sh as Q,gh as R,xh as S,vh as T,$h as U,bh as V,kh as W,Eh as X,ql as Y,Ch as Z,Dh as _,Mh as $,Lh as aa,jh as ba,Nh as ca,Bl as da,qh as ea,Bh as fa,Yh as ga,Fh as ha,Yl as ia,Uh as ja,Wh as ka,Vh as la,zh as ma,Qh as na,Gh as oa,_h as pa,Zh as qa,Kh as ra,Jh as sa,Hh as ta,Xh as ua,eS as va,Go as wa,Fl as xa,tS as ya,nS as za,iS as Aa,rS as Ba,oS as Ca,Ul as Da,aS as Ea,Wl as Fa,sS as Ga,lS as Ha,cS as Ia,Vl as Ja,dS as Ka,HD as La,an as Ma,Lo as Na,nM as Oa,jo as Pa,iM as Qa,kt as Ra,sn as Sa,Yn as Ta,nr as Ua,wl as Va,ir as Wa,Iy as Xa,gM as Ya,Bo as Za,Yo as _a,PM as $a,ee as ab,Ol as bb,Fo as cb,TM as db,RM as eb,r3 as fb,Yy as gb};
|
|
42
|
-
//# sourceMappingURL=chunk-4CLLEMBX.js.map
|