woml-cli 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var NX=Object.create;var{getPrototypeOf:PX,defineProperty:y9,getOwnPropertyNames:_X}=Object;var jX=Object.prototype.hasOwnProperty;function IX(W){return this[W]}var yX,DX,kX=(W,O,M)=>{var L=W!=null&&typeof W==="object";if(L){var $=O?yX??=new WeakMap:DX??=new WeakMap,Y=$.get(W);if(Y)return Y}M=W!=null?NX(PX(W)):{};let J=O||!W||!W.__esModule?y9(M,"default",{value:W,enumerable:!0}):M;for(let A of _X(W))if(!jX.call(J,A))y9(J,A,{get:IX.bind(W,A),enumerable:!0});if(L)$.set(W,J);return J};var y=(W,O)=>()=>(O||W((O={exports:{}}).exports,O),O.exports);var G1=y((f9)=>{Object.defineProperty(f9,"__esModule",{value:!0});f9.regexpCode=f9.getEsmExportName=f9.getProperty=f9.safeStringify=f9.stringify=f9.strConcat=f9.addCodeArg=f9.str=f9._=f9.nil=f9._Code=f9.Name=f9.IDENTIFIER=f9._CodeOrName=void 0;class KM{}f9._CodeOrName=KM;f9.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class B0 extends KM{constructor(W){super();if(!f9.IDENTIFIER.test(W))throw Error("CodeGen: name must be a valid identifier");this.str=W}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}f9.Name=B0;class $O extends KM{constructor(W){super();this._items=typeof W==="string"?[W]:W}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let W=this._items[0];return W===""||W==='""'}get str(){var W;return(W=this._str)!==null&&W!==void 0?W:this._str=this._items.reduce((O,M)=>`${O}${M}`,"")}get names(){var W;return(W=this._names)!==null&&W!==void 0?W:this._names=this._items.reduce((O,M)=>{if(M instanceof B0)O[M.str]=(O[M.str]||0)+1;return O},{})}}f9._Code=$O;f9.nil=new $O("");function k9(W,...O){let M=[W[0]],L=0;while(L<O.length)$$(M,O[L]),M.push(W[++L]);return new $O(M)}f9._=k9;var L$=new $O("+");function b9(W,...O){let M=[X1(W[0])],L=0;while(L<O.length)M.push(L$),$$(M,O[L]),M.push(L$,X1(W[++L]));return vX(M),new $O(M)}f9.str=b9;function $$(W,O){if(O instanceof $O)W.push(...O._items);else if(O instanceof B0)W.push(O);else W.push(hX(O))}f9.addCodeArg=$$;function vX(W){let O=1;while(O<W.length-1){if(W[O]===L$){let M=xX(W[O-1],W[O+1]);if(M!==void 0){W.splice(O-1,3,M);continue}W[O++]="+"}O++}}function xX(W,O){if(O==='""')return W;if(W==='""')return O;if(typeof W=="string"){if(O instanceof B0||W[W.length-1]!=='"')return;if(typeof O!="string")return`${W.slice(0,-1)}${O}"`;if(O[0]==='"')return W.slice(0,-1)+O.slice(1);return}if(typeof O=="string"&&O[0]==='"'&&!(W instanceof B0))return`"${W}${O.slice(1)}`;return}function gX(W,O){return O.emptyStr()?W:W.emptyStr()?O:b9`${W}${O}`}f9.strConcat=gX;function hX(W){return typeof W=="number"||typeof W=="boolean"||W===null?W:X1(Array.isArray(W)?W.join(","):W)}function uX(W){return new $O(X1(W))}f9.stringify=uX;function X1(W){return JSON.stringify(W).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}f9.safeStringify=X1;function lX(W){return typeof W=="string"&&f9.IDENTIFIER.test(W)?new $O(`.${W}`):k9`[${W}]`}f9.getProperty=lX;function pX(W){if(typeof W=="string"&&f9.IDENTIFIER.test(W))return new $O(`${W}`);throw Error(`CodeGen: invalid export name: ${W}, use explicit $id name mapping`)}f9.getEsmExportName=pX;function mX(W){return new $O(W.toString())}f9.regexpCode=mX});var Z$=y((h9)=>{Object.defineProperty(h9,"__esModule",{value:!0});h9.ValueScope=h9.ValueScopeName=h9.Scope=h9.varKinds=h9.UsedValueState=void 0;var fW=G1();class x9 extends Error{constructor(W){super(`CodeGen: "code" for ${W} not defined`);this.value=W.value}}var FM;(function(W){W[W.Started=0]="Started",W[W.Completed=1]="Completed"})(FM||(h9.UsedValueState=FM={}));h9.varKinds={const:new fW.Name("const"),let:new fW.Name("let"),var:new fW.Name("var")};class J${constructor({prefixes:W,parent:O}={}){this._names={},this._prefixes=W,this._parent=O}toName(W){return W instanceof fW.Name?W:this.name(W)}name(W){return new fW.Name(this._newName(W))}_newName(W){let O=this._names[W]||this._nameGroup(W);return`${W}${O.index++}`}_nameGroup(W){var O,M;if(((M=(O=this._parent)===null||O===void 0?void 0:O._prefixes)===null||M===void 0?void 0:M.has(W))||this._prefixes&&!this._prefixes.has(W))throw Error(`CodeGen: prefix "${W}" is not allowed in this scope`);return this._names[W]={prefix:W,index:0}}}h9.Scope=J$;class A$ extends fW.Name{constructor(W,O){super(O);this.prefix=W}setValue(W,{property:O,itemIndex:M}){this.value=W,this.scopePath=fW._`.${new fW.Name(O)}[${M}]`}}h9.ValueScopeName=A$;var MG=fW._`\n`;class g9 extends J${constructor(W){super(W);this._values={},this._scope=W.scope,this.opts={...W,_n:W.lines?MG:fW.nil}}get(){return this._scope}name(W){return new A$(W,this._newName(W))}value(W,O){var M;if(O.ref===void 0)throw Error("CodeGen: ref must be passed in value");let L=this.toName(W),{prefix:$}=L,Y=(M=O.key)!==null&&M!==void 0?M:O.ref,J=this._values[$];if(J){let X=J.get(Y);if(X)return X}else J=this._values[$]=new Map;J.set(Y,L);let A=this._scope[$]||(this._scope[$]=[]),Z=A.length;return A[Z]=O.ref,L.setValue(O,{property:$,itemIndex:Z}),L}getValue(W,O){let M=this._values[W];if(!M)return;return M.get(O)}scopeRefs(W,O=this._values){return this._reduceValues(O,(M)=>{if(M.scopePath===void 0)throw Error(`CodeGen: name "${M}" has no value`);return fW._`${W}${M.scopePath}`})}scopeCode(W=this._values,O,M){return this._reduceValues(W,(L)=>{if(L.value===void 0)throw Error(`CodeGen: name "${L}" has no value`);return L.value.code},O,M)}_reduceValues(W,O,M={},L){let $=fW.nil;for(let Y in W){let J=W[Y];if(!J)continue;let A=M[Y]=M[Y]||new Map;J.forEach((Z)=>{if(A.has(Z))return;A.set(Z,FM.Started);let X=O(Z);if(X){let G=this.opts.es5?h9.varKinds.var:h9.varKinds.const;$=fW._`${$}${G} ${Z} = ${X};${this.opts._n}`}else if(X=L===null||L===void 0?void 0:L(Z))$=fW._`${$}${X}${this.opts._n}`;else throw new x9(Z);A.set(Z,FM.Completed)})}return $}}h9.ValueScope=g9});var d=y((vW)=>{Object.defineProperty(vW,"__esModule",{value:!0});vW.or=vW.and=vW.not=vW.CodeGen=vW.operators=vW.varKinds=vW.ValueScopeName=vW.ValueScope=vW.Scope=vW.Name=vW.regexpCode=vW.stringify=vW.getProperty=vW.nil=vW.strConcat=vW.str=vW._=void 0;var a=G1(),YO=Z$(),uO=G1();Object.defineProperty(vW,"_",{enumerable:!0,get:function(){return uO._}});Object.defineProperty(vW,"str",{enumerable:!0,get:function(){return uO.str}});Object.defineProperty(vW,"strConcat",{enumerable:!0,get:function(){return uO.strConcat}});Object.defineProperty(vW,"nil",{enumerable:!0,get:function(){return uO.nil}});Object.defineProperty(vW,"getProperty",{enumerable:!0,get:function(){return uO.getProperty}});Object.defineProperty(vW,"stringify",{enumerable:!0,get:function(){return uO.stringify}});Object.defineProperty(vW,"regexpCode",{enumerable:!0,get:function(){return uO.regexpCode}});Object.defineProperty(vW,"Name",{enumerable:!0,get:function(){return uO.Name}});var NM=Z$();Object.defineProperty(vW,"Scope",{enumerable:!0,get:function(){return NM.Scope}});Object.defineProperty(vW,"ValueScope",{enumerable:!0,get:function(){return NM.ValueScope}});Object.defineProperty(vW,"ValueScopeName",{enumerable:!0,get:function(){return NM.ValueScopeName}});Object.defineProperty(vW,"varKinds",{enumerable:!0,get:function(){return NM.varKinds}});vW.operators={GT:new a._Code(">"),GTE:new a._Code(">="),LT:new a._Code("<"),LTE:new a._Code("<="),EQ:new a._Code("==="),NEQ:new a._Code("!=="),NOT:new a._Code("!"),OR:new a._Code("||"),AND:new a._Code("&&"),ADD:new a._Code("+")};class lO{optimizeNodes(){return this}optimizeNames(W,O){return this}}class l9 extends lO{constructor(W,O,M){super();this.varKind=W,this.name=O,this.rhs=M}render({es5:W,_n:O}){let M=W?YO.varKinds.var:this.varKind,L=this.rhs===void 0?"":` = ${this.rhs}`;return`${M} ${this.name}${L};`+O}optimizeNames(W,O){if(!W[this.name.str])return;if(this.rhs)this.rhs=C0(this.rhs,W,O);return this}get names(){return this.rhs instanceof a._CodeOrName?this.rhs.names:{}}}class Q$ extends lO{constructor(W,O,M){super();this.lhs=W,this.rhs=O,this.sideEffects=M}render({_n:W}){return`${this.lhs} = ${this.rhs};`+W}optimizeNames(W,O){if(this.lhs instanceof a.Name&&!W[this.lhs.str]&&!this.sideEffects)return;return this.rhs=C0(this.rhs,W,O),this}get names(){let W=this.lhs instanceof a.Name?{}:{...this.lhs.names};return CM(W,this.rhs)}}class p9 extends Q${constructor(W,O,M,L){super(W,M,L);this.op=O}render({_n:W}){return`${this.lhs} ${this.op}= ${this.rhs};`+W}}class m9 extends lO{constructor(W){super();this.label=W,this.names={}}render({_n:W}){return`${this.label}:`+W}}class d9 extends lO{constructor(W){super();this.label=W,this.names={}}render({_n:W}){return`break${this.label?` ${this.label}`:""};`+W}}class c9 extends lO{constructor(W){super();this.error=W}render({_n:W}){return`throw ${this.error};`+W}get names(){return this.error.names}}class i9 extends lO{constructor(W){super();this.code=W}render({_n:W}){return`${this.code};`+W}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(W,O){return this.code=C0(this.code,W,O),this}get names(){return this.code instanceof a._CodeOrName?this.code.names:{}}}class PM extends lO{constructor(W=[]){super();this.nodes=W}render(W){return this.nodes.reduce((O,M)=>O+M.render(W),"")}optimizeNodes(){let{nodes:W}=this,O=W.length;while(O--){let M=W[O].optimizeNodes();if(Array.isArray(M))W.splice(O,1,...M);else if(M)W[O]=M;else W.splice(O,1)}return W.length>0?this:void 0}optimizeNames(W,O){let{nodes:M}=this,L=M.length;while(L--){let $=M[L];if($.optimizeNames(W,O))continue;JG(W,$.names),M.splice(L,1)}return M.length>0?this:void 0}get names(){return this.nodes.reduce((W,O)=>L0(W,O.names),{})}}class pO extends PM{render(W){return"{"+W._n+super.render(W)+"}"+W._n}}class s9 extends PM{}class Q1 extends pO{}Q1.kind="else";class jO extends pO{constructor(W,O){super(O);this.condition=W}render(W){let O=`if(${this.condition})`+super.render(W);if(this.else)O+="else "+this.else.render(W);return O}optimizeNodes(){super.optimizeNodes();let W=this.condition;if(W===!0)return this.nodes;let O=this.else;if(O){let M=O.optimizeNodes();O=this.else=Array.isArray(M)?new Q1(M):M}if(O){if(W===!1)return O instanceof jO?O:O.nodes;if(this.nodes.length)return this;return new jO(t9(W),O instanceof jO?[O]:O.nodes)}if(W===!1||!this.nodes.length)return;return this}optimizeNames(W,O){var M;if(this.else=(M=this.else)===null||M===void 0?void 0:M.optimizeNames(W,O),!(super.optimizeNames(W,O)||this.else))return;return this.condition=C0(this.condition,W,O),this}get names(){let W=super.names;if(CM(W,this.condition),this.else)L0(W,this.else.names);return W}}jO.kind="if";class w0 extends pO{}w0.kind="for";class n9 extends w0{constructor(W){super();this.iteration=W}render(W){return`for(${this.iteration})`+super.render(W)}optimizeNames(W,O){if(!super.optimizeNames(W,O))return;return this.iteration=C0(this.iteration,W,O),this}get names(){return L0(super.names,this.iteration.names)}}class r9 extends w0{constructor(W,O,M,L){super();this.varKind=W,this.name=O,this.from=M,this.to=L}render(W){let O=W.es5?YO.varKinds.var:this.varKind,{name:M,from:L,to:$}=this;return`for(${O} ${M}=${L}; ${M}<${$}; ${M}++)`+super.render(W)}get names(){let W=CM(super.names,this.from);return CM(W,this.to)}}class X$ extends w0{constructor(W,O,M,L){super();this.loop=W,this.varKind=O,this.name=M,this.iterable=L}render(W){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(W)}optimizeNames(W,O){if(!super.optimizeNames(W,O))return;return this.iterable=C0(this.iterable,W,O),this}get names(){return L0(super.names,this.iterable.names)}}class EM extends pO{constructor(W,O,M){super();this.name=W,this.args=O,this.async=M}render(W){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(W)}}EM.kind="func";class qM extends PM{render(W){return"return "+super.render(W)}}qM.kind="return";class a9 extends pO{render(W){let O="try"+super.render(W);if(this.catch)O+=this.catch.render(W);if(this.finally)O+=this.finally.render(W);return O}optimizeNodes(){var W,O;return super.optimizeNodes(),(W=this.catch)===null||W===void 0||W.optimizeNodes(),(O=this.finally)===null||O===void 0||O.optimizeNodes(),this}optimizeNames(W,O){var M,L;return super.optimizeNames(W,O),(M=this.catch)===null||M===void 0||M.optimizeNames(W,O),(L=this.finally)===null||L===void 0||L.optimizeNames(W,O),this}get names(){let W=super.names;if(this.catch)L0(W,this.catch.names);if(this.finally)L0(W,this.finally.names);return W}}class BM extends pO{constructor(W){super();this.error=W}render(W){return`catch(${this.error})`+super.render(W)}}BM.kind="catch";class wM extends pO{render(W){return"finally"+super.render(W)}}wM.kind="finally";class o9{constructor(W,O={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...O,_n:O.lines?`
4
- `:""},this._extScope=W,this._scope=new YO.Scope({parent:W}),this._nodes=[new s9]}toString(){return this._root.render(this.opts)}name(W){return this._scope.name(W)}scopeName(W){return this._extScope.name(W)}scopeValue(W,O){let M=this._extScope.value(W,O);return(this._values[M.prefix]||(this._values[M.prefix]=new Set)).add(M),M}getScopeValue(W,O){return this._extScope.getValue(W,O)}scopeRefs(W){return this._extScope.scopeRefs(W,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(W,O,M,L){let $=this._scope.toName(O);if(M!==void 0&&L)this._constants[$.str]=M;return this._leafNode(new l9(W,$,M)),$}const(W,O,M){return this._def(YO.varKinds.const,W,O,M)}let(W,O,M){return this._def(YO.varKinds.let,W,O,M)}var(W,O,M){return this._def(YO.varKinds.var,W,O,M)}assign(W,O,M){return this._leafNode(new Q$(W,O,M))}add(W,O){return this._leafNode(new p9(W,vW.operators.ADD,O))}code(W){if(typeof W=="function")W();else if(W!==a.nil)this._leafNode(new i9(W));return this}object(...W){let O=["{"];for(let[M,L]of W){if(O.length>1)O.push(",");if(O.push(M),M!==L||this.opts.es5)O.push(":"),(0,a.addCodeArg)(O,L)}return O.push("}"),new a._Code(O)}if(W,O,M){if(this._blockNode(new jO(W)),O&&M)this.code(O).else().code(M).endIf();else if(O)this.code(O).endIf();else if(M)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(W){return this._elseNode(new jO(W))}else(){return this._elseNode(new Q1)}endIf(){return this._endBlockNode(jO,Q1)}_for(W,O){if(this._blockNode(W),O)this.code(O).endFor();return this}for(W,O){return this._for(new n9(W),O)}forRange(W,O,M,L,$=this.opts.es5?YO.varKinds.var:YO.varKinds.let){let Y=this._scope.toName(W);return this._for(new r9($,Y,O,M),()=>L(Y))}forOf(W,O,M,L=YO.varKinds.const){let $=this._scope.toName(W);if(this.opts.es5){let Y=O instanceof a.Name?O:this.var("_arr",O);return this.forRange("_i",0,a._`${Y}.length`,(J)=>{this.var($,a._`${Y}[${J}]`),M($)})}return this._for(new X$("of",L,$,O),()=>M($))}forIn(W,O,M,L=this.opts.es5?YO.varKinds.var:YO.varKinds.const){if(this.opts.ownProperties)return this.forOf(W,a._`Object.keys(${O})`,M);let $=this._scope.toName(W);return this._for(new X$("in",L,$,O),()=>M($))}endFor(){return this._endBlockNode(w0)}label(W){return this._leafNode(new m9(W))}break(W){return this._leafNode(new d9(W))}return(W){let O=new qM;if(this._blockNode(O),this.code(W),O.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(qM)}try(W,O,M){if(!O&&!M)throw Error('CodeGen: "try" without "catch" and "finally"');let L=new a9;if(this._blockNode(L),this.code(W),O){let $=this.name("e");this._currNode=L.catch=new BM($),O($)}if(M)this._currNode=L.finally=new wM,this.code(M);return this._endBlockNode(BM,wM)}throw(W){return this._leafNode(new c9(W))}block(W,O){if(this._blockStarts.push(this._nodes.length),W)this.code(W).endBlock(O);return this}endBlock(W){let O=this._blockStarts.pop();if(O===void 0)throw Error("CodeGen: not in self-balancing block");let M=this._nodes.length-O;if(M<0||W!==void 0&&M!==W)throw Error(`CodeGen: wrong number of nodes: ${M} vs ${W} expected`);return this._nodes.length=O,this}func(W,O=a.nil,M,L){if(this._blockNode(new EM(W,O,M)),L)this.code(L).endFunc();return this}endFunc(){return this._endBlockNode(EM)}optimize(W=1){while(W-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(W){return this._currNode.nodes.push(W),this}_blockNode(W){this._currNode.nodes.push(W),this._nodes.push(W)}_endBlockNode(W,O){let M=this._currNode;if(M instanceof W||O&&M instanceof O)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${O?`${W.kind}/${O.kind}`:W.kind}"`)}_elseNode(W){let O=this._currNode;if(!(O instanceof jO))throw Error('CodeGen: "else" without "if"');return this._currNode=O.else=W,this}get _root(){return this._nodes[0]}get _currNode(){let W=this._nodes;return W[W.length-1]}set _currNode(W){let O=this._nodes;O[O.length-1]=W}}vW.CodeGen=o9;function L0(W,O){for(let M in O)W[M]=(W[M]||0)+(O[M]||0);return W}function CM(W,O){return O instanceof a._CodeOrName?L0(W,O.names):W}function C0(W,O,M){if(W instanceof a.Name)return L(W);if(!$(W))return W;return new a._Code(W._items.reduce((Y,J)=>{if(J instanceof a.Name)J=L(J);if(J instanceof a._Code)Y.push(...J._items);else Y.push(J);return Y},[]));function L(Y){let J=M[Y.str];if(J===void 0||O[Y.str]!==1)return Y;return delete O[Y.str],J}function $(Y){return Y instanceof a._Code&&Y._items.some((J)=>J instanceof a.Name&&O[J.str]===1&&M[J.str]!==void 0)}}function JG(W,O){for(let M in O)W[M]=(W[M]||0)-(O[M]||0)}function t9(W){return typeof W=="boolean"||typeof W=="number"||W===null?!W:a._`!${G$(W)}`}vW.not=t9;var AG=e9(vW.operators.AND);function ZG(...W){return W.reduce(AG)}vW.and=ZG;var XG=e9(vW.operators.OR);function GG(...W){return W.reduce(XG)}vW.or=GG;function e9(W){return(O,M)=>O===a.nil?M:M===a.nil?O:a._`${G$(O)} ${W} ${G$(M)}`}function G$(W){return W instanceof a.Name?W:a._`(${W})`}});var s=y((ZY)=>{Object.defineProperty(ZY,"__esModule",{value:!0});ZY.checkStrictMode=ZY.getErrorPath=ZY.Type=ZY.useFunc=ZY.setEvaluated=ZY.evaluatedPropsToName=ZY.mergeEvaluated=ZY.eachItem=ZY.unescapeJsonPointer=ZY.escapeJsonPointer=ZY.escapeFragment=ZY.unescapeFragment=ZY.schemaRefOrVal=ZY.schemaHasRulesButRef=ZY.schemaHasRules=ZY.checkUnknownRules=ZY.alwaysValidSchema=ZY.toHash=void 0;var LW=d(),UG=G1();function zG(W){let O={};for(let M of W)O[M]=!0;return O}ZY.toHash=zG;function VG(W,O){if(typeof O=="boolean")return O;if(Object.keys(O).length===0)return!0;return LY(W,O),!$Y(O,W.self.RULES.all)}ZY.alwaysValidSchema=VG;function LY(W,O=W.schema){let{opts:M,self:L}=W;if(!M.strictSchema)return;if(typeof O==="boolean")return;let $=L.RULES.keywords;for(let Y in O)if(!$[Y])AY(W,`unknown keyword: "${Y}"`)}ZY.checkUnknownRules=LY;function $Y(W,O){if(typeof W=="boolean")return!W;for(let M in W)if(O[M])return!0;return!1}ZY.schemaHasRules=$Y;function HG(W,O){if(typeof W=="boolean")return!W;for(let M in W)if(M!=="$ref"&&O.all[M])return!0;return!1}ZY.schemaHasRulesButRef=HG;function KG({topSchemaRef:W,schemaPath:O},M,L,$){if(!$){if(typeof M=="number"||typeof M=="boolean")return M;if(typeof M=="string")return LW._`${M}`}return LW._`${W}${O}${(0,LW.getProperty)(L)}`}ZY.schemaRefOrVal=KG;function TG(W){return YY(decodeURIComponent(W))}ZY.unescapeFragment=TG;function FG(W){return encodeURIComponent(R$(W))}ZY.escapeFragment=FG;function R$(W){if(typeof W=="number")return`${W}`;return W.replace(/~/g,"~0").replace(/\//g,"~1")}ZY.escapeJsonPointer=R$;function YY(W){return W.replace(/~1/g,"/").replace(/~0/g,"~")}ZY.unescapeJsonPointer=YY;function EG(W,O){if(Array.isArray(W))for(let M of W)O(M);else O(W)}ZY.eachItem=EG;function OY({mergeNames:W,mergeToName:O,mergeValues:M,resultToName:L}){return($,Y,J,A)=>{let Z=J===void 0?Y:J instanceof LW.Name?(Y instanceof LW.Name?W($,Y,J):O($,Y,J),J):Y instanceof LW.Name?(O($,J,Y),Y):M(Y,J);return A===LW.Name&&!(Z instanceof LW.Name)?L($,Z):Z}}ZY.mergeEvaluated={props:OY({mergeNames:(W,O,M)=>W.if(LW._`${M} !== true && ${O} !== undefined`,()=>{W.if(LW._`${O} === true`,()=>W.assign(M,!0),()=>W.assign(M,LW._`${M} || {}`).code(LW._`Object.assign(${M}, ${O})`))}),mergeToName:(W,O,M)=>W.if(LW._`${M} !== true`,()=>{if(O===!0)W.assign(M,!0);else W.assign(M,LW._`${M} || {}`),U$(W,M,O)}),mergeValues:(W,O)=>W===!0?!0:{...W,...O},resultToName:JY}),items:OY({mergeNames:(W,O,M)=>W.if(LW._`${M} !== true && ${O} !== undefined`,()=>W.assign(M,LW._`${O} === true ? true : ${M} > ${O} ? ${M} : ${O}`)),mergeToName:(W,O,M)=>W.if(LW._`${M} !== true`,()=>W.assign(M,O===!0?!0:LW._`${M} > ${O} ? ${M} : ${O}`)),mergeValues:(W,O)=>W===!0?!0:Math.max(W,O),resultToName:(W,O)=>W.var("items",O)})};function JY(W,O){if(O===!0)return W.var("props",!0);let M=W.var("props",LW._`{}`);if(O!==void 0)U$(W,M,O);return M}ZY.evaluatedPropsToName=JY;function U$(W,O,M){Object.keys(M).forEach((L)=>W.assign(LW._`${O}${(0,LW.getProperty)(L)}`,!0))}ZY.setEvaluated=U$;var MY={};function qG(W,O){return W.scopeValue("func",{ref:O,code:MY[O.code]||(MY[O.code]=new UG._Code(O.code))})}ZY.useFunc=qG;var S$;(function(W){W[W.Num=0]="Num",W[W.Str=1]="Str"})(S$||(ZY.Type=S$={}));function BG(W,O,M){if(W instanceof LW.Name){let L=O===S$.Num;return M?L?LW._`"[" + ${W} + "]"`:LW._`"['" + ${W} + "']"`:L?LW._`"/" + ${W}`:LW._`"/" + ${W}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return M?(0,LW.getProperty)(W).toString():"/"+R$(W)}ZY.getErrorPath=BG;function AY(W,O,M=W.opts.strictSchema){if(!M)return;if(O=`strict mode: ${O}`,M===!0)throw Error(O);W.self.logger.warn(O)}ZY.checkStrictMode=AY});var nW=y((GY)=>{Object.defineProperty(GY,"__esModule",{value:!0});var qW=d(),lG={data:new qW.Name("data"),valCxt:new qW.Name("valCxt"),instancePath:new qW.Name("instancePath"),parentData:new qW.Name("parentData"),parentDataProperty:new qW.Name("parentDataProperty"),rootData:new qW.Name("rootData"),dynamicAnchors:new qW.Name("dynamicAnchors"),vErrors:new qW.Name("vErrors"),errors:new qW.Name("errors"),this:new qW.Name("this"),self:new qW.Name("self"),scope:new qW.Name("scope"),json:new qW.Name("json"),jsonPos:new qW.Name("jsonPos"),jsonLen:new qW.Name("jsonLen"),jsonPart:new qW.Name("jsonPart")};GY.default=lG});var S1=y((UY)=>{Object.defineProperty(UY,"__esModule",{value:!0});UY.extendErrors=UY.resetErrorsCount=UY.reportExtraError=UY.reportError=UY.keyword$DataError=UY.keywordError=void 0;var t=d(),jM=s(),_W=nW();UY.keywordError={message:({keyword:W})=>t.str`must pass "${W}" keyword validation`};UY.keyword$DataError={message:({keyword:W,schemaType:O})=>O?t.str`"${W}" keyword must be ${O} ($data)`:t.str`"${W}" keyword is invalid ($data)`};function mG(W,O=UY.keywordError,M,L){let{it:$}=W,{gen:Y,compositeRule:J,allErrors:A}=$,Z=RY(W,O,M);if(L!==null&&L!==void 0?L:J||A)QY(Y,Z);else SY($,t._`[${Z}]`)}UY.reportError=mG;function dG(W,O=UY.keywordError,M){let{it:L}=W,{gen:$,compositeRule:Y,allErrors:J}=L,A=RY(W,O,M);if(QY($,A),!(Y||J))SY(L,_W.default.vErrors)}UY.reportExtraError=dG;function cG(W,O){W.assign(_W.default.errors,O),W.if(t._`${_W.default.vErrors} !== null`,()=>W.if(O,()=>W.assign(t._`${_W.default.vErrors}.length`,O),()=>W.assign(_W.default.vErrors,null)))}UY.resetErrorsCount=cG;function iG({gen:W,keyword:O,schemaValue:M,data:L,errsCount:$,it:Y}){if($===void 0)throw Error("ajv implementation error");let J=W.name("err");W.forRange("i",$,_W.default.errors,(A)=>{if(W.const(J,t._`${_W.default.vErrors}[${A}]`),W.if(t._`${J}.instancePath === undefined`,()=>W.assign(t._`${J}.instancePath`,(0,t.strConcat)(_W.default.instancePath,Y.errorPath))),W.assign(t._`${J}.schemaPath`,t.str`${Y.errSchemaPath}/${O}`),Y.opts.verbose)W.assign(t._`${J}.schema`,M),W.assign(t._`${J}.data`,L)})}UY.extendErrors=iG;function QY(W,O){let M=W.const("err",O);W.if(t._`${_W.default.vErrors} === null`,()=>W.assign(_W.default.vErrors,t._`[${M}]`),t._`${_W.default.vErrors}.push(${M})`),W.code(t._`${_W.default.errors}++`)}function SY(W,O){let{gen:M,validateName:L,schemaEnv:$}=W;if($.$async)M.throw(t._`new ${W.ValidationError}(${O})`);else M.assign(t._`${L}.errors`,O),M.return(!1)}var $0={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function RY(W,O,M){let{createErrors:L}=W.it;if(L===!1)return t._`{}`;return sG(W,O,M)}function sG(W,O,M={}){let{gen:L,it:$}=W,Y=[nG($,M),rG(W,M)];return aG(W,O,Y),L.object(...Y)}function nG({errorPath:W},{instancePath:O}){let M=O?t.str`${W}${(0,jM.getErrorPath)(O,jM.Type.Str)}`:W;return[_W.default.instancePath,(0,t.strConcat)(_W.default.instancePath,M)]}function rG({keyword:W,it:{errSchemaPath:O}},{schemaPath:M,parentSchema:L}){let $=L?O:t.str`${O}/${W}`;if(M)$=t.str`${$}${(0,jM.getErrorPath)(M,jM.Type.Str)}`;return[$0.schemaPath,$]}function aG(W,{params:O,message:M},L){let{keyword:$,data:Y,schemaValue:J,it:A}=W,{opts:Z,propertyName:X,topSchemaRef:G,schemaPath:Q}=A;if(L.push([$0.keyword,$],[$0.params,typeof O=="function"?O(W):O||t._`{}`]),Z.messages)L.push([$0.message,typeof M=="function"?M(W):M]);if(Z.verbose)L.push([$0.schema,J],[$0.parentSchema,t._`${G}${Q}`],[_W.default.data,Y]);if(X)L.push([$0.propertyName,X])}});var TY=y((HY)=>{Object.defineProperty(HY,"__esModule",{value:!0});HY.boolOrEmptySchema=HY.topBoolOrEmptySchema=void 0;var OQ=S1(),MQ=d(),LQ=nW(),$Q={message:"boolean schema is false"};function YQ(W){let{gen:O,schema:M,validateName:L}=W;if(M===!1)VY(W,!1);else if(typeof M=="object"&&M.$async===!0)O.return(LQ.default.data);else O.assign(MQ._`${L}.errors`,null),O.return(!0)}HY.topBoolOrEmptySchema=YQ;function JQ(W,O){let{gen:M,schema:L}=W;if(L===!1)M.var(O,!1),VY(W);else M.var(O,!0)}HY.boolOrEmptySchema=JQ;function VY(W,O){let{gen:M,data:L}=W,$={gen:M,keyword:"false schema",data:L,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:W};(0,OQ.reportError)($,$Q,void 0,O)}});var V$=y((FY)=>{Object.defineProperty(FY,"__esModule",{value:!0});FY.getRules=FY.isJSONType=void 0;var ZQ=["string","number","integer","boolean","null","object","array"],XQ=new Set(ZQ);function GQ(W){return typeof W=="string"&&XQ.has(W)}FY.isJSONType=GQ;function QQ(){let W={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...W,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},W.number,W.string,W.array,W.object],post:{rules:[]},all:{},keywords:{}}}FY.getRules=QQ});var H$=y((wY)=>{Object.defineProperty(wY,"__esModule",{value:!0});wY.shouldUseRule=wY.shouldUseGroup=wY.schemaHasRulesForType=void 0;function RQ({schema:W,self:O},M){let L=O.RULES.types[M];return L&&L!==!0&&qY(W,L)}wY.schemaHasRulesForType=RQ;function qY(W,O){return O.rules.some((M)=>BY(W,M))}wY.shouldUseGroup=qY;function BY(W,O){var M;return W[O.keyword]!==void 0||((M=O.definition.implements)===null||M===void 0?void 0:M.some((L)=>W[L]!==void 0))}wY.shouldUseRule=BY});var R1=y((jY)=>{Object.defineProperty(jY,"__esModule",{value:!0});jY.reportTypeError=jY.checkDataTypes=jY.checkDataType=jY.coerceAndCheckDataType=jY.getJSONTypes=jY.getSchemaTypes=jY.DataType=void 0;var VQ=V$(),HQ=H$(),KQ=S1(),i=d(),NY=s(),N0;(function(W){W[W.Correct=0]="Correct",W[W.Wrong=1]="Wrong"})(N0||(jY.DataType=N0={}));function TQ(W){let O=PY(W.type);if(O.includes("null")){if(W.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!O.length&&W.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(W.nullable===!0)O.push("null")}return O}jY.getSchemaTypes=TQ;function PY(W){let O=Array.isArray(W)?W:W?[W]:[];if(O.every(VQ.isJSONType))return O;throw Error("type must be JSONType or JSONType[]: "+O.join(","))}jY.getJSONTypes=PY;function FQ(W,O){let{gen:M,data:L,opts:$}=W,Y=EQ(O,$.coerceTypes),J=O.length>0&&!(Y.length===0&&O.length===1&&(0,HQ.schemaHasRulesForType)(W,O[0]));if(J){let A=T$(O,L,$.strictNumbers,N0.Wrong);M.if(A,()=>{if(Y.length)qQ(W,O,Y);else F$(W)})}return J}jY.coerceAndCheckDataType=FQ;var _Y=new Set(["string","number","integer","boolean","null"]);function EQ(W,O){return O?W.filter((M)=>_Y.has(M)||O==="array"&&M==="array"):[]}function qQ(W,O,M){let{gen:L,data:$,opts:Y}=W,J=L.let("dataType",i._`typeof ${$}`),A=L.let("coerced",i._`undefined`);if(Y.coerceTypes==="array")L.if(i._`${J} == 'object' && Array.isArray(${$}) && ${$}.length == 1`,()=>L.assign($,i._`${$}[0]`).assign(J,i._`typeof ${$}`).if(T$(O,$,Y.strictNumbers),()=>L.assign(A,$)));L.if(i._`${A} !== undefined`);for(let X of M)if(_Y.has(X)||X==="array"&&Y.coerceTypes==="array")Z(X);L.else(),F$(W),L.endIf(),L.if(i._`${A} !== undefined`,()=>{L.assign($,A),BQ(W,A)});function Z(X){switch(X){case"string":L.elseIf(i._`${J} == "number" || ${J} == "boolean"`).assign(A,i._`"" + ${$}`).elseIf(i._`${$} === null`).assign(A,i._`""`);return;case"number":L.elseIf(i._`${J} == "boolean" || ${$} === null
3
+ var _G=Object.create;var{getPrototypeOf:jG,defineProperty:b9,getOwnPropertyNames:IG}=Object;var yG=Object.prototype.hasOwnProperty;function DG(W){return this[W]}var kG,bG,fG=(W,O,M)=>{var L=W!=null&&typeof W==="object";if(L){var $=O?kG??=new WeakMap:bG??=new WeakMap,Y=$.get(W);if(Y)return Y}M=W!=null?_G(jG(W)):{};let J=O||!W||!W.__esModule?b9(M,"default",{value:W,enumerable:!0}):M;for(let A of IG(W))if(!yG.call(J,A))b9(J,A,{get:DG.bind(W,A),enumerable:!0});if(L)$.set(W,J);return J};var y=(W,O)=>()=>(O||W((O={exports:{}}).exports,O),O.exports);var V1=y((x9)=>{Object.defineProperty(x9,"__esModule",{value:!0});x9.regexpCode=x9.getEsmExportName=x9.getProperty=x9.safeStringify=x9.stringify=x9.strConcat=x9.addCodeArg=x9.str=x9._=x9.nil=x9._Code=x9.Name=x9.IDENTIFIER=x9._CodeOrName=void 0;class TM{}x9._CodeOrName=TM;x9.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class j0 extends TM{constructor(W){super();if(!x9.IDENTIFIER.test(W))throw Error("CodeGen: name must be a valid identifier");this.str=W}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}x9.Name=j0;class JO extends TM{constructor(W){super();this._items=typeof W==="string"?[W]:W}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let W=this._items[0];return W===""||W==='""'}get str(){var W;return(W=this._str)!==null&&W!==void 0?W:this._str=this._items.reduce((O,M)=>`${O}${M}`,"")}get names(){var W;return(W=this._names)!==null&&W!==void 0?W:this._names=this._items.reduce((O,M)=>{if(M instanceof j0)O[M.str]=(O[M.str]||0)+1;return O},{})}}x9._Code=JO;x9.nil=new JO("");function v9(W,...O){let M=[W[0]],L=0;while(L<O.length)J$(M,O[L]),M.push(W[++L]);return new JO(M)}x9._=v9;var Y$=new JO("+");function g9(W,...O){let M=[z1(W[0])],L=0;while(L<O.length)M.push(Y$),J$(M,O[L]),M.push(Y$,z1(W[++L]));return xG(M),new JO(M)}x9.str=g9;function J$(W,O){if(O instanceof JO)W.push(...O._items);else if(O instanceof j0)W.push(O);else W.push(lG(O))}x9.addCodeArg=J$;function xG(W){let O=1;while(O<W.length-1){if(W[O]===Y$){let M=hG(W[O-1],W[O+1]);if(M!==void 0){W.splice(O-1,3,M);continue}W[O++]="+"}O++}}function hG(W,O){if(O==='""')return W;if(W==='""')return O;if(typeof W=="string"){if(O instanceof j0||W[W.length-1]!=='"')return;if(typeof O!="string")return`${W.slice(0,-1)}${O}"`;if(O[0]==='"')return W.slice(0,-1)+O.slice(1);return}if(typeof O=="string"&&O[0]==='"'&&!(W instanceof j0))return`"${W}${O.slice(1)}`;return}function uG(W,O){return O.emptyStr()?W:W.emptyStr()?O:g9`${W}${O}`}x9.strConcat=uG;function lG(W){return typeof W=="number"||typeof W=="boolean"||W===null?W:z1(Array.isArray(W)?W.join(","):W)}function pG(W){return new JO(z1(W))}x9.stringify=pG;function z1(W){return JSON.stringify(W).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}x9.safeStringify=z1;function mG(W){return typeof W=="string"&&x9.IDENTIFIER.test(W)?new JO(`.${W}`):v9`[${W}]`}x9.getProperty=mG;function dG(W){if(typeof W=="string"&&x9.IDENTIFIER.test(W))return new JO(`${W}`);throw Error(`CodeGen: invalid export name: ${W}, use explicit $id name mapping`)}x9.getEsmExportName=dG;function cG(W){return new JO(W.toString())}x9.regexpCode=cG});var X$=y((p9)=>{Object.defineProperty(p9,"__esModule",{value:!0});p9.ValueScope=p9.ValueScopeName=p9.Scope=p9.varKinds=p9.UsedValueState=void 0;var fW=V1();class u9 extends Error{constructor(W){super(`CodeGen: "code" for ${W} not defined`);this.value=W.value}}var EM;(function(W){W[W.Started=0]="Started",W[W.Completed=1]="Completed"})(EM||(p9.UsedValueState=EM={}));p9.varKinds={const:new fW.Name("const"),let:new fW.Name("let"),var:new fW.Name("var")};class Z${constructor({prefixes:W,parent:O}={}){this._names={},this._prefixes=W,this._parent=O}toName(W){return W instanceof fW.Name?W:this.name(W)}name(W){return new fW.Name(this._newName(W))}_newName(W){let O=this._names[W]||this._nameGroup(W);return`${W}${O.index++}`}_nameGroup(W){var O,M;if(((M=(O=this._parent)===null||O===void 0?void 0:O._prefixes)===null||M===void 0?void 0:M.has(W))||this._prefixes&&!this._prefixes.has(W))throw Error(`CodeGen: prefix "${W}" is not allowed in this scope`);return this._names[W]={prefix:W,index:0}}}p9.Scope=Z$;class G$ extends fW.Name{constructor(W,O){super(O);this.prefix=W}setValue(W,{property:O,itemIndex:M}){this.value=W,this.scopePath=fW._`.${new fW.Name(O)}[${M}]`}}p9.ValueScopeName=G$;var $X=fW._`\n`;class l9 extends Z${constructor(W){super(W);this._values={},this._scope=W.scope,this.opts={...W,_n:W.lines?$X:fW.nil}}get(){return this._scope}name(W){return new G$(W,this._newName(W))}value(W,O){var M;if(O.ref===void 0)throw Error("CodeGen: ref must be passed in value");let L=this.toName(W),{prefix:$}=L,Y=(M=O.key)!==null&&M!==void 0?M:O.ref,J=this._values[$];if(J){let G=J.get(Y);if(G)return G}else J=this._values[$]=new Map;J.set(Y,L);let A=this._scope[$]||(this._scope[$]=[]),Z=A.length;return A[Z]=O.ref,L.setValue(O,{property:$,itemIndex:Z}),L}getValue(W,O){let M=this._values[W];if(!M)return;return M.get(O)}scopeRefs(W,O=this._values){return this._reduceValues(O,(M)=>{if(M.scopePath===void 0)throw Error(`CodeGen: name "${M}" has no value`);return fW._`${W}${M.scopePath}`})}scopeCode(W=this._values,O,M){return this._reduceValues(W,(L)=>{if(L.value===void 0)throw Error(`CodeGen: name "${L}" has no value`);return L.value.code},O,M)}_reduceValues(W,O,M={},L){let $=fW.nil;for(let Y in W){let J=W[Y];if(!J)continue;let A=M[Y]=M[Y]||new Map;J.forEach((Z)=>{if(A.has(Z))return;A.set(Z,EM.Started);let G=O(Z);if(G){let X=this.opts.es5?p9.varKinds.var:p9.varKinds.const;$=fW._`${$}${X} ${Z} = ${G};${this.opts._n}`}else if(G=L===null||L===void 0?void 0:L(Z))$=fW._`${$}${G}${this.opts._n}`;else throw new u9(Z);A.set(Z,EM.Completed)})}return $}}p9.ValueScope=l9});var d=y((vW)=>{Object.defineProperty(vW,"__esModule",{value:!0});vW.or=vW.and=vW.not=vW.CodeGen=vW.operators=vW.varKinds=vW.ValueScopeName=vW.ValueScope=vW.Scope=vW.Name=vW.regexpCode=vW.stringify=vW.getProperty=vW.nil=vW.strConcat=vW.str=vW._=void 0;var a=V1(),AO=X$(),dO=V1();Object.defineProperty(vW,"_",{enumerable:!0,get:function(){return dO._}});Object.defineProperty(vW,"str",{enumerable:!0,get:function(){return dO.str}});Object.defineProperty(vW,"strConcat",{enumerable:!0,get:function(){return dO.strConcat}});Object.defineProperty(vW,"nil",{enumerable:!0,get:function(){return dO.nil}});Object.defineProperty(vW,"getProperty",{enumerable:!0,get:function(){return dO.getProperty}});Object.defineProperty(vW,"stringify",{enumerable:!0,get:function(){return dO.stringify}});Object.defineProperty(vW,"regexpCode",{enumerable:!0,get:function(){return dO.regexpCode}});Object.defineProperty(vW,"Name",{enumerable:!0,get:function(){return dO.Name}});var NM=X$();Object.defineProperty(vW,"Scope",{enumerable:!0,get:function(){return NM.Scope}});Object.defineProperty(vW,"ValueScope",{enumerable:!0,get:function(){return NM.ValueScope}});Object.defineProperty(vW,"ValueScopeName",{enumerable:!0,get:function(){return NM.ValueScopeName}});Object.defineProperty(vW,"varKinds",{enumerable:!0,get:function(){return NM.varKinds}});vW.operators={GT:new a._Code(">"),GTE:new a._Code(">="),LT:new a._Code("<"),LTE:new a._Code("<="),EQ:new a._Code("==="),NEQ:new a._Code("!=="),NOT:new a._Code("!"),OR:new a._Code("||"),AND:new a._Code("&&"),ADD:new a._Code("+")};class cO{optimizeNodes(){return this}optimizeNames(W,O){return this}}class d9 extends cO{constructor(W,O,M){super();this.varKind=W,this.name=O,this.rhs=M}render({es5:W,_n:O}){let M=W?AO.varKinds.var:this.varKind,L=this.rhs===void 0?"":` = ${this.rhs}`;return`${M} ${this.name}${L};`+O}optimizeNames(W,O){if(!W[this.name.str])return;if(this.rhs)this.rhs=y0(this.rhs,W,O);return this}get names(){return this.rhs instanceof a._CodeOrName?this.rhs.names:{}}}class S$ extends cO{constructor(W,O,M){super();this.lhs=W,this.rhs=O,this.sideEffects=M}render({_n:W}){return`${this.lhs} = ${this.rhs};`+W}optimizeNames(W,O){if(this.lhs instanceof a.Name&&!W[this.lhs.str]&&!this.sideEffects)return;return this.rhs=y0(this.rhs,W,O),this}get names(){let W=this.lhs instanceof a.Name?{}:{...this.lhs.names};return PM(W,this.rhs)}}class c9 extends S${constructor(W,O,M,L){super(W,M,L);this.op=O}render({_n:W}){return`${this.lhs} ${this.op}= ${this.rhs};`+W}}class i9 extends cO{constructor(W){super();this.label=W,this.names={}}render({_n:W}){return`${this.label}:`+W}}class s9 extends cO{constructor(W){super();this.label=W,this.names={}}render({_n:W}){return`break${this.label?` ${this.label}`:""};`+W}}class n9 extends cO{constructor(W){super();this.error=W}render({_n:W}){return`throw ${this.error};`+W}get names(){return this.error.names}}class r9 extends cO{constructor(W){super();this.code=W}render({_n:W}){return`${this.code};`+W}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(W,O){return this.code=y0(this.code,W,O),this}get names(){return this.code instanceof a._CodeOrName?this.code.names:{}}}class _M extends cO{constructor(W=[]){super();this.nodes=W}render(W){return this.nodes.reduce((O,M)=>O+M.render(W),"")}optimizeNodes(){let{nodes:W}=this,O=W.length;while(O--){let M=W[O].optimizeNodes();if(Array.isArray(M))W.splice(O,1,...M);else if(M)W[O]=M;else W.splice(O,1)}return W.length>0?this:void 0}optimizeNames(W,O){let{nodes:M}=this,L=M.length;while(L--){let $=M[L];if($.optimizeNames(W,O))continue;ZX(W,$.names),M.splice(L,1)}return M.length>0?this:void 0}get names(){return this.nodes.reduce((W,O)=>Z0(W,O.names),{})}}class iO extends _M{render(W){return"{"+W._n+super.render(W)+"}"+W._n}}class a9 extends _M{}class H1 extends iO{}H1.kind="else";class IO extends iO{constructor(W,O){super(O);this.condition=W}render(W){let O=`if(${this.condition})`+super.render(W);if(this.else)O+="else "+this.else.render(W);return O}optimizeNodes(){super.optimizeNodes();let W=this.condition;if(W===!0)return this.nodes;let O=this.else;if(O){let M=O.optimizeNodes();O=this.else=Array.isArray(M)?new H1(M):M}if(O){if(W===!1)return O instanceof IO?O:O.nodes;if(this.nodes.length)return this;return new IO(OY(W),O instanceof IO?[O]:O.nodes)}if(W===!1||!this.nodes.length)return;return this}optimizeNames(W,O){var M;if(this.else=(M=this.else)===null||M===void 0?void 0:M.optimizeNames(W,O),!(super.optimizeNames(W,O)||this.else))return;return this.condition=y0(this.condition,W,O),this}get names(){let W=super.names;if(PM(W,this.condition),this.else)Z0(W,this.else.names);return W}}IO.kind="if";class I0 extends iO{}I0.kind="for";class o9 extends I0{constructor(W){super();this.iteration=W}render(W){return`for(${this.iteration})`+super.render(W)}optimizeNames(W,O){if(!super.optimizeNames(W,O))return;return this.iteration=y0(this.iteration,W,O),this}get names(){return Z0(super.names,this.iteration.names)}}class t9 extends I0{constructor(W,O,M,L){super();this.varKind=W,this.name=O,this.from=M,this.to=L}render(W){let O=W.es5?AO.varKinds.var:this.varKind,{name:M,from:L,to:$}=this;return`for(${O} ${M}=${L}; ${M}<${$}; ${M}++)`+super.render(W)}get names(){let W=PM(super.names,this.from);return PM(W,this.to)}}class Q$ extends I0{constructor(W,O,M,L){super();this.loop=W,this.varKind=O,this.name=M,this.iterable=L}render(W){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(W)}optimizeNames(W,O){if(!super.optimizeNames(W,O))return;return this.iterable=y0(this.iterable,W,O),this}get names(){return Z0(super.names,this.iterable.names)}}class qM extends iO{constructor(W,O,M){super();this.name=W,this.args=O,this.async=M}render(W){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(W)}}qM.kind="func";class BM extends _M{render(W){return"return "+super.render(W)}}BM.kind="return";class e9 extends iO{render(W){let O="try"+super.render(W);if(this.catch)O+=this.catch.render(W);if(this.finally)O+=this.finally.render(W);return O}optimizeNodes(){var W,O;return super.optimizeNodes(),(W=this.catch)===null||W===void 0||W.optimizeNodes(),(O=this.finally)===null||O===void 0||O.optimizeNodes(),this}optimizeNames(W,O){var M,L;return super.optimizeNames(W,O),(M=this.catch)===null||M===void 0||M.optimizeNames(W,O),(L=this.finally)===null||L===void 0||L.optimizeNames(W,O),this}get names(){let W=super.names;if(this.catch)Z0(W,this.catch.names);if(this.finally)Z0(W,this.finally.names);return W}}class CM extends iO{constructor(W){super();this.error=W}render(W){return`catch(${this.error})`+super.render(W)}}CM.kind="catch";class wM extends iO{render(W){return"finally"+super.render(W)}}wM.kind="finally";class WY{constructor(W,O={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...O,_n:O.lines?`
4
+ `:""},this._extScope=W,this._scope=new AO.Scope({parent:W}),this._nodes=[new a9]}toString(){return this._root.render(this.opts)}name(W){return this._scope.name(W)}scopeName(W){return this._extScope.name(W)}scopeValue(W,O){let M=this._extScope.value(W,O);return(this._values[M.prefix]||(this._values[M.prefix]=new Set)).add(M),M}getScopeValue(W,O){return this._extScope.getValue(W,O)}scopeRefs(W){return this._extScope.scopeRefs(W,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(W,O,M,L){let $=this._scope.toName(O);if(M!==void 0&&L)this._constants[$.str]=M;return this._leafNode(new d9(W,$,M)),$}const(W,O,M){return this._def(AO.varKinds.const,W,O,M)}let(W,O,M){return this._def(AO.varKinds.let,W,O,M)}var(W,O,M){return this._def(AO.varKinds.var,W,O,M)}assign(W,O,M){return this._leafNode(new S$(W,O,M))}add(W,O){return this._leafNode(new c9(W,vW.operators.ADD,O))}code(W){if(typeof W=="function")W();else if(W!==a.nil)this._leafNode(new r9(W));return this}object(...W){let O=["{"];for(let[M,L]of W){if(O.length>1)O.push(",");if(O.push(M),M!==L||this.opts.es5)O.push(":"),(0,a.addCodeArg)(O,L)}return O.push("}"),new a._Code(O)}if(W,O,M){if(this._blockNode(new IO(W)),O&&M)this.code(O).else().code(M).endIf();else if(O)this.code(O).endIf();else if(M)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(W){return this._elseNode(new IO(W))}else(){return this._elseNode(new H1)}endIf(){return this._endBlockNode(IO,H1)}_for(W,O){if(this._blockNode(W),O)this.code(O).endFor();return this}for(W,O){return this._for(new o9(W),O)}forRange(W,O,M,L,$=this.opts.es5?AO.varKinds.var:AO.varKinds.let){let Y=this._scope.toName(W);return this._for(new t9($,Y,O,M),()=>L(Y))}forOf(W,O,M,L=AO.varKinds.const){let $=this._scope.toName(W);if(this.opts.es5){let Y=O instanceof a.Name?O:this.var("_arr",O);return this.forRange("_i",0,a._`${Y}.length`,(J)=>{this.var($,a._`${Y}[${J}]`),M($)})}return this._for(new Q$("of",L,$,O),()=>M($))}forIn(W,O,M,L=this.opts.es5?AO.varKinds.var:AO.varKinds.const){if(this.opts.ownProperties)return this.forOf(W,a._`Object.keys(${O})`,M);let $=this._scope.toName(W);return this._for(new Q$("in",L,$,O),()=>M($))}endFor(){return this._endBlockNode(I0)}label(W){return this._leafNode(new i9(W))}break(W){return this._leafNode(new s9(W))}return(W){let O=new BM;if(this._blockNode(O),this.code(W),O.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(BM)}try(W,O,M){if(!O&&!M)throw Error('CodeGen: "try" without "catch" and "finally"');let L=new e9;if(this._blockNode(L),this.code(W),O){let $=this.name("e");this._currNode=L.catch=new CM($),O($)}if(M)this._currNode=L.finally=new wM,this.code(M);return this._endBlockNode(CM,wM)}throw(W){return this._leafNode(new n9(W))}block(W,O){if(this._blockStarts.push(this._nodes.length),W)this.code(W).endBlock(O);return this}endBlock(W){let O=this._blockStarts.pop();if(O===void 0)throw Error("CodeGen: not in self-balancing block");let M=this._nodes.length-O;if(M<0||W!==void 0&&M!==W)throw Error(`CodeGen: wrong number of nodes: ${M} vs ${W} expected`);return this._nodes.length=O,this}func(W,O=a.nil,M,L){if(this._blockNode(new qM(W,O,M)),L)this.code(L).endFunc();return this}endFunc(){return this._endBlockNode(qM)}optimize(W=1){while(W-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(W){return this._currNode.nodes.push(W),this}_blockNode(W){this._currNode.nodes.push(W),this._nodes.push(W)}_endBlockNode(W,O){let M=this._currNode;if(M instanceof W||O&&M instanceof O)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${O?`${W.kind}/${O.kind}`:W.kind}"`)}_elseNode(W){let O=this._currNode;if(!(O instanceof IO))throw Error('CodeGen: "else" without "if"');return this._currNode=O.else=W,this}get _root(){return this._nodes[0]}get _currNode(){let W=this._nodes;return W[W.length-1]}set _currNode(W){let O=this._nodes;O[O.length-1]=W}}vW.CodeGen=WY;function Z0(W,O){for(let M in O)W[M]=(W[M]||0)+(O[M]||0);return W}function PM(W,O){return O instanceof a._CodeOrName?Z0(W,O.names):W}function y0(W,O,M){if(W instanceof a.Name)return L(W);if(!$(W))return W;return new a._Code(W._items.reduce((Y,J)=>{if(J instanceof a.Name)J=L(J);if(J instanceof a._Code)Y.push(...J._items);else Y.push(J);return Y},[]));function L(Y){let J=M[Y.str];if(J===void 0||O[Y.str]!==1)return Y;return delete O[Y.str],J}function $(Y){return Y instanceof a._Code&&Y._items.some((J)=>J instanceof a.Name&&O[J.str]===1&&M[J.str]!==void 0)}}function ZX(W,O){for(let M in O)W[M]=(W[M]||0)-(O[M]||0)}function OY(W){return typeof W=="boolean"||typeof W=="number"||W===null?!W:a._`!${R$(W)}`}vW.not=OY;var GX=MY(vW.operators.AND);function XX(...W){return W.reduce(GX)}vW.and=XX;var QX=MY(vW.operators.OR);function RX(...W){return W.reduce(QX)}vW.or=RX;function MY(W){return(O,M)=>O===a.nil?M:M===a.nil?O:a._`${R$(O)} ${W} ${R$(M)}`}function R$(W){return W instanceof a.Name?W:a._`(${W})`}});var s=y((QY)=>{Object.defineProperty(QY,"__esModule",{value:!0});QY.checkStrictMode=QY.getErrorPath=QY.Type=QY.useFunc=QY.setEvaluated=QY.evaluatedPropsToName=QY.mergeEvaluated=QY.eachItem=QY.unescapeJsonPointer=QY.escapeJsonPointer=QY.escapeFragment=QY.unescapeFragment=QY.schemaRefOrVal=QY.schemaHasRulesButRef=QY.schemaHasRules=QY.checkUnknownRules=QY.alwaysValidSchema=QY.toHash=void 0;var LW=d(),VX=V1();function HX(W){let O={};for(let M of W)O[M]=!0;return O}QY.toHash=HX;function KX(W,O){if(typeof O=="boolean")return O;if(Object.keys(O).length===0)return!0;return JY(W,O),!AY(O,W.self.RULES.all)}QY.alwaysValidSchema=KX;function JY(W,O=W.schema){let{opts:M,self:L}=W;if(!M.strictSchema)return;if(typeof O==="boolean")return;let $=L.RULES.keywords;for(let Y in O)if(!$[Y])XY(W,`unknown keyword: "${Y}"`)}QY.checkUnknownRules=JY;function AY(W,O){if(typeof W=="boolean")return!W;for(let M in W)if(O[M])return!0;return!1}QY.schemaHasRules=AY;function TX(W,O){if(typeof W=="boolean")return!W;for(let M in W)if(M!=="$ref"&&O.all[M])return!0;return!1}QY.schemaHasRulesButRef=TX;function FX({topSchemaRef:W,schemaPath:O},M,L,$){if(!$){if(typeof M=="number"||typeof M=="boolean")return M;if(typeof M=="string")return LW._`${M}`}return LW._`${W}${O}${(0,LW.getProperty)(L)}`}QY.schemaRefOrVal=FX;function EX(W){return ZY(decodeURIComponent(W))}QY.unescapeFragment=EX;function qX(W){return encodeURIComponent(z$(W))}QY.escapeFragment=qX;function z$(W){if(typeof W=="number")return`${W}`;return W.replace(/~/g,"~0").replace(/\//g,"~1")}QY.escapeJsonPointer=z$;function ZY(W){return W.replace(/~1/g,"/").replace(/~0/g,"~")}QY.unescapeJsonPointer=ZY;function BX(W,O){if(Array.isArray(W))for(let M of W)O(M);else O(W)}QY.eachItem=BX;function $Y({mergeNames:W,mergeToName:O,mergeValues:M,resultToName:L}){return($,Y,J,A)=>{let Z=J===void 0?Y:J instanceof LW.Name?(Y instanceof LW.Name?W($,Y,J):O($,Y,J),J):Y instanceof LW.Name?(O($,J,Y),Y):M(Y,J);return A===LW.Name&&!(Z instanceof LW.Name)?L($,Z):Z}}QY.mergeEvaluated={props:$Y({mergeNames:(W,O,M)=>W.if(LW._`${M} !== true && ${O} !== undefined`,()=>{W.if(LW._`${O} === true`,()=>W.assign(M,!0),()=>W.assign(M,LW._`${M} || {}`).code(LW._`Object.assign(${M}, ${O})`))}),mergeToName:(W,O,M)=>W.if(LW._`${M} !== true`,()=>{if(O===!0)W.assign(M,!0);else W.assign(M,LW._`${M} || {}`),V$(W,M,O)}),mergeValues:(W,O)=>W===!0?!0:{...W,...O},resultToName:GY}),items:$Y({mergeNames:(W,O,M)=>W.if(LW._`${M} !== true && ${O} !== undefined`,()=>W.assign(M,LW._`${O} === true ? true : ${M} > ${O} ? ${M} : ${O}`)),mergeToName:(W,O,M)=>W.if(LW._`${M} !== true`,()=>W.assign(M,O===!0?!0:LW._`${M} > ${O} ? ${M} : ${O}`)),mergeValues:(W,O)=>W===!0?!0:Math.max(W,O),resultToName:(W,O)=>W.var("items",O)})};function GY(W,O){if(O===!0)return W.var("props",!0);let M=W.var("props",LW._`{}`);if(O!==void 0)V$(W,M,O);return M}QY.evaluatedPropsToName=GY;function V$(W,O,M){Object.keys(M).forEach((L)=>W.assign(LW._`${O}${(0,LW.getProperty)(L)}`,!0))}QY.setEvaluated=V$;var YY={};function CX(W,O){return W.scopeValue("func",{ref:O,code:YY[O.code]||(YY[O.code]=new VX._Code(O.code))})}QY.useFunc=CX;var U$;(function(W){W[W.Num=0]="Num",W[W.Str=1]="Str"})(U$||(QY.Type=U$={}));function wX(W,O,M){if(W instanceof LW.Name){let L=O===U$.Num;return M?L?LW._`"[" + ${W} + "]"`:LW._`"['" + ${W} + "']"`:L?LW._`"/" + ${W}`:LW._`"/" + ${W}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return M?(0,LW.getProperty)(W).toString():"/"+z$(W)}QY.getErrorPath=wX;function XY(W,O,M=W.opts.strictSchema){if(!M)return;if(O=`strict mode: ${O}`,M===!0)throw Error(O);W.self.logger.warn(O)}QY.checkStrictMode=XY});var oW=y((SY)=>{Object.defineProperty(SY,"__esModule",{value:!0});var qW=d(),mX={data:new qW.Name("data"),valCxt:new qW.Name("valCxt"),instancePath:new qW.Name("instancePath"),parentData:new qW.Name("parentData"),parentDataProperty:new qW.Name("parentDataProperty"),rootData:new qW.Name("rootData"),dynamicAnchors:new qW.Name("dynamicAnchors"),vErrors:new qW.Name("vErrors"),errors:new qW.Name("errors"),this:new qW.Name("this"),self:new qW.Name("self"),scope:new qW.Name("scope"),json:new qW.Name("json"),jsonPos:new qW.Name("jsonPos"),jsonLen:new qW.Name("jsonLen"),jsonPart:new qW.Name("jsonPart")};SY.default=mX});var K1=y((HY)=>{Object.defineProperty(HY,"__esModule",{value:!0});HY.extendErrors=HY.resetErrorsCount=HY.reportExtraError=HY.reportError=HY.keyword$DataError=HY.keywordError=void 0;var t=d(),IM=s(),PW=oW();HY.keywordError={message:({keyword:W})=>t.str`must pass "${W}" keyword validation`};HY.keyword$DataError={message:({keyword:W,schemaType:O})=>O?t.str`"${W}" keyword must be ${O} ($data)`:t.str`"${W}" keyword is invalid ($data)`};function cX(W,O=HY.keywordError,M,L){let{it:$}=W,{gen:Y,compositeRule:J,allErrors:A}=$,Z=VY(W,O,M);if(L!==null&&L!==void 0?L:J||A)UY(Y,Z);else zY($,t._`[${Z}]`)}HY.reportError=cX;function iX(W,O=HY.keywordError,M){let{it:L}=W,{gen:$,compositeRule:Y,allErrors:J}=L,A=VY(W,O,M);if(UY($,A),!(Y||J))zY(L,PW.default.vErrors)}HY.reportExtraError=iX;function sX(W,O){W.assign(PW.default.errors,O),W.if(t._`${PW.default.vErrors} !== null`,()=>W.if(O,()=>W.assign(t._`${PW.default.vErrors}.length`,O),()=>W.assign(PW.default.vErrors,null)))}HY.resetErrorsCount=sX;function nX({gen:W,keyword:O,schemaValue:M,data:L,errsCount:$,it:Y}){if($===void 0)throw Error("ajv implementation error");let J=W.name("err");W.forRange("i",$,PW.default.errors,(A)=>{if(W.const(J,t._`${PW.default.vErrors}[${A}]`),W.if(t._`${J}.instancePath === undefined`,()=>W.assign(t._`${J}.instancePath`,(0,t.strConcat)(PW.default.instancePath,Y.errorPath))),W.assign(t._`${J}.schemaPath`,t.str`${Y.errSchemaPath}/${O}`),Y.opts.verbose)W.assign(t._`${J}.schema`,M),W.assign(t._`${J}.data`,L)})}HY.extendErrors=nX;function UY(W,O){let M=W.const("err",O);W.if(t._`${PW.default.vErrors} === null`,()=>W.assign(PW.default.vErrors,t._`[${M}]`),t._`${PW.default.vErrors}.push(${M})`),W.code(t._`${PW.default.errors}++`)}function zY(W,O){let{gen:M,validateName:L,schemaEnv:$}=W;if($.$async)M.throw(t._`new ${W.ValidationError}(${O})`);else M.assign(t._`${L}.errors`,O),M.return(!1)}var G0={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function VY(W,O,M){let{createErrors:L}=W.it;if(L===!1)return t._`{}`;return rX(W,O,M)}function rX(W,O,M={}){let{gen:L,it:$}=W,Y=[aX($,M),oX(W,M)];return tX(W,O,Y),L.object(...Y)}function aX({errorPath:W},{instancePath:O}){let M=O?t.str`${W}${(0,IM.getErrorPath)(O,IM.Type.Str)}`:W;return[PW.default.instancePath,(0,t.strConcat)(PW.default.instancePath,M)]}function oX({keyword:W,it:{errSchemaPath:O}},{schemaPath:M,parentSchema:L}){let $=L?O:t.str`${O}/${W}`;if(M)$=t.str`${$}${(0,IM.getErrorPath)(M,IM.Type.Str)}`;return[G0.schemaPath,$]}function tX(W,{params:O,message:M},L){let{keyword:$,data:Y,schemaValue:J,it:A}=W,{opts:Z,propertyName:G,topSchemaRef:X,schemaPath:Q}=A;if(L.push([G0.keyword,$],[G0.params,typeof O=="function"?O(W):O||t._`{}`]),Z.messages)L.push([G0.message,typeof M=="function"?M(W):M]);if(Z.verbose)L.push([G0.schema,J],[G0.parentSchema,t._`${X}${Q}`],[PW.default.data,Y]);if(G)L.push([G0.propertyName,G])}});var qY=y((FY)=>{Object.defineProperty(FY,"__esModule",{value:!0});FY.boolOrEmptySchema=FY.topBoolOrEmptySchema=void 0;var LQ=K1(),$Q=d(),YQ=oW(),JQ={message:"boolean schema is false"};function AQ(W){let{gen:O,schema:M,validateName:L}=W;if(M===!1)TY(W,!1);else if(typeof M=="object"&&M.$async===!0)O.return(YQ.default.data);else O.assign($Q._`${L}.errors`,null),O.return(!0)}FY.topBoolOrEmptySchema=AQ;function ZQ(W,O){let{gen:M,schema:L}=W;if(L===!1)M.var(O,!1),TY(W);else M.var(O,!0)}FY.boolOrEmptySchema=ZQ;function TY(W,O){let{gen:M,data:L}=W,$={gen:M,keyword:"false schema",data:L,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:W};(0,LQ.reportError)($,JQ,void 0,O)}});var K$=y((BY)=>{Object.defineProperty(BY,"__esModule",{value:!0});BY.getRules=BY.isJSONType=void 0;var XQ=["string","number","integer","boolean","null","object","array"],QQ=new Set(XQ);function RQ(W){return typeof W=="string"&&QQ.has(W)}BY.isJSONType=RQ;function SQ(){let W={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...W,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},W.number,W.string,W.array,W.object],post:{rules:[]},all:{},keywords:{}}}BY.getRules=SQ});var T$=y((NY)=>{Object.defineProperty(NY,"__esModule",{value:!0});NY.shouldUseRule=NY.shouldUseGroup=NY.schemaHasRulesForType=void 0;function zQ({schema:W,self:O},M){let L=O.RULES.types[M];return L&&L!==!0&&wY(W,L)}NY.schemaHasRulesForType=zQ;function wY(W,O){return O.rules.some((M)=>PY(W,M))}NY.shouldUseGroup=wY;function PY(W,O){var M;return W[O.keyword]!==void 0||((M=O.definition.implements)===null||M===void 0?void 0:M.some((L)=>W[L]!==void 0))}NY.shouldUseRule=PY});var T1=y((DY)=>{Object.defineProperty(DY,"__esModule",{value:!0});DY.reportTypeError=DY.checkDataTypes=DY.checkDataType=DY.coerceAndCheckDataType=DY.getJSONTypes=DY.getSchemaTypes=DY.DataType=void 0;var KQ=K$(),TQ=T$(),FQ=K1(),i=d(),jY=s(),D0;(function(W){W[W.Correct=0]="Correct",W[W.Wrong=1]="Wrong"})(D0||(DY.DataType=D0={}));function EQ(W){let O=IY(W.type);if(O.includes("null")){if(W.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!O.length&&W.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(W.nullable===!0)O.push("null")}return O}DY.getSchemaTypes=EQ;function IY(W){let O=Array.isArray(W)?W:W?[W]:[];if(O.every(KQ.isJSONType))return O;throw Error("type must be JSONType or JSONType[]: "+O.join(","))}DY.getJSONTypes=IY;function qQ(W,O){let{gen:M,data:L,opts:$}=W,Y=BQ(O,$.coerceTypes),J=O.length>0&&!(Y.length===0&&O.length===1&&(0,TQ.schemaHasRulesForType)(W,O[0]));if(J){let A=E$(O,L,$.strictNumbers,D0.Wrong);M.if(A,()=>{if(Y.length)CQ(W,O,Y);else q$(W)})}return J}DY.coerceAndCheckDataType=qQ;var yY=new Set(["string","number","integer","boolean","null"]);function BQ(W,O){return O?W.filter((M)=>yY.has(M)||O==="array"&&M==="array"):[]}function CQ(W,O,M){let{gen:L,data:$,opts:Y}=W,J=L.let("dataType",i._`typeof ${$}`),A=L.let("coerced",i._`undefined`);if(Y.coerceTypes==="array")L.if(i._`${J} == 'object' && Array.isArray(${$}) && ${$}.length == 1`,()=>L.assign($,i._`${$}[0]`).assign(J,i._`typeof ${$}`).if(E$(O,$,Y.strictNumbers),()=>L.assign(A,$)));L.if(i._`${A} !== undefined`);for(let G of M)if(yY.has(G)||G==="array"&&Y.coerceTypes==="array")Z(G);L.else(),q$(W),L.endIf(),L.if(i._`${A} !== undefined`,()=>{L.assign($,A),wQ(W,A)});function Z(G){switch(G){case"string":L.elseIf(i._`${J} == "number" || ${J} == "boolean"`).assign(A,i._`"" + ${$}`).elseIf(i._`${$} === null`).assign(A,i._`""`);return;case"number":L.elseIf(i._`${J} == "boolean" || ${$} === null
5
5
  || (${J} == "string" && ${$} && ${$} == +${$})`).assign(A,i._`+${$}`);return;case"integer":L.elseIf(i._`${J} === "boolean" || ${$} === null
6
6
  || (${J} === "string" && ${$} && ${$} == +${$} && !(${$} % 1))`).assign(A,i._`+${$}`);return;case"boolean":L.elseIf(i._`${$} === "false" || ${$} === 0 || ${$} === null`).assign(A,!1).elseIf(i._`${$} === "true" || ${$} === 1`).assign(A,!0);return;case"null":L.elseIf(i._`${$} === "" || ${$} === 0 || ${$} === false`),L.assign(A,null);return;case"array":L.elseIf(i._`${J} === "string" || ${J} === "number"
7
- || ${J} === "boolean" || ${$} === null`).assign(A,i._`[${$}]`)}}}function BQ({gen:W,parentData:O,parentDataProperty:M},L){W.if(i._`${O} !== undefined`,()=>W.assign(i._`${O}[${M}]`,L))}function K$(W,O,M,L=N0.Correct){let $=L===N0.Correct?i.operators.EQ:i.operators.NEQ,Y;switch(W){case"null":return i._`${O} ${$} null`;case"array":Y=i._`Array.isArray(${O})`;break;case"object":Y=i._`${O} && typeof ${O} == "object" && !Array.isArray(${O})`;break;case"integer":Y=J(i._`!(${O} % 1) && !isNaN(${O})`);break;case"number":Y=J();break;default:return i._`typeof ${O} ${$} ${W}`}return L===N0.Correct?Y:(0,i.not)(Y);function J(A=i.nil){return(0,i.and)(i._`typeof ${O} == "number"`,A,M?i._`isFinite(${O})`:i.nil)}}jY.checkDataType=K$;function T$(W,O,M,L){if(W.length===1)return K$(W[0],O,M,L);let $,Y=(0,NY.toHash)(W);if(Y.array&&Y.object){let J=i._`typeof ${O} != "object"`;$=Y.null?J:i._`!${O} || ${J}`,delete Y.null,delete Y.array,delete Y.object}else $=i.nil;if(Y.number)delete Y.integer;for(let J in Y)$=(0,i.and)($,K$(J,O,M,L));return $}jY.checkDataTypes=T$;var wQ={message:({schema:W})=>`must be ${W}`,params:({schema:W,schemaValue:O})=>typeof W=="string"?i._`{type: ${W}}`:i._`{type: ${O}}`};function F$(W){let O=CQ(W);(0,KQ.reportError)(O,wQ)}jY.reportTypeError=F$;function CQ(W){let{gen:O,data:M,schema:L}=W,$=(0,NY.schemaRefOrVal)(W,L,"type");return{gen:O,keyword:"type",data:M,schema:L.type,schemaCode:$,schemaValue:$,parentSchema:L,params:{},it:W}}});var bY=y((DY)=>{Object.defineProperty(DY,"__esModule",{value:!0});DY.assignDefaults=void 0;var P0=d(),DQ=s();function kQ(W,O){let{properties:M,items:L}=W.schema;if(O==="object"&&M)for(let $ in M)yY(W,$,M[$].default);else if(O==="array"&&Array.isArray(L))L.forEach(($,Y)=>yY(W,Y,$.default))}DY.assignDefaults=kQ;function yY(W,O,M){let{gen:L,compositeRule:$,data:Y,opts:J}=W;if(M===void 0)return;let A=P0._`${Y}${(0,P0.getProperty)(O)}`;if($){(0,DQ.checkStrictMode)(W,`default is ignored for: ${A}`);return}let Z=P0._`${A} === undefined`;if(J.useDefaults==="empty")Z=P0._`${Z} || ${A} === null || ${A} === ""`;L.if(Z,P0._`${A} = ${(0,P0.stringify)(M)}`)}});var rW=y((xY)=>{Object.defineProperty(xY,"__esModule",{value:!0});xY.validateUnion=xY.validateArray=xY.usePattern=xY.callValidateCode=xY.schemaProperties=xY.allSchemaProperties=xY.noPropertyInData=xY.propertyInData=xY.isOwnProperty=xY.hasPropFunc=xY.reportMissingProp=xY.checkMissingProp=xY.checkReportMissingProp=void 0;var YW=d(),E$=s(),mO=nW(),bQ=s();function fQ(W,O){let{gen:M,data:L,it:$}=W;M.if(B$(M,L,O,$.opts.ownProperties),()=>{W.setParams({missingProperty:YW._`${O}`},!0),W.error()})}xY.checkReportMissingProp=fQ;function vQ({gen:W,data:O,it:{opts:M}},L,$){return(0,YW.or)(...L.map((Y)=>(0,YW.and)(B$(W,O,Y,M.ownProperties),YW._`${$} = ${Y}`)))}xY.checkMissingProp=vQ;function xQ(W,O){W.setParams({missingProperty:O},!0),W.error()}xY.reportMissingProp=xQ;function fY(W){return W.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:YW._`Object.prototype.hasOwnProperty`})}xY.hasPropFunc=fY;function q$(W,O,M){return YW._`${fY(W)}.call(${O}, ${M})`}xY.isOwnProperty=q$;function gQ(W,O,M,L){let $=YW._`${O}${(0,YW.getProperty)(M)} !== undefined`;return L?YW._`${$} && ${q$(W,O,M)}`:$}xY.propertyInData=gQ;function B$(W,O,M,L){let $=YW._`${O}${(0,YW.getProperty)(M)} === undefined`;return L?(0,YW.or)($,(0,YW.not)(q$(W,O,M))):$}xY.noPropertyInData=B$;function vY(W){return W?Object.keys(W).filter((O)=>O!=="__proto__"):[]}xY.allSchemaProperties=vY;function hQ(W,O){return vY(O).filter((M)=>!(0,E$.alwaysValidSchema)(W,O[M]))}xY.schemaProperties=hQ;function uQ({schemaCode:W,data:O,it:{gen:M,topSchemaRef:L,schemaPath:$,errorPath:Y},it:J},A,Z,X){let G=X?YW._`${W}, ${O}, ${L}${$}`:O,Q=[[mO.default.instancePath,(0,YW.strConcat)(mO.default.instancePath,Y)],[mO.default.parentData,J.parentData],[mO.default.parentDataProperty,J.parentDataProperty],[mO.default.rootData,mO.default.rootData]];if(J.opts.dynamicRef)Q.push([mO.default.dynamicAnchors,mO.default.dynamicAnchors]);let S=YW._`${G}, ${M.object(...Q)}`;return Z!==YW.nil?YW._`${A}.call(${Z}, ${S})`:YW._`${A}(${S})`}xY.callValidateCode=uQ;var lQ=YW._`new RegExp`;function pQ({gen:W,it:{opts:O}},M){let L=O.unicodeRegExp?"u":"",{regExp:$}=O.code,Y=$(M,L);return W.scopeValue("pattern",{key:Y.toString(),ref:Y,code:YW._`${$.code==="new RegExp"?lQ:(0,bQ.useFunc)(W,$)}(${M}, ${L})`})}xY.usePattern=pQ;function mQ(W){let{gen:O,data:M,keyword:L,it:$}=W,Y=O.name("valid");if($.allErrors){let A=O.let("valid",!0);return J(()=>O.assign(A,!1)),A}return O.var(Y,!0),J(()=>O.break()),Y;function J(A){let Z=O.const("len",YW._`${M}.length`);O.forRange("i",0,Z,(X)=>{W.subschema({keyword:L,dataProp:X,dataPropType:E$.Type.Num},Y),O.if((0,YW.not)(Y),A)})}}xY.validateArray=mQ;function dQ(W){let{gen:O,schema:M,keyword:L,it:$}=W;if(!Array.isArray(M))throw Error("ajv implementation error");if(M.some((Z)=>(0,E$.alwaysValidSchema)($,Z))&&!$.opts.unevaluated)return;let J=O.let("valid",!1),A=O.name("_valid");O.block(()=>M.forEach((Z,X)=>{let G=W.subschema({keyword:L,schemaProp:X,compositeRule:!0},A);if(O.assign(J,YW._`${J} || ${A}`),!W.mergeValidEvaluated(G,A))O.if((0,YW.not)(J))})),W.result(J,()=>W.reset(),()=>W.error(!0))}xY.validateUnion=dQ});var mY=y((lY)=>{Object.defineProperty(lY,"__esModule",{value:!0});lY.validateKeywordUsage=lY.validSchemaType=lY.funcKeywordCode=lY.macroKeywordCode=void 0;var jW=d(),Y0=nW(),L7=rW(),$7=S1();function Y7(W,O){let{gen:M,keyword:L,schema:$,parentSchema:Y,it:J}=W,A=O.macro.call(J.self,$,Y,J),Z=uY(M,L,A);if(J.opts.validateSchema!==!1)J.self.validateSchema(A,!0);let X=M.name("valid");W.subschema({schema:A,schemaPath:jW.nil,errSchemaPath:`${J.errSchemaPath}/${L}`,topSchemaRef:Z,compositeRule:!0},X),W.pass(X,()=>W.error(!0))}lY.macroKeywordCode=Y7;function J7(W,O){var M;let{gen:L,keyword:$,schema:Y,parentSchema:J,$data:A,it:Z}=W;Z7(Z,O);let X=!A&&O.compile?O.compile.call(Z.self,Y,J,Z):O.validate,G=uY(L,$,X),Q=L.let("valid");W.block$data(Q,S),W.ok((M=O.valid)!==null&&M!==void 0?M:Q);function S(){if(O.errors===!1){if(R(),O.modifying)hY(W);K(()=>W.error())}else{let T=O.async?U():V();if(O.modifying)hY(W);K(()=>A7(W,T))}}function U(){let T=L.let("ruleErrs",null);return L.try(()=>R(jW._`await `),(F)=>L.assign(Q,!1).if(jW._`${F} instanceof ${Z.ValidationError}`,()=>L.assign(T,jW._`${F}.errors`),()=>L.throw(F))),T}function V(){let T=jW._`${G}.errors`;return L.assign(T,null),R(jW.nil),T}function R(T=O.async?jW._`await `:jW.nil){let F=Z.opts.passContext?Y0.default.this:Y0.default.self,N=!(("compile"in O)&&!A||O.schema===!1);L.assign(Q,jW._`${T}${(0,L7.callValidateCode)(W,G,F,N)}`,O.modifying)}function K(T){var F;L.if((0,jW.not)((F=O.valid)!==null&&F!==void 0?F:Q),T)}}lY.funcKeywordCode=J7;function hY(W){let{gen:O,data:M,it:L}=W;O.if(L.parentData,()=>O.assign(M,jW._`${L.parentData}[${L.parentDataProperty}]`))}function A7(W,O){let{gen:M}=W;M.if(jW._`Array.isArray(${O})`,()=>{M.assign(Y0.default.vErrors,jW._`${Y0.default.vErrors} === null ? ${O} : ${Y0.default.vErrors}.concat(${O})`).assign(Y0.default.errors,jW._`${Y0.default.vErrors}.length`),(0,$7.extendErrors)(W)},()=>W.error())}function Z7({schemaEnv:W},O){if(O.async&&!W.$async)throw Error("async keyword in sync schema")}function uY(W,O,M){if(M===void 0)throw Error(`keyword "${O}" failed to compile`);return W.scopeValue("keyword",typeof M=="function"?{ref:M}:{ref:M,code:(0,jW.stringify)(M)})}function X7(W,O,M=!1){return!O.length||O.some((L)=>L==="array"?Array.isArray(W):L==="object"?W&&typeof W=="object"&&!Array.isArray(W):typeof W==L||M&&typeof W>"u")}lY.validSchemaType=X7;function G7({schema:W,opts:O,self:M,errSchemaPath:L},$,Y){if(Array.isArray($.keyword)?!$.keyword.includes(Y):$.keyword!==Y)throw Error("ajv implementation error");let J=$.dependencies;if(J===null||J===void 0?void 0:J.some((A)=>!Object.prototype.hasOwnProperty.call(W,A)))throw Error(`parent schema must have dependencies of ${Y}: ${J.join(",")}`);if($.validateSchema){if(!$.validateSchema(W[Y])){let Z=`keyword "${Y}" value is invalid at path "${L}": `+M.errorsText($.validateSchema.errors);if(O.validateSchema==="log")M.logger.error(Z);else throw Error(Z)}}}lY.validateKeywordUsage=G7});var sY=y((cY)=>{Object.defineProperty(cY,"__esModule",{value:!0});cY.extendSubschemaMode=cY.extendSubschemaData=cY.getSubschema=void 0;var zO=d(),dY=s();function U7(W,{keyword:O,schemaProp:M,schema:L,schemaPath:$,errSchemaPath:Y,topSchemaRef:J}){if(O!==void 0&&L!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(O!==void 0){let A=W.schema[O];return M===void 0?{schema:A,schemaPath:zO._`${W.schemaPath}${(0,zO.getProperty)(O)}`,errSchemaPath:`${W.errSchemaPath}/${O}`}:{schema:A[M],schemaPath:zO._`${W.schemaPath}${(0,zO.getProperty)(O)}${(0,zO.getProperty)(M)}`,errSchemaPath:`${W.errSchemaPath}/${O}/${(0,dY.escapeFragment)(M)}`}}if(L!==void 0){if($===void 0||Y===void 0||J===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:L,schemaPath:$,topSchemaRef:J,errSchemaPath:Y}}throw Error('either "keyword" or "schema" must be passed')}cY.getSubschema=U7;function z7(W,O,{dataProp:M,dataPropType:L,data:$,dataTypes:Y,propertyName:J}){if($!==void 0&&M!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:A}=O;if(M!==void 0){let{errorPath:X,dataPathArr:G,opts:Q}=O,S=A.let("data",zO._`${O.data}${(0,zO.getProperty)(M)}`,!0);Z(S),W.errorPath=zO.str`${X}${(0,dY.getErrorPath)(M,L,Q.jsPropertySyntax)}`,W.parentDataProperty=zO._`${M}`,W.dataPathArr=[...G,W.parentDataProperty]}if($!==void 0){let X=$ instanceof zO.Name?$:A.let("data",$,!0);if(Z(X),J!==void 0)W.propertyName=J}if(Y)W.dataTypes=Y;function Z(X){W.data=X,W.dataLevel=O.dataLevel+1,W.dataTypes=[],O.definedProperties=new Set,W.parentData=O.data,W.dataNames=[...O.dataNames,X]}}cY.extendSubschemaData=z7;function V7(W,{jtdDiscriminator:O,jtdMetadata:M,compositeRule:L,createErrors:$,allErrors:Y}){if(L!==void 0)W.compositeRule=L;if($!==void 0)W.createErrors=$;if(Y!==void 0)W.allErrors=Y;W.jtdDiscriminator=O,W.jtdMetadata=M}cY.extendSubschemaMode=V7});var w$=y((wB,nY)=>{nY.exports=function W(O,M){if(O===M)return!0;if(O&&M&&typeof O=="object"&&typeof M=="object"){if(O.constructor!==M.constructor)return!1;var L,$,Y;if(Array.isArray(O)){if(L=O.length,L!=M.length)return!1;for($=L;$--!==0;)if(!W(O[$],M[$]))return!1;return!0}if(O.constructor===RegExp)return O.source===M.source&&O.flags===M.flags;if(O.valueOf!==Object.prototype.valueOf)return O.valueOf()===M.valueOf();if(O.toString!==Object.prototype.toString)return O.toString()===M.toString();if(Y=Object.keys(O),L=Y.length,L!==Object.keys(M).length)return!1;for($=L;$--!==0;)if(!Object.prototype.hasOwnProperty.call(M,Y[$]))return!1;for($=L;$--!==0;){var J=Y[$];if(!W(O[J],M[J]))return!1}return!0}return O!==O&&M!==M}});var aY=y((CB,rY)=>{var dO=rY.exports=function(W,O,M){if(typeof O=="function")M=O,O={};M=O.cb||M;var L=typeof M=="function"?M:M.pre||function(){},$=M.post||function(){};IM(O,L,$,W,"",W)};dO.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};dO.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};dO.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};dO.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function IM(W,O,M,L,$,Y,J,A,Z,X){if(L&&typeof L=="object"&&!Array.isArray(L)){O(L,$,Y,J,A,Z,X);for(var G in L){var Q=L[G];if(Array.isArray(Q)){if(G in dO.arrayKeywords)for(var S=0;S<Q.length;S++)IM(W,O,M,Q[S],$+"/"+G+"/"+S,Y,$,G,L,S)}else if(G in dO.propsKeywords){if(Q&&typeof Q=="object")for(var U in Q)IM(W,O,M,Q[U],$+"/"+G+"/"+T7(U),Y,$,G,L,U)}else if(G in dO.keywords||W.allKeys&&!(G in dO.skipKeywords))IM(W,O,M,Q,$+"/"+G,Y,$,G,L)}M(L,$,Y,J,A,Z,X)}}function T7(W){return W.replace(/~/g,"~0").replace(/\//g,"~1")}});var U1=y((WJ)=>{Object.defineProperty(WJ,"__esModule",{value:!0});WJ.getSchemaRefs=WJ.resolveUrl=WJ.normalizeId=WJ._getFullPath=WJ.getFullPath=WJ.inlineRef=void 0;var F7=s(),E7=w$(),q7=aY(),B7=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function w7(W,O=!0){if(typeof W=="boolean")return!0;if(O===!0)return!C$(W);if(!O)return!1;return oY(W)<=O}WJ.inlineRef=w7;var C7=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function C$(W){for(let O in W){if(C7.has(O))return!0;let M=W[O];if(Array.isArray(M)&&M.some(C$))return!0;if(typeof M=="object"&&C$(M))return!0}return!1}function oY(W){let O=0;for(let M in W){if(M==="$ref")return 1/0;if(O++,B7.has(M))continue;if(typeof W[M]=="object")(0,F7.eachItem)(W[M],(L)=>O+=oY(L));if(O===1/0)return 1/0}return O}function tY(W,O="",M){if(M!==!1)O=_0(O);let L=W.parse(O);return eY(W,L)}WJ.getFullPath=tY;function eY(W,O){return W.serialize(O).split("#")[0]+"#"}WJ._getFullPath=eY;var N7=/#\/?$/;function _0(W){return W?W.replace(N7,""):""}WJ.normalizeId=_0;function P7(W,O,M){return M=_0(M),W.resolve(O,M)}WJ.resolveUrl=P7;var _7=/^[a-z_][-a-z0-9._]*$/i;function j7(W,O){if(typeof W=="boolean")return{};let{schemaId:M,uriResolver:L}=this.opts,$=_0(W[M]||O),Y={"":$},J=tY(L,$,!1),A={},Z=new Set;return q7(W,{allKeys:!0},(Q,S,U,V)=>{if(V===void 0)return;let R=J+S,K=Y[V];if(typeof Q[M]=="string")K=T.call(this,Q[M]);F.call(this,Q.$anchor),F.call(this,Q.$dynamicAnchor),Y[S]=K;function T(N){let C=this.opts.uriResolver.resolve;if(N=_0(K?C(K,N):N),Z.has(N))throw G(N);Z.add(N);let w=this.refs[N];if(typeof w=="string")w=this.refs[w];if(typeof w=="object")X(Q,w.schema,N);else if(N!==_0(R))if(N[0]==="#")X(Q,A[N],N),A[N]=Q;else this.refs[N]=R;return N}function F(N){if(typeof N=="string"){if(!_7.test(N))throw Error(`invalid anchor "${N}"`);T.call(this,`#${N}`)}}}),A;function X(Q,S,U){if(S!==void 0&&!E7(Q,S))throw G(U)}function G(Q){return Error(`reference "${Q}" resolves to more than one schema`)}}WJ.getSchemaRefs=j7});var H1=y((VJ)=>{Object.defineProperty(VJ,"__esModule",{value:!0});VJ.getData=VJ.KeywordCxt=VJ.validateFunctionCode=void 0;var JJ=TY(),MJ=R1(),P$=H$(),yM=R1(),f7=bY(),V1=mY(),N$=sY(),h=d(),u=nW(),v7=U1(),IO=s(),z1=S1();function x7(W){if(XJ(W)){if(GJ(W),ZJ(W)){u7(W);return}}AJ(W,()=>(0,JJ.topBoolOrEmptySchema)(W))}VJ.validateFunctionCode=x7;function AJ({gen:W,validateName:O,schema:M,schemaEnv:L,opts:$},Y){if($.code.es5)W.func(O,h._`${u.default.data}, ${u.default.valCxt}`,L.$async,()=>{W.code(h._`"use strict"; ${LJ(M,$)}`),h7(W,$),W.code(Y)});else W.func(O,h._`${u.default.data}, ${g7($)}`,L.$async,()=>W.code(LJ(M,$)).code(Y))}function g7(W){return h._`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${W.dynamicRef?h._`, ${u.default.dynamicAnchors}={}`:h.nil}}={}`}function h7(W,O){W.if(u.default.valCxt,()=>{if(W.var(u.default.instancePath,h._`${u.default.valCxt}.${u.default.instancePath}`),W.var(u.default.parentData,h._`${u.default.valCxt}.${u.default.parentData}`),W.var(u.default.parentDataProperty,h._`${u.default.valCxt}.${u.default.parentDataProperty}`),W.var(u.default.rootData,h._`${u.default.valCxt}.${u.default.rootData}`),O.dynamicRef)W.var(u.default.dynamicAnchors,h._`${u.default.valCxt}.${u.default.dynamicAnchors}`)},()=>{if(W.var(u.default.instancePath,h._`""`),W.var(u.default.parentData,h._`undefined`),W.var(u.default.parentDataProperty,h._`undefined`),W.var(u.default.rootData,u.default.data),O.dynamicRef)W.var(u.default.dynamicAnchors,h._`{}`)})}function u7(W){let{schema:O,opts:M,gen:L}=W;AJ(W,()=>{if(M.$comment&&O.$comment)SJ(W);if(c7(W),L.let(u.default.vErrors,null),L.let(u.default.errors,0),M.unevaluated)l7(W);QJ(W),n7(W)});return}function l7(W){let{gen:O,validateName:M}=W;W.evaluated=O.const("evaluated",h._`${M}.evaluated`),O.if(h._`${W.evaluated}.dynamicProps`,()=>O.assign(h._`${W.evaluated}.props`,h._`undefined`)),O.if(h._`${W.evaluated}.dynamicItems`,()=>O.assign(h._`${W.evaluated}.items`,h._`undefined`))}function LJ(W,O){let M=typeof W=="object"&&W[O.schemaId];return M&&(O.code.source||O.code.process)?h._`/*# sourceURL=${M} */`:h.nil}function p7(W,O){if(XJ(W)){if(GJ(W),ZJ(W)){m7(W,O);return}}(0,JJ.boolOrEmptySchema)(W,O)}function ZJ({schema:W,self:O}){if(typeof W=="boolean")return!W;for(let M in W)if(O.RULES.all[M])return!0;return!1}function XJ(W){return typeof W.schema!="boolean"}function m7(W,O){let{schema:M,gen:L,opts:$}=W;if($.$comment&&M.$comment)SJ(W);i7(W),s7(W);let Y=L.const("_errs",u.default.errors);QJ(W,Y),L.var(O,h._`${Y} === ${u.default.errors}`)}function GJ(W){(0,IO.checkUnknownRules)(W),d7(W)}function QJ(W,O){if(W.opts.jtd)return $J(W,[],!1,O);let M=(0,MJ.getSchemaTypes)(W.schema),L=(0,MJ.coerceAndCheckDataType)(W,M);$J(W,M,!L,O)}function d7(W){let{schema:O,errSchemaPath:M,opts:L,self:$}=W;if(O.$ref&&L.ignoreKeywordsWithRef&&(0,IO.schemaHasRulesButRef)(O,$.RULES))$.logger.warn(`$ref: keywords ignored in schema at path "${M}"`)}function c7(W){let{schema:O,opts:M}=W;if(O.default!==void 0&&M.useDefaults&&M.strictSchema)(0,IO.checkStrictMode)(W,"default is ignored in the schema root")}function i7(W){let O=W.schema[W.opts.schemaId];if(O)W.baseId=(0,v7.resolveUrl)(W.opts.uriResolver,W.baseId,O)}function s7(W){if(W.schema.$async&&!W.schemaEnv.$async)throw Error("async schema in sync schema")}function SJ({gen:W,schemaEnv:O,schema:M,errSchemaPath:L,opts:$}){let Y=M.$comment;if($.$comment===!0)W.code(h._`${u.default.self}.logger.log(${Y})`);else if(typeof $.$comment=="function"){let J=h.str`${L}/$comment`,A=W.scopeValue("root",{ref:O.root});W.code(h._`${u.default.self}.opts.$comment(${Y}, ${J}, ${A}.schema)`)}}function n7(W){let{gen:O,schemaEnv:M,validateName:L,ValidationError:$,opts:Y}=W;if(M.$async)O.if(h._`${u.default.errors} === 0`,()=>O.return(u.default.data),()=>O.throw(h._`new ${$}(${u.default.vErrors})`));else{if(O.assign(h._`${L}.errors`,u.default.vErrors),Y.unevaluated)r7(W);O.return(h._`${u.default.errors} === 0`)}}function r7({gen:W,evaluated:O,props:M,items:L}){if(M instanceof h.Name)W.assign(h._`${O}.props`,M);if(L instanceof h.Name)W.assign(h._`${O}.items`,L)}function $J(W,O,M,L){let{gen:$,schema:Y,data:J,allErrors:A,opts:Z,self:X}=W,{RULES:G}=X;if(Y.$ref&&(Z.ignoreKeywordsWithRef||!(0,IO.schemaHasRulesButRef)(Y,G))){$.block(()=>UJ(W,"$ref",G.all.$ref.definition));return}if(!Z.jtd)a7(W,O);$.block(()=>{for(let S of G.rules)Q(S);Q(G.post)});function Q(S){if(!(0,P$.shouldUseGroup)(Y,S))return;if(S.type){if($.if((0,yM.checkDataType)(S.type,J,Z.strictNumbers)),YJ(W,S),O.length===1&&O[0]===S.type&&M)$.else(),(0,yM.reportTypeError)(W);$.endIf()}else YJ(W,S);if(!A)$.if(h._`${u.default.errors} === ${L||0}`)}}function YJ(W,O){let{gen:M,schema:L,opts:{useDefaults:$}}=W;if($)(0,f7.assignDefaults)(W,O.type);M.block(()=>{for(let Y of O.rules)if((0,P$.shouldUseRule)(L,Y))UJ(W,Y.keyword,Y.definition,O.type)})}function a7(W,O){if(W.schemaEnv.meta||!W.opts.strictTypes)return;if(o7(W,O),!W.opts.allowUnionTypes)t7(W,O);e7(W,W.dataTypes)}function o7(W,O){if(!O.length)return;if(!W.dataTypes.length){W.dataTypes=O;return}O.forEach((M)=>{if(!RJ(W.dataTypes,M))_$(W,`type "${M}" not allowed by context "${W.dataTypes.join(",")}"`)}),OS(W,O)}function t7(W,O){if(O.length>1&&!(O.length===2&&O.includes("null")))_$(W,"use allowUnionTypes to allow union type keyword")}function e7(W,O){let M=W.self.RULES.all;for(let L in M){let $=M[L];if(typeof $=="object"&&(0,P$.shouldUseRule)(W.schema,$)){let{type:Y}=$.definition;if(Y.length&&!Y.some((J)=>WS(O,J)))_$(W,`missing type "${Y.join(",")}" for keyword "${L}"`)}}}function WS(W,O){return W.includes(O)||O==="number"&&W.includes("integer")}function RJ(W,O){return W.includes(O)||O==="integer"&&W.includes("number")}function OS(W,O){let M=[];for(let L of W.dataTypes)if(RJ(O,L))M.push(L);else if(O.includes("integer")&&L==="number")M.push("integer");W.dataTypes=M}function _$(W,O){let M=W.schemaEnv.baseId+W.errSchemaPath;O+=` at "${M}" (strictTypes)`,(0,IO.checkStrictMode)(W,O,W.opts.strictTypes)}class j${constructor(W,O,M){if((0,V1.validateKeywordUsage)(W,O,M),this.gen=W.gen,this.allErrors=W.allErrors,this.keyword=M,this.data=W.data,this.schema=W.schema[M],this.$data=O.$data&&W.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,IO.schemaRefOrVal)(W,this.schema,M,this.$data),this.schemaType=O.schemaType,this.parentSchema=W.schema,this.params={},this.it=W,this.def=O,this.$data)this.schemaCode=W.gen.const("vSchema",zJ(this.$data,W));else if(this.schemaCode=this.schemaValue,!(0,V1.validSchemaType)(this.schema,O.schemaType,O.allowUndefined))throw Error(`${M} value must be ${JSON.stringify(O.schemaType)}`);if("code"in O?O.trackErrors:O.errors!==!1)this.errsCount=W.gen.const("_errs",u.default.errors)}result(W,O,M){this.failResult((0,h.not)(W),O,M)}failResult(W,O,M){if(this.gen.if(W),M)M();else this.error();if(O){if(this.gen.else(),O(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(W,O){this.failResult((0,h.not)(W),void 0,O)}fail(W){if(W===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(W),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(W){if(!this.$data)return this.fail(W);let{schemaCode:O}=this;this.fail(h._`${O} !== undefined && (${(0,h.or)(this.invalid$data(),W)})`)}error(W,O,M){if(O){this.setParams(O),this._error(W,M),this.setParams({});return}this._error(W,M)}_error(W,O){(W?z1.reportExtraError:z1.reportError)(this,this.def.error,O)}$dataError(){(0,z1.reportError)(this,this.def.$dataError||z1.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,z1.resetErrorsCount)(this.gen,this.errsCount)}ok(W){if(!this.allErrors)this.gen.if(W)}setParams(W,O){if(O)Object.assign(this.params,W);else this.params=W}block$data(W,O,M=h.nil){this.gen.block(()=>{this.check$data(W,M),O()})}check$data(W=h.nil,O=h.nil){if(!this.$data)return;let{gen:M,schemaCode:L,schemaType:$,def:Y}=this;if(M.if((0,h.or)(h._`${L} === undefined`,O)),W!==h.nil)M.assign(W,!0);if($.length||Y.validateSchema){if(M.elseIf(this.invalid$data()),this.$dataError(),W!==h.nil)M.assign(W,!1)}M.else()}invalid$data(){let{gen:W,schemaCode:O,schemaType:M,def:L,it:$}=this;return(0,h.or)(Y(),J());function Y(){if(M.length){if(!(O instanceof h.Name))throw Error("ajv implementation error");let A=Array.isArray(M)?M:[M];return h._`${(0,yM.checkDataTypes)(A,O,$.opts.strictNumbers,yM.DataType.Wrong)}`}return h.nil}function J(){if(L.validateSchema){let A=W.scopeValue("validate$data",{ref:L.validateSchema});return h._`!${A}(${O})`}return h.nil}}subschema(W,O){let M=(0,N$.getSubschema)(this.it,W);(0,N$.extendSubschemaData)(M,this.it,W),(0,N$.extendSubschemaMode)(M,W);let L={...this.it,...M,items:void 0,props:void 0};return p7(L,O),L}mergeEvaluated(W,O){let{it:M,gen:L}=this;if(!M.opts.unevaluated)return;if(M.props!==!0&&W.props!==void 0)M.props=IO.mergeEvaluated.props(L,W.props,M.props,O);if(M.items!==!0&&W.items!==void 0)M.items=IO.mergeEvaluated.items(L,W.items,M.items,O)}mergeValidEvaluated(W,O){let{it:M,gen:L}=this;if(M.opts.unevaluated&&(M.props!==!0||M.items!==!0))return L.if(O,()=>this.mergeEvaluated(W,h.Name)),!0}}VJ.KeywordCxt=j$;function UJ(W,O,M,L){let $=new j$(W,M,O);if("code"in M)M.code($,L);else if($.$data&&M.validate)(0,V1.funcKeywordCode)($,M);else if("macro"in M)(0,V1.macroKeywordCode)($,M);else if(M.compile||M.validate)(0,V1.funcKeywordCode)($,M)}var MS=/^\/(?:[^~]|~0|~1)*$/,LS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function zJ(W,{dataLevel:O,dataNames:M,dataPathArr:L}){let $,Y;if(W==="")return u.default.rootData;if(W[0]==="/"){if(!MS.test(W))throw Error(`Invalid JSON-pointer: ${W}`);$=W,Y=u.default.rootData}else{let X=LS.exec(W);if(!X)throw Error(`Invalid JSON-pointer: ${W}`);let G=+X[1];if($=X[2],$==="#"){if(G>=O)throw Error(Z("property/index",G));return L[O-G]}if(G>O)throw Error(Z("data",G));if(Y=M[O-G],!$)return Y}let J=Y,A=$.split("/");for(let X of A)if(X)Y=h._`${Y}${(0,h.getProperty)((0,IO.unescapeJsonPointer)(X))}`,J=h._`${J} && ${Y}`;return J;function Z(X,G){return`Cannot access ${X} ${G} levels up, current level is ${O}`}}VJ.getData=zJ});var DM=y((TJ)=>{Object.defineProperty(TJ,"__esModule",{value:!0});class KJ extends Error{constructor(W){super("validation failed");this.errors=W,this.ajv=this.validation=!0}}TJ.default=KJ});var K1=y((EJ)=>{Object.defineProperty(EJ,"__esModule",{value:!0});var I$=U1();class FJ extends Error{constructor(W,O,M,L){super(L||`can't resolve reference ${M} from id ${O}`);this.missingRef=(0,I$.resolveUrl)(W,O,M),this.missingSchema=(0,I$.normalizeId)((0,I$.getFullPath)(W,this.missingRef))}}EJ.default=FJ});var F1=y((wJ)=>{Object.defineProperty(wJ,"__esModule",{value:!0});wJ.resolveSchema=wJ.getCompilingSchema=wJ.resolveRef=wJ.compileSchema=wJ.SchemaEnv=void 0;var JO=d(),ZS=DM(),J0=nW(),AO=U1(),qJ=s(),XS=H1();class T1{constructor(W){var O;this.refs={},this.dynamicAnchors={};let M;if(typeof W.schema=="object")M=W.schema;this.schema=W.schema,this.schemaId=W.schemaId,this.root=W.root||this,this.baseId=(O=W.baseId)!==null&&O!==void 0?O:(0,AO.normalizeId)(M===null||M===void 0?void 0:M[W.schemaId||"$id"]),this.schemaPath=W.schemaPath,this.localRefs=W.localRefs,this.meta=W.meta,this.$async=M===null||M===void 0?void 0:M.$async,this.refs={}}}wJ.SchemaEnv=T1;function D$(W){let O=BJ.call(this,W);if(O)return O;let M=(0,AO.getFullPath)(this.opts.uriResolver,W.root.baseId),{es5:L,lines:$}=this.opts.code,{ownProperties:Y}=this.opts,J=new JO.CodeGen(this.scope,{es5:L,lines:$,ownProperties:Y}),A;if(W.$async)A=J.scopeValue("Error",{ref:ZS.default,code:JO._`require("ajv/dist/runtime/validation_error").default`});let Z=J.scopeName("validate");W.validateName=Z;let X={gen:J,allErrors:this.opts.allErrors,data:J0.default.data,parentData:J0.default.parentData,parentDataProperty:J0.default.parentDataProperty,dataNames:[J0.default.data],dataPathArr:[JO.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:J.scopeValue("schema",this.opts.code.source===!0?{ref:W.schema,code:(0,JO.stringify)(W.schema)}:{ref:W.schema}),validateName:Z,ValidationError:A,schema:W.schema,schemaEnv:W,rootId:M,baseId:W.baseId||M,schemaPath:JO.nil,errSchemaPath:W.schemaPath||(this.opts.jtd?"":"#"),errorPath:JO._`""`,opts:this.opts,self:this},G;try{this._compilations.add(W),(0,XS.validateFunctionCode)(X),J.optimize(this.opts.code.optimize);let Q=J.toString();if(G=`${J.scopeRefs(J0.default.scope)}return ${Q}`,this.opts.code.process)G=this.opts.code.process(G,W);let U=Function(`${J0.default.self}`,`${J0.default.scope}`,G)(this,this.scope.get());if(this.scope.value(Z,{ref:U}),U.errors=null,U.schema=W.schema,U.schemaEnv=W,W.$async)U.$async=!0;if(this.opts.code.source===!0)U.source={validateName:Z,validateCode:Q,scopeValues:J._values};if(this.opts.unevaluated){let{props:V,items:R}=X;if(U.evaluated={props:V instanceof JO.Name?void 0:V,items:R instanceof JO.Name?void 0:R,dynamicProps:V instanceof JO.Name,dynamicItems:R instanceof JO.Name},U.source)U.source.evaluated=(0,JO.stringify)(U.evaluated)}return W.validate=U,W}catch(Q){if(delete W.validate,delete W.validateName,G)this.logger.error("Error compiling schema, function code:",G);throw Q}finally{this._compilations.delete(W)}}wJ.compileSchema=D$;function GS(W,O,M){var L;M=(0,AO.resolveUrl)(this.opts.uriResolver,O,M);let $=W.refs[M];if($)return $;let Y=RS.call(this,W,M);if(Y===void 0){let J=(L=W.localRefs)===null||L===void 0?void 0:L[M],{schemaId:A}=this.opts;if(J)Y=new T1({schema:J,schemaId:A,root:W,baseId:O})}if(Y===void 0)return;return W.refs[M]=QS.call(this,Y)}wJ.resolveRef=GS;function QS(W){if((0,AO.inlineRef)(W.schema,this.opts.inlineRefs))return W.schema;return W.validate?W:D$.call(this,W)}function BJ(W){for(let O of this._compilations)if(SS(O,W))return O}wJ.getCompilingSchema=BJ;function SS(W,O){return W.schema===O.schema&&W.root===O.root&&W.baseId===O.baseId}function RS(W,O){let M;while(typeof(M=this.refs[O])=="string")O=M;return M||this.schemas[O]||kM.call(this,W,O)}function kM(W,O){let M=this.opts.uriResolver.parse(O),L=(0,AO._getFullPath)(this.opts.uriResolver,M),$=(0,AO.getFullPath)(this.opts.uriResolver,W.baseId,void 0);if(Object.keys(W.schema).length>0&&L===$)return y$.call(this,M,W);let Y=(0,AO.normalizeId)(L),J=this.refs[Y]||this.schemas[Y];if(typeof J=="string"){let A=kM.call(this,W,J);if(typeof(A===null||A===void 0?void 0:A.schema)!=="object")return;return y$.call(this,M,A)}if(typeof(J===null||J===void 0?void 0:J.schema)!=="object")return;if(!J.validate)D$.call(this,J);if(Y===(0,AO.normalizeId)(O)){let{schema:A}=J,{schemaId:Z}=this.opts,X=A[Z];if(X)$=(0,AO.resolveUrl)(this.opts.uriResolver,$,X);return new T1({schema:A,schemaId:Z,root:W,baseId:$})}return y$.call(this,M,J)}wJ.resolveSchema=kM;var US=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function y$(W,{baseId:O,schema:M,root:L}){var $;if((($=W.fragment)===null||$===void 0?void 0:$[0])!=="/")return;for(let A of W.fragment.slice(1).split("/")){if(typeof M==="boolean")return;let Z=M[(0,qJ.unescapeFragment)(A)];if(Z===void 0)return;M=Z;let X=typeof M==="object"&&M[this.opts.schemaId];if(!US.has(A)&&X)O=(0,AO.resolveUrl)(this.opts.uriResolver,O,X)}let Y;if(typeof M!="boolean"&&M.$ref&&!(0,qJ.schemaHasRulesButRef)(M,this.RULES)){let A=(0,AO.resolveUrl)(this.opts.uriResolver,O,M.$ref);Y=kM.call(this,L,A)}let{schemaId:J}=this.opts;if(Y=Y||new T1({schema:M,schemaId:J,root:L,baseId:O}),Y.schema!==Y.root.schema)return Y;return}});var NJ=y((yB,TS)=>{TS.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var f$=y((DB,DJ)=>{var FS=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),_J=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),k$=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),jJ=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),ES=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function b$(W){let O="",M=0,L=0;for(L=0;L<W.length;L++){if(M=W[L].charCodeAt(0),M===48)continue;if(!(M>=48&&M<=57||M>=65&&M<=70||M>=97&&M<=102))return"";O+=W[L];break}for(L+=1;L<W.length;L++){if(M=W[L].charCodeAt(0),!(M>=48&&M<=57||M>=65&&M<=70||M>=97&&M<=102))return"";O+=W[L]}return O}var qS=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function PJ(W){return W.length=0,!0}function BS(W,O,M){if(W.length){let L=b$(W);if(L!=="")O.push(L);else return M.error=!0,!1;W.length=0}return!0}function wS(W){let O=0,M={error:!1,address:"",zone:""},L=[],$=[],Y=!1,J=!1,A=BS;for(let Z=0;Z<W.length;Z++){let X=W[Z];if(X==="["||X==="]")continue;if(X===":"){if(Y===!0)J=!0;if(!A($,L,M))break;if(++O>7){M.error=!0;break}if(Z>0&&W[Z-1]===":")Y=!0;L.push(":");continue}else if(X==="%"){if(!A($,L,M))break;A=PJ}else{$.push(X);continue}}if($.length)if(A===PJ)M.zone=$.join("");else if(J)L.push($.join(""));else L.push(b$($));return M.address=L.join(""),M}function IJ(W){if(CS(W,":")<2)return{host:W,isIPV6:!1};let O=wS(W);if(!O.error){let{address:M,address:L}=O;if(O.zone)M+="%"+O.zone,L+="%25"+O.zone;return{host:M,isIPV6:!0,escapedHost:L}}else return{host:W,isIPV6:!1}}function CS(W,O){let M=0;for(let L=0;L<W.length;L++)if(W[L]===O)M++;return M}function NS(W){let O=W,M=[],L=-1,$=0;while($=O.length){if($===1)if(O===".")break;else if(O==="/"){M.push("/");break}else{M.push(O);break}else if($===2){if(O[0]==="."){if(O[1]===".")break;else if(O[1]==="/"){O=O.slice(2);continue}}else if(O[0]==="/"){if(O[1]==="."||O[1]==="/"){M.push("/");break}}}else if($===3){if(O==="/.."){if(M.length!==0)M.pop();M.push("/");break}}if(O[0]==="."){if(O[1]==="."){if(O[2]==="/"){O=O.slice(3);continue}}else if(O[1]==="/"){O=O.slice(2);continue}}else if(O[0]==="/"){if(O[1]==="."){if(O[2]==="/"){O=O.slice(2);continue}else if(O[2]==="."){if(O[3]==="/"){if(O=O.slice(3),M.length!==0)M.pop();continue}}}}if((L=O.indexOf("/",1))===-1){M.push(O);break}else M.push(O.slice(0,L)),O=O.slice(L)}return M.join("")}var PS={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},_S=/[@/?#:]/g,jS=/[@/?#]/g;function yJ(W,O){let M=O?jS:_S;return M.lastIndex=0,W.replace(M,(L)=>PS[L])}function IS(W,O=!1){if(W.indexOf("%")===-1)return W;let M="";for(let L=0;L<W.length;L++){if(W[L]==="%"&&L+2<W.length){let $=W.slice(L+1,L+3);if(k$($)){let Y=$.toUpperCase(),J=String.fromCharCode(parseInt(Y,16));if(O&&jJ(J))M+=J;else M+="%"+Y;L+=2;continue}}M+=W[L]}return M}function yS(W){let O="";for(let M=0;M<W.length;M++){if(W[M]==="%"&&M+2<W.length){let L=W.slice(M+1,M+3);if(k$(L)){let $=L.toUpperCase(),Y=String.fromCharCode(parseInt($,16));if(Y!=="."&&jJ(Y))O+=Y;else O+="%"+$;M+=2;continue}}if(ES(W[M]))O+=W[M];else O+=escape(W[M])}return O}function DS(W){let O="";for(let M=0;M<W.length;M++){if(W[M]==="%"&&M+2<W.length){let L=W.slice(M+1,M+3);if(k$(L)){O+="%"+L.toUpperCase(),M+=2;continue}}O+=escape(W[M])}return O}function kS(W){let O=[];if(W.userinfo!==void 0)O.push(W.userinfo),O.push("@");if(W.host!==void 0){let M=unescape(W.host);if(!_J(M)){let L=IJ(M);if(L.isIPV6===!0)M=`[${L.escapedHost}]`;else M=yJ(M,!1)}O.push(M)}if(typeof W.port==="number"||typeof W.port==="string")O.push(":"),O.push(String(W.port));return O.length?O.join(""):void 0}DJ.exports={nonSimpleDomain:qS,recomposeAuthority:kS,reescapeHostDelimiters:yJ,normalizePercentEncoding:IS,normalizePathEncoding:yS,escapePreservingEscapes:DS,removeDotSegments:NS,isIPv4:_J,isUUID:FS,normalizeIPv6:IJ,stringArrayToHexStripped:b$}});var xJ=y((kB,vJ)=>{var{isUUID:bS}=f$(),fS=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,vS=["http","https","ws","wss","urn","urn:uuid"];function xS(W){return vS.indexOf(W)!==-1}function v$(W){if(W.secure===!0)return!0;else if(W.secure===!1)return!1;else if(W.scheme)return W.scheme.length===3&&(W.scheme[0]==="w"||W.scheme[0]==="W")&&(W.scheme[1]==="s"||W.scheme[1]==="S")&&(W.scheme[2]==="s"||W.scheme[2]==="S");else return!1}function kJ(W){if(!W.host)W.error=W.error||"HTTP URIs must have a host.";return W}function bJ(W){let O=String(W.scheme).toLowerCase()==="https";if(W.port===(O?443:80)||W.port==="")W.port=void 0;if(!W.path)W.path="/";return W}function gS(W){return W.secure=v$(W),W.resourceName=(W.path||"/")+(W.query?"?"+W.query:""),W.path=void 0,W.query=void 0,W}function hS(W){if(W.port===(v$(W)?443:80)||W.port==="")W.port=void 0;if(typeof W.secure==="boolean")W.scheme=W.secure?"wss":"ws",W.secure=void 0;if(W.resourceName){let[O,M]=W.resourceName.split("?");W.path=O&&O!=="/"?O:void 0,W.query=M,W.resourceName=void 0}return W.fragment=void 0,W}function uS(W,O){if(!W.path)return W.error="URN can not be parsed",W;let M=W.path.match(fS);if(M){let L=O.scheme||W.scheme||"urn";W.nid=M[1].toLowerCase(),W.nss=M[2];let $=`${L}:${O.nid||W.nid}`,Y=x$($);if(W.path=void 0,Y)W=Y.parse(W,O)}else W.error=W.error||"URN can not be parsed.";return W}function lS(W,O){if(W.nid===void 0)throw Error("URN without nid cannot be serialized");let M=O.scheme||W.scheme||"urn",L=W.nid.toLowerCase(),$=`${M}:${O.nid||L}`,Y=x$($);if(Y)W=Y.serialize(W,O);let J=W,A=W.nss;return J.path=`${L||O.nid}:${A}`,O.skipEscape=!0,J}function pS(W,O){let M=W;if(M.uuid=M.nss,M.nss=void 0,!O.tolerant&&(!M.uuid||!bS(M.uuid)))M.error=M.error||"UUID is not valid.";return M}function mS(W){let O=W;return O.nss=(W.uuid||"").toLowerCase(),O}var fJ={scheme:"http",domainHost:!0,parse:kJ,serialize:bJ},dS={scheme:"https",domainHost:fJ.domainHost,parse:kJ,serialize:bJ},bM={scheme:"ws",domainHost:!0,parse:gS,serialize:hS},cS={scheme:"wss",domainHost:bM.domainHost,parse:bM.parse,serialize:bM.serialize},iS={scheme:"urn",parse:uS,serialize:lS,skipNormalize:!0},sS={scheme:"urn:uuid",parse:pS,serialize:mS,skipNormalize:!0},fM={http:fJ,https:dS,ws:bM,wss:cS,urn:iS,"urn:uuid":sS};Object.setPrototypeOf(fM,null);function x$(W){return W&&(fM[W]||fM[W.toLowerCase()])||void 0}vJ.exports={wsIsSecure:v$,SCHEMES:fM,isValidSchemeName:xS,getSchemeHandler:x$}});var pJ=y((bB,gM)=>{var{normalizeIPv6:nS,removeDotSegments:E1,recomposeAuthority:rS,normalizePercentEncoding:aS,normalizePathEncoding:oS,escapePreservingEscapes:tS,reescapeHostDelimiters:eS,isIPv4:WR,nonSimpleDomain:OR}=f$(),{SCHEMES:MR,getSchemeHandler:hJ}=xJ();function LR(W,O){if(typeof W==="string")W=GR(W,O);else if(typeof W==="object")W=xM(A0(W,O),O);return W}function $R(W,O,M){let L=M?Object.assign({scheme:"null"},M):{scheme:"null"},{parsed:$,malformedAuthorityOrPort:Y}=vM(W,L),{parsed:J,malformedAuthorityOrPort:A}=vM(O,L);if(Y||A)throw Error($.error||J.error||"URI is malformed.");let Z=uJ($,J,L,!0);return L.skipEscape=!0,A0(Z,L)}function uJ(W,O,M,L){let $={};if(!L)W=xM(A0(W,M),M),O=xM(A0(O,M),M);if(M=M||{},!M.tolerant&&O.scheme)$.scheme=O.scheme,$.userinfo=O.userinfo,$.host=O.host,$.port=O.port,$.path=E1(O.path||""),$.query=O.query;else{if(O.userinfo!==void 0||O.host!==void 0||O.port!==void 0)$.userinfo=O.userinfo,$.host=O.host,$.port=O.port,$.path=E1(O.path||""),$.query=O.query;else{if(!O.path)if($.path=W.path,O.query!==void 0)$.query=O.query;else $.query=W.query;else{if(O.path[0]==="/")$.path=E1(O.path);else{if((W.userinfo!==void 0||W.host!==void 0||W.port!==void 0)&&!W.path)$.path="/"+O.path;else if(!W.path)$.path=O.path;else $.path=W.path.slice(0,W.path.lastIndexOf("/")+1)+O.path;$.path=E1($.path)}$.query=O.query}$.userinfo=W.userinfo,$.host=W.host,$.port=W.port}$.scheme=W.scheme}return $.fragment=O.fragment,$}function YR(W,O,M){let L=gJ(W,M),$=gJ(O,M);return L!==void 0&&$!==void 0&&L.toLowerCase()===$.toLowerCase()}function A0(W,O){let M={host:W.host,scheme:W.scheme,userinfo:W.userinfo,port:W.port,path:W.path,query:W.query,nid:W.nid,nss:W.nss,uuid:W.uuid,fragment:W.fragment,reference:W.reference,resourceName:W.resourceName,secure:W.secure,error:""},L=Object.assign({},O),$=[],Y=hJ(L.scheme||M.scheme);if(Y&&Y.serialize)Y.serialize(M,L);if(M.path!==void 0)if(!L.skipEscape){if(M.path=tS(M.path),M.scheme!==void 0)M.path=M.path.split("%3A").join(":")}else M.path=aS(M.path);if(L.reference!=="suffix"&&M.scheme)$.push(M.scheme,":");let J=rS(M);if(J!==void 0){if(L.reference!=="suffix")$.push("//");if($.push(J),M.path&&M.path[0]!=="/")$.push("/")}if(M.path!==void 0){let A=M.path;if(!L.absolutePath&&(!Y||!Y.absolutePath))A=E1(A);if(J===void 0&&A[0]==="/"&&A[1]==="/")A="/%2F"+A.slice(2);$.push(A)}if(M.query!==void 0)$.push("?",M.query);if(M.fragment!==void 0)$.push("#",M.fragment);return $.join("")}var JR=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,AR=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,ZR=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function XR(W,O){if(O[2]!==void 0&&W.path&&W.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof W.port==="number"&&(W.port<0||W.port>65535))return"URI port is malformed.";return}function vM(W,O){let M=Object.assign({},O),L={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},$=!1,Y=!1;if(M.reference==="suffix")if(M.scheme)W=M.scheme+":"+W;else W="//"+W;let J=W.match(AR);if(J!==null&&J[1].indexOf("\\")!==-1)L.error="URI authority must not contain a literal backslash.",$=!0;let A=W.match(ZR);if(A!==null){let X=A[1],G=X.replace(/[\t\n\r]/g,"");if(G.length>=2){if(G.slice(0,2)!=="//")L.error=L.error||"URI authority must not contain a literal backslash.",$=!0;else if(X.length!==G.length)L.error=L.error||"URI authority introducer must not contain whitespace.",$=!0}}let Z=W.match(JR);if(Z){if(L.scheme=Z[1],L.userinfo=Z[3],L.host=Z[4],L.port=parseInt(Z[5],10),L.path=Z[6]||"",L.query=Z[7],L.fragment=Z[8],isNaN(L.port))L.port=Z[5];let X=XR(L,Z);if(X!==void 0)L.error=L.error||X,$=!0;if(L.host)if(WR(L.host)===!1){let S=nS(L.host);L.host=S.host.toLowerCase(),Y=S.isIPV6}else Y=!0;if(L.scheme===void 0&&L.userinfo===void 0&&L.host===void 0&&L.port===void 0&&L.query===void 0&&!L.path)L.reference="same-document";else if(L.scheme===void 0)L.reference="relative";else if(L.fragment===void 0)L.reference="absolute";else L.reference="uri";if(M.reference&&M.reference!=="suffix"&&M.reference!==L.reference)L.error=L.error||"URI is not a "+M.reference+" reference.";let G=hJ(M.scheme||L.scheme);if(!M.unicodeSupport&&(!G||!G.unicodeSupport)){if(L.host&&(M.domainHost||G&&G.domainHost)&&Y===!1&&OR(L.host))try{L.host=new URL("http://"+L.host).hostname}catch(Q){L.error=L.error||"Host's domain name can not be converted to ASCII: "+Q}}if(!G||G&&!G.skipNormalize){if(W.indexOf("%")!==-1){if(L.scheme!==void 0)L.scheme=unescape(L.scheme);if(L.host!==void 0)L.host=eS(unescape(L.host),Y)}if(L.path)L.path=oS(L.path);if(L.fragment)try{L.fragment=encodeURI(decodeURIComponent(L.fragment))}catch{L.error=L.error||"URI malformed"}}if(G&&G.parse)G.parse(L,M)}else L.error=L.error||"URI can not be parsed.";return{parsed:L,malformedAuthorityOrPort:$}}function xM(W,O){return vM(W,O).parsed}function GR(W,O){return lJ(W,O).normalized}function lJ(W,O){let{parsed:M,malformedAuthorityOrPort:L}=vM(W,O);return{normalized:L?W:A0(M,O),malformedAuthorityOrPort:L}}function gJ(W,O){if(typeof W==="string"){let{normalized:M,malformedAuthorityOrPort:L}=lJ(W,O);return L?void 0:M}if(typeof W==="object")return A0(W,O)}var g$={SCHEMES:MR,normalize:LR,resolve:$R,resolveComponent:uJ,equal:YR,serialize:A0,parse:xM};gM.exports=g$;gM.exports.default=g$;gM.exports.fastUri=g$});var cJ=y((dJ)=>{Object.defineProperty(dJ,"__esModule",{value:!0});var mJ=pJ();mJ.code='require("ajv/dist/runtime/uri").default';dJ.default=mJ});var eJ=y((yO)=>{Object.defineProperty(yO,"__esModule",{value:!0});yO.CodeGen=yO.Name=yO.nil=yO.stringify=yO.str=yO._=yO.KeywordCxt=void 0;var SR=H1();Object.defineProperty(yO,"KeywordCxt",{enumerable:!0,get:function(){return SR.KeywordCxt}});var j0=d();Object.defineProperty(yO,"_",{enumerable:!0,get:function(){return j0._}});Object.defineProperty(yO,"str",{enumerable:!0,get:function(){return j0.str}});Object.defineProperty(yO,"stringify",{enumerable:!0,get:function(){return j0.stringify}});Object.defineProperty(yO,"nil",{enumerable:!0,get:function(){return j0.nil}});Object.defineProperty(yO,"Name",{enumerable:!0,get:function(){return j0.Name}});Object.defineProperty(yO,"CodeGen",{enumerable:!0,get:function(){return j0.CodeGen}});var RR=DM(),aJ=K1(),UR=V$(),q1=F1(),zR=d(),B1=U1(),hM=R1(),u$=s(),iJ=NJ(),VR=cJ(),oJ=(W,O)=>new RegExp(W,O);oJ.code="new RegExp";var HR=["removeAdditional","useDefaults","coerceTypes"],KR=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),TR={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},FR={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},sJ=200;function ER(W){var O,M,L,$,Y,J,A,Z,X,G,Q,S,U,V,R,K,T,F,N,C,w,B,I,_,H;let q=W.strict,j=(O=W.code)===null||O===void 0?void 0:O.optimize,b=j===!0||j===void 0?1:j||0,k=(L=(M=W.code)===null||M===void 0?void 0:M.regExp)!==null&&L!==void 0?L:oJ,p=($=W.uriResolver)!==null&&$!==void 0?$:VR.default;return{strictSchema:(J=(Y=W.strictSchema)!==null&&Y!==void 0?Y:q)!==null&&J!==void 0?J:!0,strictNumbers:(Z=(A=W.strictNumbers)!==null&&A!==void 0?A:q)!==null&&Z!==void 0?Z:!0,strictTypes:(G=(X=W.strictTypes)!==null&&X!==void 0?X:q)!==null&&G!==void 0?G:"log",strictTuples:(S=(Q=W.strictTuples)!==null&&Q!==void 0?Q:q)!==null&&S!==void 0?S:"log",strictRequired:(V=(U=W.strictRequired)!==null&&U!==void 0?U:q)!==null&&V!==void 0?V:!1,code:W.code?{...W.code,optimize:b,regExp:k}:{optimize:b,regExp:k},loopRequired:(R=W.loopRequired)!==null&&R!==void 0?R:sJ,loopEnum:(K=W.loopEnum)!==null&&K!==void 0?K:sJ,meta:(T=W.meta)!==null&&T!==void 0?T:!0,messages:(F=W.messages)!==null&&F!==void 0?F:!0,inlineRefs:(N=W.inlineRefs)!==null&&N!==void 0?N:!0,schemaId:(C=W.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(w=W.addUsedSchema)!==null&&w!==void 0?w:!0,validateSchema:(B=W.validateSchema)!==null&&B!==void 0?B:!0,validateFormats:(I=W.validateFormats)!==null&&I!==void 0?I:!0,unicodeRegExp:(_=W.unicodeRegExp)!==null&&_!==void 0?_:!0,int32range:(H=W.int32range)!==null&&H!==void 0?H:!0,uriResolver:p}}class uM{constructor(W={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,W=this.opts={...W,...ER(W)};let{es5:O,lines:M}=this.opts.code;this.scope=new zR.ValueScope({scope:{},prefixes:KR,es5:O,lines:M}),this.logger=PR(W.logger);let L=W.validateFormats;if(W.validateFormats=!1,this.RULES=(0,UR.getRules)(),nJ.call(this,TR,W,"NOT SUPPORTED"),nJ.call(this,FR,W,"DEPRECATED","warn"),this._metaOpts=CR.call(this),W.formats)BR.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),W.keywords)wR.call(this,W.keywords);if(typeof W.meta=="object")this.addMetaSchema(W.meta);qR.call(this),W.validateFormats=L}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:W,meta:O,schemaId:M}=this.opts,L=iJ;if(M==="id")L={...iJ},L.id=L.$id,delete L.$id;if(O&&W)this.addMetaSchema(L,L[M],!1)}defaultMeta(){let{meta:W,schemaId:O}=this.opts;return this.opts.defaultMeta=typeof W=="object"?W[O]||W:void 0}validate(W,O){let M;if(typeof W=="string"){if(M=this.getSchema(W),!M)throw Error(`no schema with key or ref "${W}"`)}else M=this.compile(W);let L=M(O);if(!("$async"in M))this.errors=M.errors;return L}compile(W,O){let M=this._addSchema(W,O);return M.validate||this._compileSchemaEnv(M)}compileAsync(W,O){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:M}=this.opts;return L.call(this,W,O);async function L(X,G){await $.call(this,X.$schema);let Q=this._addSchema(X,G);return Q.validate||Y.call(this,Q)}async function $(X){if(X&&!this.getSchema(X))await L.call(this,{$ref:X},!0)}async function Y(X){try{return this._compileSchemaEnv(X)}catch(G){if(!(G instanceof aJ.default))throw G;return J.call(this,G),await A.call(this,G.missingSchema),Y.call(this,X)}}function J({missingSchema:X,missingRef:G}){if(this.refs[X])throw Error(`AnySchema ${X} is loaded but ${G} cannot be resolved`)}async function A(X){let G=await Z.call(this,X);if(!this.refs[X])await $.call(this,G.$schema);if(!this.refs[X])this.addSchema(G,X,O)}async function Z(X){let G=this._loading[X];if(G)return G;try{return await(this._loading[X]=M(X))}finally{delete this._loading[X]}}}addSchema(W,O,M,L=this.opts.validateSchema){if(Array.isArray(W)){for(let Y of W)this.addSchema(Y,void 0,M,L);return this}let $;if(typeof W==="object"){let{schemaId:Y}=this.opts;if($=W[Y],$!==void 0&&typeof $!="string")throw Error(`schema ${Y} must be string`)}return O=(0,B1.normalizeId)(O||$),this._checkUnique(O),this.schemas[O]=this._addSchema(W,M,O,L,!0),this}addMetaSchema(W,O,M=this.opts.validateSchema){return this.addSchema(W,O,!0,M),this}validateSchema(W,O){if(typeof W=="boolean")return!0;let M;if(M=W.$schema,M!==void 0&&typeof M!="string")throw Error("$schema must be a string");if(M=M||this.opts.defaultMeta||this.defaultMeta(),!M)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let L=this.validate(M,W);if(!L&&O){let $="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error($);else throw Error($)}return L}getSchema(W){let O;while(typeof(O=rJ.call(this,W))=="string")W=O;if(O===void 0){let{schemaId:M}=this.opts,L=new q1.SchemaEnv({schema:{},schemaId:M});if(O=q1.resolveSchema.call(this,L,W),!O)return;this.refs[W]=O}return O.validate||this._compileSchemaEnv(O)}removeSchema(W){if(W instanceof RegExp)return this._removeAllSchemas(this.schemas,W),this._removeAllSchemas(this.refs,W),this;switch(typeof W){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let O=rJ.call(this,W);if(typeof O=="object")this._cache.delete(O.schema);return delete this.schemas[W],delete this.refs[W],this}case"object":{let O=W;this._cache.delete(O);let M=W[this.opts.schemaId];if(M)M=(0,B1.normalizeId)(M),delete this.schemas[M],delete this.refs[M];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(W){for(let O of W)this.addKeyword(O);return this}addKeyword(W,O){let M;if(typeof W=="string"){if(M=W,typeof O=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),O.keyword=M}else if(typeof W=="object"&&O===void 0){if(O=W,M=O.keyword,Array.isArray(M)&&!M.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(jR.call(this,M,O),!O)return(0,u$.eachItem)(M,($)=>h$.call(this,$)),this;yR.call(this,O);let L={...O,type:(0,hM.getJSONTypes)(O.type),schemaType:(0,hM.getJSONTypes)(O.schemaType)};return(0,u$.eachItem)(M,L.type.length===0?($)=>h$.call(this,$,L):($)=>L.type.forEach((Y)=>h$.call(this,$,L,Y))),this}getKeyword(W){let O=this.RULES.all[W];return typeof O=="object"?O.definition:!!O}removeKeyword(W){let{RULES:O}=this;delete O.keywords[W],delete O.all[W];for(let M of O.rules){let L=M.rules.findIndex(($)=>$.keyword===W);if(L>=0)M.rules.splice(L,1)}return this}addFormat(W,O){if(typeof O=="string")O=new RegExp(O);return this.formats[W]=O,this}errorsText(W=this.errors,{separator:O=", ",dataVar:M="data"}={}){if(!W||W.length===0)return"No errors";return W.map((L)=>`${M}${L.instancePath} ${L.message}`).reduce((L,$)=>L+O+$)}$dataMetaSchema(W,O){let M=this.RULES.all;W=JSON.parse(JSON.stringify(W));for(let L of O){let $=L.split("/").slice(1),Y=W;for(let J of $)Y=Y[J];for(let J in M){let A=M[J];if(typeof A!="object")continue;let{$data:Z}=A.definition,X=Y[J];if(Z&&X)Y[J]=tJ(X)}}return W}_removeAllSchemas(W,O){for(let M in W){let L=W[M];if(!O||O.test(M)){if(typeof L=="string")delete W[M];else if(L&&!L.meta)this._cache.delete(L.schema),delete W[M]}}}_addSchema(W,O,M,L=this.opts.validateSchema,$=this.opts.addUsedSchema){let Y,{schemaId:J}=this.opts;if(typeof W=="object")Y=W[J];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof W!="boolean")throw Error("schema must be object or boolean");let A=this._cache.get(W);if(A!==void 0)return A;M=(0,B1.normalizeId)(Y||M);let Z=B1.getSchemaRefs.call(this,W,M);if(A=new q1.SchemaEnv({schema:W,schemaId:J,meta:O,baseId:M,localRefs:Z}),this._cache.set(A.schema,A),$&&!M.startsWith("#")){if(M)this._checkUnique(M);this.refs[M]=A}if(L)this.validateSchema(W,!0);return A}_checkUnique(W){if(this.schemas[W]||this.refs[W])throw Error(`schema with key or id "${W}" already exists`)}_compileSchemaEnv(W){if(W.meta)this._compileMetaSchema(W);else q1.compileSchema.call(this,W);if(!W.validate)throw Error("ajv implementation error");return W.validate}_compileMetaSchema(W){let O=this.opts;this.opts=this._metaOpts;try{q1.compileSchema.call(this,W)}finally{this.opts=O}}}uM.ValidationError=RR.default;uM.MissingRefError=aJ.default;yO.default=uM;function nJ(W,O,M,L="error"){for(let $ in W){let Y=$;if(Y in O)this.logger[L](`${M}: option ${$}. ${W[Y]}`)}}function rJ(W){return W=(0,B1.normalizeId)(W),this.schemas[W]||this.refs[W]}function qR(){let W=this.opts.schemas;if(!W)return;if(Array.isArray(W))this.addSchema(W);else for(let O in W)this.addSchema(W[O],O)}function BR(){for(let W in this.opts.formats){let O=this.opts.formats[W];if(O)this.addFormat(W,O)}}function wR(W){if(Array.isArray(W)){this.addVocabulary(W);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let O in W){let M=W[O];if(!M.keyword)M.keyword=O;this.addKeyword(M)}}function CR(){let W={...this.opts};for(let O of HR)delete W[O];return W}var NR={log(){},warn(){},error(){}};function PR(W){if(W===!1)return NR;if(W===void 0)return console;if(W.log&&W.warn&&W.error)return W;throw Error("logger must implement log, warn and error methods")}var _R=/^[a-z_$][a-z0-9_$:-]*$/i;function jR(W,O){let{RULES:M}=this;if((0,u$.eachItem)(W,(L)=>{if(M.keywords[L])throw Error(`Keyword ${L} is already defined`);if(!_R.test(L))throw Error(`Keyword ${L} has invalid name`)}),!O)return;if(O.$data&&!(("code"in O)||("validate"in O)))throw Error('$data keyword must have "code" or "validate" function')}function h$(W,O,M){var L;let $=O===null||O===void 0?void 0:O.post;if(M&&$)throw Error('keyword with "post" flag cannot have "type"');let{RULES:Y}=this,J=$?Y.post:Y.rules.find(({type:Z})=>Z===M);if(!J)J={type:M,rules:[]},Y.rules.push(J);if(Y.keywords[W]=!0,!O)return;let A={keyword:W,definition:{...O,type:(0,hM.getJSONTypes)(O.type),schemaType:(0,hM.getJSONTypes)(O.schemaType)}};if(O.before)IR.call(this,J,A,O.before);else J.rules.push(A);Y.all[W]=A,(L=O.implements)===null||L===void 0||L.forEach((Z)=>this.addKeyword(Z))}function IR(W,O,M){let L=W.rules.findIndex(($)=>$.keyword===M);if(L>=0)W.rules.splice(L,0,O);else W.rules.push(O),this.logger.warn(`rule ${M} is not defined`)}function yR(W){let{metaSchema:O}=W;if(O===void 0)return;if(W.$data&&this.opts.$data)O=tJ(O);W.validateSchema=this.compile(O,!0)}var DR={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function tJ(W){return{anyOf:[W,DR]}}});var OA=y((WA)=>{Object.defineProperty(WA,"__esModule",{value:!0});var fR={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};WA.default=fR});var mM=y((YA)=>{Object.defineProperty(YA,"__esModule",{value:!0});YA.callRef=YA.getValidate=void 0;var xR=K1(),MA=rW(),xW=d(),I0=nW(),LA=F1(),lM=s(),gR={keyword:"$ref",schemaType:"string",code(W){let{gen:O,schema:M,it:L}=W,{baseId:$,schemaEnv:Y,validateName:J,opts:A,self:Z}=L,{root:X}=Y;if((M==="#"||M==="#/")&&$===X.baseId)return Q();let G=LA.resolveRef.call(Z,X,$,M);if(G===void 0)throw new xR.default(L.opts.uriResolver,$,M);if(G instanceof LA.SchemaEnv)return S(G);return U(G);function Q(){if(Y===X)return pM(W,J,Y,Y.$async);let V=O.scopeValue("root",{ref:X});return pM(W,xW._`${V}.validate`,X,X.$async)}function S(V){let R=$A(W,V);pM(W,R,V,V.$async)}function U(V){let R=O.scopeValue("schema",A.code.source===!0?{ref:V,code:(0,xW.stringify)(V)}:{ref:V}),K=O.name("valid"),T=W.subschema({schema:V,dataTypes:[],schemaPath:xW.nil,topSchemaRef:R,errSchemaPath:M},K);W.mergeEvaluated(T),W.ok(K)}}};function $A(W,O){let{gen:M}=W;return O.validate?M.scopeValue("validate",{ref:O.validate}):xW._`${M.scopeValue("wrapper",{ref:O})}.validate`}YA.getValidate=$A;function pM(W,O,M,L){let{gen:$,it:Y}=W,{allErrors:J,schemaEnv:A,opts:Z}=Y,X=Z.passContext?I0.default.this:xW.nil;if(L)G();else Q();function G(){if(!A.$async)throw Error("async schema referenced by sync schema");let V=$.let("valid");$.try(()=>{if($.code(xW._`await ${(0,MA.callValidateCode)(W,O,X)}`),U(O),!J)$.assign(V,!0)},(R)=>{if($.if(xW._`!(${R} instanceof ${Y.ValidationError})`,()=>$.throw(R)),S(R),!J)$.assign(V,!1)}),W.ok(V)}function Q(){W.result((0,MA.callValidateCode)(W,O,X),()=>U(O),()=>S(O))}function S(V){let R=xW._`${V}.errors`;$.assign(I0.default.vErrors,xW._`${I0.default.vErrors} === null ? ${R} : ${I0.default.vErrors}.concat(${R})`),$.assign(I0.default.errors,xW._`${I0.default.vErrors}.length`)}function U(V){var R;if(!Y.opts.unevaluated)return;let K=(R=M===null||M===void 0?void 0:M.validate)===null||R===void 0?void 0:R.evaluated;if(Y.props!==!0)if(K&&!K.dynamicProps){if(K.props!==void 0)Y.props=lM.mergeEvaluated.props($,K.props,Y.props)}else{let T=$.var("props",xW._`${V}.evaluated.props`);Y.props=lM.mergeEvaluated.props($,T,Y.props,xW.Name)}if(Y.items!==!0)if(K&&!K.dynamicItems){if(K.items!==void 0)Y.items=lM.mergeEvaluated.items($,K.items,Y.items)}else{let T=$.var("items",xW._`${V}.evaluated.items`);Y.items=lM.mergeEvaluated.items($,T,Y.items,xW.Name)}}}YA.callRef=pM;YA.default=gR});var ZA=y((AA)=>{Object.defineProperty(AA,"__esModule",{value:!0});var lR=OA(),pR=mM(),mR=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",lR.default,pR.default];AA.default=mR});var GA=y((XA)=>{Object.defineProperty(XA,"__esModule",{value:!0});var dM=d(),cO=dM.operators,cM={maximum:{okStr:"<=",ok:cO.LTE,fail:cO.GT},minimum:{okStr:">=",ok:cO.GTE,fail:cO.LT},exclusiveMaximum:{okStr:"<",ok:cO.LT,fail:cO.GTE},exclusiveMinimum:{okStr:">",ok:cO.GT,fail:cO.LTE}},cR={message:({keyword:W,schemaCode:O})=>dM.str`must be ${cM[W].okStr} ${O}`,params:({keyword:W,schemaCode:O})=>dM._`{comparison: ${cM[W].okStr}, limit: ${O}}`},iR={keyword:Object.keys(cM),type:"number",schemaType:"number",$data:!0,error:cR,code(W){let{keyword:O,data:M,schemaCode:L}=W;W.fail$data(dM._`${M} ${cM[O].fail} ${L} || isNaN(${M})`)}};XA.default=iR});var SA=y((QA)=>{Object.defineProperty(QA,"__esModule",{value:!0});var w1=d(),nR={message:({schemaCode:W})=>w1.str`must be multiple of ${W}`,params:({schemaCode:W})=>w1._`{multipleOf: ${W}}`},rR={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:nR,code(W){let{gen:O,data:M,schemaCode:L,it:$}=W,Y=$.opts.multipleOfPrecision,J=O.let("res"),A=Y?w1._`Math.abs(Math.round(${J}) - ${J}) > 1e-${Y}`:w1._`${J} !== parseInt(${J})`;W.fail$data(w1._`(${L} === 0 || (${J} = ${M}/${L}, ${A}))`)}};QA.default=rR});var zA=y((UA)=>{Object.defineProperty(UA,"__esModule",{value:!0});function RA(W){let O=W.length,M=0,L=0,$;while(L<O)if(M++,$=W.charCodeAt(L++),$>=55296&&$<=56319&&L<O){if($=W.charCodeAt(L),($&64512)===56320)L++}return M}UA.default=RA;RA.code='require("ajv/dist/runtime/ucs2length").default'});var HA=y((VA)=>{Object.defineProperty(VA,"__esModule",{value:!0});var Z0=d(),tR=s(),eR=zA(),WU={message({keyword:W,schemaCode:O}){let M=W==="maxLength"?"more":"fewer";return Z0.str`must NOT have ${M} than ${O} characters`},params:({schemaCode:W})=>Z0._`{limit: ${W}}`},OU={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:WU,code(W){let{keyword:O,data:M,schemaCode:L,it:$}=W,Y=O==="maxLength"?Z0.operators.GT:Z0.operators.LT,J=$.opts.unicode===!1?Z0._`${M}.length`:Z0._`${(0,tR.useFunc)(W.gen,eR.default)}(${M})`;W.fail$data(Z0._`${J} ${Y} ${L}`)}};VA.default=OU});var TA=y((KA)=>{Object.defineProperty(KA,"__esModule",{value:!0});var LU=rW(),$U=s(),y0=d(),YU={message:({schemaCode:W})=>y0.str`must match pattern "${W}"`,params:({schemaCode:W})=>y0._`{pattern: ${W}}`},JU={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:YU,code(W){let{gen:O,data:M,$data:L,schema:$,schemaCode:Y,it:J}=W,A=J.opts.unicodeRegExp?"u":"";if(L){let{regExp:Z}=J.opts.code,X=Z.code==="new RegExp"?y0._`new RegExp`:(0,$U.useFunc)(O,Z),G=O.let("valid");O.try(()=>O.assign(G,y0._`${X}(${Y}, ${A}).test(${M})`),()=>O.assign(G,!1)),W.fail$data(y0._`!${G}`)}else{let Z=(0,LU.usePattern)(W,$);W.fail$data(y0._`!${Z}.test(${M})`)}}};KA.default=JU});var EA=y((FA)=>{Object.defineProperty(FA,"__esModule",{value:!0});var C1=d(),ZU={message({keyword:W,schemaCode:O}){let M=W==="maxProperties"?"more":"fewer";return C1.str`must NOT have ${M} than ${O} properties`},params:({schemaCode:W})=>C1._`{limit: ${W}}`},XU={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ZU,code(W){let{keyword:O,data:M,schemaCode:L}=W,$=O==="maxProperties"?C1.operators.GT:C1.operators.LT;W.fail$data(C1._`Object.keys(${M}).length ${$} ${L}`)}};FA.default=XU});var BA=y((qA)=>{Object.defineProperty(qA,"__esModule",{value:!0});var N1=rW(),P1=d(),QU=s(),SU={message:({params:{missingProperty:W}})=>P1.str`must have required property '${W}'`,params:({params:{missingProperty:W}})=>P1._`{missingProperty: ${W}}`},RU={keyword:"required",type:"object",schemaType:"array",$data:!0,error:SU,code(W){let{gen:O,schema:M,schemaCode:L,data:$,$data:Y,it:J}=W,{opts:A}=J;if(!Y&&M.length===0)return;let Z=M.length>=A.loopRequired;if(J.allErrors)X();else G();if(A.strictRequired){let U=W.parentSchema.properties,{definedProperties:V}=W.it;for(let R of M)if((U===null||U===void 0?void 0:U[R])===void 0&&!V.has(R)){let K=J.schemaEnv.baseId+J.errSchemaPath,T=`required property "${R}" is not defined at "${K}" (strictRequired)`;(0,QU.checkStrictMode)(J,T,J.opts.strictRequired)}}function X(){if(Z||Y)W.block$data(P1.nil,Q);else for(let U of M)(0,N1.checkReportMissingProp)(W,U)}function G(){let U=O.let("missing");if(Z||Y){let V=O.let("valid",!0);W.block$data(V,()=>S(U,V)),W.ok(V)}else O.if((0,N1.checkMissingProp)(W,M,U)),(0,N1.reportMissingProp)(W,U),O.else()}function Q(){O.forOf("prop",L,(U)=>{W.setParams({missingProperty:U}),O.if((0,N1.noPropertyInData)(O,$,U,A.ownProperties),()=>W.error())})}function S(U,V){W.setParams({missingProperty:U}),O.forOf(U,L,()=>{O.assign(V,(0,N1.propertyInData)(O,$,U,A.ownProperties)),O.if((0,P1.not)(V),()=>{W.error(),O.break()})},P1.nil)}}};qA.default=RU});var CA=y((wA)=>{Object.defineProperty(wA,"__esModule",{value:!0});var _1=d(),zU={message({keyword:W,schemaCode:O}){let M=W==="maxItems"?"more":"fewer";return _1.str`must NOT have ${M} than ${O} items`},params:({schemaCode:W})=>_1._`{limit: ${W}}`},VU={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:zU,code(W){let{keyword:O,data:M,schemaCode:L}=W,$=O==="maxItems"?_1.operators.GT:_1.operators.LT;W.fail$data(_1._`${M}.length ${$} ${L}`)}};wA.default=VU});var iM=y((PA)=>{Object.defineProperty(PA,"__esModule",{value:!0});var NA=w$();NA.code='require("ajv/dist/runtime/equal").default';PA.default=NA});var jA=y((_A)=>{Object.defineProperty(_A,"__esModule",{value:!0});var l$=R1(),FW=d(),TU=s(),FU=iM(),EU={message:({params:{i:W,j:O}})=>FW.str`must NOT have duplicate items (items ## ${O} and ${W} are identical)`,params:({params:{i:W,j:O}})=>FW._`{i: ${W}, j: ${O}}`},qU={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:EU,code(W){let{gen:O,data:M,$data:L,schema:$,parentSchema:Y,schemaCode:J,it:A}=W;if(!L&&!$)return;let Z=O.let("valid"),X=Y.items?(0,l$.getSchemaTypes)(Y.items):[];W.block$data(Z,G,FW._`${J} === false`),W.ok(Z);function G(){let V=O.let("i",FW._`${M}.length`),R=O.let("j");W.setParams({i:V,j:R}),O.assign(Z,!0),O.if(FW._`${V} > 1`,()=>(Q()?S:U)(V,R))}function Q(){return X.length>0&&!X.some((V)=>V==="object"||V==="array")}function S(V,R){let K=O.name("item"),T=(0,l$.checkDataTypes)(X,K,A.opts.strictNumbers,l$.DataType.Wrong),F=O.const("indices",FW._`{}`);O.for(FW._`;${V}--;`,()=>{if(O.let(K,FW._`${M}[${V}]`),O.if(T,FW._`continue`),X.length>1)O.if(FW._`typeof ${K} == "string"`,FW._`${K} += "_"`);O.if(FW._`typeof ${F}[${K}] == "number"`,()=>{O.assign(R,FW._`${F}[${K}]`),W.error(),O.assign(Z,!1).break()}).code(FW._`${F}[${K}] = ${V}`)})}function U(V,R){let K=(0,TU.useFunc)(O,FU.default),T=O.name("outer");O.label(T).for(FW._`;${V}--;`,()=>O.for(FW._`${R} = ${V}; ${R}--;`,()=>O.if(FW._`${K}(${M}[${V}], ${M}[${R}])`,()=>{W.error(),O.assign(Z,!1).break(T)})))}}};_A.default=qU});var yA=y((IA)=>{Object.defineProperty(IA,"__esModule",{value:!0});var p$=d(),wU=s(),CU=iM(),NU={message:"must be equal to constant",params:({schemaCode:W})=>p$._`{allowedValue: ${W}}`},PU={keyword:"const",$data:!0,error:NU,code(W){let{gen:O,data:M,$data:L,schemaCode:$,schema:Y}=W;if(L||Y&&typeof Y=="object")W.fail$data(p$._`!${(0,wU.useFunc)(O,CU.default)}(${M}, ${$})`);else W.fail(p$._`${Y} !== ${M}`)}};IA.default=PU});var kA=y((DA)=>{Object.defineProperty(DA,"__esModule",{value:!0});var j1=d(),jU=s(),IU=iM(),yU={message:"must be equal to one of the allowed values",params:({schemaCode:W})=>j1._`{allowedValues: ${W}}`},DU={keyword:"enum",schemaType:"array",$data:!0,error:yU,code(W){let{gen:O,data:M,$data:L,schema:$,schemaCode:Y,it:J}=W;if(!L&&$.length===0)throw Error("enum must have non-empty array");let A=$.length>=J.opts.loopEnum,Z,X=()=>Z!==null&&Z!==void 0?Z:Z=(0,jU.useFunc)(O,IU.default),G;if(A||L)G=O.let("valid"),W.block$data(G,Q);else{if(!Array.isArray($))throw Error("ajv implementation error");let U=O.const("vSchema",Y);G=(0,j1.or)(...$.map((V,R)=>S(U,R)))}W.pass(G);function Q(){O.assign(G,!1),O.forOf("v",Y,(U)=>O.if(j1._`${X()}(${M}, ${U})`,()=>O.assign(G,!0).break()))}function S(U,V){let R=$[V];return typeof R==="object"&&R!==null?j1._`${X()}(${M}, ${U}[${V}])`:j1._`${M} === ${R}`}}};DA.default=DU});var fA=y((bA)=>{Object.defineProperty(bA,"__esModule",{value:!0});var bU=GA(),fU=SA(),vU=HA(),xU=TA(),gU=EA(),hU=BA(),uU=CA(),lU=jA(),pU=yA(),mU=kA(),dU=[bU.default,fU.default,vU.default,xU.default,gU.default,hU.default,uU.default,lU.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},pU.default,mU.default];bA.default=dU});var d$=y((xA)=>{Object.defineProperty(xA,"__esModule",{value:!0});xA.validateAdditionalItems=void 0;var X0=d(),m$=s(),iU={message:({params:{len:W}})=>X0.str`must NOT have more than ${W} items`,params:({params:{len:W}})=>X0._`{limit: ${W}}`},sU={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:iU,code(W){let{parentSchema:O,it:M}=W,{items:L}=O;if(!Array.isArray(L)){(0,m$.checkStrictMode)(M,'"additionalItems" is ignored when "items" is not an array of schemas');return}vA(W,L)}};function vA(W,O){let{gen:M,schema:L,data:$,keyword:Y,it:J}=W;J.items=!0;let A=M.const("len",X0._`${$}.length`);if(L===!1)W.setParams({len:O.length}),W.pass(X0._`${A} <= ${O.length}`);else if(typeof L=="object"&&!(0,m$.alwaysValidSchema)(J,L)){let X=M.var("valid",X0._`${A} <= ${O.length}`);M.if((0,X0.not)(X),()=>Z(X)),W.ok(X)}function Z(X){M.forRange("i",O.length,A,(G)=>{if(W.subschema({keyword:Y,dataProp:G,dataPropType:m$.Type.Num},X),!J.allErrors)M.if((0,X0.not)(X),()=>M.break())})}}xA.validateAdditionalItems=vA;xA.default=sU});var c$=y((lA)=>{Object.defineProperty(lA,"__esModule",{value:!0});lA.validateTuple=void 0;var hA=d(),sM=s(),rU=rW(),aU={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(W){let{schema:O,it:M}=W;if(Array.isArray(O))return uA(W,"additionalItems",O);if(M.items=!0,(0,sM.alwaysValidSchema)(M,O))return;W.ok((0,rU.validateArray)(W))}};function uA(W,O,M=W.schema){let{gen:L,parentSchema:$,data:Y,keyword:J,it:A}=W;if(G($),A.opts.unevaluated&&M.length&&A.items!==!0)A.items=sM.mergeEvaluated.items(L,M.length,A.items);let Z=L.name("valid"),X=L.const("len",hA._`${Y}.length`);M.forEach((Q,S)=>{if((0,sM.alwaysValidSchema)(A,Q))return;L.if(hA._`${X} > ${S}`,()=>W.subschema({keyword:J,schemaProp:S,dataProp:S},Z)),W.ok(Z)});function G(Q){let{opts:S,errSchemaPath:U}=A,V=M.length,R=V===Q.minItems&&(V===Q.maxItems||Q[O]===!1);if(S.strictTuples&&!R){let K=`"${J}" is ${V}-tuple, but minItems or maxItems/${O} are not specified or different at path "${U}"`;(0,sM.checkStrictMode)(A,K,S.strictTuples)}}}lA.validateTuple=uA;lA.default=aU});var dA=y((mA)=>{Object.defineProperty(mA,"__esModule",{value:!0});var tU=c$(),eU={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(W)=>(0,tU.validateTuple)(W,"items")};mA.default=eU});var sA=y((iA)=>{Object.defineProperty(iA,"__esModule",{value:!0});var cA=d(),Oz=s(),Mz=rW(),Lz=d$(),$z={message:({params:{len:W}})=>cA.str`must NOT have more than ${W} items`,params:({params:{len:W}})=>cA._`{limit: ${W}}`},Yz={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:$z,code(W){let{schema:O,parentSchema:M,it:L}=W,{prefixItems:$}=M;if(L.items=!0,(0,Oz.alwaysValidSchema)(L,O))return;if($)(0,Lz.validateAdditionalItems)(W,$);else W.ok((0,Mz.validateArray)(W))}};iA.default=Yz});var rA=y((nA)=>{Object.defineProperty(nA,"__esModule",{value:!0});var aW=d(),nM=s(),Az={message:({params:{min:W,max:O}})=>O===void 0?aW.str`must contain at least ${W} valid item(s)`:aW.str`must contain at least ${W} and no more than ${O} valid item(s)`,params:({params:{min:W,max:O}})=>O===void 0?aW._`{minContains: ${W}}`:aW._`{minContains: ${W}, maxContains: ${O}}`},Zz={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Az,code(W){let{gen:O,schema:M,parentSchema:L,data:$,it:Y}=W,J,A,{minContains:Z,maxContains:X}=L;if(Y.opts.next)J=Z===void 0?1:Z,A=X;else J=1;let G=O.const("len",aW._`${$}.length`);if(W.setParams({min:J,max:A}),A===void 0&&J===0){(0,nM.checkStrictMode)(Y,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(A!==void 0&&J>A){(0,nM.checkStrictMode)(Y,'"minContains" > "maxContains" is always invalid'),W.fail();return}if((0,nM.alwaysValidSchema)(Y,M)){let R=aW._`${G} >= ${J}`;if(A!==void 0)R=aW._`${R} && ${G} <= ${A}`;W.pass(R);return}Y.items=!0;let Q=O.name("valid");if(A===void 0&&J===1)U(Q,()=>O.if(Q,()=>O.break()));else if(J===0){if(O.let(Q,!0),A!==void 0)O.if(aW._`${$}.length > 0`,S)}else O.let(Q,!1),S();W.result(Q,()=>W.reset());function S(){let R=O.name("_valid"),K=O.let("count",0);U(R,()=>O.if(R,()=>V(K)))}function U(R,K){O.forRange("i",0,G,(T)=>{W.subschema({keyword:"contains",dataProp:T,dataPropType:nM.Type.Num,compositeRule:!0},R),K()})}function V(R){if(O.code(aW._`${R}++`),A===void 0)O.if(aW._`${R} >= ${J}`,()=>O.assign(Q,!0).break());else if(O.if(aW._`${R} > ${A}`,()=>O.assign(Q,!1).break()),J===1)O.assign(Q,!0);else O.if(aW._`${R} >= ${J}`,()=>O.assign(Q,!0))}}};nA.default=Zz});var rM=y((tA)=>{Object.defineProperty(tA,"__esModule",{value:!0});tA.validateSchemaDeps=tA.validatePropertyDeps=tA.error=void 0;var i$=d(),Gz=s(),I1=rW();tA.error={message:({params:{property:W,depsCount:O,deps:M}})=>{let L=O===1?"property":"properties";return i$.str`must have ${L} ${M} when property ${W} is present`},params:({params:{property:W,depsCount:O,deps:M,missingProperty:L}})=>i$._`{property: ${W},
7
+ || ${J} === "boolean" || ${$} === null`).assign(A,i._`[${$}]`)}}}function wQ({gen:W,parentData:O,parentDataProperty:M},L){W.if(i._`${O} !== undefined`,()=>W.assign(i._`${O}[${M}]`,L))}function F$(W,O,M,L=D0.Correct){let $=L===D0.Correct?i.operators.EQ:i.operators.NEQ,Y;switch(W){case"null":return i._`${O} ${$} null`;case"array":Y=i._`Array.isArray(${O})`;break;case"object":Y=i._`${O} && typeof ${O} == "object" && !Array.isArray(${O})`;break;case"integer":Y=J(i._`!(${O} % 1) && !isNaN(${O})`);break;case"number":Y=J();break;default:return i._`typeof ${O} ${$} ${W}`}return L===D0.Correct?Y:(0,i.not)(Y);function J(A=i.nil){return(0,i.and)(i._`typeof ${O} == "number"`,A,M?i._`isFinite(${O})`:i.nil)}}DY.checkDataType=F$;function E$(W,O,M,L){if(W.length===1)return F$(W[0],O,M,L);let $,Y=(0,jY.toHash)(W);if(Y.array&&Y.object){let J=i._`typeof ${O} != "object"`;$=Y.null?J:i._`!${O} || ${J}`,delete Y.null,delete Y.array,delete Y.object}else $=i.nil;if(Y.number)delete Y.integer;for(let J in Y)$=(0,i.and)($,F$(J,O,M,L));return $}DY.checkDataTypes=E$;var PQ={message:({schema:W})=>`must be ${W}`,params:({schema:W,schemaValue:O})=>typeof W=="string"?i._`{type: ${W}}`:i._`{type: ${O}}`};function q$(W){let O=NQ(W);(0,FQ.reportError)(O,PQ)}DY.reportTypeError=q$;function NQ(W){let{gen:O,data:M,schema:L}=W,$=(0,jY.schemaRefOrVal)(W,L,"type");return{gen:O,keyword:"type",data:M,schema:L.type,schemaCode:$,schemaValue:$,parentSchema:L,params:{},it:W}}});var gY=y((fY)=>{Object.defineProperty(fY,"__esModule",{value:!0});fY.assignDefaults=void 0;var k0=d(),bQ=s();function fQ(W,O){let{properties:M,items:L}=W.schema;if(O==="object"&&M)for(let $ in M)bY(W,$,M[$].default);else if(O==="array"&&Array.isArray(L))L.forEach(($,Y)=>bY(W,Y,$.default))}fY.assignDefaults=fQ;function bY(W,O,M){let{gen:L,compositeRule:$,data:Y,opts:J}=W;if(M===void 0)return;let A=k0._`${Y}${(0,k0.getProperty)(O)}`;if($){(0,bQ.checkStrictMode)(W,`default is ignored for: ${A}`);return}let Z=k0._`${A} === undefined`;if(J.useDefaults==="empty")Z=k0._`${Z} || ${A} === null || ${A} === ""`;L.if(Z,k0._`${A} = ${(0,k0.stringify)(M)}`)}});var tW=y((uY)=>{Object.defineProperty(uY,"__esModule",{value:!0});uY.validateUnion=uY.validateArray=uY.usePattern=uY.callValidateCode=uY.schemaProperties=uY.allSchemaProperties=uY.noPropertyInData=uY.propertyInData=uY.isOwnProperty=uY.hasPropFunc=uY.reportMissingProp=uY.checkMissingProp=uY.checkReportMissingProp=void 0;var JW=d(),B$=s(),sO=oW(),vQ=s();function gQ(W,O){let{gen:M,data:L,it:$}=W;M.if(w$(M,L,O,$.opts.ownProperties),()=>{W.setParams({missingProperty:JW._`${O}`},!0),W.error()})}uY.checkReportMissingProp=gQ;function xQ({gen:W,data:O,it:{opts:M}},L,$){return(0,JW.or)(...L.map((Y)=>(0,JW.and)(w$(W,O,Y,M.ownProperties),JW._`${$} = ${Y}`)))}uY.checkMissingProp=xQ;function hQ(W,O){W.setParams({missingProperty:O},!0),W.error()}uY.reportMissingProp=hQ;function xY(W){return W.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:JW._`Object.prototype.hasOwnProperty`})}uY.hasPropFunc=xY;function C$(W,O,M){return JW._`${xY(W)}.call(${O}, ${M})`}uY.isOwnProperty=C$;function uQ(W,O,M,L){let $=JW._`${O}${(0,JW.getProperty)(M)} !== undefined`;return L?JW._`${$} && ${C$(W,O,M)}`:$}uY.propertyInData=uQ;function w$(W,O,M,L){let $=JW._`${O}${(0,JW.getProperty)(M)} === undefined`;return L?(0,JW.or)($,(0,JW.not)(C$(W,O,M))):$}uY.noPropertyInData=w$;function hY(W){return W?Object.keys(W).filter((O)=>O!=="__proto__"):[]}uY.allSchemaProperties=hY;function lQ(W,O){return hY(O).filter((M)=>!(0,B$.alwaysValidSchema)(W,O[M]))}uY.schemaProperties=lQ;function pQ({schemaCode:W,data:O,it:{gen:M,topSchemaRef:L,schemaPath:$,errorPath:Y},it:J},A,Z,G){let X=G?JW._`${W}, ${O}, ${L}${$}`:O,Q=[[sO.default.instancePath,(0,JW.strConcat)(sO.default.instancePath,Y)],[sO.default.parentData,J.parentData],[sO.default.parentDataProperty,J.parentDataProperty],[sO.default.rootData,sO.default.rootData]];if(J.opts.dynamicRef)Q.push([sO.default.dynamicAnchors,sO.default.dynamicAnchors]);let R=JW._`${X}, ${M.object(...Q)}`;return Z!==JW.nil?JW._`${A}.call(${Z}, ${R})`:JW._`${A}(${R})`}uY.callValidateCode=pQ;var mQ=JW._`new RegExp`;function dQ({gen:W,it:{opts:O}},M){let L=O.unicodeRegExp?"u":"",{regExp:$}=O.code,Y=$(M,L);return W.scopeValue("pattern",{key:Y.toString(),ref:Y,code:JW._`${$.code==="new RegExp"?mQ:(0,vQ.useFunc)(W,$)}(${M}, ${L})`})}uY.usePattern=dQ;function cQ(W){let{gen:O,data:M,keyword:L,it:$}=W,Y=O.name("valid");if($.allErrors){let A=O.let("valid",!0);return J(()=>O.assign(A,!1)),A}return O.var(Y,!0),J(()=>O.break()),Y;function J(A){let Z=O.const("len",JW._`${M}.length`);O.forRange("i",0,Z,(G)=>{W.subschema({keyword:L,dataProp:G,dataPropType:B$.Type.Num},Y),O.if((0,JW.not)(Y),A)})}}uY.validateArray=cQ;function iQ(W){let{gen:O,schema:M,keyword:L,it:$}=W;if(!Array.isArray(M))throw Error("ajv implementation error");if(M.some((Z)=>(0,B$.alwaysValidSchema)($,Z))&&!$.opts.unevaluated)return;let J=O.let("valid",!1),A=O.name("_valid");O.block(()=>M.forEach((Z,G)=>{let X=W.subschema({keyword:L,schemaProp:G,compositeRule:!0},A);if(O.assign(J,JW._`${J} || ${A}`),!W.mergeValidEvaluated(X,A))O.if((0,JW.not)(J))})),W.result(J,()=>W.reset(),()=>W.error(!0))}uY.validateUnion=iQ});var iY=y((dY)=>{Object.defineProperty(dY,"__esModule",{value:!0});dY.validateKeywordUsage=dY.validSchemaType=dY.funcKeywordCode=dY.macroKeywordCode=void 0;var NW=d(),X0=oW(),Y7=tW(),J7=K1();function A7(W,O){let{gen:M,keyword:L,schema:$,parentSchema:Y,it:J}=W,A=O.macro.call(J.self,$,Y,J),Z=mY(M,L,A);if(J.opts.validateSchema!==!1)J.self.validateSchema(A,!0);let G=M.name("valid");W.subschema({schema:A,schemaPath:NW.nil,errSchemaPath:`${J.errSchemaPath}/${L}`,topSchemaRef:Z,compositeRule:!0},G),W.pass(G,()=>W.error(!0))}dY.macroKeywordCode=A7;function Z7(W,O){var M;let{gen:L,keyword:$,schema:Y,parentSchema:J,$data:A,it:Z}=W;X7(Z,O);let G=!A&&O.compile?O.compile.call(Z.self,Y,J,Z):O.validate,X=mY(L,$,G),Q=L.let("valid");W.block$data(Q,R),W.ok((M=O.valid)!==null&&M!==void 0?M:Q);function R(){if(O.errors===!1){if(S(),O.modifying)pY(W);H(()=>W.error())}else{let F=O.async?U():T();if(O.modifying)pY(W);H(()=>G7(W,F))}}function U(){let F=L.let("ruleErrs",null);return L.try(()=>S(NW._`await `),(K)=>L.assign(Q,!1).if(NW._`${K} instanceof ${Z.ValidationError}`,()=>L.assign(F,NW._`${K}.errors`),()=>L.throw(K))),F}function T(){let F=NW._`${X}.errors`;return L.assign(F,null),S(NW.nil),F}function S(F=O.async?NW._`await `:NW.nil){let K=Z.opts.passContext?X0.default.this:X0.default.self,w=!(("compile"in O)&&!A||O.schema===!1);L.assign(Q,NW._`${F}${(0,Y7.callValidateCode)(W,X,K,w)}`,O.modifying)}function H(F){var K;L.if((0,NW.not)((K=O.valid)!==null&&K!==void 0?K:Q),F)}}dY.funcKeywordCode=Z7;function pY(W){let{gen:O,data:M,it:L}=W;O.if(L.parentData,()=>O.assign(M,NW._`${L.parentData}[${L.parentDataProperty}]`))}function G7(W,O){let{gen:M}=W;M.if(NW._`Array.isArray(${O})`,()=>{M.assign(X0.default.vErrors,NW._`${X0.default.vErrors} === null ? ${O} : ${X0.default.vErrors}.concat(${O})`).assign(X0.default.errors,NW._`${X0.default.vErrors}.length`),(0,J7.extendErrors)(W)},()=>W.error())}function X7({schemaEnv:W},O){if(O.async&&!W.$async)throw Error("async keyword in sync schema")}function mY(W,O,M){if(M===void 0)throw Error(`keyword "${O}" failed to compile`);return W.scopeValue("keyword",typeof M=="function"?{ref:M}:{ref:M,code:(0,NW.stringify)(M)})}function Q7(W,O,M=!1){return!O.length||O.some((L)=>L==="array"?Array.isArray(W):L==="object"?W&&typeof W=="object"&&!Array.isArray(W):typeof W==L||M&&typeof W>"u")}dY.validSchemaType=Q7;function R7({schema:W,opts:O,self:M,errSchemaPath:L},$,Y){if(Array.isArray($.keyword)?!$.keyword.includes(Y):$.keyword!==Y)throw Error("ajv implementation error");let J=$.dependencies;if(J===null||J===void 0?void 0:J.some((A)=>!Object.prototype.hasOwnProperty.call(W,A)))throw Error(`parent schema must have dependencies of ${Y}: ${J.join(",")}`);if($.validateSchema){if(!$.validateSchema(W[Y])){let Z=`keyword "${Y}" value is invalid at path "${L}": `+M.errorsText($.validateSchema.errors);if(O.validateSchema==="log")M.logger.error(Z);else throw Error(Z)}}}dY.validateKeywordUsage=R7});var aY=y((nY)=>{Object.defineProperty(nY,"__esModule",{value:!0});nY.extendSubschemaMode=nY.extendSubschemaData=nY.getSubschema=void 0;var HO=d(),sY=s();function V7(W,{keyword:O,schemaProp:M,schema:L,schemaPath:$,errSchemaPath:Y,topSchemaRef:J}){if(O!==void 0&&L!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(O!==void 0){let A=W.schema[O];return M===void 0?{schema:A,schemaPath:HO._`${W.schemaPath}${(0,HO.getProperty)(O)}`,errSchemaPath:`${W.errSchemaPath}/${O}`}:{schema:A[M],schemaPath:HO._`${W.schemaPath}${(0,HO.getProperty)(O)}${(0,HO.getProperty)(M)}`,errSchemaPath:`${W.errSchemaPath}/${O}/${(0,sY.escapeFragment)(M)}`}}if(L!==void 0){if($===void 0||Y===void 0||J===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:L,schemaPath:$,topSchemaRef:J,errSchemaPath:Y}}throw Error('either "keyword" or "schema" must be passed')}nY.getSubschema=V7;function H7(W,O,{dataProp:M,dataPropType:L,data:$,dataTypes:Y,propertyName:J}){if($!==void 0&&M!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:A}=O;if(M!==void 0){let{errorPath:G,dataPathArr:X,opts:Q}=O,R=A.let("data",HO._`${O.data}${(0,HO.getProperty)(M)}`,!0);Z(R),W.errorPath=HO.str`${G}${(0,sY.getErrorPath)(M,L,Q.jsPropertySyntax)}`,W.parentDataProperty=HO._`${M}`,W.dataPathArr=[...X,W.parentDataProperty]}if($!==void 0){let G=$ instanceof HO.Name?$:A.let("data",$,!0);if(Z(G),J!==void 0)W.propertyName=J}if(Y)W.dataTypes=Y;function Z(G){W.data=G,W.dataLevel=O.dataLevel+1,W.dataTypes=[],O.definedProperties=new Set,W.parentData=O.data,W.dataNames=[...O.dataNames,G]}}nY.extendSubschemaData=H7;function K7(W,{jtdDiscriminator:O,jtdMetadata:M,compositeRule:L,createErrors:$,allErrors:Y}){if(L!==void 0)W.compositeRule=L;if($!==void 0)W.createErrors=$;if(Y!==void 0)W.allErrors=Y;W.jtdDiscriminator=O,W.jtdMetadata=M}nY.extendSubschemaMode=K7});var P$=y((_B,oY)=>{oY.exports=function W(O,M){if(O===M)return!0;if(O&&M&&typeof O=="object"&&typeof M=="object"){if(O.constructor!==M.constructor)return!1;var L,$,Y;if(Array.isArray(O)){if(L=O.length,L!=M.length)return!1;for($=L;$--!==0;)if(!W(O[$],M[$]))return!1;return!0}if(O.constructor===RegExp)return O.source===M.source&&O.flags===M.flags;if(O.valueOf!==Object.prototype.valueOf)return O.valueOf()===M.valueOf();if(O.toString!==Object.prototype.toString)return O.toString()===M.toString();if(Y=Object.keys(O),L=Y.length,L!==Object.keys(M).length)return!1;for($=L;$--!==0;)if(!Object.prototype.hasOwnProperty.call(M,Y[$]))return!1;for($=L;$--!==0;){var J=Y[$];if(!W(O[J],M[J]))return!1}return!0}return O!==O&&M!==M}});var eY=y((jB,tY)=>{var nO=tY.exports=function(W,O,M){if(typeof O=="function")M=O,O={};M=O.cb||M;var L=typeof M=="function"?M:M.pre||function(){},$=M.post||function(){};yM(O,L,$,W,"",W)};nO.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};nO.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};nO.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};nO.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function yM(W,O,M,L,$,Y,J,A,Z,G){if(L&&typeof L=="object"&&!Array.isArray(L)){O(L,$,Y,J,A,Z,G);for(var X in L){var Q=L[X];if(Array.isArray(Q)){if(X in nO.arrayKeywords)for(var R=0;R<Q.length;R++)yM(W,O,M,Q[R],$+"/"+X+"/"+R,Y,$,X,L,R)}else if(X in nO.propsKeywords){if(Q&&typeof Q=="object")for(var U in Q)yM(W,O,M,Q[U],$+"/"+X+"/"+E7(U),Y,$,X,L,U)}else if(X in nO.keywords||W.allKeys&&!(X in nO.skipKeywords))yM(W,O,M,Q,$+"/"+X,Y,$,X,L)}M(L,$,Y,J,A,Z,G)}}function E7(W){return W.replace(/~/g,"~0").replace(/\//g,"~1")}});var F1=y((LJ)=>{Object.defineProperty(LJ,"__esModule",{value:!0});LJ.getSchemaRefs=LJ.resolveUrl=LJ.normalizeId=LJ._getFullPath=LJ.getFullPath=LJ.inlineRef=void 0;var q7=s(),B7=P$(),C7=eY(),w7=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function P7(W,O=!0){if(typeof W=="boolean")return!0;if(O===!0)return!N$(W);if(!O)return!1;return WJ(W)<=O}LJ.inlineRef=P7;var N7=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function N$(W){for(let O in W){if(N7.has(O))return!0;let M=W[O];if(Array.isArray(M)&&M.some(N$))return!0;if(typeof M=="object"&&N$(M))return!0}return!1}function WJ(W){let O=0;for(let M in W){if(M==="$ref")return 1/0;if(O++,w7.has(M))continue;if(typeof W[M]=="object")(0,q7.eachItem)(W[M],(L)=>O+=WJ(L));if(O===1/0)return 1/0}return O}function OJ(W,O="",M){if(M!==!1)O=b0(O);let L=W.parse(O);return MJ(W,L)}LJ.getFullPath=OJ;function MJ(W,O){return W.serialize(O).split("#")[0]+"#"}LJ._getFullPath=MJ;var _7=/#\/?$/;function b0(W){return W?W.replace(_7,""):""}LJ.normalizeId=b0;function j7(W,O,M){return M=b0(M),W.resolve(O,M)}LJ.resolveUrl=j7;var I7=/^[a-z_][-a-z0-9._]*$/i;function y7(W,O){if(typeof W=="boolean")return{};let{schemaId:M,uriResolver:L}=this.opts,$=b0(W[M]||O),Y={"":$},J=OJ(L,$,!1),A={},Z=new Set;return C7(W,{allKeys:!0},(Q,R,U,T)=>{if(T===void 0)return;let S=J+R,H=Y[T];if(typeof Q[M]=="string")H=F.call(this,Q[M]);K.call(this,Q.$anchor),K.call(this,Q.$dynamicAnchor),Y[R]=H;function F(w){let P=this.opts.uriResolver.resolve;if(w=b0(H?P(H,w):w),Z.has(w))throw X(w);Z.add(w);let B=this.refs[w];if(typeof B=="string")B=this.refs[B];if(typeof B=="object")G(Q,B.schema,w);else if(w!==b0(S))if(w[0]==="#")G(Q,A[w],w),A[w]=Q;else this.refs[w]=S;return w}function K(w){if(typeof w=="string"){if(!I7.test(w))throw Error(`invalid anchor "${w}"`);F.call(this,`#${w}`)}}}),A;function G(Q,R,U){if(R!==void 0&&!B7(Q,R))throw X(U)}function X(Q){return Error(`reference "${Q}" resolves to more than one schema`)}}LJ.getSchemaRefs=y7});var B1=y((TJ)=>{Object.defineProperty(TJ,"__esModule",{value:!0});TJ.getData=TJ.KeywordCxt=TJ.validateFunctionCode=void 0;var GJ=qY(),YJ=T1(),j$=T$(),DM=T1(),g7=gY(),q1=iY(),_$=aY(),h=d(),u=oW(),x7=F1(),yO=s(),E1=K1();function h7(W){if(RJ(W)){if(SJ(W),QJ(W)){p7(W);return}}XJ(W,()=>(0,GJ.topBoolOrEmptySchema)(W))}TJ.validateFunctionCode=h7;function XJ({gen:W,validateName:O,schema:M,schemaEnv:L,opts:$},Y){if($.code.es5)W.func(O,h._`${u.default.data}, ${u.default.valCxt}`,L.$async,()=>{W.code(h._`"use strict"; ${JJ(M,$)}`),l7(W,$),W.code(Y)});else W.func(O,h._`${u.default.data}, ${u7($)}`,L.$async,()=>W.code(JJ(M,$)).code(Y))}function u7(W){return h._`{${u.default.instancePath}="", ${u.default.parentData}, ${u.default.parentDataProperty}, ${u.default.rootData}=${u.default.data}${W.dynamicRef?h._`, ${u.default.dynamicAnchors}={}`:h.nil}}={}`}function l7(W,O){W.if(u.default.valCxt,()=>{if(W.var(u.default.instancePath,h._`${u.default.valCxt}.${u.default.instancePath}`),W.var(u.default.parentData,h._`${u.default.valCxt}.${u.default.parentData}`),W.var(u.default.parentDataProperty,h._`${u.default.valCxt}.${u.default.parentDataProperty}`),W.var(u.default.rootData,h._`${u.default.valCxt}.${u.default.rootData}`),O.dynamicRef)W.var(u.default.dynamicAnchors,h._`${u.default.valCxt}.${u.default.dynamicAnchors}`)},()=>{if(W.var(u.default.instancePath,h._`""`),W.var(u.default.parentData,h._`undefined`),W.var(u.default.parentDataProperty,h._`undefined`),W.var(u.default.rootData,u.default.data),O.dynamicRef)W.var(u.default.dynamicAnchors,h._`{}`)})}function p7(W){let{schema:O,opts:M,gen:L}=W;XJ(W,()=>{if(M.$comment&&O.$comment)zJ(W);if(s7(W),L.let(u.default.vErrors,null),L.let(u.default.errors,0),M.unevaluated)m7(W);UJ(W),a7(W)});return}function m7(W){let{gen:O,validateName:M}=W;W.evaluated=O.const("evaluated",h._`${M}.evaluated`),O.if(h._`${W.evaluated}.dynamicProps`,()=>O.assign(h._`${W.evaluated}.props`,h._`undefined`)),O.if(h._`${W.evaluated}.dynamicItems`,()=>O.assign(h._`${W.evaluated}.items`,h._`undefined`))}function JJ(W,O){let M=typeof W=="object"&&W[O.schemaId];return M&&(O.code.source||O.code.process)?h._`/*# sourceURL=${M} */`:h.nil}function d7(W,O){if(RJ(W)){if(SJ(W),QJ(W)){c7(W,O);return}}(0,GJ.boolOrEmptySchema)(W,O)}function QJ({schema:W,self:O}){if(typeof W=="boolean")return!W;for(let M in W)if(O.RULES.all[M])return!0;return!1}function RJ(W){return typeof W.schema!="boolean"}function c7(W,O){let{schema:M,gen:L,opts:$}=W;if($.$comment&&M.$comment)zJ(W);n7(W),r7(W);let Y=L.const("_errs",u.default.errors);UJ(W,Y),L.var(O,h._`${Y} === ${u.default.errors}`)}function SJ(W){(0,yO.checkUnknownRules)(W),i7(W)}function UJ(W,O){if(W.opts.jtd)return AJ(W,[],!1,O);let M=(0,YJ.getSchemaTypes)(W.schema),L=(0,YJ.coerceAndCheckDataType)(W,M);AJ(W,M,!L,O)}function i7(W){let{schema:O,errSchemaPath:M,opts:L,self:$}=W;if(O.$ref&&L.ignoreKeywordsWithRef&&(0,yO.schemaHasRulesButRef)(O,$.RULES))$.logger.warn(`$ref: keywords ignored in schema at path "${M}"`)}function s7(W){let{schema:O,opts:M}=W;if(O.default!==void 0&&M.useDefaults&&M.strictSchema)(0,yO.checkStrictMode)(W,"default is ignored in the schema root")}function n7(W){let O=W.schema[W.opts.schemaId];if(O)W.baseId=(0,x7.resolveUrl)(W.opts.uriResolver,W.baseId,O)}function r7(W){if(W.schema.$async&&!W.schemaEnv.$async)throw Error("async schema in sync schema")}function zJ({gen:W,schemaEnv:O,schema:M,errSchemaPath:L,opts:$}){let Y=M.$comment;if($.$comment===!0)W.code(h._`${u.default.self}.logger.log(${Y})`);else if(typeof $.$comment=="function"){let J=h.str`${L}/$comment`,A=W.scopeValue("root",{ref:O.root});W.code(h._`${u.default.self}.opts.$comment(${Y}, ${J}, ${A}.schema)`)}}function a7(W){let{gen:O,schemaEnv:M,validateName:L,ValidationError:$,opts:Y}=W;if(M.$async)O.if(h._`${u.default.errors} === 0`,()=>O.return(u.default.data),()=>O.throw(h._`new ${$}(${u.default.vErrors})`));else{if(O.assign(h._`${L}.errors`,u.default.vErrors),Y.unevaluated)o7(W);O.return(h._`${u.default.errors} === 0`)}}function o7({gen:W,evaluated:O,props:M,items:L}){if(M instanceof h.Name)W.assign(h._`${O}.props`,M);if(L instanceof h.Name)W.assign(h._`${O}.items`,L)}function AJ(W,O,M,L){let{gen:$,schema:Y,data:J,allErrors:A,opts:Z,self:G}=W,{RULES:X}=G;if(Y.$ref&&(Z.ignoreKeywordsWithRef||!(0,yO.schemaHasRulesButRef)(Y,X))){$.block(()=>HJ(W,"$ref",X.all.$ref.definition));return}if(!Z.jtd)t7(W,O);$.block(()=>{for(let R of X.rules)Q(R);Q(X.post)});function Q(R){if(!(0,j$.shouldUseGroup)(Y,R))return;if(R.type){if($.if((0,DM.checkDataType)(R.type,J,Z.strictNumbers)),ZJ(W,R),O.length===1&&O[0]===R.type&&M)$.else(),(0,DM.reportTypeError)(W);$.endIf()}else ZJ(W,R);if(!A)$.if(h._`${u.default.errors} === ${L||0}`)}}function ZJ(W,O){let{gen:M,schema:L,opts:{useDefaults:$}}=W;if($)(0,g7.assignDefaults)(W,O.type);M.block(()=>{for(let Y of O.rules)if((0,j$.shouldUseRule)(L,Y))HJ(W,Y.keyword,Y.definition,O.type)})}function t7(W,O){if(W.schemaEnv.meta||!W.opts.strictTypes)return;if(e7(W,O),!W.opts.allowUnionTypes)WR(W,O);OR(W,W.dataTypes)}function e7(W,O){if(!O.length)return;if(!W.dataTypes.length){W.dataTypes=O;return}O.forEach((M)=>{if(!VJ(W.dataTypes,M))I$(W,`type "${M}" not allowed by context "${W.dataTypes.join(",")}"`)}),LR(W,O)}function WR(W,O){if(O.length>1&&!(O.length===2&&O.includes("null")))I$(W,"use allowUnionTypes to allow union type keyword")}function OR(W,O){let M=W.self.RULES.all;for(let L in M){let $=M[L];if(typeof $=="object"&&(0,j$.shouldUseRule)(W.schema,$)){let{type:Y}=$.definition;if(Y.length&&!Y.some((J)=>MR(O,J)))I$(W,`missing type "${Y.join(",")}" for keyword "${L}"`)}}}function MR(W,O){return W.includes(O)||O==="number"&&W.includes("integer")}function VJ(W,O){return W.includes(O)||O==="integer"&&W.includes("number")}function LR(W,O){let M=[];for(let L of W.dataTypes)if(VJ(O,L))M.push(L);else if(O.includes("integer")&&L==="number")M.push("integer");W.dataTypes=M}function I$(W,O){let M=W.schemaEnv.baseId+W.errSchemaPath;O+=` at "${M}" (strictTypes)`,(0,yO.checkStrictMode)(W,O,W.opts.strictTypes)}class y${constructor(W,O,M){if((0,q1.validateKeywordUsage)(W,O,M),this.gen=W.gen,this.allErrors=W.allErrors,this.keyword=M,this.data=W.data,this.schema=W.schema[M],this.$data=O.$data&&W.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,yO.schemaRefOrVal)(W,this.schema,M,this.$data),this.schemaType=O.schemaType,this.parentSchema=W.schema,this.params={},this.it=W,this.def=O,this.$data)this.schemaCode=W.gen.const("vSchema",KJ(this.$data,W));else if(this.schemaCode=this.schemaValue,!(0,q1.validSchemaType)(this.schema,O.schemaType,O.allowUndefined))throw Error(`${M} value must be ${JSON.stringify(O.schemaType)}`);if("code"in O?O.trackErrors:O.errors!==!1)this.errsCount=W.gen.const("_errs",u.default.errors)}result(W,O,M){this.failResult((0,h.not)(W),O,M)}failResult(W,O,M){if(this.gen.if(W),M)M();else this.error();if(O){if(this.gen.else(),O(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(W,O){this.failResult((0,h.not)(W),void 0,O)}fail(W){if(W===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(W),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(W){if(!this.$data)return this.fail(W);let{schemaCode:O}=this;this.fail(h._`${O} !== undefined && (${(0,h.or)(this.invalid$data(),W)})`)}error(W,O,M){if(O){this.setParams(O),this._error(W,M),this.setParams({});return}this._error(W,M)}_error(W,O){(W?E1.reportExtraError:E1.reportError)(this,this.def.error,O)}$dataError(){(0,E1.reportError)(this,this.def.$dataError||E1.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,E1.resetErrorsCount)(this.gen,this.errsCount)}ok(W){if(!this.allErrors)this.gen.if(W)}setParams(W,O){if(O)Object.assign(this.params,W);else this.params=W}block$data(W,O,M=h.nil){this.gen.block(()=>{this.check$data(W,M),O()})}check$data(W=h.nil,O=h.nil){if(!this.$data)return;let{gen:M,schemaCode:L,schemaType:$,def:Y}=this;if(M.if((0,h.or)(h._`${L} === undefined`,O)),W!==h.nil)M.assign(W,!0);if($.length||Y.validateSchema){if(M.elseIf(this.invalid$data()),this.$dataError(),W!==h.nil)M.assign(W,!1)}M.else()}invalid$data(){let{gen:W,schemaCode:O,schemaType:M,def:L,it:$}=this;return(0,h.or)(Y(),J());function Y(){if(M.length){if(!(O instanceof h.Name))throw Error("ajv implementation error");let A=Array.isArray(M)?M:[M];return h._`${(0,DM.checkDataTypes)(A,O,$.opts.strictNumbers,DM.DataType.Wrong)}`}return h.nil}function J(){if(L.validateSchema){let A=W.scopeValue("validate$data",{ref:L.validateSchema});return h._`!${A}(${O})`}return h.nil}}subschema(W,O){let M=(0,_$.getSubschema)(this.it,W);(0,_$.extendSubschemaData)(M,this.it,W),(0,_$.extendSubschemaMode)(M,W);let L={...this.it,...M,items:void 0,props:void 0};return d7(L,O),L}mergeEvaluated(W,O){let{it:M,gen:L}=this;if(!M.opts.unevaluated)return;if(M.props!==!0&&W.props!==void 0)M.props=yO.mergeEvaluated.props(L,W.props,M.props,O);if(M.items!==!0&&W.items!==void 0)M.items=yO.mergeEvaluated.items(L,W.items,M.items,O)}mergeValidEvaluated(W,O){let{it:M,gen:L}=this;if(M.opts.unevaluated&&(M.props!==!0||M.items!==!0))return L.if(O,()=>this.mergeEvaluated(W,h.Name)),!0}}TJ.KeywordCxt=y$;function HJ(W,O,M,L){let $=new y$(W,M,O);if("code"in M)M.code($,L);else if($.$data&&M.validate)(0,q1.funcKeywordCode)($,M);else if("macro"in M)(0,q1.macroKeywordCode)($,M);else if(M.compile||M.validate)(0,q1.funcKeywordCode)($,M)}var $R=/^\/(?:[^~]|~0|~1)*$/,YR=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function KJ(W,{dataLevel:O,dataNames:M,dataPathArr:L}){let $,Y;if(W==="")return u.default.rootData;if(W[0]==="/"){if(!$R.test(W))throw Error(`Invalid JSON-pointer: ${W}`);$=W,Y=u.default.rootData}else{let G=YR.exec(W);if(!G)throw Error(`Invalid JSON-pointer: ${W}`);let X=+G[1];if($=G[2],$==="#"){if(X>=O)throw Error(Z("property/index",X));return L[O-X]}if(X>O)throw Error(Z("data",X));if(Y=M[O-X],!$)return Y}let J=Y,A=$.split("/");for(let G of A)if(G)Y=h._`${Y}${(0,h.getProperty)((0,yO.unescapeJsonPointer)(G))}`,J=h._`${J} && ${Y}`;return J;function Z(G,X){return`Cannot access ${G} ${X} levels up, current level is ${O}`}}TJ.getData=KJ});var kM=y((qJ)=>{Object.defineProperty(qJ,"__esModule",{value:!0});class EJ extends Error{constructor(W){super("validation failed");this.errors=W,this.ajv=this.validation=!0}}qJ.default=EJ});var C1=y((CJ)=>{Object.defineProperty(CJ,"__esModule",{value:!0});var D$=F1();class BJ extends Error{constructor(W,O,M,L){super(L||`can't resolve reference ${M} from id ${O}`);this.missingRef=(0,D$.resolveUrl)(W,O,M),this.missingSchema=(0,D$.normalizeId)((0,D$.getFullPath)(W,this.missingRef))}}CJ.default=BJ});var P1=y((NJ)=>{Object.defineProperty(NJ,"__esModule",{value:!0});NJ.resolveSchema=NJ.getCompilingSchema=NJ.resolveRef=NJ.compileSchema=NJ.SchemaEnv=void 0;var ZO=d(),XR=kM(),Q0=oW(),GO=F1(),wJ=s(),QR=B1();class w1{constructor(W){var O;this.refs={},this.dynamicAnchors={};let M;if(typeof W.schema=="object")M=W.schema;this.schema=W.schema,this.schemaId=W.schemaId,this.root=W.root||this,this.baseId=(O=W.baseId)!==null&&O!==void 0?O:(0,GO.normalizeId)(M===null||M===void 0?void 0:M[W.schemaId||"$id"]),this.schemaPath=W.schemaPath,this.localRefs=W.localRefs,this.meta=W.meta,this.$async=M===null||M===void 0?void 0:M.$async,this.refs={}}}NJ.SchemaEnv=w1;function b$(W){let O=PJ.call(this,W);if(O)return O;let M=(0,GO.getFullPath)(this.opts.uriResolver,W.root.baseId),{es5:L,lines:$}=this.opts.code,{ownProperties:Y}=this.opts,J=new ZO.CodeGen(this.scope,{es5:L,lines:$,ownProperties:Y}),A;if(W.$async)A=J.scopeValue("Error",{ref:XR.default,code:ZO._`require("ajv/dist/runtime/validation_error").default`});let Z=J.scopeName("validate");W.validateName=Z;let G={gen:J,allErrors:this.opts.allErrors,data:Q0.default.data,parentData:Q0.default.parentData,parentDataProperty:Q0.default.parentDataProperty,dataNames:[Q0.default.data],dataPathArr:[ZO.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:J.scopeValue("schema",this.opts.code.source===!0?{ref:W.schema,code:(0,ZO.stringify)(W.schema)}:{ref:W.schema}),validateName:Z,ValidationError:A,schema:W.schema,schemaEnv:W,rootId:M,baseId:W.baseId||M,schemaPath:ZO.nil,errSchemaPath:W.schemaPath||(this.opts.jtd?"":"#"),errorPath:ZO._`""`,opts:this.opts,self:this},X;try{this._compilations.add(W),(0,QR.validateFunctionCode)(G),J.optimize(this.opts.code.optimize);let Q=J.toString();if(X=`${J.scopeRefs(Q0.default.scope)}return ${Q}`,this.opts.code.process)X=this.opts.code.process(X,W);let U=Function(`${Q0.default.self}`,`${Q0.default.scope}`,X)(this,this.scope.get());if(this.scope.value(Z,{ref:U}),U.errors=null,U.schema=W.schema,U.schemaEnv=W,W.$async)U.$async=!0;if(this.opts.code.source===!0)U.source={validateName:Z,validateCode:Q,scopeValues:J._values};if(this.opts.unevaluated){let{props:T,items:S}=G;if(U.evaluated={props:T instanceof ZO.Name?void 0:T,items:S instanceof ZO.Name?void 0:S,dynamicProps:T instanceof ZO.Name,dynamicItems:S instanceof ZO.Name},U.source)U.source.evaluated=(0,ZO.stringify)(U.evaluated)}return W.validate=U,W}catch(Q){if(delete W.validate,delete W.validateName,X)this.logger.error("Error compiling schema, function code:",X);throw Q}finally{this._compilations.delete(W)}}NJ.compileSchema=b$;function RR(W,O,M){var L;M=(0,GO.resolveUrl)(this.opts.uriResolver,O,M);let $=W.refs[M];if($)return $;let Y=zR.call(this,W,M);if(Y===void 0){let J=(L=W.localRefs)===null||L===void 0?void 0:L[M],{schemaId:A}=this.opts;if(J)Y=new w1({schema:J,schemaId:A,root:W,baseId:O})}if(Y===void 0)return;return W.refs[M]=SR.call(this,Y)}NJ.resolveRef=RR;function SR(W){if((0,GO.inlineRef)(W.schema,this.opts.inlineRefs))return W.schema;return W.validate?W:b$.call(this,W)}function PJ(W){for(let O of this._compilations)if(UR(O,W))return O}NJ.getCompilingSchema=PJ;function UR(W,O){return W.schema===O.schema&&W.root===O.root&&W.baseId===O.baseId}function zR(W,O){let M;while(typeof(M=this.refs[O])=="string")O=M;return M||this.schemas[O]||bM.call(this,W,O)}function bM(W,O){let M=this.opts.uriResolver.parse(O),L=(0,GO._getFullPath)(this.opts.uriResolver,M),$=(0,GO.getFullPath)(this.opts.uriResolver,W.baseId,void 0);if(Object.keys(W.schema).length>0&&L===$)return k$.call(this,M,W);let Y=(0,GO.normalizeId)(L),J=this.refs[Y]||this.schemas[Y];if(typeof J=="string"){let A=bM.call(this,W,J);if(typeof(A===null||A===void 0?void 0:A.schema)!=="object")return;return k$.call(this,M,A)}if(typeof(J===null||J===void 0?void 0:J.schema)!=="object")return;if(!J.validate)b$.call(this,J);if(Y===(0,GO.normalizeId)(O)){let{schema:A}=J,{schemaId:Z}=this.opts,G=A[Z];if(G)$=(0,GO.resolveUrl)(this.opts.uriResolver,$,G);return new w1({schema:A,schemaId:Z,root:W,baseId:$})}return k$.call(this,M,J)}NJ.resolveSchema=bM;var VR=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function k$(W,{baseId:O,schema:M,root:L}){var $;if((($=W.fragment)===null||$===void 0?void 0:$[0])!=="/")return;for(let A of W.fragment.slice(1).split("/")){if(typeof M==="boolean")return;let Z=M[(0,wJ.unescapeFragment)(A)];if(Z===void 0)return;M=Z;let G=typeof M==="object"&&M[this.opts.schemaId];if(!VR.has(A)&&G)O=(0,GO.resolveUrl)(this.opts.uriResolver,O,G)}let Y;if(typeof M!="boolean"&&M.$ref&&!(0,wJ.schemaHasRulesButRef)(M,this.RULES)){let A=(0,GO.resolveUrl)(this.opts.uriResolver,O,M.$ref);Y=bM.call(this,L,A)}let{schemaId:J}=this.opts;if(Y=Y||new w1({schema:M,schemaId:J,root:L,baseId:O}),Y.schema!==Y.root.schema)return Y;return}});var jJ=y((fB,ER)=>{ER.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var g$=y((vB,fJ)=>{var qR=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),yJ=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),f$=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),DJ=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),BR=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function v$(W){let O="",M=0,L=0;for(L=0;L<W.length;L++){if(M=W[L].charCodeAt(0),M===48)continue;if(!(M>=48&&M<=57||M>=65&&M<=70||M>=97&&M<=102))return"";O+=W[L];break}for(L+=1;L<W.length;L++){if(M=W[L].charCodeAt(0),!(M>=48&&M<=57||M>=65&&M<=70||M>=97&&M<=102))return"";O+=W[L]}return O}var CR=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function IJ(W){return W.length=0,!0}function wR(W,O,M){if(W.length){let L=v$(W);if(L!=="")O.push(L);else return M.error=!0,!1;W.length=0}return!0}function PR(W){let O=0,M={error:!1,address:"",zone:""},L=[],$=[],Y=!1,J=!1,A=wR;for(let Z=0;Z<W.length;Z++){let G=W[Z];if(G==="["||G==="]")continue;if(G===":"){if(Y===!0)J=!0;if(!A($,L,M))break;if(++O>7){M.error=!0;break}if(Z>0&&W[Z-1]===":")Y=!0;L.push(":");continue}else if(G==="%"){if(!A($,L,M))break;A=IJ}else{$.push(G);continue}}if($.length)if(A===IJ)M.zone=$.join("");else if(J)L.push($.join(""));else L.push(v$($));return M.address=L.join(""),M}function kJ(W){if(NR(W,":")<2)return{host:W,isIPV6:!1};let O=PR(W);if(!O.error){let{address:M,address:L}=O;if(O.zone)M+="%"+O.zone,L+="%25"+O.zone;return{host:M,isIPV6:!0,escapedHost:L}}else return{host:W,isIPV6:!1}}function NR(W,O){let M=0;for(let L=0;L<W.length;L++)if(W[L]===O)M++;return M}function _R(W){let O=W,M=[],L=-1,$=0;while($=O.length){if($===1)if(O===".")break;else if(O==="/"){M.push("/");break}else{M.push(O);break}else if($===2){if(O[0]==="."){if(O[1]===".")break;else if(O[1]==="/"){O=O.slice(2);continue}}else if(O[0]==="/"){if(O[1]==="."||O[1]==="/"){M.push("/");break}}}else if($===3){if(O==="/.."){if(M.length!==0)M.pop();M.push("/");break}}if(O[0]==="."){if(O[1]==="."){if(O[2]==="/"){O=O.slice(3);continue}}else if(O[1]==="/"){O=O.slice(2);continue}}else if(O[0]==="/"){if(O[1]==="."){if(O[2]==="/"){O=O.slice(2);continue}else if(O[2]==="."){if(O[3]==="/"){if(O=O.slice(3),M.length!==0)M.pop();continue}}}}if((L=O.indexOf("/",1))===-1){M.push(O);break}else M.push(O.slice(0,L)),O=O.slice(L)}return M.join("")}var jR={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},IR=/[@/?#:]/g,yR=/[@/?#]/g;function bJ(W,O){let M=O?yR:IR;return M.lastIndex=0,W.replace(M,(L)=>jR[L])}function DR(W,O=!1){if(W.indexOf("%")===-1)return W;let M="";for(let L=0;L<W.length;L++){if(W[L]==="%"&&L+2<W.length){let $=W.slice(L+1,L+3);if(f$($)){let Y=$.toUpperCase(),J=String.fromCharCode(parseInt(Y,16));if(O&&DJ(J))M+=J;else M+="%"+Y;L+=2;continue}}M+=W[L]}return M}function kR(W){let O="";for(let M=0;M<W.length;M++){if(W[M]==="%"&&M+2<W.length){let L=W.slice(M+1,M+3);if(f$(L)){let $=L.toUpperCase(),Y=String.fromCharCode(parseInt($,16));if(Y!=="."&&DJ(Y))O+=Y;else O+="%"+$;M+=2;continue}}if(BR(W[M]))O+=W[M];else O+=escape(W[M])}return O}function bR(W){let O="";for(let M=0;M<W.length;M++){if(W[M]==="%"&&M+2<W.length){let L=W.slice(M+1,M+3);if(f$(L)){O+="%"+L.toUpperCase(),M+=2;continue}}O+=escape(W[M])}return O}function fR(W){let O=[];if(W.userinfo!==void 0)O.push(W.userinfo),O.push("@");if(W.host!==void 0){let M=unescape(W.host);if(!yJ(M)){let L=kJ(M);if(L.isIPV6===!0)M=`[${L.escapedHost}]`;else M=bJ(M,!1)}O.push(M)}if(typeof W.port==="number"||typeof W.port==="string")O.push(":"),O.push(String(W.port));return O.length?O.join(""):void 0}fJ.exports={nonSimpleDomain:CR,recomposeAuthority:fR,reescapeHostDelimiters:bJ,normalizePercentEncoding:DR,normalizePathEncoding:kR,escapePreservingEscapes:bR,removeDotSegments:_R,isIPv4:yJ,isUUID:qR,normalizeIPv6:kJ,stringArrayToHexStripped:v$}});var uJ=y((gB,hJ)=>{var{isUUID:vR}=g$(),gR=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,xR=["http","https","ws","wss","urn","urn:uuid"];function hR(W){return xR.indexOf(W)!==-1}function x$(W){if(W.secure===!0)return!0;else if(W.secure===!1)return!1;else if(W.scheme)return W.scheme.length===3&&(W.scheme[0]==="w"||W.scheme[0]==="W")&&(W.scheme[1]==="s"||W.scheme[1]==="S")&&(W.scheme[2]==="s"||W.scheme[2]==="S");else return!1}function vJ(W){if(!W.host)W.error=W.error||"HTTP URIs must have a host.";return W}function gJ(W){let O=String(W.scheme).toLowerCase()==="https";if(W.port===(O?443:80)||W.port==="")W.port=void 0;if(!W.path)W.path="/";return W}function uR(W){return W.secure=x$(W),W.resourceName=(W.path||"/")+(W.query?"?"+W.query:""),W.path=void 0,W.query=void 0,W}function lR(W){if(W.port===(x$(W)?443:80)||W.port==="")W.port=void 0;if(typeof W.secure==="boolean")W.scheme=W.secure?"wss":"ws",W.secure=void 0;if(W.resourceName){let[O,M]=W.resourceName.split("?");W.path=O&&O!=="/"?O:void 0,W.query=M,W.resourceName=void 0}return W.fragment=void 0,W}function pR(W,O){if(!W.path)return W.error="URN can not be parsed",W;let M=W.path.match(gR);if(M){let L=O.scheme||W.scheme||"urn";W.nid=M[1].toLowerCase(),W.nss=M[2];let $=`${L}:${O.nid||W.nid}`,Y=h$($);if(W.path=void 0,Y)W=Y.parse(W,O)}else W.error=W.error||"URN can not be parsed.";return W}function mR(W,O){if(W.nid===void 0)throw Error("URN without nid cannot be serialized");let M=O.scheme||W.scheme||"urn",L=W.nid.toLowerCase(),$=`${M}:${O.nid||L}`,Y=h$($);if(Y)W=Y.serialize(W,O);let J=W,A=W.nss;return J.path=`${L||O.nid}:${A}`,O.skipEscape=!0,J}function dR(W,O){let M=W;if(M.uuid=M.nss,M.nss=void 0,!O.tolerant&&(!M.uuid||!vR(M.uuid)))M.error=M.error||"UUID is not valid.";return M}function cR(W){let O=W;return O.nss=(W.uuid||"").toLowerCase(),O}var xJ={scheme:"http",domainHost:!0,parse:vJ,serialize:gJ},iR={scheme:"https",domainHost:xJ.domainHost,parse:vJ,serialize:gJ},fM={scheme:"ws",domainHost:!0,parse:uR,serialize:lR},sR={scheme:"wss",domainHost:fM.domainHost,parse:fM.parse,serialize:fM.serialize},nR={scheme:"urn",parse:pR,serialize:mR,skipNormalize:!0},rR={scheme:"urn:uuid",parse:dR,serialize:cR,skipNormalize:!0},vM={http:xJ,https:iR,ws:fM,wss:sR,urn:nR,"urn:uuid":rR};Object.setPrototypeOf(vM,null);function h$(W){return W&&(vM[W]||vM[W.toLowerCase()])||void 0}hJ.exports={wsIsSecure:x$,SCHEMES:vM,isValidSchemeName:hR,getSchemeHandler:h$}});var cJ=y((xB,hM)=>{var{normalizeIPv6:aR,removeDotSegments:N1,recomposeAuthority:oR,normalizePercentEncoding:tR,normalizePathEncoding:eR,escapePreservingEscapes:WS,reescapeHostDelimiters:OS,isIPv4:MS,nonSimpleDomain:LS}=g$(),{SCHEMES:$S,getSchemeHandler:pJ}=uJ();function YS(W,O){if(typeof W==="string")W=RS(W,O);else if(typeof W==="object")W=xM(R0(W,O),O);return W}function JS(W,O,M){let L=M?Object.assign({scheme:"null"},M):{scheme:"null"},{parsed:$,malformedAuthorityOrPort:Y}=gM(W,L),{parsed:J,malformedAuthorityOrPort:A}=gM(O,L);if(Y||A)throw Error($.error||J.error||"URI is malformed.");let Z=mJ($,J,L,!0);return L.skipEscape=!0,R0(Z,L)}function mJ(W,O,M,L){let $={};if(!L)W=xM(R0(W,M),M),O=xM(R0(O,M),M);if(M=M||{},!M.tolerant&&O.scheme)$.scheme=O.scheme,$.userinfo=O.userinfo,$.host=O.host,$.port=O.port,$.path=N1(O.path||""),$.query=O.query;else{if(O.userinfo!==void 0||O.host!==void 0||O.port!==void 0)$.userinfo=O.userinfo,$.host=O.host,$.port=O.port,$.path=N1(O.path||""),$.query=O.query;else{if(!O.path)if($.path=W.path,O.query!==void 0)$.query=O.query;else $.query=W.query;else{if(O.path[0]==="/")$.path=N1(O.path);else{if((W.userinfo!==void 0||W.host!==void 0||W.port!==void 0)&&!W.path)$.path="/"+O.path;else if(!W.path)$.path=O.path;else $.path=W.path.slice(0,W.path.lastIndexOf("/")+1)+O.path;$.path=N1($.path)}$.query=O.query}$.userinfo=W.userinfo,$.host=W.host,$.port=W.port}$.scheme=W.scheme}return $.fragment=O.fragment,$}function AS(W,O,M){let L=lJ(W,M),$=lJ(O,M);return L!==void 0&&$!==void 0&&L.toLowerCase()===$.toLowerCase()}function R0(W,O){let M={host:W.host,scheme:W.scheme,userinfo:W.userinfo,port:W.port,path:W.path,query:W.query,nid:W.nid,nss:W.nss,uuid:W.uuid,fragment:W.fragment,reference:W.reference,resourceName:W.resourceName,secure:W.secure,error:""},L=Object.assign({},O),$=[],Y=pJ(L.scheme||M.scheme);if(Y&&Y.serialize)Y.serialize(M,L);if(M.path!==void 0)if(!L.skipEscape){if(M.path=WS(M.path),M.scheme!==void 0)M.path=M.path.split("%3A").join(":")}else M.path=tR(M.path);if(L.reference!=="suffix"&&M.scheme)$.push(M.scheme,":");let J=oR(M);if(J!==void 0){if(L.reference!=="suffix")$.push("//");if($.push(J),M.path&&M.path[0]!=="/")$.push("/")}if(M.path!==void 0){let A=M.path;if(!L.absolutePath&&(!Y||!Y.absolutePath))A=N1(A);if(J===void 0&&A[0]==="/"&&A[1]==="/")A="/%2F"+A.slice(2);$.push(A)}if(M.query!==void 0)$.push("?",M.query);if(M.fragment!==void 0)$.push("#",M.fragment);return $.join("")}var ZS=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,GS=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,XS=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function QS(W,O){if(O[2]!==void 0&&W.path&&W.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof W.port==="number"&&(W.port<0||W.port>65535))return"URI port is malformed.";return}function gM(W,O){let M=Object.assign({},O),L={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},$=!1,Y=!1;if(M.reference==="suffix")if(M.scheme)W=M.scheme+":"+W;else W="//"+W;let J=W.match(GS);if(J!==null&&J[1].indexOf("\\")!==-1)L.error="URI authority must not contain a literal backslash.",$=!0;let A=W.match(XS);if(A!==null){let G=A[1],X=G.replace(/[\t\n\r]/g,"");if(X.length>=2){if(X.slice(0,2)!=="//")L.error=L.error||"URI authority must not contain a literal backslash.",$=!0;else if(G.length!==X.length)L.error=L.error||"URI authority introducer must not contain whitespace.",$=!0}}let Z=W.match(ZS);if(Z){if(L.scheme=Z[1],L.userinfo=Z[3],L.host=Z[4],L.port=parseInt(Z[5],10),L.path=Z[6]||"",L.query=Z[7],L.fragment=Z[8],isNaN(L.port))L.port=Z[5];let G=QS(L,Z);if(G!==void 0)L.error=L.error||G,$=!0;if(L.host)if(MS(L.host)===!1){let R=aR(L.host);L.host=R.host.toLowerCase(),Y=R.isIPV6}else Y=!0;if(L.scheme===void 0&&L.userinfo===void 0&&L.host===void 0&&L.port===void 0&&L.query===void 0&&!L.path)L.reference="same-document";else if(L.scheme===void 0)L.reference="relative";else if(L.fragment===void 0)L.reference="absolute";else L.reference="uri";if(M.reference&&M.reference!=="suffix"&&M.reference!==L.reference)L.error=L.error||"URI is not a "+M.reference+" reference.";let X=pJ(M.scheme||L.scheme);if(!M.unicodeSupport&&(!X||!X.unicodeSupport)){if(L.host&&(M.domainHost||X&&X.domainHost)&&Y===!1&&LS(L.host))try{L.host=new URL("http://"+L.host).hostname}catch(Q){L.error=L.error||"Host's domain name can not be converted to ASCII: "+Q}}if(!X||X&&!X.skipNormalize){if(W.indexOf("%")!==-1){if(L.scheme!==void 0)L.scheme=unescape(L.scheme);if(L.host!==void 0)L.host=OS(unescape(L.host),Y)}if(L.path)L.path=eR(L.path);if(L.fragment)try{L.fragment=encodeURI(decodeURIComponent(L.fragment))}catch{L.error=L.error||"URI malformed"}}if(X&&X.parse)X.parse(L,M)}else L.error=L.error||"URI can not be parsed.";return{parsed:L,malformedAuthorityOrPort:$}}function xM(W,O){return gM(W,O).parsed}function RS(W,O){return dJ(W,O).normalized}function dJ(W,O){let{parsed:M,malformedAuthorityOrPort:L}=gM(W,O);return{normalized:L?W:R0(M,O),malformedAuthorityOrPort:L}}function lJ(W,O){if(typeof W==="string"){let{normalized:M,malformedAuthorityOrPort:L}=dJ(W,O);return L?void 0:M}if(typeof W==="object")return R0(W,O)}var u$={SCHEMES:$S,normalize:YS,resolve:JS,resolveComponent:mJ,equal:AS,serialize:R0,parse:xM};hM.exports=u$;hM.exports.default=u$;hM.exports.fastUri=u$});var nJ=y((sJ)=>{Object.defineProperty(sJ,"__esModule",{value:!0});var iJ=cJ();iJ.code='require("ajv/dist/runtime/uri").default';sJ.default=iJ});var M6=y((DO)=>{Object.defineProperty(DO,"__esModule",{value:!0});DO.CodeGen=DO.Name=DO.nil=DO.stringify=DO.str=DO._=DO.KeywordCxt=void 0;var US=B1();Object.defineProperty(DO,"KeywordCxt",{enumerable:!0,get:function(){return US.KeywordCxt}});var f0=d();Object.defineProperty(DO,"_",{enumerable:!0,get:function(){return f0._}});Object.defineProperty(DO,"str",{enumerable:!0,get:function(){return f0.str}});Object.defineProperty(DO,"stringify",{enumerable:!0,get:function(){return f0.stringify}});Object.defineProperty(DO,"nil",{enumerable:!0,get:function(){return f0.nil}});Object.defineProperty(DO,"Name",{enumerable:!0,get:function(){return f0.Name}});Object.defineProperty(DO,"CodeGen",{enumerable:!0,get:function(){return f0.CodeGen}});var zS=kM(),eJ=C1(),VS=K$(),_1=P1(),HS=d(),j1=F1(),uM=T1(),p$=s(),rJ=jJ(),KS=nJ(),W6=(W,O)=>new RegExp(W,O);W6.code="new RegExp";var TS=["removeAdditional","useDefaults","coerceTypes"],FS=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),ES={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},qS={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},aJ=200;function BS(W){var O,M,L,$,Y,J,A,Z,G,X,Q,R,U,T,S,H,F,K,w,P,B,q,N,_,V;let C=W.strict,I=(O=W.code)===null||O===void 0?void 0:O.optimize,b=I===!0||I===void 0?1:I||0,k=(L=(M=W.code)===null||M===void 0?void 0:M.regExp)!==null&&L!==void 0?L:W6,p=($=W.uriResolver)!==null&&$!==void 0?$:KS.default;return{strictSchema:(J=(Y=W.strictSchema)!==null&&Y!==void 0?Y:C)!==null&&J!==void 0?J:!0,strictNumbers:(Z=(A=W.strictNumbers)!==null&&A!==void 0?A:C)!==null&&Z!==void 0?Z:!0,strictTypes:(X=(G=W.strictTypes)!==null&&G!==void 0?G:C)!==null&&X!==void 0?X:"log",strictTuples:(R=(Q=W.strictTuples)!==null&&Q!==void 0?Q:C)!==null&&R!==void 0?R:"log",strictRequired:(T=(U=W.strictRequired)!==null&&U!==void 0?U:C)!==null&&T!==void 0?T:!1,code:W.code?{...W.code,optimize:b,regExp:k}:{optimize:b,regExp:k},loopRequired:(S=W.loopRequired)!==null&&S!==void 0?S:aJ,loopEnum:(H=W.loopEnum)!==null&&H!==void 0?H:aJ,meta:(F=W.meta)!==null&&F!==void 0?F:!0,messages:(K=W.messages)!==null&&K!==void 0?K:!0,inlineRefs:(w=W.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(P=W.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(B=W.addUsedSchema)!==null&&B!==void 0?B:!0,validateSchema:(q=W.validateSchema)!==null&&q!==void 0?q:!0,validateFormats:(N=W.validateFormats)!==null&&N!==void 0?N:!0,unicodeRegExp:(_=W.unicodeRegExp)!==null&&_!==void 0?_:!0,int32range:(V=W.int32range)!==null&&V!==void 0?V:!0,uriResolver:p}}class lM{constructor(W={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,W=this.opts={...W,...BS(W)};let{es5:O,lines:M}=this.opts.code;this.scope=new HS.ValueScope({scope:{},prefixes:FS,es5:O,lines:M}),this.logger=jS(W.logger);let L=W.validateFormats;if(W.validateFormats=!1,this.RULES=(0,VS.getRules)(),oJ.call(this,ES,W,"NOT SUPPORTED"),oJ.call(this,qS,W,"DEPRECATED","warn"),this._metaOpts=NS.call(this),W.formats)wS.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),W.keywords)PS.call(this,W.keywords);if(typeof W.meta=="object")this.addMetaSchema(W.meta);CS.call(this),W.validateFormats=L}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:W,meta:O,schemaId:M}=this.opts,L=rJ;if(M==="id")L={...rJ},L.id=L.$id,delete L.$id;if(O&&W)this.addMetaSchema(L,L[M],!1)}defaultMeta(){let{meta:W,schemaId:O}=this.opts;return this.opts.defaultMeta=typeof W=="object"?W[O]||W:void 0}validate(W,O){let M;if(typeof W=="string"){if(M=this.getSchema(W),!M)throw Error(`no schema with key or ref "${W}"`)}else M=this.compile(W);let L=M(O);if(!("$async"in M))this.errors=M.errors;return L}compile(W,O){let M=this._addSchema(W,O);return M.validate||this._compileSchemaEnv(M)}compileAsync(W,O){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:M}=this.opts;return L.call(this,W,O);async function L(G,X){await $.call(this,G.$schema);let Q=this._addSchema(G,X);return Q.validate||Y.call(this,Q)}async function $(G){if(G&&!this.getSchema(G))await L.call(this,{$ref:G},!0)}async function Y(G){try{return this._compileSchemaEnv(G)}catch(X){if(!(X instanceof eJ.default))throw X;return J.call(this,X),await A.call(this,X.missingSchema),Y.call(this,G)}}function J({missingSchema:G,missingRef:X}){if(this.refs[G])throw Error(`AnySchema ${G} is loaded but ${X} cannot be resolved`)}async function A(G){let X=await Z.call(this,G);if(!this.refs[G])await $.call(this,X.$schema);if(!this.refs[G])this.addSchema(X,G,O)}async function Z(G){let X=this._loading[G];if(X)return X;try{return await(this._loading[G]=M(G))}finally{delete this._loading[G]}}}addSchema(W,O,M,L=this.opts.validateSchema){if(Array.isArray(W)){for(let Y of W)this.addSchema(Y,void 0,M,L);return this}let $;if(typeof W==="object"){let{schemaId:Y}=this.opts;if($=W[Y],$!==void 0&&typeof $!="string")throw Error(`schema ${Y} must be string`)}return O=(0,j1.normalizeId)(O||$),this._checkUnique(O),this.schemas[O]=this._addSchema(W,M,O,L,!0),this}addMetaSchema(W,O,M=this.opts.validateSchema){return this.addSchema(W,O,!0,M),this}validateSchema(W,O){if(typeof W=="boolean")return!0;let M;if(M=W.$schema,M!==void 0&&typeof M!="string")throw Error("$schema must be a string");if(M=M||this.opts.defaultMeta||this.defaultMeta(),!M)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let L=this.validate(M,W);if(!L&&O){let $="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error($);else throw Error($)}return L}getSchema(W){let O;while(typeof(O=tJ.call(this,W))=="string")W=O;if(O===void 0){let{schemaId:M}=this.opts,L=new _1.SchemaEnv({schema:{},schemaId:M});if(O=_1.resolveSchema.call(this,L,W),!O)return;this.refs[W]=O}return O.validate||this._compileSchemaEnv(O)}removeSchema(W){if(W instanceof RegExp)return this._removeAllSchemas(this.schemas,W),this._removeAllSchemas(this.refs,W),this;switch(typeof W){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let O=tJ.call(this,W);if(typeof O=="object")this._cache.delete(O.schema);return delete this.schemas[W],delete this.refs[W],this}case"object":{let O=W;this._cache.delete(O);let M=W[this.opts.schemaId];if(M)M=(0,j1.normalizeId)(M),delete this.schemas[M],delete this.refs[M];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(W){for(let O of W)this.addKeyword(O);return this}addKeyword(W,O){let M;if(typeof W=="string"){if(M=W,typeof O=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),O.keyword=M}else if(typeof W=="object"&&O===void 0){if(O=W,M=O.keyword,Array.isArray(M)&&!M.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(yS.call(this,M,O),!O)return(0,p$.eachItem)(M,($)=>l$.call(this,$)),this;kS.call(this,O);let L={...O,type:(0,uM.getJSONTypes)(O.type),schemaType:(0,uM.getJSONTypes)(O.schemaType)};return(0,p$.eachItem)(M,L.type.length===0?($)=>l$.call(this,$,L):($)=>L.type.forEach((Y)=>l$.call(this,$,L,Y))),this}getKeyword(W){let O=this.RULES.all[W];return typeof O=="object"?O.definition:!!O}removeKeyword(W){let{RULES:O}=this;delete O.keywords[W],delete O.all[W];for(let M of O.rules){let L=M.rules.findIndex(($)=>$.keyword===W);if(L>=0)M.rules.splice(L,1)}return this}addFormat(W,O){if(typeof O=="string")O=new RegExp(O);return this.formats[W]=O,this}errorsText(W=this.errors,{separator:O=", ",dataVar:M="data"}={}){if(!W||W.length===0)return"No errors";return W.map((L)=>`${M}${L.instancePath} ${L.message}`).reduce((L,$)=>L+O+$)}$dataMetaSchema(W,O){let M=this.RULES.all;W=JSON.parse(JSON.stringify(W));for(let L of O){let $=L.split("/").slice(1),Y=W;for(let J of $)Y=Y[J];for(let J in M){let A=M[J];if(typeof A!="object")continue;let{$data:Z}=A.definition,G=Y[J];if(Z&&G)Y[J]=O6(G)}}return W}_removeAllSchemas(W,O){for(let M in W){let L=W[M];if(!O||O.test(M)){if(typeof L=="string")delete W[M];else if(L&&!L.meta)this._cache.delete(L.schema),delete W[M]}}}_addSchema(W,O,M,L=this.opts.validateSchema,$=this.opts.addUsedSchema){let Y,{schemaId:J}=this.opts;if(typeof W=="object")Y=W[J];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof W!="boolean")throw Error("schema must be object or boolean");let A=this._cache.get(W);if(A!==void 0)return A;M=(0,j1.normalizeId)(Y||M);let Z=j1.getSchemaRefs.call(this,W,M);if(A=new _1.SchemaEnv({schema:W,schemaId:J,meta:O,baseId:M,localRefs:Z}),this._cache.set(A.schema,A),$&&!M.startsWith("#")){if(M)this._checkUnique(M);this.refs[M]=A}if(L)this.validateSchema(W,!0);return A}_checkUnique(W){if(this.schemas[W]||this.refs[W])throw Error(`schema with key or id "${W}" already exists`)}_compileSchemaEnv(W){if(W.meta)this._compileMetaSchema(W);else _1.compileSchema.call(this,W);if(!W.validate)throw Error("ajv implementation error");return W.validate}_compileMetaSchema(W){let O=this.opts;this.opts=this._metaOpts;try{_1.compileSchema.call(this,W)}finally{this.opts=O}}}lM.ValidationError=zS.default;lM.MissingRefError=eJ.default;DO.default=lM;function oJ(W,O,M,L="error"){for(let $ in W){let Y=$;if(Y in O)this.logger[L](`${M}: option ${$}. ${W[Y]}`)}}function tJ(W){return W=(0,j1.normalizeId)(W),this.schemas[W]||this.refs[W]}function CS(){let W=this.opts.schemas;if(!W)return;if(Array.isArray(W))this.addSchema(W);else for(let O in W)this.addSchema(W[O],O)}function wS(){for(let W in this.opts.formats){let O=this.opts.formats[W];if(O)this.addFormat(W,O)}}function PS(W){if(Array.isArray(W)){this.addVocabulary(W);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let O in W){let M=W[O];if(!M.keyword)M.keyword=O;this.addKeyword(M)}}function NS(){let W={...this.opts};for(let O of TS)delete W[O];return W}var _S={log(){},warn(){},error(){}};function jS(W){if(W===!1)return _S;if(W===void 0)return console;if(W.log&&W.warn&&W.error)return W;throw Error("logger must implement log, warn and error methods")}var IS=/^[a-z_$][a-z0-9_$:-]*$/i;function yS(W,O){let{RULES:M}=this;if((0,p$.eachItem)(W,(L)=>{if(M.keywords[L])throw Error(`Keyword ${L} is already defined`);if(!IS.test(L))throw Error(`Keyword ${L} has invalid name`)}),!O)return;if(O.$data&&!(("code"in O)||("validate"in O)))throw Error('$data keyword must have "code" or "validate" function')}function l$(W,O,M){var L;let $=O===null||O===void 0?void 0:O.post;if(M&&$)throw Error('keyword with "post" flag cannot have "type"');let{RULES:Y}=this,J=$?Y.post:Y.rules.find(({type:Z})=>Z===M);if(!J)J={type:M,rules:[]},Y.rules.push(J);if(Y.keywords[W]=!0,!O)return;let A={keyword:W,definition:{...O,type:(0,uM.getJSONTypes)(O.type),schemaType:(0,uM.getJSONTypes)(O.schemaType)}};if(O.before)DS.call(this,J,A,O.before);else J.rules.push(A);Y.all[W]=A,(L=O.implements)===null||L===void 0||L.forEach((Z)=>this.addKeyword(Z))}function DS(W,O,M){let L=W.rules.findIndex(($)=>$.keyword===M);if(L>=0)W.rules.splice(L,0,O);else W.rules.push(O),this.logger.warn(`rule ${M} is not defined`)}function kS(W){let{metaSchema:O}=W;if(O===void 0)return;if(W.$data&&this.opts.$data)O=O6(O);W.validateSchema=this.compile(O,!0)}var bS={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function O6(W){return{anyOf:[W,bS]}}});var $6=y((L6)=>{Object.defineProperty(L6,"__esModule",{value:!0});var gS={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};L6.default=gS});var dM=y((Z6)=>{Object.defineProperty(Z6,"__esModule",{value:!0});Z6.callRef=Z6.getValidate=void 0;var hS=C1(),Y6=tW(),gW=d(),v0=oW(),J6=P1(),pM=s(),uS={keyword:"$ref",schemaType:"string",code(W){let{gen:O,schema:M,it:L}=W,{baseId:$,schemaEnv:Y,validateName:J,opts:A,self:Z}=L,{root:G}=Y;if((M==="#"||M==="#/")&&$===G.baseId)return Q();let X=J6.resolveRef.call(Z,G,$,M);if(X===void 0)throw new hS.default(L.opts.uriResolver,$,M);if(X instanceof J6.SchemaEnv)return R(X);return U(X);function Q(){if(Y===G)return mM(W,J,Y,Y.$async);let T=O.scopeValue("root",{ref:G});return mM(W,gW._`${T}.validate`,G,G.$async)}function R(T){let S=A6(W,T);mM(W,S,T,T.$async)}function U(T){let S=O.scopeValue("schema",A.code.source===!0?{ref:T,code:(0,gW.stringify)(T)}:{ref:T}),H=O.name("valid"),F=W.subschema({schema:T,dataTypes:[],schemaPath:gW.nil,topSchemaRef:S,errSchemaPath:M},H);W.mergeEvaluated(F),W.ok(H)}}};function A6(W,O){let{gen:M}=W;return O.validate?M.scopeValue("validate",{ref:O.validate}):gW._`${M.scopeValue("wrapper",{ref:O})}.validate`}Z6.getValidate=A6;function mM(W,O,M,L){let{gen:$,it:Y}=W,{allErrors:J,schemaEnv:A,opts:Z}=Y,G=Z.passContext?v0.default.this:gW.nil;if(L)X();else Q();function X(){if(!A.$async)throw Error("async schema referenced by sync schema");let T=$.let("valid");$.try(()=>{if($.code(gW._`await ${(0,Y6.callValidateCode)(W,O,G)}`),U(O),!J)$.assign(T,!0)},(S)=>{if($.if(gW._`!(${S} instanceof ${Y.ValidationError})`,()=>$.throw(S)),R(S),!J)$.assign(T,!1)}),W.ok(T)}function Q(){W.result((0,Y6.callValidateCode)(W,O,G),()=>U(O),()=>R(O))}function R(T){let S=gW._`${T}.errors`;$.assign(v0.default.vErrors,gW._`${v0.default.vErrors} === null ? ${S} : ${v0.default.vErrors}.concat(${S})`),$.assign(v0.default.errors,gW._`${v0.default.vErrors}.length`)}function U(T){var S;if(!Y.opts.unevaluated)return;let H=(S=M===null||M===void 0?void 0:M.validate)===null||S===void 0?void 0:S.evaluated;if(Y.props!==!0)if(H&&!H.dynamicProps){if(H.props!==void 0)Y.props=pM.mergeEvaluated.props($,H.props,Y.props)}else{let F=$.var("props",gW._`${T}.evaluated.props`);Y.props=pM.mergeEvaluated.props($,F,Y.props,gW.Name)}if(Y.items!==!0)if(H&&!H.dynamicItems){if(H.items!==void 0)Y.items=pM.mergeEvaluated.items($,H.items,Y.items)}else{let F=$.var("items",gW._`${T}.evaluated.items`);Y.items=pM.mergeEvaluated.items($,F,Y.items,gW.Name)}}}Z6.callRef=mM;Z6.default=uS});var Q6=y((X6)=>{Object.defineProperty(X6,"__esModule",{value:!0});var mS=$6(),dS=dM(),cS=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",mS.default,dS.default];X6.default=cS});var S6=y((R6)=>{Object.defineProperty(R6,"__esModule",{value:!0});var cM=d(),rO=cM.operators,iM={maximum:{okStr:"<=",ok:rO.LTE,fail:rO.GT},minimum:{okStr:">=",ok:rO.GTE,fail:rO.LT},exclusiveMaximum:{okStr:"<",ok:rO.LT,fail:rO.GTE},exclusiveMinimum:{okStr:">",ok:rO.GT,fail:rO.LTE}},sS={message:({keyword:W,schemaCode:O})=>cM.str`must be ${iM[W].okStr} ${O}`,params:({keyword:W,schemaCode:O})=>cM._`{comparison: ${iM[W].okStr}, limit: ${O}}`},nS={keyword:Object.keys(iM),type:"number",schemaType:"number",$data:!0,error:sS,code(W){let{keyword:O,data:M,schemaCode:L}=W;W.fail$data(cM._`${M} ${iM[O].fail} ${L} || isNaN(${M})`)}};R6.default=nS});var z6=y((U6)=>{Object.defineProperty(U6,"__esModule",{value:!0});var I1=d(),aS={message:({schemaCode:W})=>I1.str`must be multiple of ${W}`,params:({schemaCode:W})=>I1._`{multipleOf: ${W}}`},oS={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:aS,code(W){let{gen:O,data:M,schemaCode:L,it:$}=W,Y=$.opts.multipleOfPrecision,J=O.let("res"),A=Y?I1._`Math.abs(Math.round(${J}) - ${J}) > 1e-${Y}`:I1._`${J} !== parseInt(${J})`;W.fail$data(I1._`(${L} === 0 || (${J} = ${M}/${L}, ${A}))`)}};U6.default=oS});var K6=y((H6)=>{Object.defineProperty(H6,"__esModule",{value:!0});function V6(W){let O=W.length,M=0,L=0,$;while(L<O)if(M++,$=W.charCodeAt(L++),$>=55296&&$<=56319&&L<O){if($=W.charCodeAt(L),($&64512)===56320)L++}return M}H6.default=V6;V6.code='require("ajv/dist/runtime/ucs2length").default'});var F6=y((T6)=>{Object.defineProperty(T6,"__esModule",{value:!0});var S0=d(),WU=s(),OU=K6(),MU={message({keyword:W,schemaCode:O}){let M=W==="maxLength"?"more":"fewer";return S0.str`must NOT have ${M} than ${O} characters`},params:({schemaCode:W})=>S0._`{limit: ${W}}`},LU={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:MU,code(W){let{keyword:O,data:M,schemaCode:L,it:$}=W,Y=O==="maxLength"?S0.operators.GT:S0.operators.LT,J=$.opts.unicode===!1?S0._`${M}.length`:S0._`${(0,WU.useFunc)(W.gen,OU.default)}(${M})`;W.fail$data(S0._`${J} ${Y} ${L}`)}};T6.default=LU});var q6=y((E6)=>{Object.defineProperty(E6,"__esModule",{value:!0});var YU=tW(),JU=s(),g0=d(),AU={message:({schemaCode:W})=>g0.str`must match pattern "${W}"`,params:({schemaCode:W})=>g0._`{pattern: ${W}}`},ZU={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:AU,code(W){let{gen:O,data:M,$data:L,schema:$,schemaCode:Y,it:J}=W,A=J.opts.unicodeRegExp?"u":"";if(L){let{regExp:Z}=J.opts.code,G=Z.code==="new RegExp"?g0._`new RegExp`:(0,JU.useFunc)(O,Z),X=O.let("valid");O.try(()=>O.assign(X,g0._`${G}(${Y}, ${A}).test(${M})`),()=>O.assign(X,!1)),W.fail$data(g0._`!${X}`)}else{let Z=(0,YU.usePattern)(W,$);W.fail$data(g0._`!${Z}.test(${M})`)}}};E6.default=ZU});var C6=y((B6)=>{Object.defineProperty(B6,"__esModule",{value:!0});var y1=d(),XU={message({keyword:W,schemaCode:O}){let M=W==="maxProperties"?"more":"fewer";return y1.str`must NOT have ${M} than ${O} properties`},params:({schemaCode:W})=>y1._`{limit: ${W}}`},QU={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:XU,code(W){let{keyword:O,data:M,schemaCode:L}=W,$=O==="maxProperties"?y1.operators.GT:y1.operators.LT;W.fail$data(y1._`Object.keys(${M}).length ${$} ${L}`)}};B6.default=QU});var P6=y((w6)=>{Object.defineProperty(w6,"__esModule",{value:!0});var D1=tW(),k1=d(),SU=s(),UU={message:({params:{missingProperty:W}})=>k1.str`must have required property '${W}'`,params:({params:{missingProperty:W}})=>k1._`{missingProperty: ${W}}`},zU={keyword:"required",type:"object",schemaType:"array",$data:!0,error:UU,code(W){let{gen:O,schema:M,schemaCode:L,data:$,$data:Y,it:J}=W,{opts:A}=J;if(!Y&&M.length===0)return;let Z=M.length>=A.loopRequired;if(J.allErrors)G();else X();if(A.strictRequired){let U=W.parentSchema.properties,{definedProperties:T}=W.it;for(let S of M)if((U===null||U===void 0?void 0:U[S])===void 0&&!T.has(S)){let H=J.schemaEnv.baseId+J.errSchemaPath,F=`required property "${S}" is not defined at "${H}" (strictRequired)`;(0,SU.checkStrictMode)(J,F,J.opts.strictRequired)}}function G(){if(Z||Y)W.block$data(k1.nil,Q);else for(let U of M)(0,D1.checkReportMissingProp)(W,U)}function X(){let U=O.let("missing");if(Z||Y){let T=O.let("valid",!0);W.block$data(T,()=>R(U,T)),W.ok(T)}else O.if((0,D1.checkMissingProp)(W,M,U)),(0,D1.reportMissingProp)(W,U),O.else()}function Q(){O.forOf("prop",L,(U)=>{W.setParams({missingProperty:U}),O.if((0,D1.noPropertyInData)(O,$,U,A.ownProperties),()=>W.error())})}function R(U,T){W.setParams({missingProperty:U}),O.forOf(U,L,()=>{O.assign(T,(0,D1.propertyInData)(O,$,U,A.ownProperties)),O.if((0,k1.not)(T),()=>{W.error(),O.break()})},k1.nil)}}};w6.default=zU});var _6=y((N6)=>{Object.defineProperty(N6,"__esModule",{value:!0});var b1=d(),HU={message({keyword:W,schemaCode:O}){let M=W==="maxItems"?"more":"fewer";return b1.str`must NOT have ${M} than ${O} items`},params:({schemaCode:W})=>b1._`{limit: ${W}}`},KU={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:HU,code(W){let{keyword:O,data:M,schemaCode:L}=W,$=O==="maxItems"?b1.operators.GT:b1.operators.LT;W.fail$data(b1._`${M}.length ${$} ${L}`)}};N6.default=KU});var sM=y((I6)=>{Object.defineProperty(I6,"__esModule",{value:!0});var j6=P$();j6.code='require("ajv/dist/runtime/equal").default';I6.default=j6});var D6=y((y6)=>{Object.defineProperty(y6,"__esModule",{value:!0});var m$=T1(),TW=d(),EU=s(),qU=sM(),BU={message:({params:{i:W,j:O}})=>TW.str`must NOT have duplicate items (items ## ${O} and ${W} are identical)`,params:({params:{i:W,j:O}})=>TW._`{i: ${W}, j: ${O}}`},CU={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:BU,code(W){let{gen:O,data:M,$data:L,schema:$,parentSchema:Y,schemaCode:J,it:A}=W;if(!L&&!$)return;let Z=O.let("valid"),G=Y.items?(0,m$.getSchemaTypes)(Y.items):[];W.block$data(Z,X,TW._`${J} === false`),W.ok(Z);function X(){let T=O.let("i",TW._`${M}.length`),S=O.let("j");W.setParams({i:T,j:S}),O.assign(Z,!0),O.if(TW._`${T} > 1`,()=>(Q()?R:U)(T,S))}function Q(){return G.length>0&&!G.some((T)=>T==="object"||T==="array")}function R(T,S){let H=O.name("item"),F=(0,m$.checkDataTypes)(G,H,A.opts.strictNumbers,m$.DataType.Wrong),K=O.const("indices",TW._`{}`);O.for(TW._`;${T}--;`,()=>{if(O.let(H,TW._`${M}[${T}]`),O.if(F,TW._`continue`),G.length>1)O.if(TW._`typeof ${H} == "string"`,TW._`${H} += "_"`);O.if(TW._`typeof ${K}[${H}] == "number"`,()=>{O.assign(S,TW._`${K}[${H}]`),W.error(),O.assign(Z,!1).break()}).code(TW._`${K}[${H}] = ${T}`)})}function U(T,S){let H=(0,EU.useFunc)(O,qU.default),F=O.name("outer");O.label(F).for(TW._`;${T}--;`,()=>O.for(TW._`${S} = ${T}; ${S}--;`,()=>O.if(TW._`${H}(${M}[${T}], ${M}[${S}])`,()=>{W.error(),O.assign(Z,!1).break(F)})))}}};y6.default=CU});var b6=y((k6)=>{Object.defineProperty(k6,"__esModule",{value:!0});var d$=d(),PU=s(),NU=sM(),_U={message:"must be equal to constant",params:({schemaCode:W})=>d$._`{allowedValue: ${W}}`},jU={keyword:"const",$data:!0,error:_U,code(W){let{gen:O,data:M,$data:L,schemaCode:$,schema:Y}=W;if(L||Y&&typeof Y=="object")W.fail$data(d$._`!${(0,PU.useFunc)(O,NU.default)}(${M}, ${$})`);else W.fail(d$._`${Y} !== ${M}`)}};k6.default=jU});var v6=y((f6)=>{Object.defineProperty(f6,"__esModule",{value:!0});var f1=d(),yU=s(),DU=sM(),kU={message:"must be equal to one of the allowed values",params:({schemaCode:W})=>f1._`{allowedValues: ${W}}`},bU={keyword:"enum",schemaType:"array",$data:!0,error:kU,code(W){let{gen:O,data:M,$data:L,schema:$,schemaCode:Y,it:J}=W;if(!L&&$.length===0)throw Error("enum must have non-empty array");let A=$.length>=J.opts.loopEnum,Z,G=()=>Z!==null&&Z!==void 0?Z:Z=(0,yU.useFunc)(O,DU.default),X;if(A||L)X=O.let("valid"),W.block$data(X,Q);else{if(!Array.isArray($))throw Error("ajv implementation error");let U=O.const("vSchema",Y);X=(0,f1.or)(...$.map((T,S)=>R(U,S)))}W.pass(X);function Q(){O.assign(X,!1),O.forOf("v",Y,(U)=>O.if(f1._`${G()}(${M}, ${U})`,()=>O.assign(X,!0).break()))}function R(U,T){let S=$[T];return typeof S==="object"&&S!==null?f1._`${G()}(${M}, ${U}[${T}])`:f1._`${M} === ${S}`}}};f6.default=bU});var x6=y((g6)=>{Object.defineProperty(g6,"__esModule",{value:!0});var vU=S6(),gU=z6(),xU=F6(),hU=q6(),uU=C6(),lU=P6(),pU=_6(),mU=D6(),dU=b6(),cU=v6(),iU=[vU.default,gU.default,xU.default,hU.default,uU.default,lU.default,pU.default,mU.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},dU.default,cU.default];g6.default=iU});var i$=y((u6)=>{Object.defineProperty(u6,"__esModule",{value:!0});u6.validateAdditionalItems=void 0;var U0=d(),c$=s(),nU={message:({params:{len:W}})=>U0.str`must NOT have more than ${W} items`,params:({params:{len:W}})=>U0._`{limit: ${W}}`},rU={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:nU,code(W){let{parentSchema:O,it:M}=W,{items:L}=O;if(!Array.isArray(L)){(0,c$.checkStrictMode)(M,'"additionalItems" is ignored when "items" is not an array of schemas');return}h6(W,L)}};function h6(W,O){let{gen:M,schema:L,data:$,keyword:Y,it:J}=W;J.items=!0;let A=M.const("len",U0._`${$}.length`);if(L===!1)W.setParams({len:O.length}),W.pass(U0._`${A} <= ${O.length}`);else if(typeof L=="object"&&!(0,c$.alwaysValidSchema)(J,L)){let G=M.var("valid",U0._`${A} <= ${O.length}`);M.if((0,U0.not)(G),()=>Z(G)),W.ok(G)}function Z(G){M.forRange("i",O.length,A,(X)=>{if(W.subschema({keyword:Y,dataProp:X,dataPropType:c$.Type.Num},G),!J.allErrors)M.if((0,U0.not)(G),()=>M.break())})}}u6.validateAdditionalItems=h6;u6.default=rU});var s$=y((d6)=>{Object.defineProperty(d6,"__esModule",{value:!0});d6.validateTuple=void 0;var p6=d(),nM=s(),oU=tW(),tU={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(W){let{schema:O,it:M}=W;if(Array.isArray(O))return m6(W,"additionalItems",O);if(M.items=!0,(0,nM.alwaysValidSchema)(M,O))return;W.ok((0,oU.validateArray)(W))}};function m6(W,O,M=W.schema){let{gen:L,parentSchema:$,data:Y,keyword:J,it:A}=W;if(X($),A.opts.unevaluated&&M.length&&A.items!==!0)A.items=nM.mergeEvaluated.items(L,M.length,A.items);let Z=L.name("valid"),G=L.const("len",p6._`${Y}.length`);M.forEach((Q,R)=>{if((0,nM.alwaysValidSchema)(A,Q))return;L.if(p6._`${G} > ${R}`,()=>W.subschema({keyword:J,schemaProp:R,dataProp:R},Z)),W.ok(Z)});function X(Q){let{opts:R,errSchemaPath:U}=A,T=M.length,S=T===Q.minItems&&(T===Q.maxItems||Q[O]===!1);if(R.strictTuples&&!S){let H=`"${J}" is ${T}-tuple, but minItems or maxItems/${O} are not specified or different at path "${U}"`;(0,nM.checkStrictMode)(A,H,R.strictTuples)}}}d6.validateTuple=m6;d6.default=tU});var s6=y((i6)=>{Object.defineProperty(i6,"__esModule",{value:!0});var Wz=s$(),Oz={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(W)=>(0,Wz.validateTuple)(W,"items")};i6.default=Oz});var a6=y((r6)=>{Object.defineProperty(r6,"__esModule",{value:!0});var n6=d(),Lz=s(),$z=tW(),Yz=i$(),Jz={message:({params:{len:W}})=>n6.str`must NOT have more than ${W} items`,params:({params:{len:W}})=>n6._`{limit: ${W}}`},Az={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Jz,code(W){let{schema:O,parentSchema:M,it:L}=W,{prefixItems:$}=M;if(L.items=!0,(0,Lz.alwaysValidSchema)(L,O))return;if($)(0,Yz.validateAdditionalItems)(W,$);else W.ok((0,$z.validateArray)(W))}};r6.default=Az});var t6=y((o6)=>{Object.defineProperty(o6,"__esModule",{value:!0});var eW=d(),rM=s(),Gz={message:({params:{min:W,max:O}})=>O===void 0?eW.str`must contain at least ${W} valid item(s)`:eW.str`must contain at least ${W} and no more than ${O} valid item(s)`,params:({params:{min:W,max:O}})=>O===void 0?eW._`{minContains: ${W}}`:eW._`{minContains: ${W}, maxContains: ${O}}`},Xz={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Gz,code(W){let{gen:O,schema:M,parentSchema:L,data:$,it:Y}=W,J,A,{minContains:Z,maxContains:G}=L;if(Y.opts.next)J=Z===void 0?1:Z,A=G;else J=1;let X=O.const("len",eW._`${$}.length`);if(W.setParams({min:J,max:A}),A===void 0&&J===0){(0,rM.checkStrictMode)(Y,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(A!==void 0&&J>A){(0,rM.checkStrictMode)(Y,'"minContains" > "maxContains" is always invalid'),W.fail();return}if((0,rM.alwaysValidSchema)(Y,M)){let S=eW._`${X} >= ${J}`;if(A!==void 0)S=eW._`${S} && ${X} <= ${A}`;W.pass(S);return}Y.items=!0;let Q=O.name("valid");if(A===void 0&&J===1)U(Q,()=>O.if(Q,()=>O.break()));else if(J===0){if(O.let(Q,!0),A!==void 0)O.if(eW._`${$}.length > 0`,R)}else O.let(Q,!1),R();W.result(Q,()=>W.reset());function R(){let S=O.name("_valid"),H=O.let("count",0);U(S,()=>O.if(S,()=>T(H)))}function U(S,H){O.forRange("i",0,X,(F)=>{W.subschema({keyword:"contains",dataProp:F,dataPropType:rM.Type.Num,compositeRule:!0},S),H()})}function T(S){if(O.code(eW._`${S}++`),A===void 0)O.if(eW._`${S} >= ${J}`,()=>O.assign(Q,!0).break());else if(O.if(eW._`${S} > ${A}`,()=>O.assign(Q,!1).break()),J===1)O.assign(Q,!0);else O.if(eW._`${S} >= ${J}`,()=>O.assign(Q,!0))}}};o6.default=Xz});var aM=y((O5)=>{Object.defineProperty(O5,"__esModule",{value:!0});O5.validateSchemaDeps=O5.validatePropertyDeps=O5.error=void 0;var n$=d(),Rz=s(),v1=tW();O5.error={message:({params:{property:W,depsCount:O,deps:M}})=>{let L=O===1?"property":"properties";return n$.str`must have ${L} ${M} when property ${W} is present`},params:({params:{property:W,depsCount:O,deps:M,missingProperty:L}})=>n$._`{property: ${W},
8
8
  missingProperty: ${L},
9
9
  depsCount: ${O},
10
- deps: ${M}}`};var Qz={keyword:"dependencies",type:"object",schemaType:"object",error:tA.error,code(W){let[O,M]=Sz(W);aA(W,O),oA(W,M)}};function Sz({schema:W}){let O={},M={};for(let L in W){if(L==="__proto__")continue;let $=Array.isArray(W[L])?O:M;$[L]=W[L]}return[O,M]}function aA(W,O=W.schema){let{gen:M,data:L,it:$}=W;if(Object.keys(O).length===0)return;let Y=M.let("missing");for(let J in O){let A=O[J];if(A.length===0)continue;let Z=(0,I1.propertyInData)(M,L,J,$.opts.ownProperties);if(W.setParams({property:J,depsCount:A.length,deps:A.join(", ")}),$.allErrors)M.if(Z,()=>{for(let X of A)(0,I1.checkReportMissingProp)(W,X)});else M.if(i$._`${Z} && (${(0,I1.checkMissingProp)(W,A,Y)})`),(0,I1.reportMissingProp)(W,Y),M.else()}}tA.validatePropertyDeps=aA;function oA(W,O=W.schema){let{gen:M,data:L,keyword:$,it:Y}=W,J=M.name("valid");for(let A in O){if((0,Gz.alwaysValidSchema)(Y,O[A]))continue;M.if((0,I1.propertyInData)(M,L,A,Y.opts.ownProperties),()=>{let Z=W.subschema({keyword:$,schemaProp:A},J);W.mergeValidEvaluated(Z,J)},()=>M.var(J,!0)),W.ok(J)}}tA.validateSchemaDeps=oA;tA.default=Qz});var L5=y((M5)=>{Object.defineProperty(M5,"__esModule",{value:!0});var O5=d(),zz=s(),Vz={message:"property name must be valid",params:({params:W})=>O5._`{propertyName: ${W.propertyName}}`},Hz={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Vz,code(W){let{gen:O,schema:M,data:L,it:$}=W;if((0,zz.alwaysValidSchema)($,M))return;let Y=O.name("valid");O.forIn("key",L,(J)=>{W.setParams({propertyName:J}),W.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},Y),O.if((0,O5.not)(Y),()=>{if(W.error(!0),!$.allErrors)O.break()})}),W.ok(Y)}};M5.default=Hz});var s$=y(($5)=>{Object.defineProperty($5,"__esModule",{value:!0});var aM=rW(),ZO=d(),Tz=nW(),oM=s(),Fz={message:"must NOT have additional properties",params:({params:W})=>ZO._`{additionalProperty: ${W.additionalProperty}}`},Ez={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Fz,code(W){let{gen:O,schema:M,parentSchema:L,data:$,errsCount:Y,it:J}=W;if(!Y)throw Error("ajv implementation error");let{allErrors:A,opts:Z}=J;if(J.props=!0,Z.removeAdditional!=="all"&&(0,oM.alwaysValidSchema)(J,M))return;let X=(0,aM.allSchemaProperties)(L.properties),G=(0,aM.allSchemaProperties)(L.patternProperties);Q(),W.ok(ZO._`${Y} === ${Tz.default.errors}`);function Q(){O.forIn("key",$,(K)=>{if(!X.length&&!G.length)V(K);else O.if(S(K),()=>V(K))})}function S(K){let T;if(X.length>8){let F=(0,oM.schemaRefOrVal)(J,L.properties,"properties");T=(0,aM.isOwnProperty)(O,F,K)}else if(X.length)T=(0,ZO.or)(...X.map((F)=>ZO._`${K} === ${F}`));else T=ZO.nil;if(G.length)T=(0,ZO.or)(T,...G.map((F)=>ZO._`${(0,aM.usePattern)(W,F)}.test(${K})`));return(0,ZO.not)(T)}function U(K){O.code(ZO._`delete ${$}[${K}]`)}function V(K){if(Z.removeAdditional==="all"||Z.removeAdditional&&M===!1){U(K);return}if(M===!1){if(W.setParams({additionalProperty:K}),W.error(),!A)O.break();return}if(typeof M=="object"&&!(0,oM.alwaysValidSchema)(J,M)){let T=O.name("valid");if(Z.removeAdditional==="failing")R(K,T,!1),O.if((0,ZO.not)(T),()=>{W.reset(),U(K)});else if(R(K,T),!A)O.if((0,ZO.not)(T),()=>O.break())}}function R(K,T,F){let N={keyword:"additionalProperties",dataProp:K,dataPropType:oM.Type.Str};if(F===!1)Object.assign(N,{compositeRule:!0,createErrors:!1,allErrors:!1});W.subschema(N,T)}}};$5.default=Ez});var Z5=y((A5)=>{Object.defineProperty(A5,"__esModule",{value:!0});var Bz=H1(),Y5=rW(),n$=s(),J5=s$(),wz={keyword:"properties",type:"object",schemaType:"object",code(W){let{gen:O,schema:M,parentSchema:L,data:$,it:Y}=W;if(Y.opts.removeAdditional==="all"&&L.additionalProperties===void 0)J5.default.code(new Bz.KeywordCxt(Y,J5.default,"additionalProperties"));let J=(0,Y5.allSchemaProperties)(M);for(let Q of J)Y.definedProperties.add(Q);if(Y.opts.unevaluated&&J.length&&Y.props!==!0)Y.props=n$.mergeEvaluated.props(O,(0,n$.toHash)(J),Y.props);let A=J.filter((Q)=>!(0,n$.alwaysValidSchema)(Y,M[Q]));if(A.length===0)return;let Z=O.name("valid");for(let Q of A){if(X(Q))G(Q);else{if(O.if((0,Y5.propertyInData)(O,$,Q,Y.opts.ownProperties)),G(Q),!Y.allErrors)O.else().var(Z,!0);O.endIf()}W.it.definedProperties.add(Q),W.ok(Z)}function X(Q){return Y.opts.useDefaults&&!Y.compositeRule&&M[Q].default!==void 0}function G(Q){W.subschema({keyword:"properties",schemaProp:Q,dataProp:Q},Z)}}};A5.default=wz});var R5=y((S5)=>{Object.defineProperty(S5,"__esModule",{value:!0});var X5=rW(),tM=d(),G5=s(),Q5=s(),Nz={keyword:"patternProperties",type:"object",schemaType:"object",code(W){let{gen:O,schema:M,data:L,parentSchema:$,it:Y}=W,{opts:J}=Y,A=(0,X5.allSchemaProperties)(M),Z=A.filter((R)=>(0,G5.alwaysValidSchema)(Y,M[R]));if(A.length===0||Z.length===A.length&&(!Y.opts.unevaluated||Y.props===!0))return;let X=J.strictSchema&&!J.allowMatchingProperties&&$.properties,G=O.name("valid");if(Y.props!==!0&&!(Y.props instanceof tM.Name))Y.props=(0,Q5.evaluatedPropsToName)(O,Y.props);let{props:Q}=Y;S();function S(){for(let R of A){if(X)U(R);if(Y.allErrors)V(R);else O.var(G,!0),V(R),O.if(G)}}function U(R){for(let K in X)if(new RegExp(R).test(K))(0,G5.checkStrictMode)(Y,`property ${K} matches pattern ${R} (use allowMatchingProperties)`)}function V(R){O.forIn("key",L,(K)=>{O.if(tM._`${(0,X5.usePattern)(W,R)}.test(${K})`,()=>{let T=Z.includes(R);if(!T)W.subschema({keyword:"patternProperties",schemaProp:R,dataProp:K,dataPropType:Q5.Type.Str},G);if(Y.opts.unevaluated&&Q!==!0)O.assign(tM._`${Q}[${K}]`,!0);else if(!T&&!Y.allErrors)O.if((0,tM.not)(G),()=>O.break())})})}}};S5.default=Nz});var z5=y((U5)=>{Object.defineProperty(U5,"__esModule",{value:!0});var _z=s(),jz={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(W){let{gen:O,schema:M,it:L}=W;if((0,_z.alwaysValidSchema)(L,M)){W.fail();return}let $=O.name("valid");W.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},$),W.failResult($,()=>W.reset(),()=>W.error())},error:{message:"must NOT be valid"}};U5.default=jz});var H5=y((V5)=>{Object.defineProperty(V5,"__esModule",{value:!0});var yz=rW(),Dz={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yz.validateUnion,error:{message:"must match a schema in anyOf"}};V5.default=Dz});var T5=y((K5)=>{Object.defineProperty(K5,"__esModule",{value:!0});var eM=d(),bz=s(),fz={message:"must match exactly one schema in oneOf",params:({params:W})=>eM._`{passingSchemas: ${W.passing}}`},vz={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:fz,code(W){let{gen:O,schema:M,parentSchema:L,it:$}=W;if(!Array.isArray(M))throw Error("ajv implementation error");if($.opts.discriminator&&L.discriminator)return;let Y=M,J=O.let("valid",!1),A=O.let("passing",null),Z=O.name("_valid");W.setParams({passing:A}),O.block(X),W.result(J,()=>W.reset(),()=>W.error(!0));function X(){Y.forEach((G,Q)=>{let S;if((0,bz.alwaysValidSchema)($,G))O.var(Z,!0);else S=W.subschema({keyword:"oneOf",schemaProp:Q,compositeRule:!0},Z);if(Q>0)O.if(eM._`${Z} && ${J}`).assign(J,!1).assign(A,eM._`[${A}, ${Q}]`).else();O.if(Z,()=>{if(O.assign(J,!0),O.assign(A,Q),S)W.mergeEvaluated(S,eM.Name)})})}}};K5.default=vz});var E5=y((F5)=>{Object.defineProperty(F5,"__esModule",{value:!0});var gz=s(),hz={keyword:"allOf",schemaType:"array",code(W){let{gen:O,schema:M,it:L}=W;if(!Array.isArray(M))throw Error("ajv implementation error");let $=O.name("valid");M.forEach((Y,J)=>{if((0,gz.alwaysValidSchema)(L,Y))return;let A=W.subschema({keyword:"allOf",schemaProp:J},$);W.ok($),W.mergeEvaluated(A)})}};F5.default=hz});var C5=y((w5)=>{Object.defineProperty(w5,"__esModule",{value:!0});var WL=d(),B5=s(),lz={message:({params:W})=>WL.str`must match "${W.ifClause}" schema`,params:({params:W})=>WL._`{failingKeyword: ${W.ifClause}}`},pz={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:lz,code(W){let{gen:O,parentSchema:M,it:L}=W;if(M.then===void 0&&M.else===void 0)(0,B5.checkStrictMode)(L,'"if" without "then" and "else" is ignored');let $=q5(L,"then"),Y=q5(L,"else");if(!$&&!Y)return;let J=O.let("valid",!0),A=O.name("_valid");if(Z(),W.reset(),$&&Y){let G=O.let("ifClause");W.setParams({ifClause:G}),O.if(A,X("then",G),X("else",G))}else if($)O.if(A,X("then"));else O.if((0,WL.not)(A),X("else"));W.pass(J,()=>W.error(!0));function Z(){let G=W.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},A);W.mergeEvaluated(G)}function X(G,Q){return()=>{let S=W.subschema({keyword:G},A);if(O.assign(J,A),W.mergeValidEvaluated(S,J),Q)O.assign(Q,WL._`${G}`);else W.setParams({ifClause:G})}}}};function q5(W,O){let M=W.schema[O];return M!==void 0&&!(0,B5.alwaysValidSchema)(W,M)}w5.default=pz});var P5=y((N5)=>{Object.defineProperty(N5,"__esModule",{value:!0});var dz=s(),cz={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:W,parentSchema:O,it:M}){if(O.if===void 0)(0,dz.checkStrictMode)(M,`"${W}" without "if" is ignored`)}};N5.default=cz});var j5=y((_5)=>{Object.defineProperty(_5,"__esModule",{value:!0});var sz=d$(),nz=dA(),rz=c$(),az=sA(),oz=rA(),tz=rM(),ez=L5(),WV=s$(),OV=Z5(),MV=R5(),LV=z5(),$V=H5(),YV=T5(),JV=E5(),AV=C5(),ZV=P5();function XV(W=!1){let O=[LV.default,$V.default,YV.default,JV.default,AV.default,ZV.default,ez.default,WV.default,tz.default,OV.default,MV.default];if(W)O.push(nz.default,az.default);else O.push(sz.default,rz.default);return O.push(oz.default),O}_5.default=XV});var a$=y((D5)=>{Object.defineProperty(D5,"__esModule",{value:!0});D5.dynamicAnchor=void 0;var r$=d(),QV=nW(),I5=F1(),SV=mM(),RV={keyword:"$dynamicAnchor",schemaType:"string",code:(W)=>y5(W,W.schema)};function y5(W,O){let{gen:M,it:L}=W;L.schemaEnv.root.dynamicAnchors[O]=!0;let $=r$._`${QV.default.dynamicAnchors}${(0,r$.getProperty)(O)}`,Y=L.errSchemaPath==="#"?L.validateName:UV(W);M.if(r$._`!${$}`,()=>M.assign($,Y))}D5.dynamicAnchor=y5;function UV(W){let{schemaEnv:O,schema:M,self:L}=W.it,{root:$,baseId:Y,localRefs:J,meta:A}=O.root,{schemaId:Z}=L.opts,X=new I5.SchemaEnv({schema:M,schemaId:Z,root:$,baseId:Y,localRefs:J,meta:A});return I5.compileSchema.call(L,X),(0,SV.getValidate)(W,X)}D5.default=RV});var o$=y((x5)=>{Object.defineProperty(x5,"__esModule",{value:!0});x5.dynamicRef=void 0;var b5=d(),VV=nW(),f5=mM(),HV={keyword:"$dynamicRef",schemaType:"string",code:(W)=>v5(W,W.schema)};function v5(W,O){let{gen:M,keyword:L,it:$}=W;if(O[0]!=="#")throw Error(`"${L}" only supports hash fragment reference`);let Y=O.slice(1);if($.allErrors)J();else{let Z=M.let("valid",!1);J(Z),W.ok(Z)}function J(Z){if($.schemaEnv.root.dynamicAnchors[Y]){let X=M.let("_v",b5._`${VV.default.dynamicAnchors}${(0,b5.getProperty)(Y)}`);M.if(X,A(X,Z),A($.validateName,Z))}else A($.validateName,Z)()}function A(Z,X){return X?()=>M.block(()=>{(0,f5.callRef)(W,Z),M.let(X,!0)}):()=>(0,f5.callRef)(W,Z)}}x5.dynamicRef=v5;x5.default=HV});var u5=y((h5)=>{Object.defineProperty(h5,"__esModule",{value:!0});var TV=a$(),FV=s(),EV={keyword:"$recursiveAnchor",schemaType:"boolean",code(W){if(W.schema)(0,TV.dynamicAnchor)(W,"");else(0,FV.checkStrictMode)(W.it,"$recursiveAnchor: false is ignored")}};h5.default=EV});var p5=y((l5)=>{Object.defineProperty(l5,"__esModule",{value:!0});var BV=o$(),wV={keyword:"$recursiveRef",schemaType:"string",code:(W)=>(0,BV.dynamicRef)(W,W.schema)};l5.default=wV});var d5=y((m5)=>{Object.defineProperty(m5,"__esModule",{value:!0});var NV=a$(),PV=o$(),_V=u5(),jV=p5(),IV=[NV.default,PV.default,_V.default,jV.default];m5.default=IV});var s5=y((i5)=>{Object.defineProperty(i5,"__esModule",{value:!0});var c5=rM(),DV={keyword:"dependentRequired",type:"object",schemaType:"object",error:c5.error,code:(W)=>(0,c5.validatePropertyDeps)(W)};i5.default=DV});var r5=y((n5)=>{Object.defineProperty(n5,"__esModule",{value:!0});var bV=rM(),fV={keyword:"dependentSchemas",type:"object",schemaType:"object",code:(W)=>(0,bV.validateSchemaDeps)(W)};n5.default=fV});var o5=y((a5)=>{Object.defineProperty(a5,"__esModule",{value:!0});var xV=s(),gV={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:W,parentSchema:O,it:M}){if(O.contains===void 0)(0,xV.checkStrictMode)(M,`"${W}" without "contains" is ignored`)}};a5.default=gV});var e5=y((t5)=>{Object.defineProperty(t5,"__esModule",{value:!0});var uV=s5(),lV=r5(),pV=o5(),mV=[uV.default,lV.default,pV.default];t5.default=mV});var M6=y((O6)=>{Object.defineProperty(O6,"__esModule",{value:!0});var iO=d(),W6=s(),cV=nW(),iV={message:"must NOT have unevaluated properties",params:({params:W})=>iO._`{unevaluatedProperty: ${W.unevaluatedProperty}}`},sV={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:iV,code(W){let{gen:O,schema:M,data:L,errsCount:$,it:Y}=W;if(!$)throw Error("ajv implementation error");let{allErrors:J,props:A}=Y;if(A instanceof iO.Name)O.if(iO._`${A} !== true`,()=>O.forIn("key",L,(Q)=>O.if(X(A,Q),()=>Z(Q))));else if(A!==!0)O.forIn("key",L,(Q)=>A===void 0?Z(Q):O.if(G(A,Q),()=>Z(Q)));Y.props=!0,W.ok(iO._`${$} === ${cV.default.errors}`);function Z(Q){if(M===!1){if(W.setParams({unevaluatedProperty:Q}),W.error(),!J)O.break();return}if(!(0,W6.alwaysValidSchema)(Y,M)){let S=O.name("valid");if(W.subschema({keyword:"unevaluatedProperties",dataProp:Q,dataPropType:W6.Type.Str},S),!J)O.if((0,iO.not)(S),()=>O.break())}}function X(Q,S){return iO._`!${Q} || !${Q}[${S}]`}function G(Q,S){let U=[];for(let V in Q)if(Q[V]===!0)U.push(iO._`${S} !== ${V}`);return(0,iO.and)(...U)}}};O6.default=sV});var Y6=y(($6)=>{Object.defineProperty($6,"__esModule",{value:!0});var G0=d(),L6=s(),rV={message:({params:{len:W}})=>G0.str`must NOT have more than ${W} items`,params:({params:{len:W}})=>G0._`{limit: ${W}}`},aV={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:rV,code(W){let{gen:O,schema:M,data:L,it:$}=W,Y=$.items||0;if(Y===!0)return;let J=O.const("len",G0._`${L}.length`);if(M===!1)W.setParams({len:Y}),W.fail(G0._`${J} > ${Y}`);else if(typeof M=="object"&&!(0,L6.alwaysValidSchema)($,M)){let Z=O.var("valid",G0._`${J} <= ${Y}`);O.if((0,G0.not)(Z),()=>A(Z,Y)),W.ok(Z)}$.items=!0;function A(Z,X){O.forRange("i",X,J,(G)=>{if(W.subschema({keyword:"unevaluatedItems",dataProp:G,dataPropType:L6.Type.Num},Z),!$.allErrors)O.if((0,G0.not)(Z),()=>O.break())})}}};$6.default=aV});var A6=y((J6)=>{Object.defineProperty(J6,"__esModule",{value:!0});var tV=M6(),eV=Y6(),WH=[tV.default,eV.default];J6.default=WH});var X6=y((Z6)=>{Object.defineProperty(Z6,"__esModule",{value:!0});var SW=d(),MH={message:({schemaCode:W})=>SW.str`must match format "${W}"`,params:({schemaCode:W})=>SW._`{format: ${W}}`},LH={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:MH,code(W,O){let{gen:M,data:L,$data:$,schema:Y,schemaCode:J,it:A}=W,{opts:Z,errSchemaPath:X,schemaEnv:G,self:Q}=A;if(!Z.validateFormats)return;if($)S();else U();function S(){let V=M.scopeValue("formats",{ref:Q.formats,code:Z.code.formats}),R=M.const("fDef",SW._`${V}[${J}]`),K=M.let("fType"),T=M.let("format");M.if(SW._`typeof ${R} == "object" && !(${R} instanceof RegExp)`,()=>M.assign(K,SW._`${R}.type || "string"`).assign(T,SW._`${R}.validate`),()=>M.assign(K,SW._`"string"`).assign(T,R)),W.fail$data((0,SW.or)(F(),N()));function F(){if(Z.strictSchema===!1)return SW.nil;return SW._`${J} && !${T}`}function N(){let C=G.$async?SW._`(${R}.async ? await ${T}(${L}) : ${T}(${L}))`:SW._`${T}(${L})`,w=SW._`(typeof ${T} == "function" ? ${C} : ${T}.test(${L}))`;return SW._`${T} && ${T} !== true && ${K} === ${O} && !${w}`}}function U(){let V=Q.formats[Y];if(!V){F();return}if(V===!0)return;let[R,K,T]=N(V);if(R===O)W.pass(C());function F(){if(Z.strictSchema===!1){Q.logger.warn(w());return}throw Error(w());function w(){return`unknown format "${Y}" ignored in schema at path "${X}"`}}function N(w){let B=w instanceof RegExp?(0,SW.regexpCode)(w):Z.code.formats?SW._`${Z.code.formats}${(0,SW.getProperty)(Y)}`:void 0,I=M.scopeValue("formats",{key:Y,ref:w,code:B});if(typeof w=="object"&&!(w instanceof RegExp))return[w.type||"string",w.validate,SW._`${I}.validate`];return["string",w,I]}function C(){if(typeof V=="object"&&!(V instanceof RegExp)&&V.async){if(!G.$async)throw Error("async format in sync schema");return SW._`await ${T}(${L})`}return typeof K=="function"?SW._`${T}(${L})`:SW._`${T}.test(${L})`}}}};Z6.default=LH});var Q6=y((G6)=>{Object.defineProperty(G6,"__esModule",{value:!0});var YH=X6(),JH=[YH.default];G6.default=JH});var U6=y((S6)=>{Object.defineProperty(S6,"__esModule",{value:!0});S6.contentVocabulary=S6.metadataVocabulary=void 0;S6.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];S6.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var H6=y((V6)=>{Object.defineProperty(V6,"__esModule",{value:!0});var XH=ZA(),GH=fA(),QH=j5(),SH=d5(),RH=e5(),UH=A6(),zH=Q6(),z6=U6(),VH=[SH.default,XH.default,GH.default,(0,QH.default)(!0),zH.default,z6.metadataVocabulary,z6.contentVocabulary,RH.default,UH.default];V6.default=VH});var E6=y((T6)=>{Object.defineProperty(T6,"__esModule",{value:!0});T6.DiscrError=void 0;var K6;(function(W){W.Tag="tag",W.Mapping="mapping"})(K6||(T6.DiscrError=K6={}))});var w6=y((B6)=>{Object.defineProperty(B6,"__esModule",{value:!0});var D0=d(),t$=E6(),q6=F1(),KH=K1(),TH=s(),FH={message:({params:{discrError:W,tagName:O}})=>W===t$.DiscrError.Tag?`tag "${O}" must be string`:`value of tag "${O}" must be in oneOf`,params:({params:{discrError:W,tag:O,tagName:M}})=>D0._`{error: ${W}, tag: ${M}, tagValue: ${O}}`},EH={keyword:"discriminator",type:"object",schemaType:"object",error:FH,code(W){let{gen:O,data:M,schema:L,parentSchema:$,it:Y}=W,{oneOf:J}=$;if(!Y.opts.discriminator)throw Error("discriminator: requires discriminator option");let A=L.propertyName;if(typeof A!="string")throw Error("discriminator: requires propertyName");if(L.mapping)throw Error("discriminator: mapping is not supported");if(!J)throw Error("discriminator: requires oneOf keyword");let Z=O.let("valid",!1),X=O.const("tag",D0._`${M}${(0,D0.getProperty)(A)}`);O.if(D0._`typeof ${X} == "string"`,()=>G(),()=>W.error(!1,{discrError:t$.DiscrError.Tag,tag:X,tagName:A})),W.ok(Z);function G(){let U=S();O.if(!1);for(let V in U)O.elseIf(D0._`${X} === ${V}`),O.assign(Z,Q(U[V]));O.else(),W.error(!1,{discrError:t$.DiscrError.Mapping,tag:X,tagName:A}),O.endIf()}function Q(U){let V=O.name("valid"),R=W.subschema({keyword:"oneOf",schemaProp:U},V);return W.mergeEvaluated(R,D0.Name),V}function S(){var U;let V={},R=T($),K=!0;for(let C=0;C<J.length;C++){let w=J[C];if((w===null||w===void 0?void 0:w.$ref)&&!(0,TH.schemaHasRulesButRef)(w,Y.self.RULES)){let I=w.$ref;if(w=q6.resolveRef.call(Y.self,Y.schemaEnv.root,Y.baseId,I),w instanceof q6.SchemaEnv)w=w.schema;if(w===void 0)throw new KH.default(Y.opts.uriResolver,Y.baseId,I)}let B=(U=w===null||w===void 0?void 0:w.properties)===null||U===void 0?void 0:U[A];if(typeof B!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${A}"`);K=K&&(R||T(w)),F(B,C)}if(!K)throw Error(`discriminator: "${A}" must be required`);return V;function T({required:C}){return Array.isArray(C)&&C.includes(A)}function F(C,w){if(C.const)N(C.const,w);else if(C.enum)for(let B of C.enum)N(B,w);else throw Error(`discriminator: "properties/${A}" must have "const" or "enum"`)}function N(C,w){if(typeof C!="string"||C in V)throw Error(`discriminator: "${A}" values must be unique strings`);V[C]=w}}}};B6.default=EH});var C6=y((uw,BH)=>{BH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var N6=y((lw,wH)=>{wH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var P6=y((pw,CH)=>{CH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var _6=y((mw,NH)=>{NH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var j6=y((dw,PH)=>{PH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var I6=y((cw,_H)=>{_H.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var y6=y((iw,jH)=>{jH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var D6=y((sw,IH)=>{IH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var b6=y((k6)=>{Object.defineProperty(k6,"__esModule",{value:!0});var yH=C6(),DH=N6(),kH=P6(),bH=_6(),fH=j6(),vH=I6(),xH=y6(),gH=D6(),hH=["/properties"];function uH(W){return[yH,DH,kH,bH,fH,O(this,vH),xH,O(this,gH)].forEach((M)=>this.addMetaSchema(M,void 0,!1)),this;function O(M,L){return W?M.$dataMetaSchema(L,hH):L}}k6.default=uH});var f6=y((gW,W8)=>{Object.defineProperty(gW,"__esModule",{value:!0});gW.MissingRefError=gW.ValidationError=gW.CodeGen=gW.Name=gW.nil=gW.stringify=gW.str=gW._=gW.KeywordCxt=gW.Ajv2020=void 0;var pH=eJ(),mH=H6(),dH=w6(),cH=b6(),e$="https://json-schema.org/draft/2020-12/schema";class y1 extends pH.default{constructor(W={}){super({...W,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){if(super._addVocabularies(),mH.default.forEach((W)=>this.addVocabulary(W)),this.opts.discriminator)this.addKeyword(dH.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:W,meta:O}=this.opts;if(!O)return;cH.default.call(this,W),this.refs["http://json-schema.org/schema"]=e$}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(e$)?e$:void 0)}}gW.Ajv2020=y1;W8.exports=gW=y1;W8.exports.Ajv2020=y1;Object.defineProperty(gW,"__esModule",{value:!0});gW.default=y1;var iH=H1();Object.defineProperty(gW,"KeywordCxt",{enumerable:!0,get:function(){return iH.KeywordCxt}});var k0=d();Object.defineProperty(gW,"_",{enumerable:!0,get:function(){return k0._}});Object.defineProperty(gW,"str",{enumerable:!0,get:function(){return k0.str}});Object.defineProperty(gW,"stringify",{enumerable:!0,get:function(){return k0.stringify}});Object.defineProperty(gW,"nil",{enumerable:!0,get:function(){return k0.nil}});Object.defineProperty(gW,"Name",{enumerable:!0,get:function(){return k0.Name}});Object.defineProperty(gW,"CodeGen",{enumerable:!0,get:function(){return k0.CodeGen}});var sH=DM();Object.defineProperty(gW,"ValidationError",{enumerable:!0,get:function(){return sH.default}});var nH=K1();Object.defineProperty(gW,"MissingRefError",{enumerable:!0,get:function(){return nH.default}})});import{randomUUID as mq}from"crypto";var D9=Buffer.from(`\r
10
+ deps: ${M}}`};var Sz={keyword:"dependencies",type:"object",schemaType:"object",error:O5.error,code(W){let[O,M]=Uz(W);e6(W,O),W5(W,M)}};function Uz({schema:W}){let O={},M={};for(let L in W){if(L==="__proto__")continue;let $=Array.isArray(W[L])?O:M;$[L]=W[L]}return[O,M]}function e6(W,O=W.schema){let{gen:M,data:L,it:$}=W;if(Object.keys(O).length===0)return;let Y=M.let("missing");for(let J in O){let A=O[J];if(A.length===0)continue;let Z=(0,v1.propertyInData)(M,L,J,$.opts.ownProperties);if(W.setParams({property:J,depsCount:A.length,deps:A.join(", ")}),$.allErrors)M.if(Z,()=>{for(let G of A)(0,v1.checkReportMissingProp)(W,G)});else M.if(n$._`${Z} && (${(0,v1.checkMissingProp)(W,A,Y)})`),(0,v1.reportMissingProp)(W,Y),M.else()}}O5.validatePropertyDeps=e6;function W5(W,O=W.schema){let{gen:M,data:L,keyword:$,it:Y}=W,J=M.name("valid");for(let A in O){if((0,Rz.alwaysValidSchema)(Y,O[A]))continue;M.if((0,v1.propertyInData)(M,L,A,Y.opts.ownProperties),()=>{let Z=W.subschema({keyword:$,schemaProp:A},J);W.mergeValidEvaluated(Z,J)},()=>M.var(J,!0)),W.ok(J)}}O5.validateSchemaDeps=W5;O5.default=Sz});var J5=y((Y5)=>{Object.defineProperty(Y5,"__esModule",{value:!0});var $5=d(),Hz=s(),Kz={message:"property name must be valid",params:({params:W})=>$5._`{propertyName: ${W.propertyName}}`},Tz={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Kz,code(W){let{gen:O,schema:M,data:L,it:$}=W;if((0,Hz.alwaysValidSchema)($,M))return;let Y=O.name("valid");O.forIn("key",L,(J)=>{W.setParams({propertyName:J}),W.subschema({keyword:"propertyNames",data:J,dataTypes:["string"],propertyName:J,compositeRule:!0},Y),O.if((0,$5.not)(Y),()=>{if(W.error(!0),!$.allErrors)O.break()})}),W.ok(Y)}};Y5.default=Tz});var r$=y((A5)=>{Object.defineProperty(A5,"__esModule",{value:!0});var oM=tW(),XO=d(),Ez=oW(),tM=s(),qz={message:"must NOT have additional properties",params:({params:W})=>XO._`{additionalProperty: ${W.additionalProperty}}`},Bz={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:qz,code(W){let{gen:O,schema:M,parentSchema:L,data:$,errsCount:Y,it:J}=W;if(!Y)throw Error("ajv implementation error");let{allErrors:A,opts:Z}=J;if(J.props=!0,Z.removeAdditional!=="all"&&(0,tM.alwaysValidSchema)(J,M))return;let G=(0,oM.allSchemaProperties)(L.properties),X=(0,oM.allSchemaProperties)(L.patternProperties);Q(),W.ok(XO._`${Y} === ${Ez.default.errors}`);function Q(){O.forIn("key",$,(H)=>{if(!G.length&&!X.length)T(H);else O.if(R(H),()=>T(H))})}function R(H){let F;if(G.length>8){let K=(0,tM.schemaRefOrVal)(J,L.properties,"properties");F=(0,oM.isOwnProperty)(O,K,H)}else if(G.length)F=(0,XO.or)(...G.map((K)=>XO._`${H} === ${K}`));else F=XO.nil;if(X.length)F=(0,XO.or)(F,...X.map((K)=>XO._`${(0,oM.usePattern)(W,K)}.test(${H})`));return(0,XO.not)(F)}function U(H){O.code(XO._`delete ${$}[${H}]`)}function T(H){if(Z.removeAdditional==="all"||Z.removeAdditional&&M===!1){U(H);return}if(M===!1){if(W.setParams({additionalProperty:H}),W.error(),!A)O.break();return}if(typeof M=="object"&&!(0,tM.alwaysValidSchema)(J,M)){let F=O.name("valid");if(Z.removeAdditional==="failing")S(H,F,!1),O.if((0,XO.not)(F),()=>{W.reset(),U(H)});else if(S(H,F),!A)O.if((0,XO.not)(F),()=>O.break())}}function S(H,F,K){let w={keyword:"additionalProperties",dataProp:H,dataPropType:tM.Type.Str};if(K===!1)Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1});W.subschema(w,F)}}};A5.default=Bz});var Q5=y((X5)=>{Object.defineProperty(X5,"__esModule",{value:!0});var wz=B1(),Z5=tW(),a$=s(),G5=r$(),Pz={keyword:"properties",type:"object",schemaType:"object",code(W){let{gen:O,schema:M,parentSchema:L,data:$,it:Y}=W;if(Y.opts.removeAdditional==="all"&&L.additionalProperties===void 0)G5.default.code(new wz.KeywordCxt(Y,G5.default,"additionalProperties"));let J=(0,Z5.allSchemaProperties)(M);for(let Q of J)Y.definedProperties.add(Q);if(Y.opts.unevaluated&&J.length&&Y.props!==!0)Y.props=a$.mergeEvaluated.props(O,(0,a$.toHash)(J),Y.props);let A=J.filter((Q)=>!(0,a$.alwaysValidSchema)(Y,M[Q]));if(A.length===0)return;let Z=O.name("valid");for(let Q of A){if(G(Q))X(Q);else{if(O.if((0,Z5.propertyInData)(O,$,Q,Y.opts.ownProperties)),X(Q),!Y.allErrors)O.else().var(Z,!0);O.endIf()}W.it.definedProperties.add(Q),W.ok(Z)}function G(Q){return Y.opts.useDefaults&&!Y.compositeRule&&M[Q].default!==void 0}function X(Q){W.subschema({keyword:"properties",schemaProp:Q,dataProp:Q},Z)}}};X5.default=Pz});var V5=y((z5)=>{Object.defineProperty(z5,"__esModule",{value:!0});var R5=tW(),eM=d(),S5=s(),U5=s(),_z={keyword:"patternProperties",type:"object",schemaType:"object",code(W){let{gen:O,schema:M,data:L,parentSchema:$,it:Y}=W,{opts:J}=Y,A=(0,R5.allSchemaProperties)(M),Z=A.filter((S)=>(0,S5.alwaysValidSchema)(Y,M[S]));if(A.length===0||Z.length===A.length&&(!Y.opts.unevaluated||Y.props===!0))return;let G=J.strictSchema&&!J.allowMatchingProperties&&$.properties,X=O.name("valid");if(Y.props!==!0&&!(Y.props instanceof eM.Name))Y.props=(0,U5.evaluatedPropsToName)(O,Y.props);let{props:Q}=Y;R();function R(){for(let S of A){if(G)U(S);if(Y.allErrors)T(S);else O.var(X,!0),T(S),O.if(X)}}function U(S){for(let H in G)if(new RegExp(S).test(H))(0,S5.checkStrictMode)(Y,`property ${H} matches pattern ${S} (use allowMatchingProperties)`)}function T(S){O.forIn("key",L,(H)=>{O.if(eM._`${(0,R5.usePattern)(W,S)}.test(${H})`,()=>{let F=Z.includes(S);if(!F)W.subschema({keyword:"patternProperties",schemaProp:S,dataProp:H,dataPropType:U5.Type.Str},X);if(Y.opts.unevaluated&&Q!==!0)O.assign(eM._`${Q}[${H}]`,!0);else if(!F&&!Y.allErrors)O.if((0,eM.not)(X),()=>O.break())})})}}};z5.default=_z});var K5=y((H5)=>{Object.defineProperty(H5,"__esModule",{value:!0});var Iz=s(),yz={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(W){let{gen:O,schema:M,it:L}=W;if((0,Iz.alwaysValidSchema)(L,M)){W.fail();return}let $=O.name("valid");W.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},$),W.failResult($,()=>W.reset(),()=>W.error())},error:{message:"must NOT be valid"}};H5.default=yz});var F5=y((T5)=>{Object.defineProperty(T5,"__esModule",{value:!0});var kz=tW(),bz={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:kz.validateUnion,error:{message:"must match a schema in anyOf"}};T5.default=bz});var q5=y((E5)=>{Object.defineProperty(E5,"__esModule",{value:!0});var WL=d(),vz=s(),gz={message:"must match exactly one schema in oneOf",params:({params:W})=>WL._`{passingSchemas: ${W.passing}}`},xz={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:gz,code(W){let{gen:O,schema:M,parentSchema:L,it:$}=W;if(!Array.isArray(M))throw Error("ajv implementation error");if($.opts.discriminator&&L.discriminator)return;let Y=M,J=O.let("valid",!1),A=O.let("passing",null),Z=O.name("_valid");W.setParams({passing:A}),O.block(G),W.result(J,()=>W.reset(),()=>W.error(!0));function G(){Y.forEach((X,Q)=>{let R;if((0,vz.alwaysValidSchema)($,X))O.var(Z,!0);else R=W.subschema({keyword:"oneOf",schemaProp:Q,compositeRule:!0},Z);if(Q>0)O.if(WL._`${Z} && ${J}`).assign(J,!1).assign(A,WL._`[${A}, ${Q}]`).else();O.if(Z,()=>{if(O.assign(J,!0),O.assign(A,Q),R)W.mergeEvaluated(R,WL.Name)})})}}};E5.default=xz});var C5=y((B5)=>{Object.defineProperty(B5,"__esModule",{value:!0});var uz=s(),lz={keyword:"allOf",schemaType:"array",code(W){let{gen:O,schema:M,it:L}=W;if(!Array.isArray(M))throw Error("ajv implementation error");let $=O.name("valid");M.forEach((Y,J)=>{if((0,uz.alwaysValidSchema)(L,Y))return;let A=W.subschema({keyword:"allOf",schemaProp:J},$);W.ok($),W.mergeEvaluated(A)})}};B5.default=lz});var _5=y((N5)=>{Object.defineProperty(N5,"__esModule",{value:!0});var OL=d(),P5=s(),mz={message:({params:W})=>OL.str`must match "${W.ifClause}" schema`,params:({params:W})=>OL._`{failingKeyword: ${W.ifClause}}`},dz={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:mz,code(W){let{gen:O,parentSchema:M,it:L}=W;if(M.then===void 0&&M.else===void 0)(0,P5.checkStrictMode)(L,'"if" without "then" and "else" is ignored');let $=w5(L,"then"),Y=w5(L,"else");if(!$&&!Y)return;let J=O.let("valid",!0),A=O.name("_valid");if(Z(),W.reset(),$&&Y){let X=O.let("ifClause");W.setParams({ifClause:X}),O.if(A,G("then",X),G("else",X))}else if($)O.if(A,G("then"));else O.if((0,OL.not)(A),G("else"));W.pass(J,()=>W.error(!0));function Z(){let X=W.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},A);W.mergeEvaluated(X)}function G(X,Q){return()=>{let R=W.subschema({keyword:X},A);if(O.assign(J,A),W.mergeValidEvaluated(R,J),Q)O.assign(Q,OL._`${X}`);else W.setParams({ifClause:X})}}}};function w5(W,O){let M=W.schema[O];return M!==void 0&&!(0,P5.alwaysValidSchema)(W,M)}N5.default=dz});var I5=y((j5)=>{Object.defineProperty(j5,"__esModule",{value:!0});var iz=s(),sz={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:W,parentSchema:O,it:M}){if(O.if===void 0)(0,iz.checkStrictMode)(M,`"${W}" without "if" is ignored`)}};j5.default=sz});var D5=y((y5)=>{Object.defineProperty(y5,"__esModule",{value:!0});var rz=i$(),az=s6(),oz=s$(),tz=a6(),ez=t6(),WV=aM(),OV=J5(),MV=r$(),LV=Q5(),$V=V5(),YV=K5(),JV=F5(),AV=q5(),ZV=C5(),GV=_5(),XV=I5();function QV(W=!1){let O=[YV.default,JV.default,AV.default,ZV.default,GV.default,XV.default,OV.default,MV.default,WV.default,LV.default,$V.default];if(W)O.push(az.default,tz.default);else O.push(rz.default,oz.default);return O.push(ez.default),O}y5.default=QV});var t$=y((f5)=>{Object.defineProperty(f5,"__esModule",{value:!0});f5.dynamicAnchor=void 0;var o$=d(),SV=oW(),k5=P1(),UV=dM(),zV={keyword:"$dynamicAnchor",schemaType:"string",code:(W)=>b5(W,W.schema)};function b5(W,O){let{gen:M,it:L}=W;L.schemaEnv.root.dynamicAnchors[O]=!0;let $=o$._`${SV.default.dynamicAnchors}${(0,o$.getProperty)(O)}`,Y=L.errSchemaPath==="#"?L.validateName:VV(W);M.if(o$._`!${$}`,()=>M.assign($,Y))}f5.dynamicAnchor=b5;function VV(W){let{schemaEnv:O,schema:M,self:L}=W.it,{root:$,baseId:Y,localRefs:J,meta:A}=O.root,{schemaId:Z}=L.opts,G=new k5.SchemaEnv({schema:M,schemaId:Z,root:$,baseId:Y,localRefs:J,meta:A});return k5.compileSchema.call(L,G),(0,UV.getValidate)(W,G)}f5.default=zV});var e$=y((u5)=>{Object.defineProperty(u5,"__esModule",{value:!0});u5.dynamicRef=void 0;var g5=d(),KV=oW(),x5=dM(),TV={keyword:"$dynamicRef",schemaType:"string",code:(W)=>h5(W,W.schema)};function h5(W,O){let{gen:M,keyword:L,it:$}=W;if(O[0]!=="#")throw Error(`"${L}" only supports hash fragment reference`);let Y=O.slice(1);if($.allErrors)J();else{let Z=M.let("valid",!1);J(Z),W.ok(Z)}function J(Z){if($.schemaEnv.root.dynamicAnchors[Y]){let G=M.let("_v",g5._`${KV.default.dynamicAnchors}${(0,g5.getProperty)(Y)}`);M.if(G,A(G,Z),A($.validateName,Z))}else A($.validateName,Z)()}function A(Z,G){return G?()=>M.block(()=>{(0,x5.callRef)(W,Z),M.let(G,!0)}):()=>(0,x5.callRef)(W,Z)}}u5.dynamicRef=h5;u5.default=TV});var m5=y((p5)=>{Object.defineProperty(p5,"__esModule",{value:!0});var EV=t$(),qV=s(),BV={keyword:"$recursiveAnchor",schemaType:"boolean",code(W){if(W.schema)(0,EV.dynamicAnchor)(W,"");else(0,qV.checkStrictMode)(W.it,"$recursiveAnchor: false is ignored")}};p5.default=BV});var c5=y((d5)=>{Object.defineProperty(d5,"__esModule",{value:!0});var wV=e$(),PV={keyword:"$recursiveRef",schemaType:"string",code:(W)=>(0,wV.dynamicRef)(W,W.schema)};d5.default=PV});var s5=y((i5)=>{Object.defineProperty(i5,"__esModule",{value:!0});var _V=t$(),jV=e$(),IV=m5(),yV=c5(),DV=[_V.default,jV.default,IV.default,yV.default];i5.default=DV});var a5=y((r5)=>{Object.defineProperty(r5,"__esModule",{value:!0});var n5=aM(),bV={keyword:"dependentRequired",type:"object",schemaType:"object",error:n5.error,code:(W)=>(0,n5.validatePropertyDeps)(W)};r5.default=bV});var t5=y((o5)=>{Object.defineProperty(o5,"__esModule",{value:!0});var vV=aM(),gV={keyword:"dependentSchemas",type:"object",schemaType:"object",code:(W)=>(0,vV.validateSchemaDeps)(W)};o5.default=gV});var W4=y((e5)=>{Object.defineProperty(e5,"__esModule",{value:!0});var hV=s(),uV={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:W,parentSchema:O,it:M}){if(O.contains===void 0)(0,hV.checkStrictMode)(M,`"${W}" without "contains" is ignored`)}};e5.default=uV});var M4=y((O4)=>{Object.defineProperty(O4,"__esModule",{value:!0});var pV=a5(),mV=t5(),dV=W4(),cV=[pV.default,mV.default,dV.default];O4.default=cV});var Y4=y(($4)=>{Object.defineProperty($4,"__esModule",{value:!0});var aO=d(),L4=s(),sV=oW(),nV={message:"must NOT have unevaluated properties",params:({params:W})=>aO._`{unevaluatedProperty: ${W.unevaluatedProperty}}`},rV={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:nV,code(W){let{gen:O,schema:M,data:L,errsCount:$,it:Y}=W;if(!$)throw Error("ajv implementation error");let{allErrors:J,props:A}=Y;if(A instanceof aO.Name)O.if(aO._`${A} !== true`,()=>O.forIn("key",L,(Q)=>O.if(G(A,Q),()=>Z(Q))));else if(A!==!0)O.forIn("key",L,(Q)=>A===void 0?Z(Q):O.if(X(A,Q),()=>Z(Q)));Y.props=!0,W.ok(aO._`${$} === ${sV.default.errors}`);function Z(Q){if(M===!1){if(W.setParams({unevaluatedProperty:Q}),W.error(),!J)O.break();return}if(!(0,L4.alwaysValidSchema)(Y,M)){let R=O.name("valid");if(W.subschema({keyword:"unevaluatedProperties",dataProp:Q,dataPropType:L4.Type.Str},R),!J)O.if((0,aO.not)(R),()=>O.break())}}function G(Q,R){return aO._`!${Q} || !${Q}[${R}]`}function X(Q,R){let U=[];for(let T in Q)if(Q[T]===!0)U.push(aO._`${R} !== ${T}`);return(0,aO.and)(...U)}}};$4.default=rV});var Z4=y((A4)=>{Object.defineProperty(A4,"__esModule",{value:!0});var z0=d(),J4=s(),oV={message:({params:{len:W}})=>z0.str`must NOT have more than ${W} items`,params:({params:{len:W}})=>z0._`{limit: ${W}}`},tV={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:oV,code(W){let{gen:O,schema:M,data:L,it:$}=W,Y=$.items||0;if(Y===!0)return;let J=O.const("len",z0._`${L}.length`);if(M===!1)W.setParams({len:Y}),W.fail(z0._`${J} > ${Y}`);else if(typeof M=="object"&&!(0,J4.alwaysValidSchema)($,M)){let Z=O.var("valid",z0._`${J} <= ${Y}`);O.if((0,z0.not)(Z),()=>A(Z,Y)),W.ok(Z)}$.items=!0;function A(Z,G){O.forRange("i",G,J,(X)=>{if(W.subschema({keyword:"unevaluatedItems",dataProp:X,dataPropType:J4.Type.Num},Z),!$.allErrors)O.if((0,z0.not)(Z),()=>O.break())})}}};A4.default=tV});var X4=y((G4)=>{Object.defineProperty(G4,"__esModule",{value:!0});var WH=Y4(),OH=Z4(),MH=[WH.default,OH.default];G4.default=MH});var R4=y((Q4)=>{Object.defineProperty(Q4,"__esModule",{value:!0});var QW=d(),$H={message:({schemaCode:W})=>QW.str`must match format "${W}"`,params:({schemaCode:W})=>QW._`{format: ${W}}`},YH={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:$H,code(W,O){let{gen:M,data:L,$data:$,schema:Y,schemaCode:J,it:A}=W,{opts:Z,errSchemaPath:G,schemaEnv:X,self:Q}=A;if(!Z.validateFormats)return;if($)R();else U();function R(){let T=M.scopeValue("formats",{ref:Q.formats,code:Z.code.formats}),S=M.const("fDef",QW._`${T}[${J}]`),H=M.let("fType"),F=M.let("format");M.if(QW._`typeof ${S} == "object" && !(${S} instanceof RegExp)`,()=>M.assign(H,QW._`${S}.type || "string"`).assign(F,QW._`${S}.validate`),()=>M.assign(H,QW._`"string"`).assign(F,S)),W.fail$data((0,QW.or)(K(),w()));function K(){if(Z.strictSchema===!1)return QW.nil;return QW._`${J} && !${F}`}function w(){let P=X.$async?QW._`(${S}.async ? await ${F}(${L}) : ${F}(${L}))`:QW._`${F}(${L})`,B=QW._`(typeof ${F} == "function" ? ${P} : ${F}.test(${L}))`;return QW._`${F} && ${F} !== true && ${H} === ${O} && !${B}`}}function U(){let T=Q.formats[Y];if(!T){K();return}if(T===!0)return;let[S,H,F]=w(T);if(S===O)W.pass(P());function K(){if(Z.strictSchema===!1){Q.logger.warn(B());return}throw Error(B());function B(){return`unknown format "${Y}" ignored in schema at path "${G}"`}}function w(B){let q=B instanceof RegExp?(0,QW.regexpCode)(B):Z.code.formats?QW._`${Z.code.formats}${(0,QW.getProperty)(Y)}`:void 0,N=M.scopeValue("formats",{key:Y,ref:B,code:q});if(typeof B=="object"&&!(B instanceof RegExp))return[B.type||"string",B.validate,QW._`${N}.validate`];return["string",B,N]}function P(){if(typeof T=="object"&&!(T instanceof RegExp)&&T.async){if(!X.$async)throw Error("async format in sync schema");return QW._`await ${F}(${L})`}return typeof H=="function"?QW._`${F}(${L})`:QW._`${F}.test(${L})`}}}};Q4.default=YH});var U4=y((S4)=>{Object.defineProperty(S4,"__esModule",{value:!0});var AH=R4(),ZH=[AH.default];S4.default=ZH});var H4=y((z4)=>{Object.defineProperty(z4,"__esModule",{value:!0});z4.contentVocabulary=z4.metadataVocabulary=void 0;z4.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];z4.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var F4=y((T4)=>{Object.defineProperty(T4,"__esModule",{value:!0});var QH=Q6(),RH=x6(),SH=D5(),UH=s5(),zH=M4(),VH=X4(),HH=U4(),K4=H4(),KH=[UH.default,QH.default,RH.default,(0,SH.default)(!0),HH.default,K4.metadataVocabulary,K4.contentVocabulary,zH.default,VH.default];T4.default=KH});var C4=y((q4)=>{Object.defineProperty(q4,"__esModule",{value:!0});q4.DiscrError=void 0;var E4;(function(W){W.Tag="tag",W.Mapping="mapping"})(E4||(q4.DiscrError=E4={}))});var N4=y((P4)=>{Object.defineProperty(P4,"__esModule",{value:!0});var x0=d(),W8=C4(),w4=P1(),FH=C1(),EH=s(),qH={message:({params:{discrError:W,tagName:O}})=>W===W8.DiscrError.Tag?`tag "${O}" must be string`:`value of tag "${O}" must be in oneOf`,params:({params:{discrError:W,tag:O,tagName:M}})=>x0._`{error: ${W}, tag: ${M}, tagValue: ${O}}`},BH={keyword:"discriminator",type:"object",schemaType:"object",error:qH,code(W){let{gen:O,data:M,schema:L,parentSchema:$,it:Y}=W,{oneOf:J}=$;if(!Y.opts.discriminator)throw Error("discriminator: requires discriminator option");let A=L.propertyName;if(typeof A!="string")throw Error("discriminator: requires propertyName");if(L.mapping)throw Error("discriminator: mapping is not supported");if(!J)throw Error("discriminator: requires oneOf keyword");let Z=O.let("valid",!1),G=O.const("tag",x0._`${M}${(0,x0.getProperty)(A)}`);O.if(x0._`typeof ${G} == "string"`,()=>X(),()=>W.error(!1,{discrError:W8.DiscrError.Tag,tag:G,tagName:A})),W.ok(Z);function X(){let U=R();O.if(!1);for(let T in U)O.elseIf(x0._`${G} === ${T}`),O.assign(Z,Q(U[T]));O.else(),W.error(!1,{discrError:W8.DiscrError.Mapping,tag:G,tagName:A}),O.endIf()}function Q(U){let T=O.name("valid"),S=W.subschema({keyword:"oneOf",schemaProp:U},T);return W.mergeEvaluated(S,x0.Name),T}function R(){var U;let T={},S=F($),H=!0;for(let P=0;P<J.length;P++){let B=J[P];if((B===null||B===void 0?void 0:B.$ref)&&!(0,EH.schemaHasRulesButRef)(B,Y.self.RULES)){let N=B.$ref;if(B=w4.resolveRef.call(Y.self,Y.schemaEnv.root,Y.baseId,N),B instanceof w4.SchemaEnv)B=B.schema;if(B===void 0)throw new FH.default(Y.opts.uriResolver,Y.baseId,N)}let q=(U=B===null||B===void 0?void 0:B.properties)===null||U===void 0?void 0:U[A];if(typeof q!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${A}"`);H=H&&(S||F(B)),K(q,P)}if(!H)throw Error(`discriminator: "${A}" must be required`);return T;function F({required:P}){return Array.isArray(P)&&P.includes(A)}function K(P,B){if(P.const)w(P.const,B);else if(P.enum)for(let q of P.enum)w(q,B);else throw Error(`discriminator: "properties/${A}" must have "const" or "enum"`)}function w(P,B){if(typeof P!="string"||P in T)throw Error(`discriminator: "${A}" values must be unique strings`);T[P]=B}}}};P4.default=BH});var _4=y((dC,wH)=>{wH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var j4=y((cC,PH)=>{PH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var I4=y((iC,NH)=>{NH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var y4=y((sC,_H)=>{_H.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var D4=y((nC,jH)=>{jH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var k4=y((rC,IH)=>{IH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var b4=y((aC,yH)=>{yH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var f4=y((oC,DH)=>{DH.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var g4=y((v4)=>{Object.defineProperty(v4,"__esModule",{value:!0});var kH=_4(),bH=j4(),fH=I4(),vH=y4(),gH=D4(),xH=k4(),hH=b4(),uH=f4(),lH=["/properties"];function pH(W){return[kH,bH,fH,vH,gH,O(this,xH),hH,O(this,uH)].forEach((M)=>this.addMetaSchema(M,void 0,!1)),this;function O(M,L){return W?M.$dataMetaSchema(L,lH):L}}v4.default=pH});var x4=y((xW,M8)=>{Object.defineProperty(xW,"__esModule",{value:!0});xW.MissingRefError=xW.ValidationError=xW.CodeGen=xW.Name=xW.nil=xW.stringify=xW.str=xW._=xW.KeywordCxt=xW.Ajv2020=void 0;var dH=M6(),cH=F4(),iH=N4(),sH=g4(),O8="https://json-schema.org/draft/2020-12/schema";class g1 extends dH.default{constructor(W={}){super({...W,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){if(super._addVocabularies(),cH.default.forEach((W)=>this.addVocabulary(W)),this.opts.discriminator)this.addKeyword(iH.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:W,meta:O}=this.opts;if(!O)return;sH.default.call(this,W),this.refs["http://json-schema.org/schema"]=O8}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(O8)?O8:void 0)}}xW.Ajv2020=g1;M8.exports=xW=g1;M8.exports.Ajv2020=g1;Object.defineProperty(xW,"__esModule",{value:!0});xW.default=g1;var nH=B1();Object.defineProperty(xW,"KeywordCxt",{enumerable:!0,get:function(){return nH.KeywordCxt}});var h0=d();Object.defineProperty(xW,"_",{enumerable:!0,get:function(){return h0._}});Object.defineProperty(xW,"str",{enumerable:!0,get:function(){return h0.str}});Object.defineProperty(xW,"stringify",{enumerable:!0,get:function(){return h0.stringify}});Object.defineProperty(xW,"nil",{enumerable:!0,get:function(){return h0.nil}});Object.defineProperty(xW,"Name",{enumerable:!0,get:function(){return h0.Name}});Object.defineProperty(xW,"CodeGen",{enumerable:!0,get:function(){return h0.CodeGen}});var rH=kM();Object.defineProperty(xW,"ValidationError",{enumerable:!0,get:function(){return rH.default}});var aH=C1();Object.defineProperty(xW,"MissingRefError",{enumerable:!0,get:function(){return aH.default}})});import{randomUUID as sq}from"crypto";var f9=Buffer.from(`\r
11
11
  \r
12
- `,"ascii");var bX=new TextDecoder("utf-8",{fatal:!0});class UO extends Error{constructor(W){super(W);this.name="FrameProtocolError"}}function fX(W){let O;try{O=JSON.stringify(W)}catch{throw new UO("Outbound protocol message is not JSON serializable.")}if(O===void 0)throw new UO("Outbound protocol message is not a JSON value.");let M=Buffer.from(O,"utf8"),L=Buffer.from(`Content-Length: ${M.byteLength}\r
12
+ `,"ascii");var vG=new TextDecoder("utf-8",{fatal:!0});class VO extends Error{constructor(W){super(W);this.name="FrameProtocolError"}}function gG(W){let O;try{O=JSON.stringify(W)}catch{throw new VO("Outbound protocol message is not JSON serializable.")}if(O===void 0)throw new VO("Outbound protocol message is not a JSON value.");let M=Buffer.from(O,"utf8"),L=Buffer.from(`Content-Length: ${M.byteLength}\r
13
13
  \r
14
- `,"ascii");return Buffer.concat([L,M])}class O${#W;#O=Buffer.alloc(0);constructor(W={}){this.#W=W.maxFrameBytes}push(W){if(W.byteLength>0)this.#O=Buffer.concat([this.#O,W]);let O=[];while(!0){let M=this.#O.indexOf(D9);if(M<0){if(this.#O.byteLength>128)throw new UO("Protocol frame header exceeds 128 bytes.");break}if(M>128)throw new UO("Protocol frame header exceeds 128 bytes.");let L=this.#O.subarray(0,M).toString("ascii"),$=/^Content-Length: ([0-9]+)$/.exec(L);if($===null)throw new UO("Protocol frame has an invalid Content-Length header.");let Y=Number($[1]);if(!Number.isSafeInteger(Y))throw new UO("Protocol Content-Length is not a safe integer.");if(this.#W!==void 0&&Y>this.#W)throw new UO(`Protocol frame declares ${Y} bytes, exceeding the configured limit.`);let J=M+D9.byteLength,A=J+Y;if(this.#O.byteLength<A)break;try{let Z=bX.decode(this.#O.subarray(J,A));O.push(JSON.parse(Z))}catch{throw new UO("Protocol frame body is not valid UTF-8 JSON.")}this.#O=this.#O.subarray(A)}return O}finish(){if(this.#O.byteLength!==0)throw new UO("Protocol stream ended with an incomplete frame.")}}class M${#W;#O=Promise.resolve();constructor(W){this.#W=W}send(W){let O=fX(W),M=this.#O.then(async()=>{await this.#W(O)});return this.#O=M.catch(()=>{}),M}async drain(){await this.#O}}var FZ=kX(f6(),1);import{readFileSync as LF}from"fs";import{dirname as t8,relative as W9,resolve as OM,sep as O9}from"path";function M8(W,O={}){let M=[],L=new Set,$=new Set;for(let R of W.nodes){if(L.has(R.id))$.add(R.id);L.add(R.id)}for(let R of $)M.push({code:"DUPLICATE_NODE_ID",message:`Compiled graph contains duplicate node ID "${R}".`});let Y=new Set,J=new Set,A=new Map,Z=new Map;for(let R of L)A.set(R,[]),Z.set(R,0);for(let R of W.edges){if(Y.has(R.id))J.add(R.id);if(Y.add(R.id),!L.has(R.from)||!L.has(R.to)){M.push({code:"UNKNOWN_EDGE_ENDPOINT",message:`Edge "${R.id}" references an unknown endpoint (${R.from} -> ${R.to}).`});continue}A.get(R.from)?.push(R.to),Z.set(R.to,(Z.get(R.to)??0)+1)}for(let R of J)M.push({code:"DUPLICATE_EDGE_ID",message:`Compiled graph contains duplicate edge ID "${R}".`});let X=new Set;for(let R of W.entryNodeIds){if(X.has(R)){M.push({code:"DUPLICATE_ENTRY_NODE_ID",message:`Compiled graph repeats entry node ID "${R}".`});continue}if(X.add(R),!L.has(R))M.push({code:"INVALID_ENTRY_NODE",message:`Entry node "${R}" does not exist.`});else if((Z.get(R)??0)!==0)M.push({code:"INVALID_ENTRY_NODE",message:`Entry node "${R}" has an incoming edge.`})}let G=new Set,Q=[...X].filter((R)=>L.has(R));while(Q.length>0){let R=Q.shift();if(R===void 0||G.has(R))continue;G.add(R),Q.push(...A.get(R)??[])}for(let R of L)if(!G.has(R))M.push({code:"UNREACHABLE_NODE",message:`Node "${R}" is not reachable from an entry node.`});let S=new Map(Z),U=[...L].filter((R)=>(S.get(R)??0)===0),V=0;while(U.length>0){let R=U.shift();if(R===void 0)continue;V+=1;for(let K of A.get(R)??[]){let T=(S.get(K)??0)-1;if(S.set(K,T),T===0)U.push(K)}}if(V!==L.size)M.push({code:"CYCLIC_GRAPH",message:"Compiled graph contains a cycle."});if(O.requireSingleTerminal===!0){let R=[...L].filter((K)=>(A.get(K)?.length??0)===0);if(R.length!==1)M.push({code:"TERMINAL_NODE_COUNT",message:`The first CLI profile requires exactly one terminal node; found ${R.length}.`})}return GK(W,M),XK(W,M),AK(W,M),QK(W,M),M}function oH(W){return`__woml_approval__${W}__join`}function tH(W,O,M){return W.kind==="equals"&&W.left.kind==="contextReference"&&W.left.path.length===3&&W.left.path[0]==="steps"&&W.left.path[1]===O&&W.left.path[2]==="decision"&&W.right.kind==="literal"&&W.right.value===M}var eH=/^#[a-z0-9][a-z0-9_-]{0,79}$/,WK=/^[CG][A-Z0-9]{8,31}$/,OK=/^-?[1-9][0-9]{0,19}$/,MK=/^[0-9]{17,20}$/,LK=/^[1-9][0-9]{7,15}$/,$K=/^[a-z0-9_]+$/,YK=/^[a-z]{2,3}(?:_[A-Z]{2})?$/,O8=/^[A-Z][A-Z0-9_]*$/;function v6(W,O){return Object.keys(W).length===O.length&&O.every((L)=>(L in W))}function JK(W,O){if(W===void 0)return!0;if(W.kind!=="array"||W.items.length===0)return!1;let M=-1,L=-1,$=new Set,Y=new Set;for(let J of W.items){if(J.kind!=="object")return!1;let{deliveryId:A,provider:Z,destination:X,credentials:G}=J.fields,Q=Z?.kind==="literal"?Z.value:void 0,S=Q==="slack",U=Q==="telegram",V=Q==="discord",R=Q==="whatsapp",K=R?["deliveryId","provider","destination","credentials","templateName","language"]:["deliveryId","provider","destination","credentials"];if(!v6(J.fields,K)||A?.kind!=="literal"||typeof A.value!=="string"||!S&&!U&&!V&&!R||X?.kind!=="literal"||typeof X.value!=="string"||S&&!eH.test(X.value)&&!WK.test(X.value)||U&&!OK.test(X.value)||V&&!MK.test(X.value)||R&&!LK.test(X.value)||G?.kind!=="object"||!v6(G.fields,S?["botToken","appToken"]:R?["accessToken","phoneNumberId"]:["botToken"]))return!1;let T=new RegExp(`^${O}:notify:([0-9]+):${U?"chat":R?"recipient":"channel"}:([0-9]+)$`).exec(A.value),F=G.fields.botToken,N=G.fields.appToken,C=G.fields.accessToken,w=G.fields.phoneNumberId,B=J.fields.templateName,I=J.fields.language;if(T===null||$.has(A.value)||!R&&(F?.kind!=="secretReference"||!O8.test(F.name))||S&&(N?.kind!=="secretReference"||!O8.test(N.name))||R&&(C?.kind!=="secretReference"||!O8.test(C.name)||w?.kind!=="literal"||typeof w.value!=="string"||B?.kind!=="literal"||typeof B.value!=="string"||!$K.test(B.value)||I?.kind!=="literal"||typeof I.value!=="string"||!YK.test(I.value)))return!1;let _=Number(T[1]),H=Number(T[2]),q=M===-1?_===0&&H===0:_===M?H===L+1:_===M+1&&H===0,j=R&&C?.kind==="secretReference"?C.name:F?.kind==="secretReference"?F.name:"",b=`${Q}\x00${j}\x00${N?.kind==="secretReference"?N.name:""}\x00${X.value}`;if(!q||Y.has(b))return!1;$.add(A.value),Y.add(b),M=_,L=H}return!0}function AK(W,O){let M=new Map(W.nodes.map(($)=>[$.id,$])),L=new Map;for(let $ of W.edges){if($.approvalId===void 0){if($.condition.kind==="equals")O.push({code:"INVALID_APPROVAL_GROUP",message:`Equals edge "${$.id}" must carry an approvalId.`});continue}let Y=L.get($.approvalId)??[];if(Y.push($),L.set($.approvalId,Y),$.branchId!==void 0||$.parallelId!==void 0)O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval edge "${$.id}" cannot also belong to a branch or parallel group.`})}for(let[$,Y]of L){let J=M.get($),A=oH($),Z=M.get(A),X=J?.inputs.kind==="object"?J.inputs.fields:{},G=X.timeoutMs,Q=X.onTimeout,S=X.notifications,U=JK(S,$),V=J?.metadata,R=V===void 0||Object.keys(V).every((q)=>["name","description"].includes(q))&&Object.values(V).every((q)=>typeof q==="string"&&q.length>0),K=sO.test($)&&J?.handler==="engine.approval-wait"&&J.timeoutMs===void 0&&J.retryPolicy===void 0&&J.inputs.kind==="object"&&Object.keys(X).every((q)=>["timeoutMs","onTimeout","notifications"].includes(q))&&Object.keys(X).length===1+Number(G!==void 0)+Number(S!==void 0)&&Q?.kind==="literal"&&(Q.value==="reject"||Q.value==="fail")&&(G===void 0||G.kind==="literal"&&typeof G.value==="number"&&Number.isSafeInteger(G.value)&&G.value>=1)&&U&&R,T=Z?.handler==="engine.approval-join"&&Z.timeoutMs===void 0&&Z.retryPolicy===void 0&&Z.metadata===void 0&&Z.inputs.kind==="object"&&Object.keys(Z.inputs.fields).length===0,F=Y.find((q)=>q.id===`${$}:approved`),N=Y.find((q)=>q.id===`${$}:rejected`),C=Y.find((q)=>q.id===`${$}:approved:join`),w=Y.find((q)=>q.id===`${$}:rejected:join`),I=[{decision:"approved",route:F,join:C},{decision:"rejected",route:N,join:w}].every(({decision:q,route:j,join:b})=>{if(j===void 0||j.from!==$||j.approvalId!==$||!tH(j.condition,$,q))return!1;if(j.to===A)return b===void 0;return b?.from!==$&&b?.to===A&&b?.approvalId===$&&b.condition.kind==="always"}),_=2+Number(F?.to!==A)+Number(N?.to!==A),H=W.edges.filter((q)=>q.from===$).length===2&&W.edges.filter((q)=>q.from===$).every((q)=>q.approvalId===$)&&W.edges.filter((q)=>q.to===A).every((q)=>q.approvalId===$);if(!K||!T||!I||Y.length!==_||!H)O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval group "${$}" does not match the frozen wait, decision-route, empty-arm, and join contract.`});if(!U)O.push({code:"INVALID_NOTIFICATION_GROUP",message:`Approval group "${$}" has invalid compiled notification deliveries.`})}for(let $ of W.nodes){if($.handler==="engine.approval-wait"&&!L.has($.id))O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval wait "${$.id}" has no matching edge group.`});if($.handler==="engine.approval-join"){let Y=/^__woml_approval__([a-z][A-Za-z0-9]*)__join$/.exec($.id);if(Y===null||!L.has(Y[1]))O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval join "${$.id}" has no matching edge group.`})}}}function ZK(W){return`__woml_parallel__${W}__start`}function XK(W,O){let M=new Map(W.nodes.map(($)=>[$.id,$])),L=new Map;for(let $ of W.edges){if($.parallelId===void 0)continue;let Y=L.get($.parallelId)??[];if(Y.push($),L.set($.parallelId,Y),$.branchId!==void 0||$.condition.kind!=="always")O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel edge "${$.id}" must be unconditional and cannot also belong to a branch.`})}for(let[$,Y]of L){let J=ZK($),A=M.get(J),Z=M.get($),X=A?.inputs.kind==="object"?A.inputs.fields:{},G=X.concurrency,Q=X.onError,S=Y.filter((B)=>B.from===J),U=Y.filter((B)=>B.to===$),V=S.map((B)=>B.to),R=A?.handler==="engine.parallel-start"&&Object.keys(X).length===2&&G?.kind==="literal"&&typeof G.value==="number"&&Number.isSafeInteger(G.value)&&G.value>=1&&G.value<=S.length&&Q?.kind==="literal"&&(Q.value==="fail-fast"||Q.value==="wait-all"),K=Z?.handler==="engine.parallel-join"&&Z.inputs.kind==="object"&&Object.keys(Z.inputs.fields).length===0,T=S.length>=1&&U.length===S.length&&Y.length===S.length*2&&S.every((B,I)=>B.id===`${$}:child:${I}`&&B.parallelId===$&&B.branchId===void 0&&B.condition.kind==="always"&&M.get(B.to)?.handler==="runtime.script")&&U.every((B,I)=>B.id===`${$}:join:${I}`&&B.from===V[I]&&B.parallelId===$&&B.branchId===void 0&&B.condition.kind==="always"),F=W.edges.filter((B)=>B.from===J),N=W.edges.filter((B)=>B.to===$),C=F.length===S.length&&F.every((B)=>B.parallelId===$)&&N.length===U.length&&N.every((B)=>B.parallelId===$)&&V.every((B)=>{let I=W.edges.filter((H)=>H.to===B),_=W.edges.filter((H)=>H.from===B);return I.length===1&&I[0].from===J&&I[0].parallelId===$&&_.length===1&&_[0].to===$&&_[0].parallelId===$}),w=W.edges.some((B)=>B.from===$);if(!sO.test($)||!R||!K||!T||!C||!w)O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel group "${$}" does not match the frozen start, ordered child, join, policy, and concurrency contract.`})}for(let $ of W.nodes){if($.handler==="engine.parallel-start"){let Y=/^__woml_parallel__([a-z][A-Za-z0-9]*)__start$/.exec($.id);if(Y===null||!L.has(Y[1]))O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel start "${$.id}" has no matching edge group.`})}if($.handler==="engine.parallel-join"&&!L.has($.id))O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel join "${$.id}" has no matching edge group.`})}}var sO=/^[a-z][A-Za-z0-9]*$/;function OL(W){if(W?.kind!=="contextReference")return!1;let[O,M]=W.path;return O==="trigger"&&W.path.length>=1||O==="steps"&&M!==void 0&&sO.test(M)}function GK(W,O){let M=new Map(W.nodes.map((Y)=>[Y.id,Y])),L=new Map,$=new Set((W.choices??[]).flatMap((Y)=>Y.armIds));for(let Y of W.edges){if(Y.branchId===void 0){if(Y.condition.kind==="boolean"&&!$.has(Y.id))O.push({code:"INVALID_BRANCH_GROUP",message:`Boolean edge "${Y.id}" must carry a branchId.`});continue}let J=L.get(Y.branchId)??[];J.push(Y),L.set(Y.branchId,J)}for(let Y of W.nodes)if(Y.handler==="engine.branch-select"){let A=/^__woml_branch__([a-z][A-Za-z0-9]*)__select$/.exec(Y.id)?.[1],Z=Y.inputs.kind==="object"&&Object.keys(Y.inputs.fields).length===0;if(A===void 0||!Z||!L.has(A))O.push({code:"INVALID_BRANCH_SELECTOR",message:`Branch selector "${Y.id}" does not match the frozen selector identity, inputs, and edge-group contract.`})}for(let[Y,J]of L){let A=`__woml_branch__${Y}__select`,Z=M.get(A),X=W.edges.filter((_)=>_.from===A);if(!sO.test(Y)||Z?.handler!=="engine.branch-select"||J.some((_)=>_.from!==A)||X.length!==J.length||X.some((_)=>_.branchId!==Y))O.push({code:"INVALID_BRANCH_GROUP",message:`Branch group "${Y}" must originate from its canonical selector.`});let G=J.slice(0,-1),Q=J.at(-1),S=G.length>0&&G.every((_,H)=>_.id===`${Y}:when:${H}`&&_.condition.kind==="boolean"&&OL(_.condition.value)),U=Q?.id===`${Y}:otherwise`&&Q.condition.kind==="always";if(!S||!U)O.push({code:"INVALID_BRANCH_GROUP",message:`Branch group "${Y}" must contain contiguous ordered boolean cases followed by one fallback.`});let V=M.get(Y),R=V?.inputs.kind==="object"?V.inputs.fields:{},K=J.map((_)=>_.id),T=Object.keys(R);if(V?.handler!=="engine.branch-result"||T.length!==K.length||K.some((_)=>!OL(R[_])))O.push({code:"INVALID_BRANCH_RESULT",message:`Branch result "${Y}" must expose one context reference for every ordered branch arm.`});let F=W.edges.filter((_)=>_.to===Y),N=F.length===J.length&&F.every((_)=>_.branchId===void 0&&_.condition.kind==="always"),C=new Map;for(let _ of W.edges){let H=C.get(_.from)??[];H.push(_.to),C.set(_.from,H)}let w=J.map((_)=>{let H=new Set,q=[_.to],j=!1;while(q.length>0){let b=q.shift();if(b===Y){j=!0;continue}if(H.has(b))continue;H.add(b),q.push(...C.get(b)??[])}return{reachesResult:j,visited:H}}),B=w.every((_,H)=>w.slice(H+1).every((q)=>![..._.visited].some((j)=>q.visited.has(j)))),I=F.every((_)=>w.filter((H)=>H.visited.has(_.from)).length===1);if(!N||w.some((_)=>!_.reachesResult)||!B||!I)O.push({code:"INVALID_BRANCH_GROUP",message:`Branch group "${Y}" must contain disjoint routes with one ordinary join into its result per arm.`})}for(let Y of W.nodes)if(Y.handler==="engine.branch-result"&&!L.has(Y.id))O.push({code:"INVALID_BRANCH_RESULT",message:`Branch result "${Y.id}" has no matching branch edge group.`})}function b0(W,O){return W?.handler===O&&W.timeoutMs===void 0&&W.retryPolicy===void 0&&W.scriptRuntime===void 0&&W.metadata===void 0&&W.inputs.kind==="object"&&Object.keys(W.inputs.fields).length===0}function QK(W,O){let{forks:M,choices:L,contextVisibility:$,settlement:Y}=W;if(!W.nodes.some((H)=>["engine.fork-open","engine.fork-branch-terminal","engine.fork-join","engine.choice-select","engine.choice-join","engine.workflow-settlement"].includes(H.handler))&&!(M!==void 0||L!==void 0||$!==void 0||Y!==void 0))return;if(M===void 0||L===void 0||$===void 0||Y===void 0){O.push({code:"INVALID_FORK_GRAPH",message:"Model v13 graph metadata requires forks, choices, contextVisibility, and settlement together."});return}let Z=new Map(W.nodes.map((H)=>[H.id,H])),X=new Map,G=new Map;for(let H of W.nodes)X.set(H.id,[]),G.set(H.id,[]);for(let H of W.edges)X.get(H.from)?.push(H),G.get(H.to)?.push(H);let Q=new Set,S=[],U=new Set,V=new Map;for(let H of M){let q=sO.test(H.forkId)&&!Q.has(H.forkId)&&H.openNodeId===`__woml_fork__${H.forkId}__open`&&H.joinNodeId===`__woml_fork__${H.forkId}__join`&&b0(Z.get(H.openNodeId),"engine.fork-open")&&b0(Z.get(H.joinNodeId),"engine.fork-join")&&H.branches.length>=1;Q.add(H.forkId),U.add(H.openNodeId),U.add(H.joinNodeId);let j=new Set,b=new Map;for(let g of H.branches){let VW=`__woml_fork__${H.forkId}__${g.branchId}__terminal`;q&&=sO.test(g.branchId)&&g.branchId!=="all"&&g.branchId!=="none"&&!j.has(g.branchId)&&g.terminalNodeId===VW&&Z.has(g.entryNodeId)&&b0(Z.get(g.terminalNodeId),"engine.fork-branch-terminal"),j.add(g.branchId),b.set(g.branchId,g.terminalNodeId),S.push(g.terminalNodeId),U.add(g.terminalNodeId);let _O=G.get(g.entryNodeId)??[];q&&=_O.length===1&&_O[0].from===H.openNodeId&&_O[0].condition.kind==="always";let A1=[g.entryNodeId],hO=new Set,Z1=!1;while(A1.length>0){let NW=A1.pop();if(hO.has(NW))continue;if(hO.add(NW),NW===g.terminalNodeId){Z1=!0;continue}for(let QW of X.get(NW)??[])if(QW.to!==H.joinNodeId&&QW.to!==Y.nodeId)A1.push(QW.to)}q&&=Z1;for(let NW of hO){let QW=V.get(NW);if(QW!==void 0&&QW!==`${H.forkId}:${g.branchId}`)q=!1;V.set(NW,`${H.forkId}:${g.branchId}`)}}let k=H.branches.filter((g)=>H.joinedBranchIds.includes(g.branchId)).map((g)=>g.branchId);q&&=new Set(H.joinedBranchIds).size===H.joinedBranchIds.length&&H.joinedBranchIds.every((g)=>j.has(g))&&JSON.stringify(k)===JSON.stringify(H.joinedBranchIds);let p=X.get(H.openNodeId)??[],ZW=new Set(H.branches.map((g)=>g.entryNodeId));q&&=H.branches.every((g)=>p.some((VW)=>VW.to===g.entryNodeId&&VW.condition.kind==="always"));let MW=(G.get(H.joinNodeId)??[]).map((g)=>g.from),GW=H.joinedBranchIds.length===0?[H.openNodeId]:H.joinedBranchIds.map((g)=>b.get(g));if(q&&=p.every((g)=>ZW.has(g.to)||H.joinedBranchIds.length===0&&g.to===H.joinNodeId)&&JSON.stringify(MW)===JSON.stringify(GW)&&(G.get(H.joinNodeId)??[]).every((g)=>g.condition.kind==="always"),!q)O.push({code:"INVALID_FORK_GRAPH",message:`Fork "${H.forkId}" does not match the frozen Model v13 ownership, route, and join contract.`})}for(let H of W.nodes)if(["engine.fork-open","engine.fork-branch-terminal","engine.fork-join"].includes(H.handler)&&!U.has(H.id))O.push({code:"INVALID_FORK_GRAPH",message:`Fork control node "${H.id}" is not owned by a fork descriptor.`});let R=new Set,K=new Set;for(let H of L){let q=H.stringSelector!==void 0,j=q?H.stringCases!==void 0&&H.defaultArmId!==void 0&&H.stringCases.length>=1&&H.stringCases.length===H.armIds.length-1&&OL(H.stringSelector)&&new Set(H.stringCases.map((MW)=>MW.value)).size===H.stringCases.length&&H.stringCases.every((MW,GW)=>MW.armId===H.armIds[GW]&&MW.value.length>0)&&H.defaultArmId===H.armIds.at(-1):H.stringCases===void 0&&H.defaultArmId===void 0&&H.resultNodeId===void 0,k=/^__woml_choice__[a-z0-9_]+$/.test(H.choiceId)&&!R.has(H.choiceId)&&H.selectorNodeId===`${H.choiceId}__select`&&H.joinNodeId===`${H.choiceId}__join`&&b0(Z.get(H.selectorNodeId),"engine.choice-select")&&b0(Z.get(H.joinNodeId),"engine.choice-join")&&H.armIds.length>=2&&new Set(H.armIds).size===H.armIds.length&&j;if(R.add(H.choiceId),K.add(H.selectorNodeId),K.add(H.joinNodeId),H.resultNodeId!==void 0){K.add(H.resultNodeId);let MW=Z.get(H.resultNodeId),GW=MW?.inputs.kind==="object"?MW.inputs.fields:{},g=G.get(H.resultNodeId)??[];k&&=q&&sO.test(H.resultNodeId)&&MW?.handler==="engine.choice-result"&&MW.retryPolicy===void 0&&MW.timeoutMs===void 0&&Object.keys(GW).length===H.armIds.length&&H.armIds.every((VW)=>OL(GW[VW]))&&g.length===1&&g[0].from===H.joinNodeId&&g[0].condition.kind==="always"}let p=X.get(H.selectorNodeId)??[],ZW=G.get(H.joinNodeId)??[];if(k&&=p.length===H.armIds.length&&ZW.length===H.armIds.length,H.armIds.forEach((MW,GW)=>{let g=p[GW],VW=ZW[GW];k&&=MW.startsWith(`${H.choiceId}:`)&&g?.id===MW&&g.branchId===void 0&&g.parallelId===void 0&&g.approvalId===void 0&&(q?g.condition.kind==="always":GW===H.armIds.length-1?g.condition.kind==="always":g.condition.kind==="boolean")&&VW?.id===`${MW}:join`&&VW.to===H.joinNodeId&&VW.condition.kind==="always"}),!k)O.push({code:"INVALID_CONTROL_CHOICE",message:`Control choice "${H.choiceId}" does not match the frozen selector, ordered-arm, and join contract.`})}for(let H of W.nodes)if(["engine.choice-select","engine.choice-join","engine.choice-result"].includes(H.handler)&&!K.has(H.id))O.push({code:"INVALID_CONTROL_CHOICE",message:`Control-choice node "${H.id}" has no matching descriptor.`});let T=W.nodes.filter((H)=>H.handler==="runtime.script").map((H)=>H.id),F=new Set,N=$.length===T.length;if($.forEach((H,q)=>{N&&=H.nodeId===T[q]&&!F.has(H.nodeId)&&new Set(H.stepIds).size===H.stepIds.length&&H.stepIds.every((j)=>sO.test(j)&&Z.has(j)),F.add(H.nodeId)}),!N)O.push({code:"INVALID_CONTEXT_VISIBILITY",message:"Model v13 contextVisibility must describe every runtime.script node once, in graph order, with existing public output IDs."});let C=G.get(Y.nodeId)??[],w=M.flatMap((H)=>H.branches.map((q)=>q.terminalNodeId)),B=new Set(w),I=C.filter((H)=>!B.has(H.from));if(!(Y.nodeId==="__woml_workflow__settlement"&&b0(Z.get(Y.nodeId),"engine.workflow-settlement")&&Z.has(Y.mainResultNodeId)&&JSON.stringify(Y.ownedBranchTerminalNodeIds)===JSON.stringify(w)&&I.length===1&&C.length===w.length+1&&C.every((H)=>H.condition.kind==="always")&&(X.get(Y.nodeId)?.length??0)===0))O.push({code:"INVALID_WORKFLOW_SETTLEMENT",message:"Model v13 settlement must preserve one main result and depend on the main continuation plus every owned branch terminal."})}var SK=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],l6=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],RK="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",p6="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",L8={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},$8="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",UK={5:$8,"5module":$8+" export import",6:$8+" const class extends export import super"},zK=/^in(stanceof)?$/,VK=new RegExp("["+p6+"]"),HK=new RegExp("["+p6+RK+"]");function Y8(W,O){var M=65536;for(var L=0;L<O.length;L+=2){if(M+=O[L],M>W)return!1;if(M+=O[L+1],M>=W)return!0}return!1}function VO(W,O){if(W<65)return W===36;if(W<91)return!0;if(W<97)return W===95;if(W<123)return!0;if(W<=65535)return W>=170&&VK.test(String.fromCharCode(W));if(O===!1)return!1;return Y8(W,l6)}function rO(W,O){if(W<48)return W===36;if(W<58)return!0;if(W<65)return!1;if(W<91)return!0;if(W<97)return W===95;if(W<123)return!0;if(W<=65535)return W>=170&&HK.test(String.fromCharCode(W));if(O===!1)return!1;return Y8(W,l6)||Y8(W,SK)}var WW=function(O,M){if(M===void 0)M={};this.label=O,this.keyword=M.keyword,this.beforeExpr=!!M.beforeExpr,this.startsExpr=!!M.startsExpr,this.isLoop=!!M.isLoop,this.isAssign=!!M.isAssign,this.prefix=!!M.prefix,this.postfix=!!M.postfix,this.binop=M.binop||null,this.updateContext=null};function oW(W,O){return new WW(W,{beforeExpr:!0,binop:O})}var tW={beforeExpr:!0},hW={startsExpr:!0},G8={};function o(W,O){if(O===void 0)O={};return O.keyword=W,G8[W]=new WW(W,O)}var z={num:new WW("num",hW),regexp:new WW("regexp",hW),string:new WW("string",hW),name:new WW("name",hW),privateId:new WW("privateId",hW),eof:new WW("eof"),bracketL:new WW("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new WW("]"),braceL:new WW("{",{beforeExpr:!0,startsExpr:!0}),braceR:new WW("}"),parenL:new WW("(",{beforeExpr:!0,startsExpr:!0}),parenR:new WW(")"),comma:new WW(",",tW),semi:new WW(";",tW),colon:new WW(":",tW),dot:new WW("."),question:new WW("?",tW),questionDot:new WW("?."),arrow:new WW("=>",tW),template:new WW("template"),invalidTemplate:new WW("invalidTemplate"),ellipsis:new WW("...",tW),backQuote:new WW("`",hW),dollarBraceL:new WW("${",{beforeExpr:!0,startsExpr:!0}),eq:new WW("=",{beforeExpr:!0,isAssign:!0}),assign:new WW("_=",{beforeExpr:!0,isAssign:!0}),incDec:new WW("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new WW("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:oW("||",1),logicalAND:oW("&&",2),bitwiseOR:oW("|",3),bitwiseXOR:oW("^",4),bitwiseAND:oW("&",5),equality:oW("==/!=/===/!==",6),relational:oW("</>/<=/>=",7),bitShift:oW("<</>>/>>>",8),plusMin:new WW("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:oW("%",10),star:oW("*",10),slash:oW("/",10),starstar:new WW("**",{beforeExpr:!0}),coalesce:oW("??",1),_break:o("break"),_case:o("case",tW),_catch:o("catch"),_continue:o("continue"),_debugger:o("debugger"),_default:o("default",tW),_do:o("do",{isLoop:!0,beforeExpr:!0}),_else:o("else",tW),_finally:o("finally"),_for:o("for",{isLoop:!0}),_function:o("function",hW),_if:o("if"),_return:o("return",tW),_switch:o("switch"),_throw:o("throw",tW),_try:o("try"),_var:o("var"),_const:o("const"),_while:o("while",{isLoop:!0}),_with:o("with"),_new:o("new",{beforeExpr:!0,startsExpr:!0}),_this:o("this",hW),_super:o("super",hW),_class:o("class",hW),_extends:o("extends",tW),_export:o("export"),_import:o("import",hW),_null:o("null",hW),_true:o("true",hW),_false:o("false",hW),_in:o("in",{beforeExpr:!0,binop:7}),_instanceof:o("instanceof",{beforeExpr:!0,binop:7}),_typeof:o("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:o("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:o("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},uW=/\r\n?|\n|\u2028|\u2029/,KK=new RegExp(uW.source,"g");function f0(W){return W===10||W===13||W===8232||W===8233}function m6(W,O,M){if(M===void 0)M=W.length;for(var L=O;L<M;L++){var $=W.charCodeAt(L);if(f0($))return L<M-1&&$===13&&W.charCodeAt(L+1)===10?L+2:L+1}return-1}var d6=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,BW=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,c6=Object.prototype,TK=c6.hasOwnProperty,FK=c6.toString,v0=Object.hasOwn||function(W,O){return TK.call(W,O)},x6=Array.isArray||function(W){return FK.call(W)==="[object Array]"},g6=Object.create(null);function nO(W){return g6[W]||(g6[W]=new RegExp("^(?:"+W.replace(/ /g,"|")+")$"))}function DO(W){if(W<=65535)return String.fromCharCode(W);return W-=65536,String.fromCharCode((W>>10)+55296,(W&1023)+56320)}var EK=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,b1=function(O,M){this.line=O,this.column=M};b1.prototype.offset=function(O){return new b1(this.line,this.column+O)};var AL=function(O,M,L){if(this.start=M,this.end=L,O.sourceFile!==null)this.source=O.sourceFile};function i6(W,O){for(var M=1,L=0;;){var $=m6(W,L,O);if($<0)return new b1(M,O-L);++M,L=$}}var J8={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},h6=!1;function qK(W){var O={};for(var M in J8)O[M]=W&&v0(W,M)?W[M]:J8[M];if(O.ecmaVersion==="latest")O.ecmaVersion=1e8;else if(O.ecmaVersion==null){if(!h6&&typeof console==="object"&&console.warn)h6=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
15
- Defaulting to 2020, but this will stop working in the future.`);O.ecmaVersion=11}else if(O.ecmaVersion>=2015)O.ecmaVersion-=2009;if(O.allowReserved==null)O.allowReserved=O.ecmaVersion<5;if(!W||W.allowHashBang==null)O.allowHashBang=O.ecmaVersion>=14;if(x6(O.onToken)){var L=O.onToken;O.onToken=function($){return L.push($)}}if(x6(O.onComment))O.onComment=BK(O,O.onComment);return O}function BK(W,O){return function(M,L,$,Y,J,A){var Z={type:M?"Block":"Line",value:L,start:$,end:Y};if(W.locations)Z.loc=new AL(this,J,A);if(W.ranges)Z.range=[$,Y];O.push(Z)}}var f1=1,x0=2,Q8=4,s6=8,S8=16,n6=32,ZL=64,r6=128,Q0=256,v1=512,XL=f1|x0|Q0;function R8(W,O){return x0|(W?Q8:0)|(O?s6:0)}var LL=0,U8=1,bO=2,a6=3,o6=4,t6=5,HW=function(O,M,L){this.options=O=qK(O),this.sourceFile=O.sourceFile,this.keywords=nO(UK[O.ecmaVersion>=6?6:O.sourceType==="module"?"5module":5]);var $="";if(O.allowReserved!==!0){if($=L8[O.ecmaVersion>=6?6:O.ecmaVersion===5?5:3],O.sourceType==="module")$+=" await"}this.reservedWords=nO($);var Y=($?$+" ":"")+L8.strict;if(this.reservedWordsStrict=nO(Y),this.reservedWordsStrictBind=nO(Y+" "+L8.strictBind),this.input=String(M),this.containsEsc=!1,L)this.pos=L,this.lineStart=this.input.lastIndexOf(`
16
- `,L-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(uW).length;else this.pos=this.lineStart=0,this.curLine=1;if(this.type=z.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=O.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&O.allowHashBang&&this.input.slice(0,2)==="#!")this.skipLineComment(2);this.scopeStack=[],this.enterScope(f1),this.regexpState=null,this.privateNameStack=[]},HO={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};HW.prototype.parse=function(){var O=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(O)};HO.inFunction.get=function(){return(this.currentVarScope().flags&x0)>0};HO.inGenerator.get=function(){return(this.currentVarScope().flags&s6)>0};HO.inAsync.get=function(){return(this.currentVarScope().flags&Q8)>0};HO.canAwait.get=function(){for(var W=this.scopeStack.length-1;W>=0;W--){var O=this.scopeStack[W],M=O.flags;if(M&(Q0|v1))return!1;if(M&x0)return(M&Q8)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};HO.allowSuper.get=function(){var W=this.currentThisScope(),O=W.flags;return(O&ZL)>0||this.options.allowSuperOutsideMethod};HO.allowDirectSuper.get=function(){return(this.currentThisScope().flags&r6)>0};HO.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};HO.allowNewDotTarget.get=function(){for(var W=this.scopeStack.length-1;W>=0;W--){var O=this.scopeStack[W],M=O.flags;if(M&(Q0|v1)||M&x0&&!(M&S8))return!0}return!1};HO.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Q0)>0};HW.extend=function(){var O=[],M=arguments.length;while(M--)O[M]=arguments[M];var L=this;for(var $=0;$<O.length;$++)L=O[$](L);return L};HW.parse=function(O,M){return new this(M,O).parse()};HW.parseExpressionAt=function(O,M,L){var $=new this(L,O,M);return $.nextToken(),$.parseExpression()};HW.tokenizer=function(O,M){return new this(M,O)};Object.defineProperties(HW.prototype,HO);var IW=HW.prototype,wK=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;IW.strictDirective=function(W){if(this.options.ecmaVersion<5)return!1;for(;;){BW.lastIndex=W,W+=BW.exec(this.input)[0].length;var O=wK.exec(this.input.slice(W));if(!O)return!1;if((O[1]||O[2])==="use strict"){BW.lastIndex=W+O[0].length;var M=BW.exec(this.input),L=M.index+M[0].length,$=this.input.charAt(L);return $===";"||$==="}"||uW.test(M[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test($)||$==="!"&&this.input.charAt(L+1)==="=")}if(W+=O[0].length,BW.lastIndex=W,W+=BW.exec(this.input)[0].length,this.input[W]===";")W++}};IW.eat=function(W){if(this.type===W)return this.next(),!0;else return!1};IW.isContextual=function(W){return this.type===z.name&&this.value===W&&!this.containsEsc};IW.eatContextual=function(W){if(!this.isContextual(W))return!1;return this.next(),!0};IW.expectContextual=function(W){if(!this.eatContextual(W))this.unexpected()};IW.canInsertSemicolon=function(){return this.type===z.eof||this.type===z.braceR||uW.test(this.input.slice(this.lastTokEnd,this.start))};IW.insertSemicolon=function(){if(this.canInsertSemicolon()){if(this.options.onInsertedSemicolon)this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc);return!0}};IW.semicolon=function(){if(!this.eat(z.semi)&&!this.insertSemicolon())this.unexpected()};IW.afterTrailingComma=function(W,O){if(this.type===W){if(this.options.onTrailingComma)this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc);if(!O)this.next();return!0}};IW.expect=function(W){this.eat(W)||this.unexpected()};IW.unexpected=function(W){this.raise(W!=null?W:this.start,"Unexpected token")};var GL=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};IW.checkPatternErrors=function(W,O){if(!W)return;if(W.trailingComma>-1)this.raiseRecoverable(W.trailingComma,"Comma is not permitted after the rest element");var M=O?W.parenthesizedAssign:W.parenthesizedBind;if(M>-1)this.raiseRecoverable(M,O?"Assigning to rvalue":"Parenthesized pattern")};IW.checkExpressionErrors=function(W,O){if(!W)return!1;var{shorthandAssign:M,doubleProto:L}=W;if(!O)return M>=0||L>=0;if(M>=0)this.raise(M,"Shorthand property assignments are valid only in destructuring patterns");if(L>=0)this.raiseRecoverable(L,"Redefinition of __proto__ property")};IW.checkYieldAwaitInDefaultParams=function(){if(this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos))this.raise(this.yieldPos,"Yield expression cannot be a default value");if(this.awaitPos)this.raise(this.awaitPos,"Await expression cannot be a default value")};IW.isSimpleAssignTarget=function(W){if(W.type==="ParenthesizedExpression")return this.isSimpleAssignTarget(W.expression);return W.type==="Identifier"||W.type==="MemberExpression"};var x=HW.prototype;x.parseTopLevel=function(W){var O=Object.create(null);if(!W.body)W.body=[];while(this.type!==z.eof){var M=this.parseStatement(null,!0,O);W.body.push(M)}if(this.inModule)for(var L=0,$=Object.keys(this.undefinedExports);L<$.length;L+=1){var Y=$[L];this.raiseRecoverable(this.undefinedExports[Y].start,"Export '"+Y+"' is not defined")}return this.adaptDirectivePrologue(W.body),this.next(),W.sourceType=this.options.sourceType,this.finishNode(W,"Program")};var z8={kind:"loop"},CK={kind:"switch"};x.isLet=function(W){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;BW.lastIndex=this.pos;var O=BW.exec(this.input),M=this.pos+O[0].length,L=this.input.charCodeAt(M);if(L===91||L===92)return!0;if(W)return!1;if(L===123||L>55295&&L<56320)return!0;if(VO(L,!0)){var $=M+1;while(rO(L=this.input.charCodeAt($),!0))++$;if(L===92||L>55295&&L<56320)return!0;var Y=this.input.slice(M,$);if(!zK.test(Y))return!0}return!1};x.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;BW.lastIndex=this.pos;var W=BW.exec(this.input),O=this.pos+W[0].length,M;return!uW.test(this.input.slice(this.pos,O))&&this.input.slice(O,O+8)==="function"&&(O+8===this.input.length||!(rO(M=this.input.charCodeAt(O+8))||M>55295&&M<56320))};x.isUsingKeyword=function(W,O){if(this.options.ecmaVersion<17||!this.isContextual(W?"await":"using"))return!1;BW.lastIndex=this.pos;var M=BW.exec(this.input),L=this.pos+M[0].length;if(uW.test(this.input.slice(this.pos,L)))return!1;if(W){var $=L+5,Y;if(this.input.slice(L,$)!=="using"||$===this.input.length||rO(Y=this.input.charCodeAt($))||Y>55295&&Y<56320)return!1;BW.lastIndex=$;var J=BW.exec(this.input);if(J&&uW.test(this.input.slice($,$+J[0].length)))return!1}if(O){var A=L+2,Z;if(this.input.slice(L,A)==="of"){if(A===this.input.length||!rO(Z=this.input.charCodeAt(A))&&!(Z>55295&&Z<56320))return!1}}var X=this.input.charCodeAt(L);return VO(X,!0)||X===92};x.isAwaitUsing=function(W){return this.isUsingKeyword(!0,W)};x.isUsing=function(W){return this.isUsingKeyword(!1,W)};x.parseStatement=function(W,O,M){var L=this.type,$=this.startNode(),Y;if(this.isLet(W))L=z._var,Y="let";switch(L){case z._break:case z._continue:return this.parseBreakContinueStatement($,L.keyword);case z._debugger:return this.parseDebuggerStatement($);case z._do:return this.parseDoStatement($);case z._for:return this.parseForStatement($);case z._function:if(W&&(this.strict||W!=="if"&&W!=="label")&&this.options.ecmaVersion>=6)this.unexpected();return this.parseFunctionStatement($,!1,!W);case z._class:if(W)this.unexpected();return this.parseClass($,!0);case z._if:return this.parseIfStatement($);case z._return:return this.parseReturnStatement($);case z._switch:return this.parseSwitchStatement($);case z._throw:return this.parseThrowStatement($);case z._try:return this.parseTryStatement($);case z._const:case z._var:if(Y=Y||this.value,W&&Y!=="var")this.unexpected();return this.parseVarStatement($,Y);case z._while:return this.parseWhileStatement($);case z._with:return this.parseWithStatement($);case z.braceL:return this.parseBlock(!0,$);case z.semi:return this.parseEmptyStatement($);case z._export:case z._import:if(this.options.ecmaVersion>10&&L===z._import){BW.lastIndex=this.pos;var J=BW.exec(this.input),A=this.pos+J[0].length,Z=this.input.charCodeAt(A);if(Z===40||Z===46)return this.parseExpressionStatement($,this.parseExpression())}if(!this.options.allowImportExportEverywhere){if(!O)this.raise(this.start,"'import' and 'export' may only appear at the top level");if(!this.inModule)this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")}return L===z._import?this.parseImport($):this.parseExport($,M);default:if(this.isAsyncFunction()){if(W)this.unexpected();return this.next(),this.parseFunctionStatement($,!0,!W)}var X=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(X){if(O&&this.options.sourceType==="script")this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`");if(X==="await using"){if(!this.canAwait)this.raise(this.start,"Await using cannot appear outside of async function");this.next()}return this.next(),this.parseVar($,!1,X),this.semicolon(),this.finishNode($,"VariableDeclaration")}var G=this.value,Q=this.parseExpression();if(L===z.name&&Q.type==="Identifier"&&this.eat(z.colon))return this.parseLabeledStatement($,G,Q,W);else return this.parseExpressionStatement($,Q)}};x.parseBreakContinueStatement=function(W,O){var M=O==="break";if(this.next(),this.eat(z.semi)||this.insertSemicolon())W.label=null;else if(this.type!==z.name)this.unexpected();else W.label=this.parseIdent(),this.semicolon();var L=0;for(;L<this.labels.length;++L){var $=this.labels[L];if(W.label==null||$.name===W.label.name){if($.kind!=null&&(M||$.kind==="loop"))break;if(W.label&&M)break}}if(L===this.labels.length)this.raise(W.start,"Unsyntactic "+O);return this.finishNode(W,M?"BreakStatement":"ContinueStatement")};x.parseDebuggerStatement=function(W){return this.next(),this.semicolon(),this.finishNode(W,"DebuggerStatement")};x.parseDoStatement=function(W){if(this.next(),this.labels.push(z8),W.body=this.parseStatement("do"),this.labels.pop(),this.expect(z._while),W.test=this.parseParenExpression(),this.options.ecmaVersion>=6)this.eat(z.semi);else this.semicolon();return this.finishNode(W,"DoWhileStatement")};x.parseForStatement=function(W){this.next();var O=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(z8),this.enterScope(0),this.expect(z.parenL),this.type===z.semi){if(O>-1)this.unexpected(O);return this.parseFor(W,null)}var M=this.isLet();if(this.type===z._var||this.type===z._const||M){var L=this.startNode(),$=M?"let":this.value;return this.next(),this.parseVar(L,!0,$),this.finishNode(L,"VariableDeclaration"),this.parseForAfterInit(W,L,O)}var Y=this.isContextual("let"),J=!1,A=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(A){var Z=this.startNode();if(this.next(),A==="await using")this.next();return this.parseVar(Z,!0,A),this.finishNode(Z,"VariableDeclaration"),this.parseForAfterInit(W,Z,O)}var X=this.containsEsc,G=new GL,Q=this.start,S=O>-1?this.parseExprSubscripts(G,"await"):this.parseExpression(!0,G);if(this.type===z._in||(J=this.options.ecmaVersion>=6&&this.isContextual("of"))){if(O>-1){if(this.type===z._in)this.unexpected(O);W.await=!0}else if(J&&this.options.ecmaVersion>=8){if(S.start===Q&&!X&&S.type==="Identifier"&&S.name==="async")this.unexpected();else if(this.options.ecmaVersion>=9)W.await=!1}if(Y&&J)this.raise(S.start,"The left-hand side of a for-of loop may not start with 'let'.");return this.toAssignable(S,!1,G),this.checkLValPattern(S),this.parseForIn(W,S)}else this.checkExpressionErrors(G,!0);if(O>-1)this.unexpected(O);return this.parseFor(W,S)};x.parseForAfterInit=function(W,O,M){if((this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&O.declarations.length===1){if(this.options.ecmaVersion>=9)if(this.type===z._in){if(M>-1)this.unexpected(M)}else W.await=M>-1;return this.parseForIn(W,O)}if(M>-1)this.unexpected(M);return this.parseFor(W,O)};x.parseFunctionStatement=function(W,O,M){return this.next(),this.parseFunction(W,k1|(M?0:A8),!1,O)};x.parseIfStatement=function(W){return this.next(),W.test=this.parseParenExpression(),W.consequent=this.parseStatement("if"),W.alternate=this.eat(z._else)?this.parseStatement("if"):null,this.finishNode(W,"IfStatement")};x.parseReturnStatement=function(W){if(!this.inFunction&&!this.options.allowReturnOutsideFunction)this.raise(this.start,"'return' outside of function");if(this.next(),this.eat(z.semi)||this.insertSemicolon())W.argument=null;else W.argument=this.parseExpression(),this.semicolon();return this.finishNode(W,"ReturnStatement")};x.parseSwitchStatement=function(W){this.next(),W.discriminant=this.parseParenExpression(),W.cases=[],this.expect(z.braceL),this.labels.push(CK),this.enterScope(0);var O;for(var M=!1;this.type!==z.braceR;)if(this.type===z._case||this.type===z._default){var L=this.type===z._case;if(O)this.finishNode(O,"SwitchCase");if(W.cases.push(O=this.startNode()),O.consequent=[],this.next(),L)O.test=this.parseExpression();else{if(M)this.raiseRecoverable(this.lastTokStart,"Multiple default clauses");M=!0,O.test=null}this.expect(z.colon)}else{if(!O)this.unexpected();O.consequent.push(this.parseStatement(null))}if(this.exitScope(),O)this.finishNode(O,"SwitchCase");return this.next(),this.labels.pop(),this.finishNode(W,"SwitchStatement")};x.parseThrowStatement=function(W){if(this.next(),uW.test(this.input.slice(this.lastTokEnd,this.start)))this.raise(this.lastTokEnd,"Illegal newline after throw");return W.argument=this.parseExpression(),this.semicolon(),this.finishNode(W,"ThrowStatement")};var NK=[];x.parseCatchClauseParam=function(){var W=this.parseBindingAtom(),O=W.type==="Identifier";return this.enterScope(O?n6:0),this.checkLValPattern(W,O?o6:bO),this.expect(z.parenR),W};x.parseTryStatement=function(W){if(this.next(),W.block=this.parseBlock(),W.handler=null,this.type===z._catch){var O=this.startNode();if(this.next(),this.eat(z.parenL))O.param=this.parseCatchClauseParam();else{if(this.options.ecmaVersion<10)this.unexpected();O.param=null,this.enterScope(0)}O.body=this.parseBlock(!1),this.exitScope(),W.handler=this.finishNode(O,"CatchClause")}if(W.finalizer=this.eat(z._finally)?this.parseBlock():null,!W.handler&&!W.finalizer)this.raise(W.start,"Missing catch or finally clause");return this.finishNode(W,"TryStatement")};x.parseVarStatement=function(W,O,M){return this.next(),this.parseVar(W,!1,O,M),this.semicolon(),this.finishNode(W,"VariableDeclaration")};x.parseWhileStatement=function(W){return this.next(),W.test=this.parseParenExpression(),this.labels.push(z8),W.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(W,"WhileStatement")};x.parseWithStatement=function(W){if(this.strict)this.raise(this.start,"'with' in strict mode");return this.next(),W.object=this.parseParenExpression(),W.body=this.parseStatement("with"),this.finishNode(W,"WithStatement")};x.parseEmptyStatement=function(W){return this.next(),this.finishNode(W,"EmptyStatement")};x.parseLabeledStatement=function(W,O,M,L){for(var $=0,Y=this.labels;$<Y.length;$+=1){var J=Y[$];if(J.name===O)this.raise(M.start,"Label '"+O+"' is already declared")}var A=this.type.isLoop?"loop":this.type===z._switch?"switch":null;for(var Z=this.labels.length-1;Z>=0;Z--){var X=this.labels[Z];if(X.statementStart===W.start)X.statementStart=this.start,X.kind=A;else break}return this.labels.push({name:O,kind:A,statementStart:this.start}),W.body=this.parseStatement(L?L.indexOf("label")===-1?L+"label":L:"label"),this.labels.pop(),W.label=M,this.finishNode(W,"LabeledStatement")};x.parseExpressionStatement=function(W,O){return W.expression=O,this.semicolon(),this.finishNode(W,"ExpressionStatement")};x.parseBlock=function(W,O,M){if(W===void 0)W=!0;if(O===void 0)O=this.startNode();if(O.body=[],this.expect(z.braceL),W)this.enterScope(0);while(this.type!==z.braceR){var L=this.parseStatement(null);O.body.push(L)}if(M)this.strict=!1;if(this.next(),W)this.exitScope();return this.finishNode(O,"BlockStatement")};x.parseFor=function(W,O){return W.init=O,this.expect(z.semi),W.test=this.type===z.semi?null:this.parseExpression(),this.expect(z.semi),W.update=this.type===z.parenR?null:this.parseExpression(),this.expect(z.parenR),W.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(W,"ForStatement")};x.parseForIn=function(W,O){var M=this.type===z._in;if(this.next(),O.type==="VariableDeclaration"&&O.declarations[0].init!=null&&(!M||this.options.ecmaVersion<8||this.strict||O.kind!=="var"||O.declarations[0].id.type!=="Identifier"))this.raise(O.start,(M?"for-in":"for-of")+" loop variable declaration may not have an initializer");return W.left=O,W.right=M?this.parseExpression():this.parseMaybeAssign(),this.expect(z.parenR),W.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(W,M?"ForInStatement":"ForOfStatement")};x.parseVar=function(W,O,M,L){W.declarations=[],W.kind=M;for(;;){var $=this.startNode();if(this.parseVarId($,M),this.eat(z.eq))$.init=this.parseMaybeAssign(O);else if(!L&&M==="const"&&!(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual("of")))this.unexpected();else if(!L&&(M==="using"||M==="await using")&&this.options.ecmaVersion>=17&&this.type!==z._in&&!this.isContextual("of"))this.raise(this.lastTokEnd,"Missing initializer in "+M+" declaration");else if(!L&&$.id.type!=="Identifier"&&!(O&&(this.type===z._in||this.isContextual("of"))))this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value");else $.init=null;if(W.declarations.push(this.finishNode($,"VariableDeclarator")),!this.eat(z.comma))break}return W};x.parseVarId=function(W,O){W.id=O==="using"||O==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(W.id,O==="var"?U8:bO,!1)};var k1=1,A8=2,e6=4;x.parseFunction=function(W,O,M,L,$){if(this.initFunction(W),this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!L){if(this.type===z.star&&O&A8)this.unexpected();W.generator=this.eat(z.star)}if(this.options.ecmaVersion>=8)W.async=!!L;if(O&k1){if(W.id=O&e6&&this.type!==z.name?null:this.parseIdent(),W.id&&!(O&A8))this.checkLValSimple(W.id,this.strict||W.generator||W.async?this.treatFunctionsAsVar?U8:bO:a6)}var Y=this.yieldPos,J=this.awaitPos,A=this.awaitIdentPos;if(this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(R8(W.async,W.generator)),!(O&k1))W.id=this.type===z.name?this.parseIdent():null;return this.parseFunctionParams(W),this.parseFunctionBody(W,M,!1,$),this.yieldPos=Y,this.awaitPos=J,this.awaitIdentPos=A,this.finishNode(W,O&k1?"FunctionDeclaration":"FunctionExpression")};x.parseFunctionParams=function(W){this.expect(z.parenL),W.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};x.parseClass=function(W,O){this.next();var M=this.strict;this.strict=!0,this.parseClassId(W,O),this.parseClassSuper(W);var L=this.enterClassBody(),$=this.startNode(),Y=!1;$.body=[],this.expect(z.braceL);while(this.type!==z.braceR){var J=this.parseClassElement(W.superClass!==null);if(J){if($.body.push(J),J.type==="MethodDefinition"&&J.kind==="constructor"){if(Y)this.raiseRecoverable(J.start,"Duplicate constructor in the same class");Y=!0}else if(J.key&&J.key.type==="PrivateIdentifier"&&PK(L,J))this.raiseRecoverable(J.key.start,"Identifier '#"+J.key.name+"' has already been declared")}}return this.strict=M,this.next(),W.body=this.finishNode($,"ClassBody"),this.exitClassBody(),this.finishNode(W,O?"ClassDeclaration":"ClassExpression")};x.parseClassElement=function(W){if(this.eat(z.semi))return null;var O=this.options.ecmaVersion,M=this.startNode(),L="",$=!1,Y=!1,J="method",A=!1;if(this.eatContextual("static")){if(O>=13&&this.eat(z.braceL))return this.parseClassStaticBlock(M),M;if(this.isClassElementNameStart()||this.type===z.star)A=!0;else L="static"}if(M.static=A,!L&&O>=8&&this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===z.star)&&!this.canInsertSemicolon())Y=!0;else L="async";if(!L&&(O>=9||!Y)&&this.eat(z.star))$=!0;if(!L&&!Y&&!$){var Z=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())J=Z;else L=Z}if(L)M.computed=!1,M.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),M.key.name=L,this.finishNode(M.key,"Identifier");else this.parseClassElementName(M);if(O<13||this.type===z.parenL||J!=="method"||$||Y){var X=!M.static&&$L(M,"constructor"),G=X&&W;if(X&&J!=="method")this.raise(M.key.start,"Constructor can't have get/set modifier");M.kind=X?"constructor":J,this.parseClassMethod(M,$,Y,G)}else this.parseClassField(M);return M};x.isClassElementNameStart=function(){return this.type===z.name||this.type===z.privateId||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword};x.parseClassElementName=function(W){if(this.type===z.privateId){if(this.value==="constructor")this.raise(this.start,"Classes can't have an element named '#constructor'");W.computed=!1,W.key=this.parsePrivateIdent()}else this.parsePropertyName(W)};x.parseClassMethod=function(W,O,M,L){var $=W.key;if(W.kind==="constructor"){if(O)this.raise($.start,"Constructor can't be a generator");if(M)this.raise($.start,"Constructor can't be an async method")}else if(W.static&&$L(W,"prototype"))this.raise($.start,"Classes may not have a static property named prototype");var Y=W.value=this.parseMethod(O,M,L);if(W.kind==="get"&&Y.params.length!==0)this.raiseRecoverable(Y.start,"getter should have no params");if(W.kind==="set"&&Y.params.length!==1)this.raiseRecoverable(Y.start,"setter should have exactly one param");if(W.kind==="set"&&Y.params[0].type==="RestElement")this.raiseRecoverable(Y.params[0].start,"Setter cannot use rest params");return this.finishNode(W,"MethodDefinition")};x.parseClassField=function(W){if($L(W,"constructor"))this.raise(W.key.start,"Classes can't have a field named 'constructor'");else if(W.static&&$L(W,"prototype"))this.raise(W.key.start,"Classes can't have a static field named 'prototype'");if(this.eat(z.eq))this.enterScope(v1|ZL),W.value=this.parseMaybeAssign(),this.exitScope();else W.value=null;return this.semicolon(),this.finishNode(W,"PropertyDefinition")};x.parseClassStaticBlock=function(W){W.body=[];var O=this.labels;this.labels=[],this.enterScope(Q0|ZL);while(this.type!==z.braceR){var M=this.parseStatement(null);W.body.push(M)}return this.next(),this.exitScope(),this.labels=O,this.finishNode(W,"StaticBlock")};x.parseClassId=function(W,O){if(this.type===z.name){if(W.id=this.parseIdent(),O)this.checkLValSimple(W.id,bO,!1)}else{if(O===!0)this.unexpected();W.id=null}};x.parseClassSuper=function(W){W.superClass=this.eat(z._extends)?this.parseExprSubscripts(null,!1):null};x.enterClassBody=function(){var W={declared:Object.create(null),used:[]};return this.privateNameStack.push(W),W.declared};x.exitClassBody=function(){var W=this.privateNameStack.pop(),O=W.declared,M=W.used;if(!this.options.checkPrivateFields)return;var L=this.privateNameStack.length,$=L===0?null:this.privateNameStack[L-1];for(var Y=0;Y<M.length;++Y){var J=M[Y];if(!v0(O,J.name))if($)$.used.push(J);else this.raiseRecoverable(J.start,"Private field '#"+J.name+"' must be declared in an enclosing class")}};function PK(W,O){var M=O.key.name,L=W[M],$="true";if(O.type==="MethodDefinition"&&(O.kind==="get"||O.kind==="set"))$=(O.static?"s":"i")+O.kind;if(L==="iget"&&$==="iset"||L==="iset"&&$==="iget"||L==="sget"&&$==="sset"||L==="sset"&&$==="sget")return W[M]="true",!1;else if(!L)return W[M]=$,!1;else return!0}function $L(W,O){var{computed:M,key:L}=W;return!M&&(L.type==="Identifier"&&L.name===O||L.type==="Literal"&&L.value===O)}x.parseExportAllDeclaration=function(W,O){if(this.options.ecmaVersion>=11)if(this.eatContextual("as"))W.exported=this.parseModuleExportName(),this.checkExport(O,W.exported,this.lastTokStart);else W.exported=null;if(this.expectContextual("from"),this.type!==z.string)this.unexpected();if(W.source=this.parseExprAtom(),this.options.ecmaVersion>=16)W.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(W,"ExportAllDeclaration")};x.parseExport=function(W,O){if(this.next(),this.eat(z.star))return this.parseExportAllDeclaration(W,O);if(this.eat(z._default))return this.checkExport(O,"default",this.lastTokStart),W.declaration=this.parseExportDefaultDeclaration(),this.finishNode(W,"ExportDefaultDeclaration");if(this.shouldParseExportStatement()){if(W.declaration=this.parseExportDeclaration(W),W.declaration.type==="VariableDeclaration")this.checkVariableExport(O,W.declaration.declarations);else this.checkExport(O,W.declaration.id,W.declaration.id.start);if(W.specifiers=[],W.source=null,this.options.ecmaVersion>=16)W.attributes=[]}else{if(W.declaration=null,W.specifiers=this.parseExportSpecifiers(O),this.eatContextual("from")){if(this.type!==z.string)this.unexpected();if(W.source=this.parseExprAtom(),this.options.ecmaVersion>=16)W.attributes=this.parseWithClause()}else{for(var M=0,L=W.specifiers;M<L.length;M+=1){var $=L[M];if(this.checkUnreserved($.local),this.checkLocalExport($.local),$.local.type==="Literal")this.raise($.local.start,"A string literal cannot be used as an exported binding without `from`.")}if(W.source=null,this.options.ecmaVersion>=16)W.attributes=[]}this.semicolon()}return this.finishNode(W,"ExportNamedDeclaration")};x.parseExportDeclaration=function(W){return this.parseStatement(null)};x.parseExportDefaultDeclaration=function(){var W;if(this.type===z._function||(W=this.isAsyncFunction())){var O=this.startNode();if(this.next(),W)this.next();return this.parseFunction(O,k1|e6,!1,W)}else if(this.type===z._class){var M=this.startNode();return this.parseClass(M,"nullableID")}else{var L=this.parseMaybeAssign();return this.semicolon(),L}};x.checkExport=function(W,O,M){if(!W)return;if(typeof O!=="string")O=O.type==="Identifier"?O.name:O.value;if(v0(W,O))this.raiseRecoverable(M,"Duplicate export '"+O+"'");W[O]=!0};x.checkPatternExport=function(W,O){var M=O.type;if(M==="Identifier")this.checkExport(W,O,O.start);else if(M==="ObjectPattern")for(var L=0,$=O.properties;L<$.length;L+=1){var Y=$[L];this.checkPatternExport(W,Y)}else if(M==="ArrayPattern")for(var J=0,A=O.elements;J<A.length;J+=1){var Z=A[J];if(Z)this.checkPatternExport(W,Z)}else if(M==="Property")this.checkPatternExport(W,O.value);else if(M==="AssignmentPattern")this.checkPatternExport(W,O.left);else if(M==="RestElement")this.checkPatternExport(W,O.argument)};x.checkVariableExport=function(W,O){if(!W)return;for(var M=0,L=O;M<L.length;M+=1){var $=L[M];this.checkPatternExport(W,$.id)}};x.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};x.parseExportSpecifier=function(W){var O=this.startNode();return O.local=this.parseModuleExportName(),O.exported=this.eatContextual("as")?this.parseModuleExportName():O.local,this.checkExport(W,O.exported,O.exported.start),this.finishNode(O,"ExportSpecifier")};x.parseExportSpecifiers=function(W){var O=[],M=!0;this.expect(z.braceL);while(!this.eat(z.braceR)){if(!M){if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break}else M=!1;O.push(this.parseExportSpecifier(W))}return O};x.parseImport=function(W){if(this.next(),this.type===z.string)W.specifiers=NK,W.source=this.parseExprAtom();else W.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),W.source=this.type===z.string?this.parseExprAtom():this.unexpected();if(this.options.ecmaVersion>=16)W.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(W,"ImportDeclaration")};x.parseImportSpecifier=function(){var W=this.startNode();if(W.imported=this.parseModuleExportName(),this.eatContextual("as"))W.local=this.parseIdent();else this.checkUnreserved(W.imported),W.local=W.imported;return this.checkLValSimple(W.local,bO),this.finishNode(W,"ImportSpecifier")};x.parseImportDefaultSpecifier=function(){var W=this.startNode();return W.local=this.parseIdent(),this.checkLValSimple(W.local,bO),this.finishNode(W,"ImportDefaultSpecifier")};x.parseImportNamespaceSpecifier=function(){var W=this.startNode();return this.next(),this.expectContextual("as"),W.local=this.parseIdent(),this.checkLValSimple(W.local,bO),this.finishNode(W,"ImportNamespaceSpecifier")};x.parseImportSpecifiers=function(){var W=[],O=!0;if(this.type===z.name){if(W.push(this.parseImportDefaultSpecifier()),!this.eat(z.comma))return W}if(this.type===z.star)return W.push(this.parseImportNamespaceSpecifier()),W;this.expect(z.braceL);while(!this.eat(z.braceR)){if(!O){if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break}else O=!1;W.push(this.parseImportSpecifier())}return W};x.parseWithClause=function(){var W=[];if(!this.eat(z._with))return W;this.expect(z.braceL);var O={},M=!0;while(!this.eat(z.braceR)){if(!M){if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break}else M=!1;var L=this.parseImportAttribute(),$=L.key.type==="Identifier"?L.key.name:L.key.value;if(v0(O,$))this.raiseRecoverable(L.key.start,"Duplicate attribute key '"+$+"'");O[$]=!0,W.push(L)}return W};x.parseImportAttribute=function(){var W=this.startNode();if(W.key=this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(z.colon),this.type!==z.string)this.unexpected();return W.value=this.parseExprAtom(),this.finishNode(W,"ImportAttribute")};x.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===z.string){var W=this.parseLiteral(this.value);if(EK.test(W.value))this.raise(W.start,"An export name cannot include a lone surrogate.");return W}return this.parseIdent(!0)};x.adaptDirectivePrologue=function(W){for(var O=0;O<W.length&&this.isDirectiveCandidate(W[O]);++O)W[O].directive=W[O].expression.raw.slice(1,-1)};x.isDirectiveCandidate=function(W){return this.options.ecmaVersion>=5&&W.type==="ExpressionStatement"&&W.expression.type==="Literal"&&typeof W.expression.value==="string"&&(this.input[W.start]==='"'||this.input[W.start]==="'")};var WO=HW.prototype;WO.toAssignable=function(W,O,M){if(this.options.ecmaVersion>=6&&W)switch(W.type){case"Identifier":if(this.inAsync&&W.name==="await")this.raise(W.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":if(W.type="ObjectPattern",M)this.checkPatternErrors(M,!0);for(var L=0,$=W.properties;L<$.length;L+=1){var Y=$[L];if(this.toAssignable(Y,O),Y.type==="RestElement"&&(Y.argument.type==="ArrayPattern"||Y.argument.type==="ObjectPattern"))this.raise(Y.argument.start,"Unexpected token")}break;case"Property":if(W.kind!=="init")this.raise(W.key.start,"Object pattern can't contain getter or setter");this.toAssignable(W.value,O);break;case"ArrayExpression":if(W.type="ArrayPattern",M)this.checkPatternErrors(M,!0);this.toAssignableList(W.elements,O);break;case"SpreadElement":if(W.type="RestElement",this.toAssignable(W.argument,O),W.argument.type==="AssignmentPattern")this.raise(W.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":if(W.operator!=="=")this.raise(W.left.end,"Only '=' operator can be used for specifying default value.");W.type="AssignmentPattern",delete W.operator,this.toAssignable(W.left,O);break;case"ParenthesizedExpression":this.toAssignable(W.expression,O,M);break;case"ChainExpression":this.raiseRecoverable(W.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!O)break;default:this.raise(W.start,"Assigning to rvalue")}else if(M)this.checkPatternErrors(M,!0);return W};WO.toAssignableList=function(W,O){var M=W.length;for(var L=0;L<M;L++){var $=W[L];if($)this.toAssignable($,O)}if(M){var Y=W[M-1];if(this.options.ecmaVersion===6&&O&&Y&&Y.type==="RestElement"&&Y.argument.type!=="Identifier")this.unexpected(Y.argument.start)}return W};WO.parseSpread=function(W){var O=this.startNode();return this.next(),O.argument=this.parseMaybeAssign(!1,W),this.finishNode(O,"SpreadElement")};WO.parseRestBinding=function(){var W=this.startNode();if(this.next(),this.options.ecmaVersion===6&&this.type!==z.name)this.unexpected();return W.argument=this.parseBindingAtom(),this.finishNode(W,"RestElement")};WO.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case z.bracketL:var W=this.startNode();return this.next(),W.elements=this.parseBindingList(z.bracketR,!0,!0),this.finishNode(W,"ArrayPattern");case z.braceL:return this.parseObj(!0)}return this.parseIdent()};WO.parseBindingList=function(W,O,M,L){var $=[],Y=!0;while(!this.eat(W)){if(Y)Y=!1;else this.expect(z.comma);if(O&&this.type===z.comma)$.push(null);else if(M&&this.afterTrailingComma(W))break;else if(this.type===z.ellipsis){var J=this.parseRestBinding();if(this.parseBindingListItem(J),$.push(J),this.type===z.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");this.expect(W);break}else $.push(this.parseAssignableListItem(L))}return $};WO.parseAssignableListItem=function(W){var O=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(O),O};WO.parseBindingListItem=function(W){return W};WO.parseMaybeDefault=function(W,O,M){if(M=M||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(z.eq))return M;var L=this.startNodeAt(W,O);return L.left=M,L.right=this.parseMaybeAssign(),this.finishNode(L,"AssignmentPattern")};WO.checkLValSimple=function(W,O,M){if(O===void 0)O=LL;var L=O!==LL;switch(W.type){case"Identifier":if(this.strict&&this.reservedWordsStrictBind.test(W.name))this.raiseRecoverable(W.start,(L?"Binding ":"Assigning to ")+W.name+" in strict mode");if(L){if(O===bO&&W.name==="let")this.raiseRecoverable(W.start,"let is disallowed as a lexically bound name");if(M){if(v0(M,W.name))this.raiseRecoverable(W.start,"Argument name clash");M[W.name]=!0}if(O!==t6)this.declareName(W.name,O,W.start)}break;case"ChainExpression":this.raiseRecoverable(W.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(L)this.raiseRecoverable(W.start,"Binding member expression");break;case"ParenthesizedExpression":if(L)this.raiseRecoverable(W.start,"Binding parenthesized expression");return this.checkLValSimple(W.expression,O,M);default:this.raise(W.start,(L?"Binding":"Assigning to")+" rvalue")}};WO.checkLValPattern=function(W,O,M){if(O===void 0)O=LL;switch(W.type){case"ObjectPattern":for(var L=0,$=W.properties;L<$.length;L+=1){var Y=$[L];this.checkLValInnerPattern(Y,O,M)}break;case"ArrayPattern":for(var J=0,A=W.elements;J<A.length;J+=1){var Z=A[J];if(Z)this.checkLValInnerPattern(Z,O,M)}break;default:this.checkLValSimple(W,O,M)}};WO.checkLValInnerPattern=function(W,O,M){if(O===void 0)O=LL;switch(W.type){case"Property":this.checkLValInnerPattern(W.value,O,M);break;case"AssignmentPattern":this.checkLValPattern(W.left,O,M);break;case"RestElement":this.checkLValPattern(W.argument,O,M);break;default:this.checkLValPattern(W,O,M)}};var XO=function(O,M,L,$,Y){this.token=O,this.isExpr=!!M,this.preserveSpace=!!L,this.override=$,this.generator=!!Y},JW={b_stat:new XO("{",!1),b_expr:new XO("{",!0),b_tmpl:new XO("${",!1),p_stat:new XO("(",!1),p_expr:new XO("(",!0),q_tmpl:new XO("`",!0,!0,function(W){return W.tryReadTemplateToken()}),f_stat:new XO("function",!1),f_expr:new XO("function",!0),f_expr_gen:new XO("function",!0,!1,null,!0),f_gen:new XO("function",!1,!1,null,!0)},g0=HW.prototype;g0.initialContext=function(){return[JW.b_stat]};g0.curContext=function(){return this.context[this.context.length-1]};g0.braceIsBlock=function(W){var O=this.curContext();if(O===JW.f_expr||O===JW.f_stat)return!0;if(W===z.colon&&(O===JW.b_stat||O===JW.b_expr))return!O.isExpr;if(W===z._return||W===z.name&&this.exprAllowed)return uW.test(this.input.slice(this.lastTokEnd,this.start));if(W===z._else||W===z.semi||W===z.eof||W===z.parenR||W===z.arrow)return!0;if(W===z.braceL)return O===JW.b_stat;if(W===z._var||W===z._const||W===z.name)return!1;return!this.exprAllowed};g0.inGeneratorContext=function(){for(var W=this.context.length-1;W>=1;W--){var O=this.context[W];if(O.token==="function")return O.generator}return!1};g0.updateContext=function(W){var O,M=this.type;if(M.keyword&&W===z.dot)this.exprAllowed=!1;else if(O=M.updateContext)O.call(this,W);else this.exprAllowed=M.beforeExpr};g0.overrideContext=function(W){if(this.curContext()!==W)this.context[this.context.length-1]=W};z.parenR.updateContext=z.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var W=this.context.pop();if(W===JW.b_stat&&this.curContext().token==="function")W=this.context.pop();this.exprAllowed=!W.isExpr};z.braceL.updateContext=function(W){this.context.push(this.braceIsBlock(W)?JW.b_stat:JW.b_expr),this.exprAllowed=!0};z.dollarBraceL.updateContext=function(){this.context.push(JW.b_tmpl),this.exprAllowed=!0};z.parenL.updateContext=function(W){var O=W===z._if||W===z._for||W===z._with||W===z._while;this.context.push(O?JW.p_stat:JW.p_expr),this.exprAllowed=!0};z.incDec.updateContext=function(){};z._function.updateContext=z._class.updateContext=function(W){if(W.beforeExpr&&W!==z._else&&!(W===z.semi&&this.curContext()!==JW.p_stat)&&!(W===z._return&&uW.test(this.input.slice(this.lastTokEnd,this.start)))&&!((W===z.colon||W===z.braceL)&&this.curContext()===JW.b_stat))this.context.push(JW.f_expr);else this.context.push(JW.f_stat);this.exprAllowed=!1};z.colon.updateContext=function(){if(this.curContext().token==="function")this.context.pop();this.exprAllowed=!0};z.backQuote.updateContext=function(){if(this.curContext()===JW.q_tmpl)this.context.pop();else this.context.push(JW.q_tmpl);this.exprAllowed=!1};z.star.updateContext=function(W){if(W===z._function){var O=this.context.length-1;if(this.context[O]===JW.f_expr)this.context[O]=JW.f_expr_gen;else this.context[O]=JW.f_gen}this.exprAllowed=!0};z.name.updateContext=function(W){var O=!1;if(this.options.ecmaVersion>=6&&W!==z.dot){if(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())O=!0}this.exprAllowed=O};var l=HW.prototype;l.checkPropClash=function(W,O,M){if(this.options.ecmaVersion>=9&&W.type==="SpreadElement")return;if(this.options.ecmaVersion>=6&&(W.computed||W.method||W.shorthand))return;var L=W.key,$;switch(L.type){case"Identifier":$=L.name;break;case"Literal":$=String(L.value);break;default:return}var Y=W.kind;if(this.options.ecmaVersion>=6){if($==="__proto__"&&Y==="init"){if(O.proto)if(M){if(M.doubleProto<0)M.doubleProto=L.start}else this.raiseRecoverable(L.start,"Redefinition of __proto__ property");O.proto=!0}return}$="$"+$;var J=O[$];if(J){var A;if(Y==="init")A=this.strict&&J.init||J.get||J.set;else A=J.init||J[Y];if(A)this.raiseRecoverable(L.start,"Redefinition of property")}else J=O[$]={init:!1,get:!1,set:!1};J[Y]=!0};l.parseExpression=function(W,O){var M=this.start,L=this.startLoc,$=this.parseMaybeAssign(W,O);if(this.type===z.comma){var Y=this.startNodeAt(M,L);Y.expressions=[$];while(this.eat(z.comma))Y.expressions.push(this.parseMaybeAssign(W,O));return this.finishNode(Y,"SequenceExpression")}return $};l.parseMaybeAssign=function(W,O,M){if(this.isContextual("yield"))if(this.inGenerator)return this.parseYield(W);else this.exprAllowed=!1;var L=!1,$=-1,Y=-1,J=-1;if(O)$=O.parenthesizedAssign,Y=O.trailingComma,J=O.doubleProto,O.parenthesizedAssign=O.trailingComma=-1;else O=new GL,L=!0;var A=this.start,Z=this.startLoc;if(this.type===z.parenL||this.type===z.name)this.potentialArrowAt=this.start,this.potentialArrowInForAwait=W==="await";var X=this.parseMaybeConditional(W,O);if(M)X=M.call(this,X,A,Z);if(this.type.isAssign){var G=this.startNodeAt(A,Z);if(G.operator=this.value,this.type===z.eq)X=this.toAssignable(X,!1,O);if(!L)O.parenthesizedAssign=O.trailingComma=O.doubleProto=-1;if(O.shorthandAssign>=X.start)O.shorthandAssign=-1;if(this.type===z.eq)this.checkLValPattern(X);else this.checkLValSimple(X);if(G.left=X,this.next(),G.right=this.parseMaybeAssign(W),J>-1)O.doubleProto=J;return this.finishNode(G,"AssignmentExpression")}else if(L)this.checkExpressionErrors(O,!0);if($>-1)O.parenthesizedAssign=$;if(Y>-1)O.trailingComma=Y;return X};l.parseMaybeConditional=function(W,O){var M=this.start,L=this.startLoc,$=this.parseExprOps(W,O);if(this.checkExpressionErrors(O))return $;if(this.eat(z.question)){var Y=this.startNodeAt(M,L);return Y.test=$,Y.consequent=this.parseMaybeAssign(),this.expect(z.colon),Y.alternate=this.parseMaybeAssign(W),this.finishNode(Y,"ConditionalExpression")}return $};l.parseExprOps=function(W,O){var M=this.start,L=this.startLoc,$=this.parseMaybeUnary(O,!1,!1,W);if(this.checkExpressionErrors(O))return $;return $.start===M&&$.type==="ArrowFunctionExpression"?$:this.parseExprOp($,M,L,-1,W)};l.parseExprOp=function(W,O,M,L,$){var Y=this.type.binop;if(Y!=null&&(!$||this.type!==z._in)){if(Y>L){var J=this.type===z.logicalOR||this.type===z.logicalAND,A=this.type===z.coalesce;if(A)Y=z.logicalAND.binop;var Z=this.value;this.next();var X=this.start,G=this.startLoc,Q=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,$),X,G,Y,$),S=this.buildBinary(O,M,W,Q,Z,J||A);if(J&&this.type===z.coalesce||A&&(this.type===z.logicalOR||this.type===z.logicalAND))this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");return this.parseExprOp(S,O,M,L,$)}}return W};l.buildBinary=function(W,O,M,L,$,Y){if(L.type==="PrivateIdentifier")this.raise(L.start,"Private identifier can only be left side of binary expression");var J=this.startNodeAt(W,O);return J.left=M,J.operator=$,J.right=L,this.finishNode(J,Y?"LogicalExpression":"BinaryExpression")};l.parseMaybeUnary=function(W,O,M,L){var $=this.start,Y=this.startLoc,J;if(this.isContextual("await")&&this.canAwait)J=this.parseAwait(L),O=!0;else if(this.type.prefix){var A=this.startNode(),Z=this.type===z.incDec;if(A.operator=this.value,A.prefix=!0,this.next(),A.argument=this.parseMaybeUnary(null,!0,Z,L),this.checkExpressionErrors(W,!0),Z)this.checkLValSimple(A.argument);else if(this.strict&&A.operator==="delete"&&W4(A.argument))this.raiseRecoverable(A.start,"Deleting local variable in strict mode");else if(A.operator==="delete"&&Z8(A.argument))this.raiseRecoverable(A.start,"Private fields can not be deleted");else O=!0;J=this.finishNode(A,Z?"UpdateExpression":"UnaryExpression")}else if(!O&&this.type===z.privateId){if((L||this.privateNameStack.length===0)&&this.options.checkPrivateFields)this.unexpected();if(J=this.parsePrivateIdent(),this.type!==z._in)this.unexpected()}else{if(J=this.parseExprSubscripts(W,L),this.checkExpressionErrors(W))return J;while(this.type.postfix&&!this.canInsertSemicolon()){var X=this.startNodeAt($,Y);X.operator=this.value,X.prefix=!1,X.argument=J,this.checkLValSimple(J),this.next(),J=this.finishNode(X,"UpdateExpression")}}if(!M&&this.eat(z.starstar))if(O)this.unexpected(this.lastTokStart);else return this.buildBinary($,Y,J,this.parseMaybeUnary(null,!1,!1,L),"**",!1);else return J};function W4(W){return W.type==="Identifier"||W.type==="ParenthesizedExpression"&&W4(W.expression)}function Z8(W){return W.type==="MemberExpression"&&W.property.type==="PrivateIdentifier"||W.type==="ChainExpression"&&Z8(W.expression)||W.type==="ParenthesizedExpression"&&Z8(W.expression)}l.parseExprSubscripts=function(W,O){var M=this.start,L=this.startLoc,$=this.parseExprAtom(W,O);if($.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return $;var Y=this.parseSubscripts($,M,L,!1,O);if(W&&Y.type==="MemberExpression"){if(W.parenthesizedAssign>=Y.start)W.parenthesizedAssign=-1;if(W.parenthesizedBind>=Y.start)W.parenthesizedBind=-1;if(W.trailingComma>=Y.start)W.trailingComma=-1}return Y};l.parseSubscripts=function(W,O,M,L,$){var Y=this.options.ecmaVersion>=8&&W.type==="Identifier"&&W.name==="async"&&this.lastTokEnd===W.end&&!this.canInsertSemicolon()&&W.end-W.start===5&&this.potentialArrowAt===W.start,J=!1;while(!0){var A=this.parseSubscript(W,O,M,L,Y,J,$);if(A.optional)J=!0;if(A===W||A.type==="ArrowFunctionExpression"){if(J){var Z=this.startNodeAt(O,M);Z.expression=A,A=this.finishNode(Z,"ChainExpression")}return A}W=A}};l.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(z.arrow)};l.parseSubscriptAsyncArrow=function(W,O,M,L){return this.parseArrowExpression(this.startNodeAt(W,O),M,!0,L)};l.parseSubscript=function(W,O,M,L,$,Y,J){var A=this.options.ecmaVersion>=11,Z=A&&this.eat(z.questionDot);if(L&&Z)this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var X=this.eat(z.bracketL);if(X||Z&&this.type!==z.parenL&&this.type!==z.backQuote||this.eat(z.dot)){var G=this.startNodeAt(O,M);if(G.object=W,X)G.property=this.parseExpression(),this.expect(z.bracketR);else if(this.type===z.privateId&&W.type!=="Super")G.property=this.parsePrivateIdent();else G.property=this.parseIdent(this.options.allowReserved!=="never");if(G.computed=!!X,A)G.optional=Z;W=this.finishNode(G,"MemberExpression")}else if(!L&&this.eat(z.parenL)){var Q=new GL,S=this.yieldPos,U=this.awaitPos,V=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var R=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1,Q);if($&&!Z&&this.shouldParseAsyncArrow()){if(this.checkPatternErrors(Q,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0)this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function");return this.yieldPos=S,this.awaitPos=U,this.awaitIdentPos=V,this.parseSubscriptAsyncArrow(O,M,R,J)}this.checkExpressionErrors(Q,!0),this.yieldPos=S||this.yieldPos,this.awaitPos=U||this.awaitPos,this.awaitIdentPos=V||this.awaitIdentPos;var K=this.startNodeAt(O,M);if(K.callee=W,K.arguments=R,A)K.optional=Z;W=this.finishNode(K,"CallExpression")}else if(this.type===z.backQuote){if(Z||Y)this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var T=this.startNodeAt(O,M);T.tag=W,T.quasi=this.parseTemplate({isTagged:!0}),W=this.finishNode(T,"TaggedTemplateExpression")}return W};l.parseExprAtom=function(W,O,M){if(this.type===z.slash)this.readRegexp();var L,$=this.potentialArrowAt===this.start;switch(this.type){case z._super:if(!this.allowSuper)this.raise(this.start,"'super' keyword outside a method");if(L=this.startNode(),this.next(),this.type===z.parenL&&!this.allowDirectSuper)this.raise(L.start,"super() call outside constructor of a subclass");if(this.type!==z.dot&&this.type!==z.bracketL&&this.type!==z.parenL)this.unexpected();return this.finishNode(L,"Super");case z._this:return L=this.startNode(),this.next(),this.finishNode(L,"ThisExpression");case z.name:var Y=this.start,J=this.startLoc,A=this.containsEsc,Z=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!A&&Z.name==="async"&&!this.canInsertSemicolon()&&this.eat(z._function))return this.overrideContext(JW.f_expr),this.parseFunction(this.startNodeAt(Y,J),0,!1,!0,O);if($&&!this.canInsertSemicolon()){if(this.eat(z.arrow))return this.parseArrowExpression(this.startNodeAt(Y,J),[Z],!1,O);if(this.options.ecmaVersion>=8&&Z.name==="async"&&this.type===z.name&&!A&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc)){if(Z=this.parseIdent(!1),this.canInsertSemicolon()||!this.eat(z.arrow))this.unexpected();return this.parseArrowExpression(this.startNodeAt(Y,J),[Z],!0,O)}}return Z;case z.regexp:var X=this.value;return L=this.parseLiteral(X.value),L.regex={pattern:X.pattern,flags:X.flags},L;case z.num:case z.string:return this.parseLiteral(this.value);case z._null:case z._true:case z._false:return L=this.startNode(),L.value=this.type===z._null?null:this.type===z._true,L.raw=this.type.keyword,this.next(),this.finishNode(L,"Literal");case z.parenL:var G=this.start,Q=this.parseParenAndDistinguishExpression($,O);if(W){if(W.parenthesizedAssign<0&&!this.isSimpleAssignTarget(Q))W.parenthesizedAssign=G;if(W.parenthesizedBind<0)W.parenthesizedBind=G}return Q;case z.bracketL:return L=this.startNode(),this.next(),L.elements=this.parseExprList(z.bracketR,!0,!0,W),this.finishNode(L,"ArrayExpression");case z.braceL:return this.overrideContext(JW.b_expr),this.parseObj(!1,W);case z._function:return L=this.startNode(),this.next(),this.parseFunction(L,0);case z._class:return this.parseClass(this.startNode(),!1);case z._new:return this.parseNew();case z.backQuote:return this.parseTemplate();case z._import:if(this.options.ecmaVersion>=11)return this.parseExprImport(M);else return this.unexpected();default:return this.parseExprAtomDefault()}};l.parseExprAtomDefault=function(){this.unexpected()};l.parseExprImport=function(W){var O=this.startNode();if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword import");if(this.next(),this.type===z.parenL&&!W)return this.parseDynamicImport(O);else if(this.type===z.dot){var M=this.startNodeAt(O.start,O.loc&&O.loc.start);return M.name="import",O.meta=this.finishNode(M,"Identifier"),this.parseImportMeta(O)}else this.unexpected()};l.parseDynamicImport=function(W){if(this.next(),W.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)if(!this.eat(z.parenR))if(this.expect(z.comma),!this.afterTrailingComma(z.parenR)){if(W.options=this.parseMaybeAssign(),!this.eat(z.parenR)){if(this.expect(z.comma),!this.afterTrailingComma(z.parenR))this.unexpected()}}else W.options=null;else W.options=null;else if(!this.eat(z.parenR)){var O=this.start;if(this.eat(z.comma)&&this.eat(z.parenR))this.raiseRecoverable(O,"Trailing comma is not allowed in import()");else this.unexpected(O)}return this.finishNode(W,"ImportExpression")};l.parseImportMeta=function(W){this.next();var O=this.containsEsc;if(W.property=this.parseIdent(!0),W.property.name!=="meta")this.raiseRecoverable(W.property.start,"The only valid meta property for import is 'import.meta'");if(O)this.raiseRecoverable(W.start,"'import.meta' must not contain escaped characters");if(this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere)this.raiseRecoverable(W.start,"Cannot use 'import.meta' outside a module");return this.finishNode(W,"MetaProperty")};l.parseLiteral=function(W){var O=this.startNode();if(O.value=W,O.raw=this.input.slice(this.start,this.end),O.raw.charCodeAt(O.raw.length-1)===110)O.bigint=O.value!=null?O.value.toString():O.raw.slice(0,-1).replace(/_/g,"");return this.next(),this.finishNode(O,"Literal")};l.parseParenExpression=function(){this.expect(z.parenL);var W=this.parseExpression();return this.expect(z.parenR),W};l.shouldParseArrow=function(W){return!this.canInsertSemicolon()};l.parseParenAndDistinguishExpression=function(W,O){var M=this.start,L=this.startLoc,$,Y=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var J=this.start,A=this.startLoc,Z=[],X=!0,G=!1,Q=new GL,S=this.yieldPos,U=this.awaitPos,V;this.yieldPos=0,this.awaitPos=0;while(this.type!==z.parenR)if(X?X=!1:this.expect(z.comma),Y&&this.afterTrailingComma(z.parenR,!0)){G=!0;break}else if(this.type===z.ellipsis){if(V=this.start,Z.push(this.parseParenItem(this.parseRestBinding())),this.type===z.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else Z.push(this.parseMaybeAssign(!1,Q,this.parseParenItem));var R=this.lastTokEnd,K=this.lastTokEndLoc;if(this.expect(z.parenR),W&&this.shouldParseArrow(Z)&&this.eat(z.arrow))return this.checkPatternErrors(Q,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=S,this.awaitPos=U,this.parseParenArrowList(M,L,Z,O);if(!Z.length||G)this.unexpected(this.lastTokStart);if(V)this.unexpected(V);if(this.checkExpressionErrors(Q,!0),this.yieldPos=S||this.yieldPos,this.awaitPos=U||this.awaitPos,Z.length>1)$=this.startNodeAt(J,A),$.expressions=Z,this.finishNodeAt($,"SequenceExpression",R,K);else $=Z[0]}else $=this.parseParenExpression();if(this.options.preserveParens){var T=this.startNodeAt(M,L);return T.expression=$,this.finishNode(T,"ParenthesizedExpression")}else return $};l.parseParenItem=function(W){return W};l.parseParenArrowList=function(W,O,M,L){return this.parseArrowExpression(this.startNodeAt(W,O),M,!1,L)};var _K=[];l.parseNew=function(){if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword new");var W=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===z.dot){var O=this.startNodeAt(W.start,W.loc&&W.loc.start);O.name="new",W.meta=this.finishNode(O,"Identifier"),this.next();var M=this.containsEsc;if(W.property=this.parseIdent(!0),W.property.name!=="target")this.raiseRecoverable(W.property.start,"The only valid meta property for new is 'new.target'");if(M)this.raiseRecoverable(W.start,"'new.target' must not contain escaped characters");if(!this.allowNewDotTarget)this.raiseRecoverable(W.start,"'new.target' can only be used in functions and class static block");return this.finishNode(W,"MetaProperty")}var L=this.start,$=this.startLoc;if(W.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),L,$,!0,!1),this.eat(z.parenL))W.arguments=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1);else W.arguments=_K;return this.finishNode(W,"NewExpression")};l.parseTemplateElement=function(W){var O=W.isTagged,M=this.startNode();if(this.type===z.invalidTemplate){if(!O)this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal");M.value={raw:this.value.replace(/\r\n?/g,`
14
+ `,"ascii");return Buffer.concat([L,M])}class L${#W;#O=Buffer.alloc(0);constructor(W={}){this.#W=W.maxFrameBytes}push(W){if(W.byteLength>0)this.#O=Buffer.concat([this.#O,W]);let O=[];while(!0){let M=this.#O.indexOf(f9);if(M<0){if(this.#O.byteLength>128)throw new VO("Protocol frame header exceeds 128 bytes.");break}if(M>128)throw new VO("Protocol frame header exceeds 128 bytes.");let L=this.#O.subarray(0,M).toString("ascii"),$=/^Content-Length: ([0-9]+)$/.exec(L);if($===null)throw new VO("Protocol frame has an invalid Content-Length header.");let Y=Number($[1]);if(!Number.isSafeInteger(Y))throw new VO("Protocol Content-Length is not a safe integer.");if(this.#W!==void 0&&Y>this.#W)throw new VO(`Protocol frame declares ${Y} bytes, exceeding the configured limit.`);let J=M+f9.byteLength,A=J+Y;if(this.#O.byteLength<A)break;try{let Z=vG.decode(this.#O.subarray(J,A));O.push(JSON.parse(Z))}catch{throw new VO("Protocol frame body is not valid UTF-8 JSON.")}this.#O=this.#O.subarray(A)}return O}finish(){if(this.#O.byteLength!==0)throw new VO("Protocol stream ended with an incomplete frame.")}}class $${#W;#O=Promise.resolve();constructor(W){this.#W=W}send(W){let O=gG(W),M=this.#O.then(async()=>{await this.#W(O)});return this.#O=M.catch(()=>{}),M}async drain(){await this.#O}}var qZ=fG(x4(),1);import{readFileSync as YF}from"fs";import{dirname as W9,relative as M9,resolve as AM,sep as L9}from"path";function $8(W,O={}){let M=[],L=new Set,$=new Set;for(let S of W.nodes){if(L.has(S.id))$.add(S.id);L.add(S.id)}for(let S of $)M.push({code:"DUPLICATE_NODE_ID",message:`Compiled graph contains duplicate node ID "${S}".`});let Y=new Set,J=new Set,A=new Map,Z=new Map;for(let S of L)A.set(S,[]),Z.set(S,0);for(let S of W.edges){if(Y.has(S.id))J.add(S.id);if(Y.add(S.id),!L.has(S.from)||!L.has(S.to)){M.push({code:"UNKNOWN_EDGE_ENDPOINT",message:`Edge "${S.id}" references an unknown endpoint (${S.from} -> ${S.to}).`});continue}A.get(S.from)?.push(S.to),Z.set(S.to,(Z.get(S.to)??0)+1)}for(let S of J)M.push({code:"DUPLICATE_EDGE_ID",message:`Compiled graph contains duplicate edge ID "${S}".`});let G=new Set;for(let S of W.entryNodeIds){if(G.has(S)){M.push({code:"DUPLICATE_ENTRY_NODE_ID",message:`Compiled graph repeats entry node ID "${S}".`});continue}if(G.add(S),!L.has(S))M.push({code:"INVALID_ENTRY_NODE",message:`Entry node "${S}" does not exist.`});else if((Z.get(S)??0)!==0)M.push({code:"INVALID_ENTRY_NODE",message:`Entry node "${S}" has an incoming edge.`})}let X=new Set,Q=[...G].filter((S)=>L.has(S));while(Q.length>0){let S=Q.shift();if(S===void 0||X.has(S))continue;X.add(S),Q.push(...A.get(S)??[])}for(let S of L)if(!X.has(S))M.push({code:"UNREACHABLE_NODE",message:`Node "${S}" is not reachable from an entry node.`});let R=new Map(Z),U=[...L].filter((S)=>(R.get(S)??0)===0),T=0;while(U.length>0){let S=U.shift();if(S===void 0)continue;T+=1;for(let H of A.get(S)??[]){let F=(R.get(H)??0)-1;if(R.set(H,F),F===0)U.push(H)}}if(T!==L.size)M.push({code:"CYCLIC_GRAPH",message:"Compiled graph contains a cycle."});if(O.requireSingleTerminal===!0){let S=[...L].filter((H)=>(A.get(H)?.length??0)===0);if(S.length!==1)M.push({code:"TERMINAL_NODE_COUNT",message:`The first CLI profile requires exactly one terminal node; found ${S.length}.`})}return RK(W,M),QK(W,M),GK(W,M),SK(W,M),M}function eH(W){return`__woml_approval__${W}__join`}function WK(W,O,M){return W.kind==="equals"&&W.left.kind==="contextReference"&&W.left.path.length===3&&W.left.path[0]==="steps"&&W.left.path[1]===O&&W.left.path[2]==="decision"&&W.right.kind==="literal"&&W.right.value===M}var OK=/^#[a-z0-9][a-z0-9_-]{0,79}$/,MK=/^[CG][A-Z0-9]{8,31}$/,LK=/^-?[1-9][0-9]{0,19}$/,$K=/^[0-9]{17,20}$/,YK=/^[1-9][0-9]{7,15}$/,JK=/^[a-z0-9_]+$/,AK=/^[a-z]{2,3}(?:_[A-Z]{2})?$/,L8=/^[A-Z][A-Z0-9_]*$/;function h4(W,O){return Object.keys(W).length===O.length&&O.every((L)=>(L in W))}function ZK(W,O){if(W===void 0)return!0;if(W.kind!=="array"||W.items.length===0)return!1;let M=-1,L=-1,$=new Set,Y=new Set;for(let J of W.items){if(J.kind!=="object")return!1;let{deliveryId:A,provider:Z,destination:G,credentials:X}=J.fields,Q=Z?.kind==="literal"?Z.value:void 0,R=Q==="slack",U=Q==="telegram",T=Q==="discord",S=Q==="whatsapp",H=S?["deliveryId","provider","destination","credentials","templateName","language"]:["deliveryId","provider","destination","credentials"];if(!h4(J.fields,H)||A?.kind!=="literal"||typeof A.value!=="string"||!R&&!U&&!T&&!S||G?.kind!=="literal"||typeof G.value!=="string"||R&&!OK.test(G.value)&&!MK.test(G.value)||U&&!LK.test(G.value)||T&&!$K.test(G.value)||S&&!YK.test(G.value)||X?.kind!=="object"||!h4(X.fields,R?["botToken","appToken"]:S?["accessToken","phoneNumberId"]:["botToken"]))return!1;let F=new RegExp(`^${O}:notify:([0-9]+):${U?"chat":S?"recipient":"channel"}:([0-9]+)$`).exec(A.value),K=X.fields.botToken,w=X.fields.appToken,P=X.fields.accessToken,B=X.fields.phoneNumberId,q=J.fields.templateName,N=J.fields.language;if(F===null||$.has(A.value)||!S&&(K?.kind!=="secretReference"||!L8.test(K.name))||R&&(w?.kind!=="secretReference"||!L8.test(w.name))||S&&(P?.kind!=="secretReference"||!L8.test(P.name)||B?.kind!=="literal"||typeof B.value!=="string"||q?.kind!=="literal"||typeof q.value!=="string"||!JK.test(q.value)||N?.kind!=="literal"||typeof N.value!=="string"||!AK.test(N.value)))return!1;let _=Number(F[1]),V=Number(F[2]),C=M===-1?_===0&&V===0:_===M?V===L+1:_===M+1&&V===0,I=S&&P?.kind==="secretReference"?P.name:K?.kind==="secretReference"?K.name:"",b=`${Q}\x00${I}\x00${w?.kind==="secretReference"?w.name:""}\x00${G.value}`;if(!C||Y.has(b))return!1;$.add(A.value),Y.add(b),M=_,L=V}return!0}function GK(W,O){let M=new Map(W.nodes.map(($)=>[$.id,$])),L=new Map;for(let $ of W.edges){if($.approvalId===void 0){if($.condition.kind==="equals")O.push({code:"INVALID_APPROVAL_GROUP",message:`Equals edge "${$.id}" must carry an approvalId.`});continue}let Y=L.get($.approvalId)??[];if(Y.push($),L.set($.approvalId,Y),$.branchId!==void 0||$.parallelId!==void 0)O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval edge "${$.id}" cannot also belong to a branch or parallel group.`})}for(let[$,Y]of L){let J=M.get($),A=eH($),Z=M.get(A),G=J?.inputs.kind==="object"?J.inputs.fields:{},X=G.timeoutMs,Q=G.onTimeout,R=G.notifications,U=ZK(R,$),T=J?.metadata,S=T===void 0||Object.keys(T).every((C)=>["name","description"].includes(C))&&Object.values(T).every((C)=>typeof C==="string"&&C.length>0),H=oO.test($)&&J?.handler==="engine.approval-wait"&&J.timeoutMs===void 0&&J.retryPolicy===void 0&&J.inputs.kind==="object"&&Object.keys(G).every((C)=>["timeoutMs","onTimeout","notifications"].includes(C))&&Object.keys(G).length===1+Number(X!==void 0)+Number(R!==void 0)&&Q?.kind==="literal"&&(Q.value==="reject"||Q.value==="fail")&&(X===void 0||X.kind==="literal"&&typeof X.value==="number"&&Number.isSafeInteger(X.value)&&X.value>=1)&&U&&S,F=Z?.handler==="engine.approval-join"&&Z.timeoutMs===void 0&&Z.retryPolicy===void 0&&Z.metadata===void 0&&Z.inputs.kind==="object"&&Object.keys(Z.inputs.fields).length===0,K=Y.find((C)=>C.id===`${$}:approved`),w=Y.find((C)=>C.id===`${$}:rejected`),P=Y.find((C)=>C.id===`${$}:approved:join`),B=Y.find((C)=>C.id===`${$}:rejected:join`),N=[{decision:"approved",route:K,join:P},{decision:"rejected",route:w,join:B}].every(({decision:C,route:I,join:b})=>{if(I===void 0||I.from!==$||I.approvalId!==$||!WK(I.condition,$,C))return!1;if(I.to===A)return b===void 0;return b?.from!==$&&b?.to===A&&b?.approvalId===$&&b.condition.kind==="always"}),_=2+Number(K?.to!==A)+Number(w?.to!==A),V=W.edges.filter((C)=>C.from===$).length===2&&W.edges.filter((C)=>C.from===$).every((C)=>C.approvalId===$)&&W.edges.filter((C)=>C.to===A).every((C)=>C.approvalId===$);if(!H||!F||!N||Y.length!==_||!V)O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval group "${$}" does not match the frozen wait, decision-route, empty-arm, and join contract.`});if(!U)O.push({code:"INVALID_NOTIFICATION_GROUP",message:`Approval group "${$}" has invalid compiled notification deliveries.`})}for(let $ of W.nodes){if($.handler==="engine.approval-wait"&&!L.has($.id))O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval wait "${$.id}" has no matching edge group.`});if($.handler==="engine.approval-join"){let Y=/^__woml_approval__([a-z][A-Za-z0-9]*)__join$/.exec($.id);if(Y===null||!L.has(Y[1]))O.push({code:"INVALID_APPROVAL_GROUP",message:`Approval join "${$.id}" has no matching edge group.`})}}}function XK(W){return`__woml_parallel__${W}__start`}function QK(W,O){let M=new Map(W.nodes.map(($)=>[$.id,$])),L=new Map;for(let $ of W.edges){if($.parallelId===void 0)continue;let Y=L.get($.parallelId)??[];if(Y.push($),L.set($.parallelId,Y),$.branchId!==void 0||$.condition.kind!=="always")O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel edge "${$.id}" must be unconditional and cannot also belong to a branch.`})}for(let[$,Y]of L){let J=XK($),A=M.get(J),Z=M.get($),G=A?.inputs.kind==="object"?A.inputs.fields:{},X=G.concurrency,Q=G.onError,R=Y.filter((q)=>q.from===J),U=Y.filter((q)=>q.to===$),T=R.map((q)=>q.to),S=A?.handler==="engine.parallel-start"&&Object.keys(G).length===2&&X?.kind==="literal"&&typeof X.value==="number"&&Number.isSafeInteger(X.value)&&X.value>=1&&X.value<=R.length&&Q?.kind==="literal"&&(Q.value==="fail-fast"||Q.value==="wait-all"),H=Z?.handler==="engine.parallel-join"&&Z.inputs.kind==="object"&&Object.keys(Z.inputs.fields).length===0,F=R.length>=1&&U.length===R.length&&Y.length===R.length*2&&R.every((q,N)=>q.id===`${$}:child:${N}`&&q.parallelId===$&&q.branchId===void 0&&q.condition.kind==="always"&&M.get(q.to)?.handler==="runtime.script")&&U.every((q,N)=>q.id===`${$}:join:${N}`&&q.from===T[N]&&q.parallelId===$&&q.branchId===void 0&&q.condition.kind==="always"),K=W.edges.filter((q)=>q.from===J),w=W.edges.filter((q)=>q.to===$),P=K.length===R.length&&K.every((q)=>q.parallelId===$)&&w.length===U.length&&w.every((q)=>q.parallelId===$)&&T.every((q)=>{let N=W.edges.filter((V)=>V.to===q),_=W.edges.filter((V)=>V.from===q);return N.length===1&&N[0].from===J&&N[0].parallelId===$&&_.length===1&&_[0].to===$&&_[0].parallelId===$}),B=W.edges.some((q)=>q.from===$);if(!oO.test($)||!S||!H||!F||!P||!B)O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel group "${$}" does not match the frozen start, ordered child, join, policy, and concurrency contract.`})}for(let $ of W.nodes){if($.handler==="engine.parallel-start"){let Y=/^__woml_parallel__([a-z][A-Za-z0-9]*)__start$/.exec($.id);if(Y===null||!L.has(Y[1]))O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel start "${$.id}" has no matching edge group.`})}if($.handler==="engine.parallel-join"&&!L.has($.id))O.push({code:"INVALID_PARALLEL_GROUP",message:`Parallel join "${$.id}" has no matching edge group.`})}}var oO=/^[a-z][A-Za-z0-9]*$/;function ML(W){if(W?.kind!=="contextReference")return!1;let[O,M]=W.path;return O==="trigger"&&W.path.length>=1||O==="steps"&&M!==void 0&&oO.test(M)}function RK(W,O){let M=new Map(W.nodes.map((Y)=>[Y.id,Y])),L=new Map,$=new Set((W.choices??[]).flatMap((Y)=>Y.armIds));for(let Y of W.edges){if(Y.branchId===void 0){if(Y.condition.kind==="boolean"&&!$.has(Y.id))O.push({code:"INVALID_BRANCH_GROUP",message:`Boolean edge "${Y.id}" must carry a branchId.`});continue}let J=L.get(Y.branchId)??[];J.push(Y),L.set(Y.branchId,J)}for(let Y of W.nodes)if(Y.handler==="engine.branch-select"){let A=/^__woml_branch__([a-z][A-Za-z0-9]*)__select$/.exec(Y.id)?.[1],Z=Y.inputs.kind==="object"&&Object.keys(Y.inputs.fields).length===0;if(A===void 0||!Z||!L.has(A))O.push({code:"INVALID_BRANCH_SELECTOR",message:`Branch selector "${Y.id}" does not match the frozen selector identity, inputs, and edge-group contract.`})}for(let[Y,J]of L){let A=`__woml_branch__${Y}__select`,Z=M.get(A),G=W.edges.filter((_)=>_.from===A);if(!oO.test(Y)||Z?.handler!=="engine.branch-select"||J.some((_)=>_.from!==A)||G.length!==J.length||G.some((_)=>_.branchId!==Y))O.push({code:"INVALID_BRANCH_GROUP",message:`Branch group "${Y}" must originate from its canonical selector.`});let X=J.slice(0,-1),Q=J.at(-1),R=X.length>0&&X.every((_,V)=>_.id===`${Y}:when:${V}`&&_.condition.kind==="boolean"&&ML(_.condition.value)),U=Q?.id===`${Y}:otherwise`&&Q.condition.kind==="always";if(!R||!U)O.push({code:"INVALID_BRANCH_GROUP",message:`Branch group "${Y}" must contain contiguous ordered boolean cases followed by one fallback.`});let T=M.get(Y),S=T?.inputs.kind==="object"?T.inputs.fields:{},H=J.map((_)=>_.id),F=Object.keys(S);if(T?.handler!=="engine.branch-result"||F.length!==H.length||H.some((_)=>!ML(S[_])))O.push({code:"INVALID_BRANCH_RESULT",message:`Branch result "${Y}" must expose one context reference for every ordered branch arm.`});let K=W.edges.filter((_)=>_.to===Y),w=K.length===J.length&&K.every((_)=>_.branchId===void 0&&_.condition.kind==="always"),P=new Map;for(let _ of W.edges){let V=P.get(_.from)??[];V.push(_.to),P.set(_.from,V)}let B=J.map((_)=>{let V=new Set,C=[_.to],I=!1;while(C.length>0){let b=C.shift();if(b===Y){I=!0;continue}if(V.has(b))continue;V.add(b),C.push(...P.get(b)??[])}return{reachesResult:I,visited:V}}),q=B.every((_,V)=>B.slice(V+1).every((C)=>![..._.visited].some((I)=>C.visited.has(I)))),N=K.every((_)=>B.filter((V)=>V.visited.has(_.from)).length===1);if(!w||B.some((_)=>!_.reachesResult)||!q||!N)O.push({code:"INVALID_BRANCH_GROUP",message:`Branch group "${Y}" must contain disjoint routes with one ordinary join into its result per arm.`})}for(let Y of W.nodes)if(Y.handler==="engine.branch-result"&&!L.has(Y.id))O.push({code:"INVALID_BRANCH_RESULT",message:`Branch result "${Y.id}" has no matching branch edge group.`})}function u0(W,O){return W?.handler===O&&W.timeoutMs===void 0&&W.retryPolicy===void 0&&W.scriptRuntime===void 0&&W.metadata===void 0&&W.inputs.kind==="object"&&Object.keys(W.inputs.fields).length===0}function SK(W,O){let{forks:M,choices:L,contextVisibility:$,settlement:Y}=W;if(!W.nodes.some((V)=>["engine.fork-open","engine.fork-branch-terminal","engine.fork-join","engine.choice-select","engine.choice-join","engine.workflow-settlement"].includes(V.handler))&&!(M!==void 0||L!==void 0||$!==void 0||Y!==void 0))return;if(M===void 0||L===void 0||$===void 0||Y===void 0){O.push({code:"INVALID_FORK_GRAPH",message:"Model v13 graph metadata requires forks, choices, contextVisibility, and settlement together."});return}let Z=new Map(W.nodes.map((V)=>[V.id,V])),G=new Map,X=new Map;for(let V of W.nodes)G.set(V.id,[]),X.set(V.id,[]);for(let V of W.edges)G.get(V.from)?.push(V),X.get(V.to)?.push(V);let Q=new Set,R=[],U=new Set,T=new Map;for(let V of M){let C=oO.test(V.forkId)&&!Q.has(V.forkId)&&V.openNodeId===`__woml_fork__${V.forkId}__open`&&V.joinNodeId===`__woml_fork__${V.forkId}__join`&&u0(Z.get(V.openNodeId),"engine.fork-open")&&u0(Z.get(V.joinNodeId),"engine.fork-join")&&V.branches.length>=1;Q.add(V.forkId),U.add(V.openNodeId),U.add(V.joinNodeId);let I=new Set,b=new Map;for(let v of V.branches){let kW=`__woml_fork__${V.forkId}__${v.branchId}__terminal`;C&&=oO.test(v.branchId)&&v.branchId!=="all"&&v.branchId!=="none"&&!I.has(v.branchId)&&v.terminalNodeId===kW&&Z.has(v.entryNodeId)&&u0(Z.get(v.terminalNodeId),"engine.fork-branch-terminal"),I.add(v.branchId),b.set(v.branchId,v.terminalNodeId),R.push(v.terminalNodeId),U.add(v.terminalNodeId);let iW=X.get(v.entryNodeId)??[];C&&=iW.length===1&&iW[0].from===V.openNodeId&&iW[0].condition.kind==="always";let _0=[v.entryNodeId],U1=new Set,mO=!1;while(_0.length>0){let aW=_0.pop();if(U1.has(aW))continue;if(U1.add(aW),aW===v.terminalNodeId){mO=!0;continue}for(let bW of G.get(aW)??[])if(bW.to!==V.joinNodeId&&bW.to!==Y.nodeId)_0.push(bW.to)}C&&=mO;for(let aW of U1){let bW=T.get(aW);if(bW!==void 0&&bW!==`${V.forkId}:${v.branchId}`)C=!1;T.set(aW,`${V.forkId}:${v.branchId}`)}}let k=V.branches.filter((v)=>V.joinedBranchIds.includes(v.branchId)).map((v)=>v.branchId);C&&=new Set(V.joinedBranchIds).size===V.joinedBranchIds.length&&V.joinedBranchIds.every((v)=>I.has(v))&&JSON.stringify(k)===JSON.stringify(V.joinedBranchIds);let p=G.get(V.openNodeId)??[],XW=new Set(V.branches.map((v)=>v.entryNodeId));C&&=V.branches.every((v)=>p.some((kW)=>kW.to===v.entryNodeId&&kW.condition.kind==="always"));let MW=(X.get(V.joinNodeId)??[]).map((v)=>v.from),AW=V.joinedBranchIds.length===0?[V.openNodeId]:V.joinedBranchIds.map((v)=>b.get(v));if(C&&=p.every((v)=>XW.has(v.to)||V.joinedBranchIds.length===0&&v.to===V.joinNodeId)&&JSON.stringify(MW)===JSON.stringify(AW)&&(X.get(V.joinNodeId)??[]).every((v)=>v.condition.kind==="always"),!C)O.push({code:"INVALID_FORK_GRAPH",message:`Fork "${V.forkId}" does not match the frozen Model v13 ownership, route, and join contract.`})}for(let V of W.nodes)if(["engine.fork-open","engine.fork-branch-terminal","engine.fork-join"].includes(V.handler)&&!U.has(V.id))O.push({code:"INVALID_FORK_GRAPH",message:`Fork control node "${V.id}" is not owned by a fork descriptor.`});let S=new Set,H=new Set;for(let V of L){let C=V.stringSelector!==void 0,I=C?V.stringCases!==void 0&&V.defaultArmId!==void 0&&V.stringCases.length>=1&&V.stringCases.length===V.armIds.length-1&&ML(V.stringSelector)&&new Set(V.stringCases.map((MW)=>MW.value)).size===V.stringCases.length&&V.stringCases.every((MW,AW)=>MW.armId===V.armIds[AW]&&MW.value.length>0)&&V.defaultArmId===V.armIds.at(-1):V.stringCases===void 0&&V.defaultArmId===void 0&&V.resultNodeId===void 0,k=/^__woml_choice__[a-z0-9_]+$/.test(V.choiceId)&&!S.has(V.choiceId)&&V.selectorNodeId===`${V.choiceId}__select`&&V.joinNodeId===`${V.choiceId}__join`&&u0(Z.get(V.selectorNodeId),"engine.choice-select")&&u0(Z.get(V.joinNodeId),"engine.choice-join")&&V.armIds.length>=2&&new Set(V.armIds).size===V.armIds.length&&I;if(S.add(V.choiceId),H.add(V.selectorNodeId),H.add(V.joinNodeId),V.resultNodeId!==void 0){H.add(V.resultNodeId);let MW=Z.get(V.resultNodeId),AW=MW?.inputs.kind==="object"?MW.inputs.fields:{},v=X.get(V.resultNodeId)??[];k&&=C&&oO.test(V.resultNodeId)&&MW?.handler==="engine.choice-result"&&MW.retryPolicy===void 0&&MW.timeoutMs===void 0&&Object.keys(AW).length===V.armIds.length&&V.armIds.every((kW)=>ML(AW[kW]))&&v.length===1&&v[0].from===V.joinNodeId&&v[0].condition.kind==="always"}let p=G.get(V.selectorNodeId)??[],XW=X.get(V.joinNodeId)??[];if(k&&=p.length===V.armIds.length&&XW.length===V.armIds.length,V.armIds.forEach((MW,AW)=>{let v=p[AW],kW=XW[AW];k&&=MW.startsWith(`${V.choiceId}:`)&&v?.id===MW&&v.branchId===void 0&&v.parallelId===void 0&&v.approvalId===void 0&&(C?v.condition.kind==="always":AW===V.armIds.length-1?v.condition.kind==="always":v.condition.kind==="boolean")&&kW?.id===`${MW}:join`&&kW.to===V.joinNodeId&&kW.condition.kind==="always"}),!k)O.push({code:"INVALID_CONTROL_CHOICE",message:`Control choice "${V.choiceId}" does not match the frozen selector, ordered-arm, and join contract.`})}for(let V of W.nodes)if(["engine.choice-select","engine.choice-join","engine.choice-result"].includes(V.handler)&&!H.has(V.id))O.push({code:"INVALID_CONTROL_CHOICE",message:`Control-choice node "${V.id}" has no matching descriptor.`});let F=W.nodes.filter((V)=>V.handler==="runtime.script").map((V)=>V.id),K=new Set,w=$.length===F.length;if($.forEach((V,C)=>{w&&=V.nodeId===F[C]&&!K.has(V.nodeId)&&new Set(V.stepIds).size===V.stepIds.length&&V.stepIds.every((I)=>oO.test(I)&&Z.has(I)),K.add(V.nodeId)}),!w)O.push({code:"INVALID_CONTEXT_VISIBILITY",message:"Model v13 contextVisibility must describe every runtime.script node once, in graph order, with existing public output IDs."});let P=X.get(Y.nodeId)??[],B=M.flatMap((V)=>V.branches.map((C)=>C.terminalNodeId)),q=new Set(B),N=P.filter((V)=>!q.has(V.from));if(!(Y.nodeId==="__woml_workflow__settlement"&&u0(Z.get(Y.nodeId),"engine.workflow-settlement")&&Z.has(Y.mainResultNodeId)&&JSON.stringify(Y.ownedBranchTerminalNodeIds)===JSON.stringify(B)&&N.length===1&&P.length===B.length+1&&P.every((V)=>V.condition.kind==="always")&&(G.get(Y.nodeId)?.length??0)===0))O.push({code:"INVALID_WORKFLOW_SETTLEMENT",message:"Model v13 settlement must preserve one main result and depend on the main continuation plus every owned branch terminal."})}var UK=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],d4=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],zK="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",c4="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",Y8={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},J8="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",VK={5:J8,"5module":J8+" export import",6:J8+" const class extends export import super"},HK=/^in(stanceof)?$/,KK=new RegExp("["+c4+"]"),TK=new RegExp("["+c4+zK+"]");function A8(W,O){var M=65536;for(var L=0;L<O.length;L+=2){if(M+=O[L],M>W)return!1;if(M+=O[L+1],M>=W)return!0}return!1}function KO(W,O){if(W<65)return W===36;if(W<91)return!0;if(W<97)return W===95;if(W<123)return!0;if(W<=65535)return W>=170&&KK.test(String.fromCharCode(W));if(O===!1)return!1;return A8(W,d4)}function eO(W,O){if(W<48)return W===36;if(W<58)return!0;if(W<65)return!1;if(W<91)return!0;if(W<97)return W===95;if(W<123)return!0;if(W<=65535)return W>=170&&TK.test(String.fromCharCode(W));if(O===!1)return!1;return A8(W,d4)||A8(W,UK)}var OW=function(O,M){if(M===void 0)M={};this.label=O,this.keyword=M.keyword,this.beforeExpr=!!M.beforeExpr,this.startsExpr=!!M.startsExpr,this.isLoop=!!M.isLoop,this.isAssign=!!M.isAssign,this.prefix=!!M.prefix,this.postfix=!!M.postfix,this.binop=M.binop||null,this.updateContext=null};function WO(W,O){return new OW(W,{beforeExpr:!0,binop:O})}var OO={beforeExpr:!0},hW={startsExpr:!0},R8={};function o(W,O){if(O===void 0)O={};return O.keyword=W,R8[W]=new OW(W,O)}var z={num:new OW("num",hW),regexp:new OW("regexp",hW),string:new OW("string",hW),name:new OW("name",hW),privateId:new OW("privateId",hW),eof:new OW("eof"),bracketL:new OW("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new OW("]"),braceL:new OW("{",{beforeExpr:!0,startsExpr:!0}),braceR:new OW("}"),parenL:new OW("(",{beforeExpr:!0,startsExpr:!0}),parenR:new OW(")"),comma:new OW(",",OO),semi:new OW(";",OO),colon:new OW(":",OO),dot:new OW("."),question:new OW("?",OO),questionDot:new OW("?."),arrow:new OW("=>",OO),template:new OW("template"),invalidTemplate:new OW("invalidTemplate"),ellipsis:new OW("...",OO),backQuote:new OW("`",hW),dollarBraceL:new OW("${",{beforeExpr:!0,startsExpr:!0}),eq:new OW("=",{beforeExpr:!0,isAssign:!0}),assign:new OW("_=",{beforeExpr:!0,isAssign:!0}),incDec:new OW("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new OW("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:WO("||",1),logicalAND:WO("&&",2),bitwiseOR:WO("|",3),bitwiseXOR:WO("^",4),bitwiseAND:WO("&",5),equality:WO("==/!=/===/!==",6),relational:WO("</>/<=/>=",7),bitShift:WO("<</>>/>>>",8),plusMin:new OW("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:WO("%",10),star:WO("*",10),slash:WO("/",10),starstar:new OW("**",{beforeExpr:!0}),coalesce:WO("??",1),_break:o("break"),_case:o("case",OO),_catch:o("catch"),_continue:o("continue"),_debugger:o("debugger"),_default:o("default",OO),_do:o("do",{isLoop:!0,beforeExpr:!0}),_else:o("else",OO),_finally:o("finally"),_for:o("for",{isLoop:!0}),_function:o("function",hW),_if:o("if"),_return:o("return",OO),_switch:o("switch"),_throw:o("throw",OO),_try:o("try"),_var:o("var"),_const:o("const"),_while:o("while",{isLoop:!0}),_with:o("with"),_new:o("new",{beforeExpr:!0,startsExpr:!0}),_this:o("this",hW),_super:o("super",hW),_class:o("class",hW),_extends:o("extends",OO),_export:o("export"),_import:o("import",hW),_null:o("null",hW),_true:o("true",hW),_false:o("false",hW),_in:o("in",{beforeExpr:!0,binop:7}),_instanceof:o("instanceof",{beforeExpr:!0,binop:7}),_typeof:o("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:o("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:o("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},uW=/\r\n?|\n|\u2028|\u2029/,FK=new RegExp(uW.source,"g");function l0(W){return W===10||W===13||W===8232||W===8233}function i4(W,O,M){if(M===void 0)M=W.length;for(var L=O;L<M;L++){var $=W.charCodeAt(L);if(l0($))return L<M-1&&$===13&&W.charCodeAt(L+1)===10?L+2:L+1}return-1}var s4=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,BW=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,n4=Object.prototype,EK=n4.hasOwnProperty,qK=n4.toString,p0=Object.hasOwn||function(W,O){return EK.call(W,O)},u4=Array.isArray||function(W){return qK.call(W)==="[object Array]"},l4=Object.create(null);function tO(W){return l4[W]||(l4[W]=new RegExp("^(?:"+W.replace(/ /g,"|")+")$"))}function kO(W){if(W<=65535)return String.fromCharCode(W);return W-=65536,String.fromCharCode((W>>10)+55296,(W&1023)+56320)}var BK=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,u1=function(O,M){this.line=O,this.column=M};u1.prototype.offset=function(O){return new u1(this.line,this.column+O)};var ZL=function(O,M,L){if(this.start=M,this.end=L,O.sourceFile!==null)this.source=O.sourceFile};function r4(W,O){for(var M=1,L=0;;){var $=i4(W,L,O);if($<0)return new u1(M,O-L);++M,L=$}}var Z8={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},p4=!1;function CK(W){var O={};for(var M in Z8)O[M]=W&&p0(W,M)?W[M]:Z8[M];if(O.ecmaVersion==="latest")O.ecmaVersion=1e8;else if(O.ecmaVersion==null){if(!p4&&typeof console==="object"&&console.warn)p4=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
15
+ Defaulting to 2020, but this will stop working in the future.`);O.ecmaVersion=11}else if(O.ecmaVersion>=2015)O.ecmaVersion-=2009;if(O.allowReserved==null)O.allowReserved=O.ecmaVersion<5;if(!W||W.allowHashBang==null)O.allowHashBang=O.ecmaVersion>=14;if(u4(O.onToken)){var L=O.onToken;O.onToken=function($){return L.push($)}}if(u4(O.onComment))O.onComment=wK(O,O.onComment);return O}function wK(W,O){return function(M,L,$,Y,J,A){var Z={type:M?"Block":"Line",value:L,start:$,end:Y};if(W.locations)Z.loc=new ZL(this,J,A);if(W.ranges)Z.range=[$,Y];O.push(Z)}}var l1=1,m0=2,S8=4,a4=8,U8=16,o4=32,GL=64,t4=128,V0=256,p1=512,XL=l1|m0|V0;function z8(W,O){return m0|(W?S8:0)|(O?a4:0)}var $L=0,V8=1,fO=2,e4=3,WA=4,OA=5,VW=function(O,M,L){this.options=O=CK(O),this.sourceFile=O.sourceFile,this.keywords=tO(VK[O.ecmaVersion>=6?6:O.sourceType==="module"?"5module":5]);var $="";if(O.allowReserved!==!0){if($=Y8[O.ecmaVersion>=6?6:O.ecmaVersion===5?5:3],O.sourceType==="module")$+=" await"}this.reservedWords=tO($);var Y=($?$+" ":"")+Y8.strict;if(this.reservedWordsStrict=tO(Y),this.reservedWordsStrictBind=tO(Y+" "+Y8.strictBind),this.input=String(M),this.containsEsc=!1,L)this.pos=L,this.lineStart=this.input.lastIndexOf(`
16
+ `,L-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(uW).length;else this.pos=this.lineStart=0,this.curLine=1;if(this.type=z.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=O.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&O.allowHashBang&&this.input.slice(0,2)==="#!")this.skipLineComment(2);this.scopeStack=[],this.enterScope(l1),this.regexpState=null,this.privateNameStack=[]},TO={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};VW.prototype.parse=function(){var O=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(O)};TO.inFunction.get=function(){return(this.currentVarScope().flags&m0)>0};TO.inGenerator.get=function(){return(this.currentVarScope().flags&a4)>0};TO.inAsync.get=function(){return(this.currentVarScope().flags&S8)>0};TO.canAwait.get=function(){for(var W=this.scopeStack.length-1;W>=0;W--){var O=this.scopeStack[W],M=O.flags;if(M&(V0|p1))return!1;if(M&m0)return(M&S8)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};TO.allowSuper.get=function(){var W=this.currentThisScope(),O=W.flags;return(O&GL)>0||this.options.allowSuperOutsideMethod};TO.allowDirectSuper.get=function(){return(this.currentThisScope().flags&t4)>0};TO.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};TO.allowNewDotTarget.get=function(){for(var W=this.scopeStack.length-1;W>=0;W--){var O=this.scopeStack[W],M=O.flags;if(M&(V0|p1)||M&m0&&!(M&U8))return!0}return!1};TO.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&V0)>0};VW.extend=function(){var O=[],M=arguments.length;while(M--)O[M]=arguments[M];var L=this;for(var $=0;$<O.length;$++)L=O[$](L);return L};VW.parse=function(O,M){return new this(M,O).parse()};VW.parseExpressionAt=function(O,M,L){var $=new this(L,O,M);return $.nextToken(),$.parseExpression()};VW.tokenizer=function(O,M){return new this(M,O)};Object.defineProperties(VW.prototype,TO);var _W=VW.prototype,PK=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;_W.strictDirective=function(W){if(this.options.ecmaVersion<5)return!1;for(;;){BW.lastIndex=W,W+=BW.exec(this.input)[0].length;var O=PK.exec(this.input.slice(W));if(!O)return!1;if((O[1]||O[2])==="use strict"){BW.lastIndex=W+O[0].length;var M=BW.exec(this.input),L=M.index+M[0].length,$=this.input.charAt(L);return $===";"||$==="}"||uW.test(M[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test($)||$==="!"&&this.input.charAt(L+1)==="=")}if(W+=O[0].length,BW.lastIndex=W,W+=BW.exec(this.input)[0].length,this.input[W]===";")W++}};_W.eat=function(W){if(this.type===W)return this.next(),!0;else return!1};_W.isContextual=function(W){return this.type===z.name&&this.value===W&&!this.containsEsc};_W.eatContextual=function(W){if(!this.isContextual(W))return!1;return this.next(),!0};_W.expectContextual=function(W){if(!this.eatContextual(W))this.unexpected()};_W.canInsertSemicolon=function(){return this.type===z.eof||this.type===z.braceR||uW.test(this.input.slice(this.lastTokEnd,this.start))};_W.insertSemicolon=function(){if(this.canInsertSemicolon()){if(this.options.onInsertedSemicolon)this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc);return!0}};_W.semicolon=function(){if(!this.eat(z.semi)&&!this.insertSemicolon())this.unexpected()};_W.afterTrailingComma=function(W,O){if(this.type===W){if(this.options.onTrailingComma)this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc);if(!O)this.next();return!0}};_W.expect=function(W){this.eat(W)||this.unexpected()};_W.unexpected=function(W){this.raise(W!=null?W:this.start,"Unexpected token")};var QL=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};_W.checkPatternErrors=function(W,O){if(!W)return;if(W.trailingComma>-1)this.raiseRecoverable(W.trailingComma,"Comma is not permitted after the rest element");var M=O?W.parenthesizedAssign:W.parenthesizedBind;if(M>-1)this.raiseRecoverable(M,O?"Assigning to rvalue":"Parenthesized pattern")};_W.checkExpressionErrors=function(W,O){if(!W)return!1;var{shorthandAssign:M,doubleProto:L}=W;if(!O)return M>=0||L>=0;if(M>=0)this.raise(M,"Shorthand property assignments are valid only in destructuring patterns");if(L>=0)this.raiseRecoverable(L,"Redefinition of __proto__ property")};_W.checkYieldAwaitInDefaultParams=function(){if(this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos))this.raise(this.yieldPos,"Yield expression cannot be a default value");if(this.awaitPos)this.raise(this.awaitPos,"Await expression cannot be a default value")};_W.isSimpleAssignTarget=function(W){if(W.type==="ParenthesizedExpression")return this.isSimpleAssignTarget(W.expression);return W.type==="Identifier"||W.type==="MemberExpression"};var x=VW.prototype;x.parseTopLevel=function(W){var O=Object.create(null);if(!W.body)W.body=[];while(this.type!==z.eof){var M=this.parseStatement(null,!0,O);W.body.push(M)}if(this.inModule)for(var L=0,$=Object.keys(this.undefinedExports);L<$.length;L+=1){var Y=$[L];this.raiseRecoverable(this.undefinedExports[Y].start,"Export '"+Y+"' is not defined")}return this.adaptDirectivePrologue(W.body),this.next(),W.sourceType=this.options.sourceType,this.finishNode(W,"Program")};var H8={kind:"loop"},NK={kind:"switch"};x.isLet=function(W){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;BW.lastIndex=this.pos;var O=BW.exec(this.input),M=this.pos+O[0].length,L=this.input.charCodeAt(M);if(L===91||L===92)return!0;if(W)return!1;if(L===123||L>55295&&L<56320)return!0;if(KO(L,!0)){var $=M+1;while(eO(L=this.input.charCodeAt($),!0))++$;if(L===92||L>55295&&L<56320)return!0;var Y=this.input.slice(M,$);if(!HK.test(Y))return!0}return!1};x.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;BW.lastIndex=this.pos;var W=BW.exec(this.input),O=this.pos+W[0].length,M;return!uW.test(this.input.slice(this.pos,O))&&this.input.slice(O,O+8)==="function"&&(O+8===this.input.length||!(eO(M=this.input.charCodeAt(O+8))||M>55295&&M<56320))};x.isUsingKeyword=function(W,O){if(this.options.ecmaVersion<17||!this.isContextual(W?"await":"using"))return!1;BW.lastIndex=this.pos;var M=BW.exec(this.input),L=this.pos+M[0].length;if(uW.test(this.input.slice(this.pos,L)))return!1;if(W){var $=L+5,Y;if(this.input.slice(L,$)!=="using"||$===this.input.length||eO(Y=this.input.charCodeAt($))||Y>55295&&Y<56320)return!1;BW.lastIndex=$;var J=BW.exec(this.input);if(J&&uW.test(this.input.slice($,$+J[0].length)))return!1}if(O){var A=L+2,Z;if(this.input.slice(L,A)==="of"){if(A===this.input.length||!eO(Z=this.input.charCodeAt(A))&&!(Z>55295&&Z<56320))return!1}}var G=this.input.charCodeAt(L);return KO(G,!0)||G===92};x.isAwaitUsing=function(W){return this.isUsingKeyword(!0,W)};x.isUsing=function(W){return this.isUsingKeyword(!1,W)};x.parseStatement=function(W,O,M){var L=this.type,$=this.startNode(),Y;if(this.isLet(W))L=z._var,Y="let";switch(L){case z._break:case z._continue:return this.parseBreakContinueStatement($,L.keyword);case z._debugger:return this.parseDebuggerStatement($);case z._do:return this.parseDoStatement($);case z._for:return this.parseForStatement($);case z._function:if(W&&(this.strict||W!=="if"&&W!=="label")&&this.options.ecmaVersion>=6)this.unexpected();return this.parseFunctionStatement($,!1,!W);case z._class:if(W)this.unexpected();return this.parseClass($,!0);case z._if:return this.parseIfStatement($);case z._return:return this.parseReturnStatement($);case z._switch:return this.parseSwitchStatement($);case z._throw:return this.parseThrowStatement($);case z._try:return this.parseTryStatement($);case z._const:case z._var:if(Y=Y||this.value,W&&Y!=="var")this.unexpected();return this.parseVarStatement($,Y);case z._while:return this.parseWhileStatement($);case z._with:return this.parseWithStatement($);case z.braceL:return this.parseBlock(!0,$);case z.semi:return this.parseEmptyStatement($);case z._export:case z._import:if(this.options.ecmaVersion>10&&L===z._import){BW.lastIndex=this.pos;var J=BW.exec(this.input),A=this.pos+J[0].length,Z=this.input.charCodeAt(A);if(Z===40||Z===46)return this.parseExpressionStatement($,this.parseExpression())}if(!this.options.allowImportExportEverywhere){if(!O)this.raise(this.start,"'import' and 'export' may only appear at the top level");if(!this.inModule)this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")}return L===z._import?this.parseImport($):this.parseExport($,M);default:if(this.isAsyncFunction()){if(W)this.unexpected();return this.next(),this.parseFunctionStatement($,!0,!W)}var G=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(G){if(O&&this.options.sourceType==="script")this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`");if(G==="await using"){if(!this.canAwait)this.raise(this.start,"Await using cannot appear outside of async function");this.next()}return this.next(),this.parseVar($,!1,G),this.semicolon(),this.finishNode($,"VariableDeclaration")}var X=this.value,Q=this.parseExpression();if(L===z.name&&Q.type==="Identifier"&&this.eat(z.colon))return this.parseLabeledStatement($,X,Q,W);else return this.parseExpressionStatement($,Q)}};x.parseBreakContinueStatement=function(W,O){var M=O==="break";if(this.next(),this.eat(z.semi)||this.insertSemicolon())W.label=null;else if(this.type!==z.name)this.unexpected();else W.label=this.parseIdent(),this.semicolon();var L=0;for(;L<this.labels.length;++L){var $=this.labels[L];if(W.label==null||$.name===W.label.name){if($.kind!=null&&(M||$.kind==="loop"))break;if(W.label&&M)break}}if(L===this.labels.length)this.raise(W.start,"Unsyntactic "+O);return this.finishNode(W,M?"BreakStatement":"ContinueStatement")};x.parseDebuggerStatement=function(W){return this.next(),this.semicolon(),this.finishNode(W,"DebuggerStatement")};x.parseDoStatement=function(W){if(this.next(),this.labels.push(H8),W.body=this.parseStatement("do"),this.labels.pop(),this.expect(z._while),W.test=this.parseParenExpression(),this.options.ecmaVersion>=6)this.eat(z.semi);else this.semicolon();return this.finishNode(W,"DoWhileStatement")};x.parseForStatement=function(W){this.next();var O=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(H8),this.enterScope(0),this.expect(z.parenL),this.type===z.semi){if(O>-1)this.unexpected(O);return this.parseFor(W,null)}var M=this.isLet();if(this.type===z._var||this.type===z._const||M){var L=this.startNode(),$=M?"let":this.value;return this.next(),this.parseVar(L,!0,$),this.finishNode(L,"VariableDeclaration"),this.parseForAfterInit(W,L,O)}var Y=this.isContextual("let"),J=!1,A=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(A){var Z=this.startNode();if(this.next(),A==="await using")this.next();return this.parseVar(Z,!0,A),this.finishNode(Z,"VariableDeclaration"),this.parseForAfterInit(W,Z,O)}var G=this.containsEsc,X=new QL,Q=this.start,R=O>-1?this.parseExprSubscripts(X,"await"):this.parseExpression(!0,X);if(this.type===z._in||(J=this.options.ecmaVersion>=6&&this.isContextual("of"))){if(O>-1){if(this.type===z._in)this.unexpected(O);W.await=!0}else if(J&&this.options.ecmaVersion>=8){if(R.start===Q&&!G&&R.type==="Identifier"&&R.name==="async")this.unexpected();else if(this.options.ecmaVersion>=9)W.await=!1}if(Y&&J)this.raise(R.start,"The left-hand side of a for-of loop may not start with 'let'.");return this.toAssignable(R,!1,X),this.checkLValPattern(R),this.parseForIn(W,R)}else this.checkExpressionErrors(X,!0);if(O>-1)this.unexpected(O);return this.parseFor(W,R)};x.parseForAfterInit=function(W,O,M){if((this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&O.declarations.length===1){if(this.options.ecmaVersion>=9)if(this.type===z._in){if(M>-1)this.unexpected(M)}else W.await=M>-1;return this.parseForIn(W,O)}if(M>-1)this.unexpected(M);return this.parseFor(W,O)};x.parseFunctionStatement=function(W,O,M){return this.next(),this.parseFunction(W,h1|(M?0:G8),!1,O)};x.parseIfStatement=function(W){return this.next(),W.test=this.parseParenExpression(),W.consequent=this.parseStatement("if"),W.alternate=this.eat(z._else)?this.parseStatement("if"):null,this.finishNode(W,"IfStatement")};x.parseReturnStatement=function(W){if(!this.inFunction&&!this.options.allowReturnOutsideFunction)this.raise(this.start,"'return' outside of function");if(this.next(),this.eat(z.semi)||this.insertSemicolon())W.argument=null;else W.argument=this.parseExpression(),this.semicolon();return this.finishNode(W,"ReturnStatement")};x.parseSwitchStatement=function(W){this.next(),W.discriminant=this.parseParenExpression(),W.cases=[],this.expect(z.braceL),this.labels.push(NK),this.enterScope(0);var O;for(var M=!1;this.type!==z.braceR;)if(this.type===z._case||this.type===z._default){var L=this.type===z._case;if(O)this.finishNode(O,"SwitchCase");if(W.cases.push(O=this.startNode()),O.consequent=[],this.next(),L)O.test=this.parseExpression();else{if(M)this.raiseRecoverable(this.lastTokStart,"Multiple default clauses");M=!0,O.test=null}this.expect(z.colon)}else{if(!O)this.unexpected();O.consequent.push(this.parseStatement(null))}if(this.exitScope(),O)this.finishNode(O,"SwitchCase");return this.next(),this.labels.pop(),this.finishNode(W,"SwitchStatement")};x.parseThrowStatement=function(W){if(this.next(),uW.test(this.input.slice(this.lastTokEnd,this.start)))this.raise(this.lastTokEnd,"Illegal newline after throw");return W.argument=this.parseExpression(),this.semicolon(),this.finishNode(W,"ThrowStatement")};var _K=[];x.parseCatchClauseParam=function(){var W=this.parseBindingAtom(),O=W.type==="Identifier";return this.enterScope(O?o4:0),this.checkLValPattern(W,O?WA:fO),this.expect(z.parenR),W};x.parseTryStatement=function(W){if(this.next(),W.block=this.parseBlock(),W.handler=null,this.type===z._catch){var O=this.startNode();if(this.next(),this.eat(z.parenL))O.param=this.parseCatchClauseParam();else{if(this.options.ecmaVersion<10)this.unexpected();O.param=null,this.enterScope(0)}O.body=this.parseBlock(!1),this.exitScope(),W.handler=this.finishNode(O,"CatchClause")}if(W.finalizer=this.eat(z._finally)?this.parseBlock():null,!W.handler&&!W.finalizer)this.raise(W.start,"Missing catch or finally clause");return this.finishNode(W,"TryStatement")};x.parseVarStatement=function(W,O,M){return this.next(),this.parseVar(W,!1,O,M),this.semicolon(),this.finishNode(W,"VariableDeclaration")};x.parseWhileStatement=function(W){return this.next(),W.test=this.parseParenExpression(),this.labels.push(H8),W.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(W,"WhileStatement")};x.parseWithStatement=function(W){if(this.strict)this.raise(this.start,"'with' in strict mode");return this.next(),W.object=this.parseParenExpression(),W.body=this.parseStatement("with"),this.finishNode(W,"WithStatement")};x.parseEmptyStatement=function(W){return this.next(),this.finishNode(W,"EmptyStatement")};x.parseLabeledStatement=function(W,O,M,L){for(var $=0,Y=this.labels;$<Y.length;$+=1){var J=Y[$];if(J.name===O)this.raise(M.start,"Label '"+O+"' is already declared")}var A=this.type.isLoop?"loop":this.type===z._switch?"switch":null;for(var Z=this.labels.length-1;Z>=0;Z--){var G=this.labels[Z];if(G.statementStart===W.start)G.statementStart=this.start,G.kind=A;else break}return this.labels.push({name:O,kind:A,statementStart:this.start}),W.body=this.parseStatement(L?L.indexOf("label")===-1?L+"label":L:"label"),this.labels.pop(),W.label=M,this.finishNode(W,"LabeledStatement")};x.parseExpressionStatement=function(W,O){return W.expression=O,this.semicolon(),this.finishNode(W,"ExpressionStatement")};x.parseBlock=function(W,O,M){if(W===void 0)W=!0;if(O===void 0)O=this.startNode();if(O.body=[],this.expect(z.braceL),W)this.enterScope(0);while(this.type!==z.braceR){var L=this.parseStatement(null);O.body.push(L)}if(M)this.strict=!1;if(this.next(),W)this.exitScope();return this.finishNode(O,"BlockStatement")};x.parseFor=function(W,O){return W.init=O,this.expect(z.semi),W.test=this.type===z.semi?null:this.parseExpression(),this.expect(z.semi),W.update=this.type===z.parenR?null:this.parseExpression(),this.expect(z.parenR),W.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(W,"ForStatement")};x.parseForIn=function(W,O){var M=this.type===z._in;if(this.next(),O.type==="VariableDeclaration"&&O.declarations[0].init!=null&&(!M||this.options.ecmaVersion<8||this.strict||O.kind!=="var"||O.declarations[0].id.type!=="Identifier"))this.raise(O.start,(M?"for-in":"for-of")+" loop variable declaration may not have an initializer");return W.left=O,W.right=M?this.parseExpression():this.parseMaybeAssign(),this.expect(z.parenR),W.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(W,M?"ForInStatement":"ForOfStatement")};x.parseVar=function(W,O,M,L){W.declarations=[],W.kind=M;for(;;){var $=this.startNode();if(this.parseVarId($,M),this.eat(z.eq))$.init=this.parseMaybeAssign(O);else if(!L&&M==="const"&&!(this.type===z._in||this.options.ecmaVersion>=6&&this.isContextual("of")))this.unexpected();else if(!L&&(M==="using"||M==="await using")&&this.options.ecmaVersion>=17&&this.type!==z._in&&!this.isContextual("of"))this.raise(this.lastTokEnd,"Missing initializer in "+M+" declaration");else if(!L&&$.id.type!=="Identifier"&&!(O&&(this.type===z._in||this.isContextual("of"))))this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value");else $.init=null;if(W.declarations.push(this.finishNode($,"VariableDeclarator")),!this.eat(z.comma))break}return W};x.parseVarId=function(W,O){W.id=O==="using"||O==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(W.id,O==="var"?V8:fO,!1)};var h1=1,G8=2,MA=4;x.parseFunction=function(W,O,M,L,$){if(this.initFunction(W),this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!L){if(this.type===z.star&&O&G8)this.unexpected();W.generator=this.eat(z.star)}if(this.options.ecmaVersion>=8)W.async=!!L;if(O&h1){if(W.id=O&MA&&this.type!==z.name?null:this.parseIdent(),W.id&&!(O&G8))this.checkLValSimple(W.id,this.strict||W.generator||W.async?this.treatFunctionsAsVar?V8:fO:e4)}var Y=this.yieldPos,J=this.awaitPos,A=this.awaitIdentPos;if(this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(z8(W.async,W.generator)),!(O&h1))W.id=this.type===z.name?this.parseIdent():null;return this.parseFunctionParams(W),this.parseFunctionBody(W,M,!1,$),this.yieldPos=Y,this.awaitPos=J,this.awaitIdentPos=A,this.finishNode(W,O&h1?"FunctionDeclaration":"FunctionExpression")};x.parseFunctionParams=function(W){this.expect(z.parenL),W.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};x.parseClass=function(W,O){this.next();var M=this.strict;this.strict=!0,this.parseClassId(W,O),this.parseClassSuper(W);var L=this.enterClassBody(),$=this.startNode(),Y=!1;$.body=[],this.expect(z.braceL);while(this.type!==z.braceR){var J=this.parseClassElement(W.superClass!==null);if(J){if($.body.push(J),J.type==="MethodDefinition"&&J.kind==="constructor"){if(Y)this.raiseRecoverable(J.start,"Duplicate constructor in the same class");Y=!0}else if(J.key&&J.key.type==="PrivateIdentifier"&&jK(L,J))this.raiseRecoverable(J.key.start,"Identifier '#"+J.key.name+"' has already been declared")}}return this.strict=M,this.next(),W.body=this.finishNode($,"ClassBody"),this.exitClassBody(),this.finishNode(W,O?"ClassDeclaration":"ClassExpression")};x.parseClassElement=function(W){if(this.eat(z.semi))return null;var O=this.options.ecmaVersion,M=this.startNode(),L="",$=!1,Y=!1,J="method",A=!1;if(this.eatContextual("static")){if(O>=13&&this.eat(z.braceL))return this.parseClassStaticBlock(M),M;if(this.isClassElementNameStart()||this.type===z.star)A=!0;else L="static"}if(M.static=A,!L&&O>=8&&this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===z.star)&&!this.canInsertSemicolon())Y=!0;else L="async";if(!L&&(O>=9||!Y)&&this.eat(z.star))$=!0;if(!L&&!Y&&!$){var Z=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())J=Z;else L=Z}if(L)M.computed=!1,M.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),M.key.name=L,this.finishNode(M.key,"Identifier");else this.parseClassElementName(M);if(O<13||this.type===z.parenL||J!=="method"||$||Y){var G=!M.static&&YL(M,"constructor"),X=G&&W;if(G&&J!=="method")this.raise(M.key.start,"Constructor can't have get/set modifier");M.kind=G?"constructor":J,this.parseClassMethod(M,$,Y,X)}else this.parseClassField(M);return M};x.isClassElementNameStart=function(){return this.type===z.name||this.type===z.privateId||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword};x.parseClassElementName=function(W){if(this.type===z.privateId){if(this.value==="constructor")this.raise(this.start,"Classes can't have an element named '#constructor'");W.computed=!1,W.key=this.parsePrivateIdent()}else this.parsePropertyName(W)};x.parseClassMethod=function(W,O,M,L){var $=W.key;if(W.kind==="constructor"){if(O)this.raise($.start,"Constructor can't be a generator");if(M)this.raise($.start,"Constructor can't be an async method")}else if(W.static&&YL(W,"prototype"))this.raise($.start,"Classes may not have a static property named prototype");var Y=W.value=this.parseMethod(O,M,L);if(W.kind==="get"&&Y.params.length!==0)this.raiseRecoverable(Y.start,"getter should have no params");if(W.kind==="set"&&Y.params.length!==1)this.raiseRecoverable(Y.start,"setter should have exactly one param");if(W.kind==="set"&&Y.params[0].type==="RestElement")this.raiseRecoverable(Y.params[0].start,"Setter cannot use rest params");return this.finishNode(W,"MethodDefinition")};x.parseClassField=function(W){if(YL(W,"constructor"))this.raise(W.key.start,"Classes can't have a field named 'constructor'");else if(W.static&&YL(W,"prototype"))this.raise(W.key.start,"Classes can't have a static field named 'prototype'");if(this.eat(z.eq))this.enterScope(p1|GL),W.value=this.parseMaybeAssign(),this.exitScope();else W.value=null;return this.semicolon(),this.finishNode(W,"PropertyDefinition")};x.parseClassStaticBlock=function(W){W.body=[];var O=this.labels;this.labels=[],this.enterScope(V0|GL);while(this.type!==z.braceR){var M=this.parseStatement(null);W.body.push(M)}return this.next(),this.exitScope(),this.labels=O,this.finishNode(W,"StaticBlock")};x.parseClassId=function(W,O){if(this.type===z.name){if(W.id=this.parseIdent(),O)this.checkLValSimple(W.id,fO,!1)}else{if(O===!0)this.unexpected();W.id=null}};x.parseClassSuper=function(W){W.superClass=this.eat(z._extends)?this.parseExprSubscripts(null,!1):null};x.enterClassBody=function(){var W={declared:Object.create(null),used:[]};return this.privateNameStack.push(W),W.declared};x.exitClassBody=function(){var W=this.privateNameStack.pop(),O=W.declared,M=W.used;if(!this.options.checkPrivateFields)return;var L=this.privateNameStack.length,$=L===0?null:this.privateNameStack[L-1];for(var Y=0;Y<M.length;++Y){var J=M[Y];if(!p0(O,J.name))if($)$.used.push(J);else this.raiseRecoverable(J.start,"Private field '#"+J.name+"' must be declared in an enclosing class")}};function jK(W,O){var M=O.key.name,L=W[M],$="true";if(O.type==="MethodDefinition"&&(O.kind==="get"||O.kind==="set"))$=(O.static?"s":"i")+O.kind;if(L==="iget"&&$==="iset"||L==="iset"&&$==="iget"||L==="sget"&&$==="sset"||L==="sset"&&$==="sget")return W[M]="true",!1;else if(!L)return W[M]=$,!1;else return!0}function YL(W,O){var{computed:M,key:L}=W;return!M&&(L.type==="Identifier"&&L.name===O||L.type==="Literal"&&L.value===O)}x.parseExportAllDeclaration=function(W,O){if(this.options.ecmaVersion>=11)if(this.eatContextual("as"))W.exported=this.parseModuleExportName(),this.checkExport(O,W.exported,this.lastTokStart);else W.exported=null;if(this.expectContextual("from"),this.type!==z.string)this.unexpected();if(W.source=this.parseExprAtom(),this.options.ecmaVersion>=16)W.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(W,"ExportAllDeclaration")};x.parseExport=function(W,O){if(this.next(),this.eat(z.star))return this.parseExportAllDeclaration(W,O);if(this.eat(z._default))return this.checkExport(O,"default",this.lastTokStart),W.declaration=this.parseExportDefaultDeclaration(),this.finishNode(W,"ExportDefaultDeclaration");if(this.shouldParseExportStatement()){if(W.declaration=this.parseExportDeclaration(W),W.declaration.type==="VariableDeclaration")this.checkVariableExport(O,W.declaration.declarations);else this.checkExport(O,W.declaration.id,W.declaration.id.start);if(W.specifiers=[],W.source=null,this.options.ecmaVersion>=16)W.attributes=[]}else{if(W.declaration=null,W.specifiers=this.parseExportSpecifiers(O),this.eatContextual("from")){if(this.type!==z.string)this.unexpected();if(W.source=this.parseExprAtom(),this.options.ecmaVersion>=16)W.attributes=this.parseWithClause()}else{for(var M=0,L=W.specifiers;M<L.length;M+=1){var $=L[M];if(this.checkUnreserved($.local),this.checkLocalExport($.local),$.local.type==="Literal")this.raise($.local.start,"A string literal cannot be used as an exported binding without `from`.")}if(W.source=null,this.options.ecmaVersion>=16)W.attributes=[]}this.semicolon()}return this.finishNode(W,"ExportNamedDeclaration")};x.parseExportDeclaration=function(W){return this.parseStatement(null)};x.parseExportDefaultDeclaration=function(){var W;if(this.type===z._function||(W=this.isAsyncFunction())){var O=this.startNode();if(this.next(),W)this.next();return this.parseFunction(O,h1|MA,!1,W)}else if(this.type===z._class){var M=this.startNode();return this.parseClass(M,"nullableID")}else{var L=this.parseMaybeAssign();return this.semicolon(),L}};x.checkExport=function(W,O,M){if(!W)return;if(typeof O!=="string")O=O.type==="Identifier"?O.name:O.value;if(p0(W,O))this.raiseRecoverable(M,"Duplicate export '"+O+"'");W[O]=!0};x.checkPatternExport=function(W,O){var M=O.type;if(M==="Identifier")this.checkExport(W,O,O.start);else if(M==="ObjectPattern")for(var L=0,$=O.properties;L<$.length;L+=1){var Y=$[L];this.checkPatternExport(W,Y)}else if(M==="ArrayPattern")for(var J=0,A=O.elements;J<A.length;J+=1){var Z=A[J];if(Z)this.checkPatternExport(W,Z)}else if(M==="Property")this.checkPatternExport(W,O.value);else if(M==="AssignmentPattern")this.checkPatternExport(W,O.left);else if(M==="RestElement")this.checkPatternExport(W,O.argument)};x.checkVariableExport=function(W,O){if(!W)return;for(var M=0,L=O;M<L.length;M+=1){var $=L[M];this.checkPatternExport(W,$.id)}};x.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};x.parseExportSpecifier=function(W){var O=this.startNode();return O.local=this.parseModuleExportName(),O.exported=this.eatContextual("as")?this.parseModuleExportName():O.local,this.checkExport(W,O.exported,O.exported.start),this.finishNode(O,"ExportSpecifier")};x.parseExportSpecifiers=function(W){var O=[],M=!0;this.expect(z.braceL);while(!this.eat(z.braceR)){if(!M){if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break}else M=!1;O.push(this.parseExportSpecifier(W))}return O};x.parseImport=function(W){if(this.next(),this.type===z.string)W.specifiers=_K,W.source=this.parseExprAtom();else W.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),W.source=this.type===z.string?this.parseExprAtom():this.unexpected();if(this.options.ecmaVersion>=16)W.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(W,"ImportDeclaration")};x.parseImportSpecifier=function(){var W=this.startNode();if(W.imported=this.parseModuleExportName(),this.eatContextual("as"))W.local=this.parseIdent();else this.checkUnreserved(W.imported),W.local=W.imported;return this.checkLValSimple(W.local,fO),this.finishNode(W,"ImportSpecifier")};x.parseImportDefaultSpecifier=function(){var W=this.startNode();return W.local=this.parseIdent(),this.checkLValSimple(W.local,fO),this.finishNode(W,"ImportDefaultSpecifier")};x.parseImportNamespaceSpecifier=function(){var W=this.startNode();return this.next(),this.expectContextual("as"),W.local=this.parseIdent(),this.checkLValSimple(W.local,fO),this.finishNode(W,"ImportNamespaceSpecifier")};x.parseImportSpecifiers=function(){var W=[],O=!0;if(this.type===z.name){if(W.push(this.parseImportDefaultSpecifier()),!this.eat(z.comma))return W}if(this.type===z.star)return W.push(this.parseImportNamespaceSpecifier()),W;this.expect(z.braceL);while(!this.eat(z.braceR)){if(!O){if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break}else O=!1;W.push(this.parseImportSpecifier())}return W};x.parseWithClause=function(){var W=[];if(!this.eat(z._with))return W;this.expect(z.braceL);var O={},M=!0;while(!this.eat(z.braceR)){if(!M){if(this.expect(z.comma),this.afterTrailingComma(z.braceR))break}else M=!1;var L=this.parseImportAttribute(),$=L.key.type==="Identifier"?L.key.name:L.key.value;if(p0(O,$))this.raiseRecoverable(L.key.start,"Duplicate attribute key '"+$+"'");O[$]=!0,W.push(L)}return W};x.parseImportAttribute=function(){var W=this.startNode();if(W.key=this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(z.colon),this.type!==z.string)this.unexpected();return W.value=this.parseExprAtom(),this.finishNode(W,"ImportAttribute")};x.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===z.string){var W=this.parseLiteral(this.value);if(BK.test(W.value))this.raise(W.start,"An export name cannot include a lone surrogate.");return W}return this.parseIdent(!0)};x.adaptDirectivePrologue=function(W){for(var O=0;O<W.length&&this.isDirectiveCandidate(W[O]);++O)W[O].directive=W[O].expression.raw.slice(1,-1)};x.isDirectiveCandidate=function(W){return this.options.ecmaVersion>=5&&W.type==="ExpressionStatement"&&W.expression.type==="Literal"&&typeof W.expression.value==="string"&&(this.input[W.start]==='"'||this.input[W.start]==="'")};var LO=VW.prototype;LO.toAssignable=function(W,O,M){if(this.options.ecmaVersion>=6&&W)switch(W.type){case"Identifier":if(this.inAsync&&W.name==="await")this.raise(W.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":if(W.type="ObjectPattern",M)this.checkPatternErrors(M,!0);for(var L=0,$=W.properties;L<$.length;L+=1){var Y=$[L];if(this.toAssignable(Y,O),Y.type==="RestElement"&&(Y.argument.type==="ArrayPattern"||Y.argument.type==="ObjectPattern"))this.raise(Y.argument.start,"Unexpected token")}break;case"Property":if(W.kind!=="init")this.raise(W.key.start,"Object pattern can't contain getter or setter");this.toAssignable(W.value,O);break;case"ArrayExpression":if(W.type="ArrayPattern",M)this.checkPatternErrors(M,!0);this.toAssignableList(W.elements,O);break;case"SpreadElement":if(W.type="RestElement",this.toAssignable(W.argument,O),W.argument.type==="AssignmentPattern")this.raise(W.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":if(W.operator!=="=")this.raise(W.left.end,"Only '=' operator can be used for specifying default value.");W.type="AssignmentPattern",delete W.operator,this.toAssignable(W.left,O);break;case"ParenthesizedExpression":this.toAssignable(W.expression,O,M);break;case"ChainExpression":this.raiseRecoverable(W.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!O)break;default:this.raise(W.start,"Assigning to rvalue")}else if(M)this.checkPatternErrors(M,!0);return W};LO.toAssignableList=function(W,O){var M=W.length;for(var L=0;L<M;L++){var $=W[L];if($)this.toAssignable($,O)}if(M){var Y=W[M-1];if(this.options.ecmaVersion===6&&O&&Y&&Y.type==="RestElement"&&Y.argument.type!=="Identifier")this.unexpected(Y.argument.start)}return W};LO.parseSpread=function(W){var O=this.startNode();return this.next(),O.argument=this.parseMaybeAssign(!1,W),this.finishNode(O,"SpreadElement")};LO.parseRestBinding=function(){var W=this.startNode();if(this.next(),this.options.ecmaVersion===6&&this.type!==z.name)this.unexpected();return W.argument=this.parseBindingAtom(),this.finishNode(W,"RestElement")};LO.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case z.bracketL:var W=this.startNode();return this.next(),W.elements=this.parseBindingList(z.bracketR,!0,!0),this.finishNode(W,"ArrayPattern");case z.braceL:return this.parseObj(!0)}return this.parseIdent()};LO.parseBindingList=function(W,O,M,L){var $=[],Y=!0;while(!this.eat(W)){if(Y)Y=!1;else this.expect(z.comma);if(O&&this.type===z.comma)$.push(null);else if(M&&this.afterTrailingComma(W))break;else if(this.type===z.ellipsis){var J=this.parseRestBinding();if(this.parseBindingListItem(J),$.push(J),this.type===z.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");this.expect(W);break}else $.push(this.parseAssignableListItem(L))}return $};LO.parseAssignableListItem=function(W){var O=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(O),O};LO.parseBindingListItem=function(W){return W};LO.parseMaybeDefault=function(W,O,M){if(M=M||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(z.eq))return M;var L=this.startNodeAt(W,O);return L.left=M,L.right=this.parseMaybeAssign(),this.finishNode(L,"AssignmentPattern")};LO.checkLValSimple=function(W,O,M){if(O===void 0)O=$L;var L=O!==$L;switch(W.type){case"Identifier":if(this.strict&&this.reservedWordsStrictBind.test(W.name))this.raiseRecoverable(W.start,(L?"Binding ":"Assigning to ")+W.name+" in strict mode");if(L){if(O===fO&&W.name==="let")this.raiseRecoverable(W.start,"let is disallowed as a lexically bound name");if(M){if(p0(M,W.name))this.raiseRecoverable(W.start,"Argument name clash");M[W.name]=!0}if(O!==OA)this.declareName(W.name,O,W.start)}break;case"ChainExpression":this.raiseRecoverable(W.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(L)this.raiseRecoverable(W.start,"Binding member expression");break;case"ParenthesizedExpression":if(L)this.raiseRecoverable(W.start,"Binding parenthesized expression");return this.checkLValSimple(W.expression,O,M);default:this.raise(W.start,(L?"Binding":"Assigning to")+" rvalue")}};LO.checkLValPattern=function(W,O,M){if(O===void 0)O=$L;switch(W.type){case"ObjectPattern":for(var L=0,$=W.properties;L<$.length;L+=1){var Y=$[L];this.checkLValInnerPattern(Y,O,M)}break;case"ArrayPattern":for(var J=0,A=W.elements;J<A.length;J+=1){var Z=A[J];if(Z)this.checkLValInnerPattern(Z,O,M)}break;default:this.checkLValSimple(W,O,M)}};LO.checkLValInnerPattern=function(W,O,M){if(O===void 0)O=$L;switch(W.type){case"Property":this.checkLValInnerPattern(W.value,O,M);break;case"AssignmentPattern":this.checkLValPattern(W.left,O,M);break;case"RestElement":this.checkLValPattern(W.argument,O,M);break;default:this.checkLValPattern(W,O,M)}};var QO=function(O,M,L,$,Y){this.token=O,this.isExpr=!!M,this.preserveSpace=!!L,this.override=$,this.generator=!!Y},ZW={b_stat:new QO("{",!1),b_expr:new QO("{",!0),b_tmpl:new QO("${",!1),p_stat:new QO("(",!1),p_expr:new QO("(",!0),q_tmpl:new QO("`",!0,!0,function(W){return W.tryReadTemplateToken()}),f_stat:new QO("function",!1),f_expr:new QO("function",!0),f_expr_gen:new QO("function",!0,!1,null,!0),f_gen:new QO("function",!1,!1,null,!0)},d0=VW.prototype;d0.initialContext=function(){return[ZW.b_stat]};d0.curContext=function(){return this.context[this.context.length-1]};d0.braceIsBlock=function(W){var O=this.curContext();if(O===ZW.f_expr||O===ZW.f_stat)return!0;if(W===z.colon&&(O===ZW.b_stat||O===ZW.b_expr))return!O.isExpr;if(W===z._return||W===z.name&&this.exprAllowed)return uW.test(this.input.slice(this.lastTokEnd,this.start));if(W===z._else||W===z.semi||W===z.eof||W===z.parenR||W===z.arrow)return!0;if(W===z.braceL)return O===ZW.b_stat;if(W===z._var||W===z._const||W===z.name)return!1;return!this.exprAllowed};d0.inGeneratorContext=function(){for(var W=this.context.length-1;W>=1;W--){var O=this.context[W];if(O.token==="function")return O.generator}return!1};d0.updateContext=function(W){var O,M=this.type;if(M.keyword&&W===z.dot)this.exprAllowed=!1;else if(O=M.updateContext)O.call(this,W);else this.exprAllowed=M.beforeExpr};d0.overrideContext=function(W){if(this.curContext()!==W)this.context[this.context.length-1]=W};z.parenR.updateContext=z.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var W=this.context.pop();if(W===ZW.b_stat&&this.curContext().token==="function")W=this.context.pop();this.exprAllowed=!W.isExpr};z.braceL.updateContext=function(W){this.context.push(this.braceIsBlock(W)?ZW.b_stat:ZW.b_expr),this.exprAllowed=!0};z.dollarBraceL.updateContext=function(){this.context.push(ZW.b_tmpl),this.exprAllowed=!0};z.parenL.updateContext=function(W){var O=W===z._if||W===z._for||W===z._with||W===z._while;this.context.push(O?ZW.p_stat:ZW.p_expr),this.exprAllowed=!0};z.incDec.updateContext=function(){};z._function.updateContext=z._class.updateContext=function(W){if(W.beforeExpr&&W!==z._else&&!(W===z.semi&&this.curContext()!==ZW.p_stat)&&!(W===z._return&&uW.test(this.input.slice(this.lastTokEnd,this.start)))&&!((W===z.colon||W===z.braceL)&&this.curContext()===ZW.b_stat))this.context.push(ZW.f_expr);else this.context.push(ZW.f_stat);this.exprAllowed=!1};z.colon.updateContext=function(){if(this.curContext().token==="function")this.context.pop();this.exprAllowed=!0};z.backQuote.updateContext=function(){if(this.curContext()===ZW.q_tmpl)this.context.pop();else this.context.push(ZW.q_tmpl);this.exprAllowed=!1};z.star.updateContext=function(W){if(W===z._function){var O=this.context.length-1;if(this.context[O]===ZW.f_expr)this.context[O]=ZW.f_expr_gen;else this.context[O]=ZW.f_gen}this.exprAllowed=!0};z.name.updateContext=function(W){var O=!1;if(this.options.ecmaVersion>=6&&W!==z.dot){if(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())O=!0}this.exprAllowed=O};var l=VW.prototype;l.checkPropClash=function(W,O,M){if(this.options.ecmaVersion>=9&&W.type==="SpreadElement")return;if(this.options.ecmaVersion>=6&&(W.computed||W.method||W.shorthand))return;var L=W.key,$;switch(L.type){case"Identifier":$=L.name;break;case"Literal":$=String(L.value);break;default:return}var Y=W.kind;if(this.options.ecmaVersion>=6){if($==="__proto__"&&Y==="init"){if(O.proto)if(M){if(M.doubleProto<0)M.doubleProto=L.start}else this.raiseRecoverable(L.start,"Redefinition of __proto__ property");O.proto=!0}return}$="$"+$;var J=O[$];if(J){var A;if(Y==="init")A=this.strict&&J.init||J.get||J.set;else A=J.init||J[Y];if(A)this.raiseRecoverable(L.start,"Redefinition of property")}else J=O[$]={init:!1,get:!1,set:!1};J[Y]=!0};l.parseExpression=function(W,O){var M=this.start,L=this.startLoc,$=this.parseMaybeAssign(W,O);if(this.type===z.comma){var Y=this.startNodeAt(M,L);Y.expressions=[$];while(this.eat(z.comma))Y.expressions.push(this.parseMaybeAssign(W,O));return this.finishNode(Y,"SequenceExpression")}return $};l.parseMaybeAssign=function(W,O,M){if(this.isContextual("yield"))if(this.inGenerator)return this.parseYield(W);else this.exprAllowed=!1;var L=!1,$=-1,Y=-1,J=-1;if(O)$=O.parenthesizedAssign,Y=O.trailingComma,J=O.doubleProto,O.parenthesizedAssign=O.trailingComma=-1;else O=new QL,L=!0;var A=this.start,Z=this.startLoc;if(this.type===z.parenL||this.type===z.name)this.potentialArrowAt=this.start,this.potentialArrowInForAwait=W==="await";var G=this.parseMaybeConditional(W,O);if(M)G=M.call(this,G,A,Z);if(this.type.isAssign){var X=this.startNodeAt(A,Z);if(X.operator=this.value,this.type===z.eq)G=this.toAssignable(G,!1,O);if(!L)O.parenthesizedAssign=O.trailingComma=O.doubleProto=-1;if(O.shorthandAssign>=G.start)O.shorthandAssign=-1;if(this.type===z.eq)this.checkLValPattern(G);else this.checkLValSimple(G);if(X.left=G,this.next(),X.right=this.parseMaybeAssign(W),J>-1)O.doubleProto=J;return this.finishNode(X,"AssignmentExpression")}else if(L)this.checkExpressionErrors(O,!0);if($>-1)O.parenthesizedAssign=$;if(Y>-1)O.trailingComma=Y;return G};l.parseMaybeConditional=function(W,O){var M=this.start,L=this.startLoc,$=this.parseExprOps(W,O);if(this.checkExpressionErrors(O))return $;if(this.eat(z.question)){var Y=this.startNodeAt(M,L);return Y.test=$,Y.consequent=this.parseMaybeAssign(),this.expect(z.colon),Y.alternate=this.parseMaybeAssign(W),this.finishNode(Y,"ConditionalExpression")}return $};l.parseExprOps=function(W,O){var M=this.start,L=this.startLoc,$=this.parseMaybeUnary(O,!1,!1,W);if(this.checkExpressionErrors(O))return $;return $.start===M&&$.type==="ArrowFunctionExpression"?$:this.parseExprOp($,M,L,-1,W)};l.parseExprOp=function(W,O,M,L,$){var Y=this.type.binop;if(Y!=null&&(!$||this.type!==z._in)){if(Y>L){var J=this.type===z.logicalOR||this.type===z.logicalAND,A=this.type===z.coalesce;if(A)Y=z.logicalAND.binop;var Z=this.value;this.next();var G=this.start,X=this.startLoc,Q=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,$),G,X,Y,$),R=this.buildBinary(O,M,W,Q,Z,J||A);if(J&&this.type===z.coalesce||A&&(this.type===z.logicalOR||this.type===z.logicalAND))this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");return this.parseExprOp(R,O,M,L,$)}}return W};l.buildBinary=function(W,O,M,L,$,Y){if(L.type==="PrivateIdentifier")this.raise(L.start,"Private identifier can only be left side of binary expression");var J=this.startNodeAt(W,O);return J.left=M,J.operator=$,J.right=L,this.finishNode(J,Y?"LogicalExpression":"BinaryExpression")};l.parseMaybeUnary=function(W,O,M,L){var $=this.start,Y=this.startLoc,J;if(this.isContextual("await")&&this.canAwait)J=this.parseAwait(L),O=!0;else if(this.type.prefix){var A=this.startNode(),Z=this.type===z.incDec;if(A.operator=this.value,A.prefix=!0,this.next(),A.argument=this.parseMaybeUnary(null,!0,Z,L),this.checkExpressionErrors(W,!0),Z)this.checkLValSimple(A.argument);else if(this.strict&&A.operator==="delete"&&LA(A.argument))this.raiseRecoverable(A.start,"Deleting local variable in strict mode");else if(A.operator==="delete"&&X8(A.argument))this.raiseRecoverable(A.start,"Private fields can not be deleted");else O=!0;J=this.finishNode(A,Z?"UpdateExpression":"UnaryExpression")}else if(!O&&this.type===z.privateId){if((L||this.privateNameStack.length===0)&&this.options.checkPrivateFields)this.unexpected();if(J=this.parsePrivateIdent(),this.type!==z._in)this.unexpected()}else{if(J=this.parseExprSubscripts(W,L),this.checkExpressionErrors(W))return J;while(this.type.postfix&&!this.canInsertSemicolon()){var G=this.startNodeAt($,Y);G.operator=this.value,G.prefix=!1,G.argument=J,this.checkLValSimple(J),this.next(),J=this.finishNode(G,"UpdateExpression")}}if(!M&&this.eat(z.starstar))if(O)this.unexpected(this.lastTokStart);else return this.buildBinary($,Y,J,this.parseMaybeUnary(null,!1,!1,L),"**",!1);else return J};function LA(W){return W.type==="Identifier"||W.type==="ParenthesizedExpression"&&LA(W.expression)}function X8(W){return W.type==="MemberExpression"&&W.property.type==="PrivateIdentifier"||W.type==="ChainExpression"&&X8(W.expression)||W.type==="ParenthesizedExpression"&&X8(W.expression)}l.parseExprSubscripts=function(W,O){var M=this.start,L=this.startLoc,$=this.parseExprAtom(W,O);if($.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return $;var Y=this.parseSubscripts($,M,L,!1,O);if(W&&Y.type==="MemberExpression"){if(W.parenthesizedAssign>=Y.start)W.parenthesizedAssign=-1;if(W.parenthesizedBind>=Y.start)W.parenthesizedBind=-1;if(W.trailingComma>=Y.start)W.trailingComma=-1}return Y};l.parseSubscripts=function(W,O,M,L,$){var Y=this.options.ecmaVersion>=8&&W.type==="Identifier"&&W.name==="async"&&this.lastTokEnd===W.end&&!this.canInsertSemicolon()&&W.end-W.start===5&&this.potentialArrowAt===W.start,J=!1;while(!0){var A=this.parseSubscript(W,O,M,L,Y,J,$);if(A.optional)J=!0;if(A===W||A.type==="ArrowFunctionExpression"){if(J){var Z=this.startNodeAt(O,M);Z.expression=A,A=this.finishNode(Z,"ChainExpression")}return A}W=A}};l.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(z.arrow)};l.parseSubscriptAsyncArrow=function(W,O,M,L){return this.parseArrowExpression(this.startNodeAt(W,O),M,!0,L)};l.parseSubscript=function(W,O,M,L,$,Y,J){var A=this.options.ecmaVersion>=11,Z=A&&this.eat(z.questionDot);if(L&&Z)this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var G=this.eat(z.bracketL);if(G||Z&&this.type!==z.parenL&&this.type!==z.backQuote||this.eat(z.dot)){var X=this.startNodeAt(O,M);if(X.object=W,G)X.property=this.parseExpression(),this.expect(z.bracketR);else if(this.type===z.privateId&&W.type!=="Super")X.property=this.parsePrivateIdent();else X.property=this.parseIdent(this.options.allowReserved!=="never");if(X.computed=!!G,A)X.optional=Z;W=this.finishNode(X,"MemberExpression")}else if(!L&&this.eat(z.parenL)){var Q=new QL,R=this.yieldPos,U=this.awaitPos,T=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var S=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1,Q);if($&&!Z&&this.shouldParseAsyncArrow()){if(this.checkPatternErrors(Q,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0)this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function");return this.yieldPos=R,this.awaitPos=U,this.awaitIdentPos=T,this.parseSubscriptAsyncArrow(O,M,S,J)}this.checkExpressionErrors(Q,!0),this.yieldPos=R||this.yieldPos,this.awaitPos=U||this.awaitPos,this.awaitIdentPos=T||this.awaitIdentPos;var H=this.startNodeAt(O,M);if(H.callee=W,H.arguments=S,A)H.optional=Z;W=this.finishNode(H,"CallExpression")}else if(this.type===z.backQuote){if(Z||Y)this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var F=this.startNodeAt(O,M);F.tag=W,F.quasi=this.parseTemplate({isTagged:!0}),W=this.finishNode(F,"TaggedTemplateExpression")}return W};l.parseExprAtom=function(W,O,M){if(this.type===z.slash)this.readRegexp();var L,$=this.potentialArrowAt===this.start;switch(this.type){case z._super:if(!this.allowSuper)this.raise(this.start,"'super' keyword outside a method");if(L=this.startNode(),this.next(),this.type===z.parenL&&!this.allowDirectSuper)this.raise(L.start,"super() call outside constructor of a subclass");if(this.type!==z.dot&&this.type!==z.bracketL&&this.type!==z.parenL)this.unexpected();return this.finishNode(L,"Super");case z._this:return L=this.startNode(),this.next(),this.finishNode(L,"ThisExpression");case z.name:var Y=this.start,J=this.startLoc,A=this.containsEsc,Z=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!A&&Z.name==="async"&&!this.canInsertSemicolon()&&this.eat(z._function))return this.overrideContext(ZW.f_expr),this.parseFunction(this.startNodeAt(Y,J),0,!1,!0,O);if($&&!this.canInsertSemicolon()){if(this.eat(z.arrow))return this.parseArrowExpression(this.startNodeAt(Y,J),[Z],!1,O);if(this.options.ecmaVersion>=8&&Z.name==="async"&&this.type===z.name&&!A&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc)){if(Z=this.parseIdent(!1),this.canInsertSemicolon()||!this.eat(z.arrow))this.unexpected();return this.parseArrowExpression(this.startNodeAt(Y,J),[Z],!0,O)}}return Z;case z.regexp:var G=this.value;return L=this.parseLiteral(G.value),L.regex={pattern:G.pattern,flags:G.flags},L;case z.num:case z.string:return this.parseLiteral(this.value);case z._null:case z._true:case z._false:return L=this.startNode(),L.value=this.type===z._null?null:this.type===z._true,L.raw=this.type.keyword,this.next(),this.finishNode(L,"Literal");case z.parenL:var X=this.start,Q=this.parseParenAndDistinguishExpression($,O);if(W){if(W.parenthesizedAssign<0&&!this.isSimpleAssignTarget(Q))W.parenthesizedAssign=X;if(W.parenthesizedBind<0)W.parenthesizedBind=X}return Q;case z.bracketL:return L=this.startNode(),this.next(),L.elements=this.parseExprList(z.bracketR,!0,!0,W),this.finishNode(L,"ArrayExpression");case z.braceL:return this.overrideContext(ZW.b_expr),this.parseObj(!1,W);case z._function:return L=this.startNode(),this.next(),this.parseFunction(L,0);case z._class:return this.parseClass(this.startNode(),!1);case z._new:return this.parseNew();case z.backQuote:return this.parseTemplate();case z._import:if(this.options.ecmaVersion>=11)return this.parseExprImport(M);else return this.unexpected();default:return this.parseExprAtomDefault()}};l.parseExprAtomDefault=function(){this.unexpected()};l.parseExprImport=function(W){var O=this.startNode();if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword import");if(this.next(),this.type===z.parenL&&!W)return this.parseDynamicImport(O);else if(this.type===z.dot){var M=this.startNodeAt(O.start,O.loc&&O.loc.start);return M.name="import",O.meta=this.finishNode(M,"Identifier"),this.parseImportMeta(O)}else this.unexpected()};l.parseDynamicImport=function(W){if(this.next(),W.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)if(!this.eat(z.parenR))if(this.expect(z.comma),!this.afterTrailingComma(z.parenR)){if(W.options=this.parseMaybeAssign(),!this.eat(z.parenR)){if(this.expect(z.comma),!this.afterTrailingComma(z.parenR))this.unexpected()}}else W.options=null;else W.options=null;else if(!this.eat(z.parenR)){var O=this.start;if(this.eat(z.comma)&&this.eat(z.parenR))this.raiseRecoverable(O,"Trailing comma is not allowed in import()");else this.unexpected(O)}return this.finishNode(W,"ImportExpression")};l.parseImportMeta=function(W){this.next();var O=this.containsEsc;if(W.property=this.parseIdent(!0),W.property.name!=="meta")this.raiseRecoverable(W.property.start,"The only valid meta property for import is 'import.meta'");if(O)this.raiseRecoverable(W.start,"'import.meta' must not contain escaped characters");if(this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere)this.raiseRecoverable(W.start,"Cannot use 'import.meta' outside a module");return this.finishNode(W,"MetaProperty")};l.parseLiteral=function(W){var O=this.startNode();if(O.value=W,O.raw=this.input.slice(this.start,this.end),O.raw.charCodeAt(O.raw.length-1)===110)O.bigint=O.value!=null?O.value.toString():O.raw.slice(0,-1).replace(/_/g,"");return this.next(),this.finishNode(O,"Literal")};l.parseParenExpression=function(){this.expect(z.parenL);var W=this.parseExpression();return this.expect(z.parenR),W};l.shouldParseArrow=function(W){return!this.canInsertSemicolon()};l.parseParenAndDistinguishExpression=function(W,O){var M=this.start,L=this.startLoc,$,Y=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var J=this.start,A=this.startLoc,Z=[],G=!0,X=!1,Q=new QL,R=this.yieldPos,U=this.awaitPos,T;this.yieldPos=0,this.awaitPos=0;while(this.type!==z.parenR)if(G?G=!1:this.expect(z.comma),Y&&this.afterTrailingComma(z.parenR,!0)){X=!0;break}else if(this.type===z.ellipsis){if(T=this.start,Z.push(this.parseParenItem(this.parseRestBinding())),this.type===z.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else Z.push(this.parseMaybeAssign(!1,Q,this.parseParenItem));var S=this.lastTokEnd,H=this.lastTokEndLoc;if(this.expect(z.parenR),W&&this.shouldParseArrow(Z)&&this.eat(z.arrow))return this.checkPatternErrors(Q,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=R,this.awaitPos=U,this.parseParenArrowList(M,L,Z,O);if(!Z.length||X)this.unexpected(this.lastTokStart);if(T)this.unexpected(T);if(this.checkExpressionErrors(Q,!0),this.yieldPos=R||this.yieldPos,this.awaitPos=U||this.awaitPos,Z.length>1)$=this.startNodeAt(J,A),$.expressions=Z,this.finishNodeAt($,"SequenceExpression",S,H);else $=Z[0]}else $=this.parseParenExpression();if(this.options.preserveParens){var F=this.startNodeAt(M,L);return F.expression=$,this.finishNode(F,"ParenthesizedExpression")}else return $};l.parseParenItem=function(W){return W};l.parseParenArrowList=function(W,O,M,L){return this.parseArrowExpression(this.startNodeAt(W,O),M,!1,L)};var IK=[];l.parseNew=function(){if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword new");var W=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===z.dot){var O=this.startNodeAt(W.start,W.loc&&W.loc.start);O.name="new",W.meta=this.finishNode(O,"Identifier"),this.next();var M=this.containsEsc;if(W.property=this.parseIdent(!0),W.property.name!=="target")this.raiseRecoverable(W.property.start,"The only valid meta property for new is 'new.target'");if(M)this.raiseRecoverable(W.start,"'new.target' must not contain escaped characters");if(!this.allowNewDotTarget)this.raiseRecoverable(W.start,"'new.target' can only be used in functions and class static block");return this.finishNode(W,"MetaProperty")}var L=this.start,$=this.startLoc;if(W.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),L,$,!0,!1),this.eat(z.parenL))W.arguments=this.parseExprList(z.parenR,this.options.ecmaVersion>=8,!1);else W.arguments=IK;return this.finishNode(W,"NewExpression")};l.parseTemplateElement=function(W){var O=W.isTagged,M=this.startNode();if(this.type===z.invalidTemplate){if(!O)this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal");M.value={raw:this.value.replace(/\r\n?/g,`
17
17
  `),cooked:null}}else M.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
18
- `),cooked:this.value};return this.next(),M.tail=this.type===z.backQuote,this.finishNode(M,"TemplateElement")};l.parseTemplate=function(W){if(W===void 0)W={};var O=W.isTagged;if(O===void 0)O=!1;var M=this.startNode();this.next(),M.expressions=[];var L=this.parseTemplateElement({isTagged:O});M.quasis=[L];while(!L.tail){if(this.type===z.eof)this.raise(this.pos,"Unterminated template literal");this.expect(z.dollarBraceL),M.expressions.push(this.parseExpression()),this.expect(z.braceR),M.quasis.push(L=this.parseTemplateElement({isTagged:O}))}return this.next(),this.finishNode(M,"TemplateLiteral")};l.isAsyncProp=function(W){return!W.computed&&W.key.type==="Identifier"&&W.key.name==="async"&&(this.type===z.name||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===z.star)&&!uW.test(this.input.slice(this.lastTokEnd,this.start))};l.parseObj=function(W,O){var M=this.startNode(),L=!0,$={};M.properties=[],this.next();while(!this.eat(z.braceR)){if(!L){if(this.expect(z.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(z.braceR))break}else L=!1;var Y=this.parseProperty(W,O);if(!W)this.checkPropClash(Y,$,O);M.properties.push(Y)}return this.finishNode(M,W?"ObjectPattern":"ObjectExpression")};l.parseProperty=function(W,O){var M=this.startNode(),L,$,Y,J;if(this.options.ecmaVersion>=9&&this.eat(z.ellipsis)){if(W){if(M.argument=this.parseIdent(!1),this.type===z.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");return this.finishNode(M,"RestElement")}if(M.argument=this.parseMaybeAssign(!1,O),this.type===z.comma&&O&&O.trailingComma<0)O.trailingComma=this.start;return this.finishNode(M,"SpreadElement")}if(this.options.ecmaVersion>=6){if(M.method=!1,M.shorthand=!1,W||O)Y=this.start,J=this.startLoc;if(!W)L=this.eat(z.star)}var A=this.containsEsc;if(this.parsePropertyName(M),!W&&!A&&this.options.ecmaVersion>=8&&!L&&this.isAsyncProp(M))$=!0,L=this.options.ecmaVersion>=9&&this.eat(z.star),this.parsePropertyName(M);else $=!1;return this.parsePropertyValue(M,W,L,$,Y,J,O,A),this.finishNode(M,"Property")};l.parseGetterSetter=function(W){var O=W.key.name;this.parsePropertyName(W),W.value=this.parseMethod(!1),W.kind=O;var M=W.kind==="get"?0:1;if(W.value.params.length!==M){var L=W.value.start;if(W.kind==="get")this.raiseRecoverable(L,"getter should have no params");else this.raiseRecoverable(L,"setter should have exactly one param")}else if(W.kind==="set"&&W.value.params[0].type==="RestElement")this.raiseRecoverable(W.value.params[0].start,"Setter cannot use rest params")};l.parsePropertyValue=function(W,O,M,L,$,Y,J,A){if((M||L)&&this.type===z.colon)this.unexpected();if(this.eat(z.colon))W.value=O?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,J),W.kind="init";else if(this.options.ecmaVersion>=6&&this.type===z.parenL){if(O)this.unexpected();W.method=!0,W.value=this.parseMethod(M,L),W.kind="init"}else if(!O&&!A&&this.options.ecmaVersion>=5&&!W.computed&&W.key.type==="Identifier"&&(W.key.name==="get"||W.key.name==="set")&&(this.type!==z.comma&&this.type!==z.braceR&&this.type!==z.eq)){if(M||L)this.unexpected();this.parseGetterSetter(W)}else if(this.options.ecmaVersion>=6&&!W.computed&&W.key.type==="Identifier"){if(M||L)this.unexpected();if(this.checkUnreserved(W.key),W.key.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=$;if(O)W.value=this.parseMaybeDefault($,Y,this.copyNode(W.key));else if(this.type===z.eq&&J){if(J.shorthandAssign<0)J.shorthandAssign=this.start;W.value=this.parseMaybeDefault($,Y,this.copyNode(W.key))}else W.value=this.copyNode(W.key);W.kind="init",W.shorthand=!0}else this.unexpected()};l.parsePropertyName=function(W){if(this.options.ecmaVersion>=6)if(this.eat(z.bracketL))return W.computed=!0,W.key=this.parseMaybeAssign(),this.expect(z.bracketR),W.key;else W.computed=!1;return W.key=this.type===z.num||this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};l.initFunction=function(W){if(W.id=null,this.options.ecmaVersion>=6)W.generator=W.expression=!1;if(this.options.ecmaVersion>=8)W.async=!1};l.parseMethod=function(W,O,M){var L=this.startNode(),$=this.yieldPos,Y=this.awaitPos,J=this.awaitIdentPos;if(this.initFunction(L),this.options.ecmaVersion>=6)L.generator=W;if(this.options.ecmaVersion>=8)L.async=!!O;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(R8(O,L.generator)|ZL|(M?r6:0)),this.expect(z.parenL),L.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(L,!1,!0,!1),this.yieldPos=$,this.awaitPos=Y,this.awaitIdentPos=J,this.finishNode(L,"FunctionExpression")};l.parseArrowExpression=function(W,O,M,L){var $=this.yieldPos,Y=this.awaitPos,J=this.awaitIdentPos;if(this.enterScope(R8(M,!1)|S8),this.initFunction(W),this.options.ecmaVersion>=8)W.async=!!M;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,W.params=this.toAssignableList(O,!0),this.parseFunctionBody(W,!0,!1,L),this.yieldPos=$,this.awaitPos=Y,this.awaitIdentPos=J,this.finishNode(W,"ArrowFunctionExpression")};l.parseFunctionBody=function(W,O,M,L){var $=O&&this.type!==z.braceL,Y=this.strict,J=!1;if($)W.body=this.parseMaybeAssign(L),W.expression=!0,this.checkParams(W,!1);else{var A=this.options.ecmaVersion>=7&&!this.isSimpleParamList(W.params);if(!Y||A){if(J=this.strictDirective(this.end),J&&A)this.raiseRecoverable(W.start,"Illegal 'use strict' directive in function with non-simple parameter list")}var Z=this.labels;if(this.labels=[],J)this.strict=!0;if(this.checkParams(W,!Y&&!J&&!O&&!M&&this.isSimpleParamList(W.params)),this.strict&&W.id)this.checkLValSimple(W.id,t6);W.body=this.parseBlock(!1,void 0,J&&!Y),W.expression=!1,this.adaptDirectivePrologue(W.body.body),this.labels=Z}this.exitScope()};l.isSimpleParamList=function(W){for(var O=0,M=W;O<M.length;O+=1){var L=M[O];if(L.type!=="Identifier")return!1}return!0};l.checkParams=function(W,O){var M=Object.create(null);for(var L=0,$=W.params;L<$.length;L+=1){var Y=$[L];this.checkLValInnerPattern(Y,U8,O?null:M)}};l.parseExprList=function(W,O,M,L){var $=[],Y=!0;while(!this.eat(W)){if(!Y){if(this.expect(z.comma),O&&this.afterTrailingComma(W))break}else Y=!1;var J=void 0;if(M&&this.type===z.comma)J=null;else if(this.type===z.ellipsis){if(J=this.parseSpread(L),L&&this.type===z.comma&&L.trailingComma<0)L.trailingComma=this.start}else J=this.parseMaybeAssign(!1,L);$.push(J)}return $};l.checkUnreserved=function(W){var{start:O,end:M,name:L}=W;if(this.inGenerator&&L==="yield")this.raiseRecoverable(O,"Cannot use 'yield' as identifier inside a generator");if(this.inAsync&&L==="await")this.raiseRecoverable(O,"Cannot use 'await' as identifier inside an async function");if(!(this.currentThisScope().flags&XL)&&L==="arguments")this.raiseRecoverable(O,"Cannot use 'arguments' in class field initializer");if(this.inClassStaticBlock&&(L==="arguments"||L==="await"))this.raise(O,"Cannot use "+L+" in class static initialization block");if(this.keywords.test(L))this.raise(O,"Unexpected keyword '"+L+"'");if(this.options.ecmaVersion<6&&this.input.slice(O,M).indexOf("\\")!==-1)return;var $=this.strict?this.reservedWordsStrict:this.reservedWords;if($.test(L)){if(!this.inAsync&&L==="await")this.raiseRecoverable(O,"Cannot use keyword 'await' outside an async function");this.raiseRecoverable(O,"The keyword '"+L+"' is reserved")}};l.parseIdent=function(W){var O=this.parseIdentNode();if(this.next(!!W),this.finishNode(O,"Identifier"),!W){if(this.checkUnreserved(O),O.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=O.start}return O};l.parseIdentNode=function(){var W=this.startNode();if(this.type===z.name)W.name=this.value;else if(this.type.keyword){if(W.name=this.type.keyword,(W.name==="class"||W.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46))this.context.pop();this.type=z.name}else this.unexpected();return W};l.parsePrivateIdent=function(){var W=this.startNode();if(this.type===z.privateId)W.name=this.value;else this.unexpected();if(this.next(),this.finishNode(W,"PrivateIdentifier"),this.options.checkPrivateFields)if(this.privateNameStack.length===0)this.raise(W.start,"Private field '#"+W.name+"' must be declared in an enclosing class");else this.privateNameStack[this.privateNameStack.length-1].used.push(W);return W};l.parseYield=function(W){if(!this.yieldPos)this.yieldPos=this.start;var O=this.startNode();if(this.next(),this.type===z.semi||this.canInsertSemicolon()||this.type!==z.star&&!this.type.startsExpr)O.delegate=!1,O.argument=null;else O.delegate=this.eat(z.star),O.argument=this.parseMaybeAssign(W);return this.finishNode(O,"YieldExpression")};l.parseAwait=function(W){if(!this.awaitPos)this.awaitPos=this.start;var O=this.startNode();return this.next(),O.argument=this.parseMaybeUnary(null,!0,!1,W),this.finishNode(O,"AwaitExpression")};var YL=HW.prototype;YL.raise=function(W,O){var M=i6(this.input,W);if(O+=" ("+M.line+":"+M.column+")",this.sourceFile)O+=" in "+this.sourceFile;var L=SyntaxError(O);throw L.pos=W,L.loc=M,L.raisedAt=this.pos,L};YL.raiseRecoverable=YL.raise;YL.curPosition=function(){if(this.options.locations)return new b1(this.curLine,this.pos-this.lineStart)};var aO=HW.prototype,jK=function(O){this.flags=O,this.var=[],this.lexical=[],this.functions=[]};aO.enterScope=function(W){this.scopeStack.push(new jK(W))};aO.exitScope=function(){this.scopeStack.pop()};aO.treatFunctionsAsVarInScope=function(W){return W.flags&x0||!this.inModule&&W.flags&f1};aO.declareName=function(W,O,M){var L=!1;if(O===bO){var $=this.currentScope();if(L=$.lexical.indexOf(W)>-1||$.functions.indexOf(W)>-1||$.var.indexOf(W)>-1,$.lexical.push(W),this.inModule&&$.flags&f1)delete this.undefinedExports[W]}else if(O===o6){var Y=this.currentScope();Y.lexical.push(W)}else if(O===a6){var J=this.currentScope();if(this.treatFunctionsAsVar)L=J.lexical.indexOf(W)>-1;else L=J.lexical.indexOf(W)>-1||J.var.indexOf(W)>-1;J.functions.push(W)}else for(var A=this.scopeStack.length-1;A>=0;--A){var Z=this.scopeStack[A];if(Z.lexical.indexOf(W)>-1&&!(Z.flags&n6&&Z.lexical[0]===W)||!this.treatFunctionsAsVarInScope(Z)&&Z.functions.indexOf(W)>-1){L=!0;break}if(Z.var.push(W),this.inModule&&Z.flags&f1)delete this.undefinedExports[W];if(Z.flags&XL)break}if(L)this.raiseRecoverable(M,"Identifier '"+W+"' has already been declared")};aO.checkLocalExport=function(W){if(this.scopeStack[0].lexical.indexOf(W.name)===-1&&this.scopeStack[0].var.indexOf(W.name)===-1)this.undefinedExports[W.name]=W};aO.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};aO.currentVarScope=function(){for(var W=this.scopeStack.length-1;;W--){var O=this.scopeStack[W];if(O.flags&(XL|v1|Q0))return O}};aO.currentThisScope=function(){for(var W=this.scopeStack.length-1;;W--){var O=this.scopeStack[W];if(O.flags&(XL|v1|Q0)&&!(O.flags&S8))return O}};var QL=function(O,M,L){if(this.type="",this.start=M,this.end=0,O.options.locations)this.loc=new AL(O,L);if(O.options.directSourceFile)this.sourceFile=O.options.directSourceFile;if(O.options.ranges)this.range=[M,0]},x1=HW.prototype;x1.startNode=function(){return new QL(this,this.start,this.startLoc)};x1.startNodeAt=function(W,O){return new QL(this,W,O)};function O4(W,O,M,L){if(W.type=O,W.end=M,this.options.locations)W.loc.end=L;if(this.options.ranges)W.range[1]=M;return W}x1.finishNode=function(W,O){return O4.call(this,W,O,this.lastTokEnd,this.lastTokEndLoc)};x1.finishNodeAt=function(W,O,M,L){return O4.call(this,W,O,M,L)};x1.copyNode=function(W){var O=new QL(this,W.start,this.startLoc);for(var M in W)O[M]=W[M];return O};var IK="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",M4="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",L4=M4+" Extended_Pictographic",$4=L4,Y4=$4+" EBase EComp EMod EPres ExtPict",J4=Y4,yK=J4,DK={9:M4,10:L4,11:$4,12:Y4,13:J4,14:yK},kK="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",bK={9:"",10:"",11:"",12:"",13:"",14:kK},u6="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",A4="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Z4=A4+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",X4=Z4+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",G4=X4+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Q4=G4+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",fK=Q4+" "+IK,vK={9:A4,10:Z4,11:X4,12:G4,13:Q4,14:fK},S4={};function xK(W){var O=S4[W]={binary:nO(DK[W]+" "+u6),binaryOfStrings:nO(bK[W]),nonBinary:{General_Category:nO(u6),Script:nO(vK[W])}};O.nonBinary.Script_Extensions=O.nonBinary.Script,O.nonBinary.gc=O.nonBinary.General_Category,O.nonBinary.sc=O.nonBinary.Script,O.nonBinary.scx=O.nonBinary.Script_Extensions}for(D1=0,ML=[9,10,11,12,13,14];D1<ML.length;D1+=1)X8=ML[D1],xK(X8);var X8,D1,ML,v=HW.prototype,JL=function(O,M){this.parent=O,this.base=M||this};JL.prototype.separatedFrom=function(O){for(var M=this;M;M=M.parent)for(var L=O;L;L=L.parent)if(M.base===L.base&&M!==L)return!0;return!1};JL.prototype.sibling=function(){return new JL(this.parent,this.base)};var KO=function(O){this.parser=O,this.validFlags="gim"+(O.options.ecmaVersion>=6?"uy":"")+(O.options.ecmaVersion>=9?"s":"")+(O.options.ecmaVersion>=13?"d":"")+(O.options.ecmaVersion>=15?"v":""),this.unicodeProperties=S4[O.options.ecmaVersion>=14?14:O.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};KO.prototype.reset=function(O,M,L){var $=L.indexOf("v")!==-1,Y=L.indexOf("u")!==-1;if(this.start=O|0,this.source=M+"",this.flags=L,$&&this.parser.options.ecmaVersion>=15)this.switchU=!0,this.switchV=!0,this.switchN=!0;else this.switchU=Y&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=Y&&this.parser.options.ecmaVersion>=9};KO.prototype.raise=function(O){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+O)};KO.prototype.at=function(O,M){if(M===void 0)M=!1;var L=this.source,$=L.length;if(O>=$)return-1;var Y=L.charCodeAt(O);if(!(M||this.switchU)||Y<=55295||Y>=57344||O+1>=$)return Y;var J=L.charCodeAt(O+1);return J>=56320&&J<=57343?(Y<<10)+J-56613888:Y};KO.prototype.nextIndex=function(O,M){if(M===void 0)M=!1;var L=this.source,$=L.length;if(O>=$)return $;var Y=L.charCodeAt(O),J;if(!(M||this.switchU)||Y<=55295||Y>=57344||O+1>=$||(J=L.charCodeAt(O+1))<56320||J>57343)return O+1;return O+2};KO.prototype.current=function(O){if(O===void 0)O=!1;return this.at(this.pos,O)};KO.prototype.lookahead=function(O){if(O===void 0)O=!1;return this.at(this.nextIndex(this.pos,O),O)};KO.prototype.advance=function(O){if(O===void 0)O=!1;this.pos=this.nextIndex(this.pos,O)};KO.prototype.eat=function(O,M){if(M===void 0)M=!1;if(this.current(M)===O)return this.advance(M),!0;return!1};KO.prototype.eatChars=function(O,M){if(M===void 0)M=!1;var L=this.pos;for(var $=0,Y=O;$<Y.length;$+=1){var J=Y[$],A=this.at(L,M);if(A===-1||A!==J)return!1;L=this.nextIndex(L,M)}return this.pos=L,!0};v.validateRegExpFlags=function(W){var{validFlags:O,flags:M}=W,L=!1,$=!1;for(var Y=0;Y<M.length;Y++){var J=M.charAt(Y);if(O.indexOf(J)===-1)this.raise(W.start,"Invalid regular expression flag");if(M.indexOf(J,Y+1)>-1)this.raise(W.start,"Duplicate regular expression flag");if(J==="u")L=!0;if(J==="v")$=!0}if(this.options.ecmaVersion>=15&&L&&$)this.raise(W.start,"Invalid regular expression flag")};function gK(W){for(var O in W)return!0;return!1}v.validateRegExpPattern=function(W){if(this.regexp_pattern(W),!W.switchN&&this.options.ecmaVersion>=9&&gK(W.groupNames))W.switchN=!0,this.regexp_pattern(W)};v.regexp_pattern=function(W){if(W.pos=0,W.lastIntValue=0,W.lastStringValue="",W.lastAssertionIsQuantifiable=!1,W.numCapturingParens=0,W.maxBackReference=0,W.groupNames=Object.create(null),W.backReferenceNames.length=0,W.branchID=null,this.regexp_disjunction(W),W.pos!==W.source.length){if(W.eat(41))W.raise("Unmatched ')'");if(W.eat(93)||W.eat(125))W.raise("Lone quantifier brackets")}if(W.maxBackReference>W.numCapturingParens)W.raise("Invalid escape");for(var O=0,M=W.backReferenceNames;O<M.length;O+=1){var L=M[O];if(!W.groupNames[L])W.raise("Invalid named capture referenced")}};v.regexp_disjunction=function(W){var O=this.options.ecmaVersion>=16;if(O)W.branchID=new JL(W.branchID,null);this.regexp_alternative(W);while(W.eat(124)){if(O)W.branchID=W.branchID.sibling();this.regexp_alternative(W)}if(O)W.branchID=W.branchID.parent;if(this.regexp_eatQuantifier(W,!0))W.raise("Nothing to repeat");if(W.eat(123))W.raise("Lone quantifier brackets")};v.regexp_alternative=function(W){while(W.pos<W.source.length&&this.regexp_eatTerm(W));};v.regexp_eatTerm=function(W){if(this.regexp_eatAssertion(W)){if(W.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(W)){if(W.switchU)W.raise("Invalid quantifier")}return!0}if(W.switchU?this.regexp_eatAtom(W):this.regexp_eatExtendedAtom(W))return this.regexp_eatQuantifier(W),!0;return!1};v.regexp_eatAssertion=function(W){var O=W.pos;if(W.lastAssertionIsQuantifiable=!1,W.eat(94)||W.eat(36))return!0;if(W.eat(92)){if(W.eat(66)||W.eat(98))return!0;W.pos=O}if(W.eat(40)&&W.eat(63)){var M=!1;if(this.options.ecmaVersion>=9)M=W.eat(60);if(W.eat(61)||W.eat(33)){if(this.regexp_disjunction(W),!W.eat(41))W.raise("Unterminated group");return W.lastAssertionIsQuantifiable=!M,!0}}return W.pos=O,!1};v.regexp_eatQuantifier=function(W,O){if(O===void 0)O=!1;if(this.regexp_eatQuantifierPrefix(W,O))return W.eat(63),!0;return!1};v.regexp_eatQuantifierPrefix=function(W,O){return W.eat(42)||W.eat(43)||W.eat(63)||this.regexp_eatBracedQuantifier(W,O)};v.regexp_eatBracedQuantifier=function(W,O){var M=W.pos;if(W.eat(123)){var L=0,$=-1;if(this.regexp_eatDecimalDigits(W)){if(L=W.lastIntValue,W.eat(44)&&this.regexp_eatDecimalDigits(W))$=W.lastIntValue;if(W.eat(125)){if($!==-1&&$<L&&!O)W.raise("numbers out of order in {} quantifier");return!0}}if(W.switchU&&!O)W.raise("Incomplete quantifier");W.pos=M}return!1};v.regexp_eatAtom=function(W){return this.regexp_eatPatternCharacters(W)||W.eat(46)||this.regexp_eatReverseSolidusAtomEscape(W)||this.regexp_eatCharacterClass(W)||this.regexp_eatUncapturingGroup(W)||this.regexp_eatCapturingGroup(W)};v.regexp_eatReverseSolidusAtomEscape=function(W){var O=W.pos;if(W.eat(92)){if(this.regexp_eatAtomEscape(W))return!0;W.pos=O}return!1};v.regexp_eatUncapturingGroup=function(W){var O=W.pos;if(W.eat(40)){if(W.eat(63)){if(this.options.ecmaVersion>=16){var M=this.regexp_eatModifiers(W),L=W.eat(45);if(M||L){for(var $=0;$<M.length;$++){var Y=M.charAt($);if(M.indexOf(Y,$+1)>-1)W.raise("Duplicate regular expression modifiers")}if(L){var J=this.regexp_eatModifiers(W);if(!M&&!J&&W.current()===58)W.raise("Invalid regular expression modifiers");for(var A=0;A<J.length;A++){var Z=J.charAt(A);if(J.indexOf(Z,A+1)>-1||M.indexOf(Z)>-1)W.raise("Duplicate regular expression modifiers")}}}}if(W.eat(58)){if(this.regexp_disjunction(W),W.eat(41))return!0;W.raise("Unterminated group")}}W.pos=O}return!1};v.regexp_eatCapturingGroup=function(W){if(W.eat(40)){if(this.options.ecmaVersion>=9)this.regexp_groupSpecifier(W);else if(W.current()===63)W.raise("Invalid group");if(this.regexp_disjunction(W),W.eat(41))return W.numCapturingParens+=1,!0;W.raise("Unterminated group")}return!1};v.regexp_eatModifiers=function(W){var O="",M=0;while((M=W.current())!==-1&&hK(M))O+=DO(M),W.advance();return O};function hK(W){return W===105||W===109||W===115}v.regexp_eatExtendedAtom=function(W){return W.eat(46)||this.regexp_eatReverseSolidusAtomEscape(W)||this.regexp_eatCharacterClass(W)||this.regexp_eatUncapturingGroup(W)||this.regexp_eatCapturingGroup(W)||this.regexp_eatInvalidBracedQuantifier(W)||this.regexp_eatExtendedPatternCharacter(W)};v.regexp_eatInvalidBracedQuantifier=function(W){if(this.regexp_eatBracedQuantifier(W,!0))W.raise("Nothing to repeat");return!1};v.regexp_eatSyntaxCharacter=function(W){var O=W.current();if(R4(O))return W.lastIntValue=O,W.advance(),!0;return!1};function R4(W){return W===36||W>=40&&W<=43||W===46||W===63||W>=91&&W<=94||W>=123&&W<=125}v.regexp_eatPatternCharacters=function(W){var O=W.pos,M=0;while((M=W.current())!==-1&&!R4(M))W.advance();return W.pos!==O};v.regexp_eatExtendedPatternCharacter=function(W){var O=W.current();if(O!==-1&&O!==36&&!(O>=40&&O<=43)&&O!==46&&O!==63&&O!==91&&O!==94&&O!==124)return W.advance(),!0;return!1};v.regexp_groupSpecifier=function(W){if(W.eat(63)){if(!this.regexp_eatGroupName(W))W.raise("Invalid group");var O=this.options.ecmaVersion>=16,M=W.groupNames[W.lastStringValue];if(M)if(O)for(var L=0,$=M;L<$.length;L+=1){var Y=$[L];if(!Y.separatedFrom(W.branchID))W.raise("Duplicate capture group name")}else W.raise("Duplicate capture group name");if(O)(M||(W.groupNames[W.lastStringValue]=[])).push(W.branchID);else W.groupNames[W.lastStringValue]=!0}};v.regexp_eatGroupName=function(W){if(W.lastStringValue="",W.eat(60)){if(this.regexp_eatRegExpIdentifierName(W)&&W.eat(62))return!0;W.raise("Invalid capture group name")}return!1};v.regexp_eatRegExpIdentifierName=function(W){if(W.lastStringValue="",this.regexp_eatRegExpIdentifierStart(W)){W.lastStringValue+=DO(W.lastIntValue);while(this.regexp_eatRegExpIdentifierPart(W))W.lastStringValue+=DO(W.lastIntValue);return!0}return!1};v.regexp_eatRegExpIdentifierStart=function(W){var O=W.pos,M=this.options.ecmaVersion>=11,L=W.current(M);if(W.advance(M),L===92&&this.regexp_eatRegExpUnicodeEscapeSequence(W,M))L=W.lastIntValue;if(uK(L))return W.lastIntValue=L,!0;return W.pos=O,!1};function uK(W){return VO(W,!0)||W===36||W===95}v.regexp_eatRegExpIdentifierPart=function(W){var O=W.pos,M=this.options.ecmaVersion>=11,L=W.current(M);if(W.advance(M),L===92&&this.regexp_eatRegExpUnicodeEscapeSequence(W,M))L=W.lastIntValue;if(lK(L))return W.lastIntValue=L,!0;return W.pos=O,!1};function lK(W){return rO(W,!0)||W===36||W===95||W===8204||W===8205}v.regexp_eatAtomEscape=function(W){if(this.regexp_eatBackReference(W)||this.regexp_eatCharacterClassEscape(W)||this.regexp_eatCharacterEscape(W)||W.switchN&&this.regexp_eatKGroupName(W))return!0;if(W.switchU){if(W.current()===99)W.raise("Invalid unicode escape");W.raise("Invalid escape")}return!1};v.regexp_eatBackReference=function(W){var O=W.pos;if(this.regexp_eatDecimalEscape(W)){var M=W.lastIntValue;if(W.switchU){if(M>W.maxBackReference)W.maxBackReference=M;return!0}if(M<=W.numCapturingParens)return!0;W.pos=O}return!1};v.regexp_eatKGroupName=function(W){if(W.eat(107)){if(this.regexp_eatGroupName(W))return W.backReferenceNames.push(W.lastStringValue),!0;W.raise("Invalid named reference")}return!1};v.regexp_eatCharacterEscape=function(W){return this.regexp_eatControlEscape(W)||this.regexp_eatCControlLetter(W)||this.regexp_eatZero(W)||this.regexp_eatHexEscapeSequence(W)||this.regexp_eatRegExpUnicodeEscapeSequence(W,!1)||!W.switchU&&this.regexp_eatLegacyOctalEscapeSequence(W)||this.regexp_eatIdentityEscape(W)};v.regexp_eatCControlLetter=function(W){var O=W.pos;if(W.eat(99)){if(this.regexp_eatControlLetter(W))return!0;W.pos=O}return!1};v.regexp_eatZero=function(W){if(W.current()===48&&!SL(W.lookahead()))return W.lastIntValue=0,W.advance(),!0;return!1};v.regexp_eatControlEscape=function(W){var O=W.current();if(O===116)return W.lastIntValue=9,W.advance(),!0;if(O===110)return W.lastIntValue=10,W.advance(),!0;if(O===118)return W.lastIntValue=11,W.advance(),!0;if(O===102)return W.lastIntValue=12,W.advance(),!0;if(O===114)return W.lastIntValue=13,W.advance(),!0;return!1};v.regexp_eatControlLetter=function(W){var O=W.current();if(U4(O))return W.lastIntValue=O%32,W.advance(),!0;return!1};function U4(W){return W>=65&&W<=90||W>=97&&W<=122}v.regexp_eatRegExpUnicodeEscapeSequence=function(W,O){if(O===void 0)O=!1;var M=W.pos,L=O||W.switchU;if(W.eat(117)){if(this.regexp_eatFixedHexDigits(W,4)){var $=W.lastIntValue;if(L&&$>=55296&&$<=56319){var Y=W.pos;if(W.eat(92)&&W.eat(117)&&this.regexp_eatFixedHexDigits(W,4)){var J=W.lastIntValue;if(J>=56320&&J<=57343)return W.lastIntValue=($-55296)*1024+(J-56320)+65536,!0}W.pos=Y,W.lastIntValue=$}return!0}if(L&&W.eat(123)&&this.regexp_eatHexDigits(W)&&W.eat(125)&&pK(W.lastIntValue))return!0;if(L)W.raise("Invalid unicode escape");W.pos=M}return!1};function pK(W){return W>=0&&W<=1114111}v.regexp_eatIdentityEscape=function(W){if(W.switchU){if(this.regexp_eatSyntaxCharacter(W))return!0;if(W.eat(47))return W.lastIntValue=47,!0;return!1}var O=W.current();if(O!==99&&(!W.switchN||O!==107))return W.lastIntValue=O,W.advance(),!0;return!1};v.regexp_eatDecimalEscape=function(W){W.lastIntValue=0;var O=W.current();if(O>=49&&O<=57){do W.lastIntValue=10*W.lastIntValue+(O-48),W.advance();while((O=W.current())>=48&&O<=57);return!0}return!1};var z4=0,kO=1,eW=2;v.regexp_eatCharacterClassEscape=function(W){var O=W.current();if(mK(O))return W.lastIntValue=-1,W.advance(),kO;var M=!1;if(W.switchU&&this.options.ecmaVersion>=9&&((M=O===80)||O===112)){W.lastIntValue=-1,W.advance();var L;if(W.eat(123)&&(L=this.regexp_eatUnicodePropertyValueExpression(W))&&W.eat(125)){if(M&&L===eW)W.raise("Invalid property name");return L}W.raise("Invalid property name")}return z4};function mK(W){return W===100||W===68||W===115||W===83||W===119||W===87}v.regexp_eatUnicodePropertyValueExpression=function(W){var O=W.pos;if(this.regexp_eatUnicodePropertyName(W)&&W.eat(61)){var M=W.lastStringValue;if(this.regexp_eatUnicodePropertyValue(W)){var L=W.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(W,M,L),kO}}if(W.pos=O,this.regexp_eatLoneUnicodePropertyNameOrValue(W)){var $=W.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(W,$)}return z4};v.regexp_validateUnicodePropertyNameAndValue=function(W,O,M){if(!v0(W.unicodeProperties.nonBinary,O))W.raise("Invalid property name");if(!W.unicodeProperties.nonBinary[O].test(M))W.raise("Invalid property value")};v.regexp_validateUnicodePropertyNameOrValue=function(W,O){if(W.unicodeProperties.binary.test(O))return kO;if(W.switchV&&W.unicodeProperties.binaryOfStrings.test(O))return eW;W.raise("Invalid property name")};v.regexp_eatUnicodePropertyName=function(W){var O=0;W.lastStringValue="";while(V4(O=W.current()))W.lastStringValue+=DO(O),W.advance();return W.lastStringValue!==""};function V4(W){return U4(W)||W===95}v.regexp_eatUnicodePropertyValue=function(W){var O=0;W.lastStringValue="";while(dK(O=W.current()))W.lastStringValue+=DO(O),W.advance();return W.lastStringValue!==""};function dK(W){return V4(W)||SL(W)}v.regexp_eatLoneUnicodePropertyNameOrValue=function(W){return this.regexp_eatUnicodePropertyValue(W)};v.regexp_eatCharacterClass=function(W){if(W.eat(91)){var O=W.eat(94),M=this.regexp_classContents(W);if(!W.eat(93))W.raise("Unterminated character class");if(O&&M===eW)W.raise("Negated character class may contain strings");return!0}return!1};v.regexp_classContents=function(W){if(W.current()===93)return kO;if(W.switchV)return this.regexp_classSetExpression(W);return this.regexp_nonEmptyClassRanges(W),kO};v.regexp_nonEmptyClassRanges=function(W){while(this.regexp_eatClassAtom(W)){var O=W.lastIntValue;if(W.eat(45)&&this.regexp_eatClassAtom(W)){var M=W.lastIntValue;if(W.switchU&&(O===-1||M===-1))W.raise("Invalid character class");if(O!==-1&&M!==-1&&O>M)W.raise("Range out of order in character class")}}};v.regexp_eatClassAtom=function(W){var O=W.pos;if(W.eat(92)){if(this.regexp_eatClassEscape(W))return!0;if(W.switchU){var M=W.current();if(M===99||T4(M))W.raise("Invalid class escape");W.raise("Invalid escape")}W.pos=O}var L=W.current();if(L!==93)return W.lastIntValue=L,W.advance(),!0;return!1};v.regexp_eatClassEscape=function(W){var O=W.pos;if(W.eat(98))return W.lastIntValue=8,!0;if(W.switchU&&W.eat(45))return W.lastIntValue=45,!0;if(!W.switchU&&W.eat(99)){if(this.regexp_eatClassControlLetter(W))return!0;W.pos=O}return this.regexp_eatCharacterClassEscape(W)||this.regexp_eatCharacterEscape(W)};v.regexp_classSetExpression=function(W){var O=kO,M;if(this.regexp_eatClassSetRange(W));else if(M=this.regexp_eatClassSetOperand(W)){if(M===eW)O=eW;var L=W.pos;while(W.eatChars([38,38])){if(W.current()!==38&&(M=this.regexp_eatClassSetOperand(W))){if(M!==eW)O=kO;continue}W.raise("Invalid character in character class")}if(L!==W.pos)return O;while(W.eatChars([45,45])){if(this.regexp_eatClassSetOperand(W))continue;W.raise("Invalid character in character class")}if(L!==W.pos)return O}else W.raise("Invalid character in character class");for(;;){if(this.regexp_eatClassSetRange(W))continue;if(M=this.regexp_eatClassSetOperand(W),!M)return O;if(M===eW)O=eW}};v.regexp_eatClassSetRange=function(W){var O=W.pos;if(this.regexp_eatClassSetCharacter(W)){var M=W.lastIntValue;if(W.eat(45)&&this.regexp_eatClassSetCharacter(W)){var L=W.lastIntValue;if(M!==-1&&L!==-1&&M>L)W.raise("Range out of order in character class");return!0}W.pos=O}return!1};v.regexp_eatClassSetOperand=function(W){if(this.regexp_eatClassSetCharacter(W))return kO;return this.regexp_eatClassStringDisjunction(W)||this.regexp_eatNestedClass(W)};v.regexp_eatNestedClass=function(W){var O=W.pos;if(W.eat(91)){var M=W.eat(94),L=this.regexp_classContents(W);if(W.eat(93)){if(M&&L===eW)W.raise("Negated character class may contain strings");return L}W.pos=O}if(W.eat(92)){var $=this.regexp_eatCharacterClassEscape(W);if($)return $;W.pos=O}return null};v.regexp_eatClassStringDisjunction=function(W){var O=W.pos;if(W.eatChars([92,113])){if(W.eat(123)){var M=this.regexp_classStringDisjunctionContents(W);if(W.eat(125))return M}else W.raise("Invalid escape");W.pos=O}return null};v.regexp_classStringDisjunctionContents=function(W){var O=this.regexp_classString(W);while(W.eat(124))if(this.regexp_classString(W)===eW)O=eW;return O};v.regexp_classString=function(W){var O=0;while(this.regexp_eatClassSetCharacter(W))O++;return O===1?kO:eW};v.regexp_eatClassSetCharacter=function(W){var O=W.pos;if(W.eat(92)){if(this.regexp_eatCharacterEscape(W)||this.regexp_eatClassSetReservedPunctuator(W))return!0;if(W.eat(98))return W.lastIntValue=8,!0;return W.pos=O,!1}var M=W.current();if(M<0||M===W.lookahead()&&cK(M))return!1;if(iK(M))return!1;return W.advance(),W.lastIntValue=M,!0};function cK(W){return W===33||W>=35&&W<=38||W>=42&&W<=44||W===46||W>=58&&W<=64||W===94||W===96||W===126}function iK(W){return W===40||W===41||W===45||W===47||W>=91&&W<=93||W>=123&&W<=125}v.regexp_eatClassSetReservedPunctuator=function(W){var O=W.current();if(sK(O))return W.lastIntValue=O,W.advance(),!0;return!1};function sK(W){return W===33||W===35||W===37||W===38||W===44||W===45||W>=58&&W<=62||W===64||W===96||W===126}v.regexp_eatClassControlLetter=function(W){var O=W.current();if(SL(O)||O===95)return W.lastIntValue=O%32,W.advance(),!0;return!1};v.regexp_eatHexEscapeSequence=function(W){var O=W.pos;if(W.eat(120)){if(this.regexp_eatFixedHexDigits(W,2))return!0;if(W.switchU)W.raise("Invalid escape");W.pos=O}return!1};v.regexp_eatDecimalDigits=function(W){var O=W.pos,M=0;W.lastIntValue=0;while(SL(M=W.current()))W.lastIntValue=10*W.lastIntValue+(M-48),W.advance();return W.pos!==O};function SL(W){return W>=48&&W<=57}v.regexp_eatHexDigits=function(W){var O=W.pos,M=0;W.lastIntValue=0;while(H4(M=W.current()))W.lastIntValue=16*W.lastIntValue+K4(M),W.advance();return W.pos!==O};function H4(W){return W>=48&&W<=57||W>=65&&W<=70||W>=97&&W<=102}function K4(W){if(W>=65&&W<=70)return 10+(W-65);if(W>=97&&W<=102)return 10+(W-97);return W-48}v.regexp_eatLegacyOctalEscapeSequence=function(W){if(this.regexp_eatOctalDigit(W)){var O=W.lastIntValue;if(this.regexp_eatOctalDigit(W)){var M=W.lastIntValue;if(O<=3&&this.regexp_eatOctalDigit(W))W.lastIntValue=O*64+M*8+W.lastIntValue;else W.lastIntValue=O*8+M}else W.lastIntValue=O;return!0}return!1};v.regexp_eatOctalDigit=function(W){var O=W.current();if(T4(O))return W.lastIntValue=O-48,W.advance(),!0;return W.lastIntValue=0,!1};function T4(W){return W>=48&&W<=55}v.regexp_eatFixedHexDigits=function(W,O){var M=W.pos;W.lastIntValue=0;for(var L=0;L<O;++L){var $=W.current();if(!H4($))return W.pos=M,!1;W.lastIntValue=16*W.lastIntValue+K4($),W.advance()}return!0};var V8=function(O){if(this.type=O.type,this.value=O.value,this.start=O.start,this.end=O.end,O.options.locations)this.loc=new AL(O,O.startLoc,O.endLoc);if(O.options.ranges)this.range=[O.start,O.end]},r=HW.prototype;r.next=function(W){if(!W&&this.type.keyword&&this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword);if(this.options.onToken)this.options.onToken(new V8(this));this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};r.getToken=function(){return this.next(),new V8(this)};if(typeof Symbol<"u")r[Symbol.iterator]=function(){var W=this;return{next:function(){var O=W.getToken();return{done:O.type===z.eof,value:O}}}};r.nextToken=function(){var W=this.curContext();if(!W||!W.preserveSpace)this.skipSpace();if(this.start=this.pos,this.options.locations)this.startLoc=this.curPosition();if(this.pos>=this.input.length)return this.finishToken(z.eof);if(W.override)return W.override(this);else this.readToken(this.fullCharCodeAtPos())};r.readToken=function(W){if(VO(W,this.options.ecmaVersion>=6)||W===92)return this.readWord();return this.getTokenFromCode(W)};r.fullCharCodeAtPos=function(){var W=this.input.charCodeAt(this.pos);if(W<=55295||W>=56320)return W;var O=this.input.charCodeAt(this.pos+1);return O<=56319||O>=57344?W:(W<<10)+O-56613888};r.skipBlockComment=function(){var W=this.options.onComment&&this.curPosition(),O=this.pos,M=this.input.indexOf("*/",this.pos+=2);if(M===-1)this.raise(this.pos-2,"Unterminated comment");if(this.pos=M+2,this.options.locations)for(var L=void 0,$=O;(L=m6(this.input,$,this.pos))>-1;)++this.curLine,$=this.lineStart=L;if(this.options.onComment)this.options.onComment(!0,this.input.slice(O+2,M),O,this.pos,W,this.curPosition())};r.skipLineComment=function(W){var O=this.pos,M=this.options.onComment&&this.curPosition(),L=this.input.charCodeAt(this.pos+=W);while(this.pos<this.input.length&&!f0(L))L=this.input.charCodeAt(++this.pos);if(this.options.onComment)this.options.onComment(!1,this.input.slice(O+W,this.pos),O,this.pos,M,this.curPosition())};r.skipSpace=function(){W:while(this.pos<this.input.length){var W=this.input.charCodeAt(this.pos);switch(W){case 32:case 160:++this.pos;break;case 13:if(this.input.charCodeAt(this.pos+1)===10)++this.pos;case 10:case 8232:case 8233:if(++this.pos,this.options.locations)++this.curLine,this.lineStart=this.pos;break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break W}break;default:if(W>8&&W<14||W>=5760&&d6.test(String.fromCharCode(W)))++this.pos;else break W}}};r.finishToken=function(W,O){if(this.end=this.pos,this.options.locations)this.endLoc=this.curPosition();var M=this.type;this.type=W,this.value=O,this.updateContext(M)};r.readToken_dot=function(){var W=this.input.charCodeAt(this.pos+1);if(W>=48&&W<=57)return this.readNumber(!0);var O=this.input.charCodeAt(this.pos+2);if(this.options.ecmaVersion>=6&&W===46&&O===46)return this.pos+=3,this.finishToken(z.ellipsis);else return++this.pos,this.finishToken(z.dot)};r.readToken_slash=function(){var W=this.input.charCodeAt(this.pos+1);if(this.exprAllowed)return++this.pos,this.readRegexp();if(W===61)return this.finishOp(z.assign,2);return this.finishOp(z.slash,1)};r.readToken_mult_modulo_exp=function(W){var O=this.input.charCodeAt(this.pos+1),M=1,L=W===42?z.star:z.modulo;if(this.options.ecmaVersion>=7&&W===42&&O===42)++M,L=z.starstar,O=this.input.charCodeAt(this.pos+2);if(O===61)return this.finishOp(z.assign,M+1);return this.finishOp(L,M)};r.readToken_pipe_amp=function(W){var O=this.input.charCodeAt(this.pos+1);if(O===W){if(this.options.ecmaVersion>=12){var M=this.input.charCodeAt(this.pos+2);if(M===61)return this.finishOp(z.assign,3)}return this.finishOp(W===124?z.logicalOR:z.logicalAND,2)}if(O===61)return this.finishOp(z.assign,2);return this.finishOp(W===124?z.bitwiseOR:z.bitwiseAND,1)};r.readToken_caret=function(){var W=this.input.charCodeAt(this.pos+1);if(W===61)return this.finishOp(z.assign,2);return this.finishOp(z.bitwiseXOR,1)};r.readToken_plus_min=function(W){var O=this.input.charCodeAt(this.pos+1);if(O===W){if(O===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||uW.test(this.input.slice(this.lastTokEnd,this.pos))))return this.skipLineComment(3),this.skipSpace(),this.nextToken();return this.finishOp(z.incDec,2)}if(O===61)return this.finishOp(z.assign,2);return this.finishOp(z.plusMin,1)};r.readToken_lt_gt=function(W){var O=this.input.charCodeAt(this.pos+1),M=1;if(O===W){if(M=W===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+M)===61)return this.finishOp(z.assign,M+1);return this.finishOp(z.bitShift,M)}if(O===33&&W===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45)return this.skipLineComment(4),this.skipSpace(),this.nextToken();if(O===61)M=2;return this.finishOp(z.relational,M)};r.readToken_eq_excl=function(W){var O=this.input.charCodeAt(this.pos+1);if(O===61)return this.finishOp(z.equality,this.input.charCodeAt(this.pos+2)===61?3:2);if(W===61&&O===62&&this.options.ecmaVersion>=6)return this.pos+=2,this.finishToken(z.arrow);return this.finishOp(W===61?z.eq:z.prefix,1)};r.readToken_question=function(){var W=this.options.ecmaVersion;if(W>=11){var O=this.input.charCodeAt(this.pos+1);if(O===46){var M=this.input.charCodeAt(this.pos+2);if(M<48||M>57)return this.finishOp(z.questionDot,2)}if(O===63){if(W>=12){var L=this.input.charCodeAt(this.pos+2);if(L===61)return this.finishOp(z.assign,3)}return this.finishOp(z.coalesce,2)}}return this.finishOp(z.question,1)};r.readToken_numberSign=function(){var W=this.options.ecmaVersion,O=35;if(W>=13){if(++this.pos,O=this.fullCharCodeAtPos(),VO(O,!0)||O===92)return this.finishToken(z.privateId,this.readWord1())}this.raise(this.pos,"Unexpected character '"+DO(O)+"'")};r.getTokenFromCode=function(W){switch(W){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(z.parenL);case 41:return++this.pos,this.finishToken(z.parenR);case 59:return++this.pos,this.finishToken(z.semi);case 44:return++this.pos,this.finishToken(z.comma);case 91:return++this.pos,this.finishToken(z.bracketL);case 93:return++this.pos,this.finishToken(z.bracketR);case 123:return++this.pos,this.finishToken(z.braceL);case 125:return++this.pos,this.finishToken(z.braceR);case 58:return++this.pos,this.finishToken(z.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(z.backQuote);case 48:var O=this.input.charCodeAt(this.pos+1);if(O===120||O===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(O===111||O===79)return this.readRadixNumber(8);if(O===98||O===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(W);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(W);case 124:case 38:return this.readToken_pipe_amp(W);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(W);case 60:case 62:return this.readToken_lt_gt(W);case 61:case 33:return this.readToken_eq_excl(W);case 63:return this.readToken_question();case 126:return this.finishOp(z.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+DO(W)+"'")};r.finishOp=function(W,O){var M=this.input.slice(this.pos,this.pos+O);return this.pos+=O,this.finishToken(W,M)};r.readRegexp=function(){var W,O,M=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(M,"Unterminated regular expression");var L=this.input.charAt(this.pos);if(uW.test(L))this.raise(M,"Unterminated regular expression");if(!W){if(L==="[")O=!0;else if(L==="]"&&O)O=!1;else if(L==="/"&&!O)break;W=L==="\\"}else W=!1;++this.pos}var $=this.input.slice(M,this.pos);++this.pos;var Y=this.pos,J=this.readWord1();if(this.containsEsc)this.unexpected(Y);var A=this.regexpState||(this.regexpState=new KO(this));A.reset(M,$,J),this.validateRegExpFlags(A),this.validateRegExpPattern(A);var Z=null;try{Z=new RegExp($,J)}catch(X){}return this.finishToken(z.regexp,{pattern:$,flags:J,value:Z})};r.readInt=function(W,O,M){var L=this.options.ecmaVersion>=12&&O===void 0,$=M&&this.input.charCodeAt(this.pos)===48,Y=this.pos,J=0,A=0;for(var Z=0,X=O==null?1/0:O;Z<X;++Z,++this.pos){var G=this.input.charCodeAt(this.pos),Q=void 0;if(L&&G===95){if($)this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals");if(A===95)this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore");if(Z===0)this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits");A=G;continue}if(G>=97)Q=G-97+10;else if(G>=65)Q=G-65+10;else if(G>=48&&G<=57)Q=G-48;else Q=1/0;if(Q>=W)break;A=G,J=J*W+Q}if(L&&A===95)this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits");if(this.pos===Y||O!=null&&this.pos-Y!==O)return null;return J};function nK(W,O){if(O)return parseInt(W,8);return parseFloat(W.replace(/_/g,""))}function F4(W){if(typeof BigInt!=="function")return null;return BigInt(W.replace(/_/g,""))}r.readRadixNumber=function(W){var O=this.pos;this.pos+=2;var M=this.readInt(W);if(M==null)this.raise(this.start+2,"Expected number in radix "+W);if(this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110)M=F4(this.input.slice(O,this.pos)),++this.pos;else if(VO(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(z.num,M)};r.readNumber=function(W){var O=this.pos;if(!W&&this.readInt(10,void 0,!0)===null)this.raise(O,"Invalid number");var M=this.pos-O>=2&&this.input.charCodeAt(O)===48;if(M&&this.strict)this.raise(O,"Invalid number");var L=this.input.charCodeAt(this.pos);if(!M&&!W&&this.options.ecmaVersion>=11&&L===110){var $=F4(this.input.slice(O,this.pos));if(++this.pos,VO(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(z.num,$)}if(M&&/[89]/.test(this.input.slice(O,this.pos)))M=!1;if(L===46&&!M)++this.pos,this.readInt(10),L=this.input.charCodeAt(this.pos);if((L===69||L===101)&&!M){if(L=this.input.charCodeAt(++this.pos),L===43||L===45)++this.pos;if(this.readInt(10)===null)this.raise(O,"Invalid number")}if(VO(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");var Y=nK(this.input.slice(O,this.pos),M);return this.finishToken(z.num,Y)};r.readCodePoint=function(){var W=this.input.charCodeAt(this.pos),O;if(W===123){if(this.options.ecmaVersion<6)this.unexpected();var M=++this.pos;if(O=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,O>1114111)this.invalidStringToken(M,"Code point out of bounds")}else O=this.readHexChar(4);return O};r.readString=function(W){var O="",M=++this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated string constant");var L=this.input.charCodeAt(this.pos);if(L===W)break;if(L===92)O+=this.input.slice(M,this.pos),O+=this.readEscapedChar(!1),M=this.pos;else if(L===8232||L===8233){if(this.options.ecmaVersion<10)this.raise(this.start,"Unterminated string constant");if(++this.pos,this.options.locations)this.curLine++,this.lineStart=this.pos}else{if(f0(L))this.raise(this.start,"Unterminated string constant");++this.pos}}return O+=this.input.slice(M,this.pos++),this.finishToken(z.string,O)};var E4={};r.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(W){if(W===E4)this.readInvalidTemplateToken();else throw W}this.inTemplateElement=!1};r.invalidStringToken=function(W,O){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw E4;else this.raise(W,O)};r.readTmplToken=function(){var W="",O=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated template");var M=this.input.charCodeAt(this.pos);if(M===96||M===36&&this.input.charCodeAt(this.pos+1)===123){if(this.pos===this.start&&(this.type===z.template||this.type===z.invalidTemplate))if(M===36)return this.pos+=2,this.finishToken(z.dollarBraceL);else return++this.pos,this.finishToken(z.backQuote);return W+=this.input.slice(O,this.pos),this.finishToken(z.template,W)}if(M===92)W+=this.input.slice(O,this.pos),W+=this.readEscapedChar(!0),O=this.pos;else if(f0(M)){switch(W+=this.input.slice(O,this.pos),++this.pos,M){case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:W+=`
18
+ `),cooked:this.value};return this.next(),M.tail=this.type===z.backQuote,this.finishNode(M,"TemplateElement")};l.parseTemplate=function(W){if(W===void 0)W={};var O=W.isTagged;if(O===void 0)O=!1;var M=this.startNode();this.next(),M.expressions=[];var L=this.parseTemplateElement({isTagged:O});M.quasis=[L];while(!L.tail){if(this.type===z.eof)this.raise(this.pos,"Unterminated template literal");this.expect(z.dollarBraceL),M.expressions.push(this.parseExpression()),this.expect(z.braceR),M.quasis.push(L=this.parseTemplateElement({isTagged:O}))}return this.next(),this.finishNode(M,"TemplateLiteral")};l.isAsyncProp=function(W){return!W.computed&&W.key.type==="Identifier"&&W.key.name==="async"&&(this.type===z.name||this.type===z.num||this.type===z.string||this.type===z.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===z.star)&&!uW.test(this.input.slice(this.lastTokEnd,this.start))};l.parseObj=function(W,O){var M=this.startNode(),L=!0,$={};M.properties=[],this.next();while(!this.eat(z.braceR)){if(!L){if(this.expect(z.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(z.braceR))break}else L=!1;var Y=this.parseProperty(W,O);if(!W)this.checkPropClash(Y,$,O);M.properties.push(Y)}return this.finishNode(M,W?"ObjectPattern":"ObjectExpression")};l.parseProperty=function(W,O){var M=this.startNode(),L,$,Y,J;if(this.options.ecmaVersion>=9&&this.eat(z.ellipsis)){if(W){if(M.argument=this.parseIdent(!1),this.type===z.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");return this.finishNode(M,"RestElement")}if(M.argument=this.parseMaybeAssign(!1,O),this.type===z.comma&&O&&O.trailingComma<0)O.trailingComma=this.start;return this.finishNode(M,"SpreadElement")}if(this.options.ecmaVersion>=6){if(M.method=!1,M.shorthand=!1,W||O)Y=this.start,J=this.startLoc;if(!W)L=this.eat(z.star)}var A=this.containsEsc;if(this.parsePropertyName(M),!W&&!A&&this.options.ecmaVersion>=8&&!L&&this.isAsyncProp(M))$=!0,L=this.options.ecmaVersion>=9&&this.eat(z.star),this.parsePropertyName(M);else $=!1;return this.parsePropertyValue(M,W,L,$,Y,J,O,A),this.finishNode(M,"Property")};l.parseGetterSetter=function(W){var O=W.key.name;this.parsePropertyName(W),W.value=this.parseMethod(!1),W.kind=O;var M=W.kind==="get"?0:1;if(W.value.params.length!==M){var L=W.value.start;if(W.kind==="get")this.raiseRecoverable(L,"getter should have no params");else this.raiseRecoverable(L,"setter should have exactly one param")}else if(W.kind==="set"&&W.value.params[0].type==="RestElement")this.raiseRecoverable(W.value.params[0].start,"Setter cannot use rest params")};l.parsePropertyValue=function(W,O,M,L,$,Y,J,A){if((M||L)&&this.type===z.colon)this.unexpected();if(this.eat(z.colon))W.value=O?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,J),W.kind="init";else if(this.options.ecmaVersion>=6&&this.type===z.parenL){if(O)this.unexpected();W.method=!0,W.value=this.parseMethod(M,L),W.kind="init"}else if(!O&&!A&&this.options.ecmaVersion>=5&&!W.computed&&W.key.type==="Identifier"&&(W.key.name==="get"||W.key.name==="set")&&(this.type!==z.comma&&this.type!==z.braceR&&this.type!==z.eq)){if(M||L)this.unexpected();this.parseGetterSetter(W)}else if(this.options.ecmaVersion>=6&&!W.computed&&W.key.type==="Identifier"){if(M||L)this.unexpected();if(this.checkUnreserved(W.key),W.key.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=$;if(O)W.value=this.parseMaybeDefault($,Y,this.copyNode(W.key));else if(this.type===z.eq&&J){if(J.shorthandAssign<0)J.shorthandAssign=this.start;W.value=this.parseMaybeDefault($,Y,this.copyNode(W.key))}else W.value=this.copyNode(W.key);W.kind="init",W.shorthand=!0}else this.unexpected()};l.parsePropertyName=function(W){if(this.options.ecmaVersion>=6)if(this.eat(z.bracketL))return W.computed=!0,W.key=this.parseMaybeAssign(),this.expect(z.bracketR),W.key;else W.computed=!1;return W.key=this.type===z.num||this.type===z.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};l.initFunction=function(W){if(W.id=null,this.options.ecmaVersion>=6)W.generator=W.expression=!1;if(this.options.ecmaVersion>=8)W.async=!1};l.parseMethod=function(W,O,M){var L=this.startNode(),$=this.yieldPos,Y=this.awaitPos,J=this.awaitIdentPos;if(this.initFunction(L),this.options.ecmaVersion>=6)L.generator=W;if(this.options.ecmaVersion>=8)L.async=!!O;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(z8(O,L.generator)|GL|(M?t4:0)),this.expect(z.parenL),L.params=this.parseBindingList(z.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(L,!1,!0,!1),this.yieldPos=$,this.awaitPos=Y,this.awaitIdentPos=J,this.finishNode(L,"FunctionExpression")};l.parseArrowExpression=function(W,O,M,L){var $=this.yieldPos,Y=this.awaitPos,J=this.awaitIdentPos;if(this.enterScope(z8(M,!1)|U8),this.initFunction(W),this.options.ecmaVersion>=8)W.async=!!M;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,W.params=this.toAssignableList(O,!0),this.parseFunctionBody(W,!0,!1,L),this.yieldPos=$,this.awaitPos=Y,this.awaitIdentPos=J,this.finishNode(W,"ArrowFunctionExpression")};l.parseFunctionBody=function(W,O,M,L){var $=O&&this.type!==z.braceL,Y=this.strict,J=!1;if($)W.body=this.parseMaybeAssign(L),W.expression=!0,this.checkParams(W,!1);else{var A=this.options.ecmaVersion>=7&&!this.isSimpleParamList(W.params);if(!Y||A){if(J=this.strictDirective(this.end),J&&A)this.raiseRecoverable(W.start,"Illegal 'use strict' directive in function with non-simple parameter list")}var Z=this.labels;if(this.labels=[],J)this.strict=!0;if(this.checkParams(W,!Y&&!J&&!O&&!M&&this.isSimpleParamList(W.params)),this.strict&&W.id)this.checkLValSimple(W.id,OA);W.body=this.parseBlock(!1,void 0,J&&!Y),W.expression=!1,this.adaptDirectivePrologue(W.body.body),this.labels=Z}this.exitScope()};l.isSimpleParamList=function(W){for(var O=0,M=W;O<M.length;O+=1){var L=M[O];if(L.type!=="Identifier")return!1}return!0};l.checkParams=function(W,O){var M=Object.create(null);for(var L=0,$=W.params;L<$.length;L+=1){var Y=$[L];this.checkLValInnerPattern(Y,V8,O?null:M)}};l.parseExprList=function(W,O,M,L){var $=[],Y=!0;while(!this.eat(W)){if(!Y){if(this.expect(z.comma),O&&this.afterTrailingComma(W))break}else Y=!1;var J=void 0;if(M&&this.type===z.comma)J=null;else if(this.type===z.ellipsis){if(J=this.parseSpread(L),L&&this.type===z.comma&&L.trailingComma<0)L.trailingComma=this.start}else J=this.parseMaybeAssign(!1,L);$.push(J)}return $};l.checkUnreserved=function(W){var{start:O,end:M,name:L}=W;if(this.inGenerator&&L==="yield")this.raiseRecoverable(O,"Cannot use 'yield' as identifier inside a generator");if(this.inAsync&&L==="await")this.raiseRecoverable(O,"Cannot use 'await' as identifier inside an async function");if(!(this.currentThisScope().flags&XL)&&L==="arguments")this.raiseRecoverable(O,"Cannot use 'arguments' in class field initializer");if(this.inClassStaticBlock&&(L==="arguments"||L==="await"))this.raise(O,"Cannot use "+L+" in class static initialization block");if(this.keywords.test(L))this.raise(O,"Unexpected keyword '"+L+"'");if(this.options.ecmaVersion<6&&this.input.slice(O,M).indexOf("\\")!==-1)return;var $=this.strict?this.reservedWordsStrict:this.reservedWords;if($.test(L)){if(!this.inAsync&&L==="await")this.raiseRecoverable(O,"Cannot use keyword 'await' outside an async function");this.raiseRecoverable(O,"The keyword '"+L+"' is reserved")}};l.parseIdent=function(W){var O=this.parseIdentNode();if(this.next(!!W),this.finishNode(O,"Identifier"),!W){if(this.checkUnreserved(O),O.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=O.start}return O};l.parseIdentNode=function(){var W=this.startNode();if(this.type===z.name)W.name=this.value;else if(this.type.keyword){if(W.name=this.type.keyword,(W.name==="class"||W.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46))this.context.pop();this.type=z.name}else this.unexpected();return W};l.parsePrivateIdent=function(){var W=this.startNode();if(this.type===z.privateId)W.name=this.value;else this.unexpected();if(this.next(),this.finishNode(W,"PrivateIdentifier"),this.options.checkPrivateFields)if(this.privateNameStack.length===0)this.raise(W.start,"Private field '#"+W.name+"' must be declared in an enclosing class");else this.privateNameStack[this.privateNameStack.length-1].used.push(W);return W};l.parseYield=function(W){if(!this.yieldPos)this.yieldPos=this.start;var O=this.startNode();if(this.next(),this.type===z.semi||this.canInsertSemicolon()||this.type!==z.star&&!this.type.startsExpr)O.delegate=!1,O.argument=null;else O.delegate=this.eat(z.star),O.argument=this.parseMaybeAssign(W);return this.finishNode(O,"YieldExpression")};l.parseAwait=function(W){if(!this.awaitPos)this.awaitPos=this.start;var O=this.startNode();return this.next(),O.argument=this.parseMaybeUnary(null,!0,!1,W),this.finishNode(O,"AwaitExpression")};var JL=VW.prototype;JL.raise=function(W,O){var M=r4(this.input,W);if(O+=" ("+M.line+":"+M.column+")",this.sourceFile)O+=" in "+this.sourceFile;var L=SyntaxError(O);throw L.pos=W,L.loc=M,L.raisedAt=this.pos,L};JL.raiseRecoverable=JL.raise;JL.curPosition=function(){if(this.options.locations)return new u1(this.curLine,this.pos-this.lineStart)};var W0=VW.prototype,yK=function(O){this.flags=O,this.var=[],this.lexical=[],this.functions=[]};W0.enterScope=function(W){this.scopeStack.push(new yK(W))};W0.exitScope=function(){this.scopeStack.pop()};W0.treatFunctionsAsVarInScope=function(W){return W.flags&m0||!this.inModule&&W.flags&l1};W0.declareName=function(W,O,M){var L=!1;if(O===fO){var $=this.currentScope();if(L=$.lexical.indexOf(W)>-1||$.functions.indexOf(W)>-1||$.var.indexOf(W)>-1,$.lexical.push(W),this.inModule&&$.flags&l1)delete this.undefinedExports[W]}else if(O===WA){var Y=this.currentScope();Y.lexical.push(W)}else if(O===e4){var J=this.currentScope();if(this.treatFunctionsAsVar)L=J.lexical.indexOf(W)>-1;else L=J.lexical.indexOf(W)>-1||J.var.indexOf(W)>-1;J.functions.push(W)}else for(var A=this.scopeStack.length-1;A>=0;--A){var Z=this.scopeStack[A];if(Z.lexical.indexOf(W)>-1&&!(Z.flags&o4&&Z.lexical[0]===W)||!this.treatFunctionsAsVarInScope(Z)&&Z.functions.indexOf(W)>-1){L=!0;break}if(Z.var.push(W),this.inModule&&Z.flags&l1)delete this.undefinedExports[W];if(Z.flags&XL)break}if(L)this.raiseRecoverable(M,"Identifier '"+W+"' has already been declared")};W0.checkLocalExport=function(W){if(this.scopeStack[0].lexical.indexOf(W.name)===-1&&this.scopeStack[0].var.indexOf(W.name)===-1)this.undefinedExports[W.name]=W};W0.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};W0.currentVarScope=function(){for(var W=this.scopeStack.length-1;;W--){var O=this.scopeStack[W];if(O.flags&(XL|p1|V0))return O}};W0.currentThisScope=function(){for(var W=this.scopeStack.length-1;;W--){var O=this.scopeStack[W];if(O.flags&(XL|p1|V0)&&!(O.flags&U8))return O}};var RL=function(O,M,L){if(this.type="",this.start=M,this.end=0,O.options.locations)this.loc=new ZL(O,L);if(O.options.directSourceFile)this.sourceFile=O.options.directSourceFile;if(O.options.ranges)this.range=[M,0]},m1=VW.prototype;m1.startNode=function(){return new RL(this,this.start,this.startLoc)};m1.startNodeAt=function(W,O){return new RL(this,W,O)};function $A(W,O,M,L){if(W.type=O,W.end=M,this.options.locations)W.loc.end=L;if(this.options.ranges)W.range[1]=M;return W}m1.finishNode=function(W,O){return $A.call(this,W,O,this.lastTokEnd,this.lastTokEndLoc)};m1.finishNodeAt=function(W,O,M,L){return $A.call(this,W,O,M,L)};m1.copyNode=function(W){var O=new RL(this,W.start,this.startLoc);for(var M in W)O[M]=W[M];return O};var DK="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",YA="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",JA=YA+" Extended_Pictographic",AA=JA,ZA=AA+" EBase EComp EMod EPres ExtPict",GA=ZA,kK=GA,bK={9:YA,10:JA,11:AA,12:ZA,13:GA,14:kK},fK="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",vK={9:"",10:"",11:"",12:"",13:"",14:fK},m4="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",XA="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",QA=XA+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",RA=QA+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",SA=RA+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",UA=SA+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",gK=UA+" "+DK,xK={9:XA,10:QA,11:RA,12:SA,13:UA,14:gK},zA={};function hK(W){var O=zA[W]={binary:tO(bK[W]+" "+m4),binaryOfStrings:tO(vK[W]),nonBinary:{General_Category:tO(m4),Script:tO(xK[W])}};O.nonBinary.Script_Extensions=O.nonBinary.Script,O.nonBinary.gc=O.nonBinary.General_Category,O.nonBinary.sc=O.nonBinary.Script,O.nonBinary.scx=O.nonBinary.Script_Extensions}for(x1=0,LL=[9,10,11,12,13,14];x1<LL.length;x1+=1)Q8=LL[x1],hK(Q8);var Q8,x1,LL,g=VW.prototype,AL=function(O,M){this.parent=O,this.base=M||this};AL.prototype.separatedFrom=function(O){for(var M=this;M;M=M.parent)for(var L=O;L;L=L.parent)if(M.base===L.base&&M!==L)return!0;return!1};AL.prototype.sibling=function(){return new AL(this.parent,this.base)};var FO=function(O){this.parser=O,this.validFlags="gim"+(O.options.ecmaVersion>=6?"uy":"")+(O.options.ecmaVersion>=9?"s":"")+(O.options.ecmaVersion>=13?"d":"")+(O.options.ecmaVersion>=15?"v":""),this.unicodeProperties=zA[O.options.ecmaVersion>=14?14:O.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};FO.prototype.reset=function(O,M,L){var $=L.indexOf("v")!==-1,Y=L.indexOf("u")!==-1;if(this.start=O|0,this.source=M+"",this.flags=L,$&&this.parser.options.ecmaVersion>=15)this.switchU=!0,this.switchV=!0,this.switchN=!0;else this.switchU=Y&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=Y&&this.parser.options.ecmaVersion>=9};FO.prototype.raise=function(O){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+O)};FO.prototype.at=function(O,M){if(M===void 0)M=!1;var L=this.source,$=L.length;if(O>=$)return-1;var Y=L.charCodeAt(O);if(!(M||this.switchU)||Y<=55295||Y>=57344||O+1>=$)return Y;var J=L.charCodeAt(O+1);return J>=56320&&J<=57343?(Y<<10)+J-56613888:Y};FO.prototype.nextIndex=function(O,M){if(M===void 0)M=!1;var L=this.source,$=L.length;if(O>=$)return $;var Y=L.charCodeAt(O),J;if(!(M||this.switchU)||Y<=55295||Y>=57344||O+1>=$||(J=L.charCodeAt(O+1))<56320||J>57343)return O+1;return O+2};FO.prototype.current=function(O){if(O===void 0)O=!1;return this.at(this.pos,O)};FO.prototype.lookahead=function(O){if(O===void 0)O=!1;return this.at(this.nextIndex(this.pos,O),O)};FO.prototype.advance=function(O){if(O===void 0)O=!1;this.pos=this.nextIndex(this.pos,O)};FO.prototype.eat=function(O,M){if(M===void 0)M=!1;if(this.current(M)===O)return this.advance(M),!0;return!1};FO.prototype.eatChars=function(O,M){if(M===void 0)M=!1;var L=this.pos;for(var $=0,Y=O;$<Y.length;$+=1){var J=Y[$],A=this.at(L,M);if(A===-1||A!==J)return!1;L=this.nextIndex(L,M)}return this.pos=L,!0};g.validateRegExpFlags=function(W){var{validFlags:O,flags:M}=W,L=!1,$=!1;for(var Y=0;Y<M.length;Y++){var J=M.charAt(Y);if(O.indexOf(J)===-1)this.raise(W.start,"Invalid regular expression flag");if(M.indexOf(J,Y+1)>-1)this.raise(W.start,"Duplicate regular expression flag");if(J==="u")L=!0;if(J==="v")$=!0}if(this.options.ecmaVersion>=15&&L&&$)this.raise(W.start,"Invalid regular expression flag")};function uK(W){for(var O in W)return!0;return!1}g.validateRegExpPattern=function(W){if(this.regexp_pattern(W),!W.switchN&&this.options.ecmaVersion>=9&&uK(W.groupNames))W.switchN=!0,this.regexp_pattern(W)};g.regexp_pattern=function(W){if(W.pos=0,W.lastIntValue=0,W.lastStringValue="",W.lastAssertionIsQuantifiable=!1,W.numCapturingParens=0,W.maxBackReference=0,W.groupNames=Object.create(null),W.backReferenceNames.length=0,W.branchID=null,this.regexp_disjunction(W),W.pos!==W.source.length){if(W.eat(41))W.raise("Unmatched ')'");if(W.eat(93)||W.eat(125))W.raise("Lone quantifier brackets")}if(W.maxBackReference>W.numCapturingParens)W.raise("Invalid escape");for(var O=0,M=W.backReferenceNames;O<M.length;O+=1){var L=M[O];if(!W.groupNames[L])W.raise("Invalid named capture referenced")}};g.regexp_disjunction=function(W){var O=this.options.ecmaVersion>=16;if(O)W.branchID=new AL(W.branchID,null);this.regexp_alternative(W);while(W.eat(124)){if(O)W.branchID=W.branchID.sibling();this.regexp_alternative(W)}if(O)W.branchID=W.branchID.parent;if(this.regexp_eatQuantifier(W,!0))W.raise("Nothing to repeat");if(W.eat(123))W.raise("Lone quantifier brackets")};g.regexp_alternative=function(W){while(W.pos<W.source.length&&this.regexp_eatTerm(W));};g.regexp_eatTerm=function(W){if(this.regexp_eatAssertion(W)){if(W.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(W)){if(W.switchU)W.raise("Invalid quantifier")}return!0}if(W.switchU?this.regexp_eatAtom(W):this.regexp_eatExtendedAtom(W))return this.regexp_eatQuantifier(W),!0;return!1};g.regexp_eatAssertion=function(W){var O=W.pos;if(W.lastAssertionIsQuantifiable=!1,W.eat(94)||W.eat(36))return!0;if(W.eat(92)){if(W.eat(66)||W.eat(98))return!0;W.pos=O}if(W.eat(40)&&W.eat(63)){var M=!1;if(this.options.ecmaVersion>=9)M=W.eat(60);if(W.eat(61)||W.eat(33)){if(this.regexp_disjunction(W),!W.eat(41))W.raise("Unterminated group");return W.lastAssertionIsQuantifiable=!M,!0}}return W.pos=O,!1};g.regexp_eatQuantifier=function(W,O){if(O===void 0)O=!1;if(this.regexp_eatQuantifierPrefix(W,O))return W.eat(63),!0;return!1};g.regexp_eatQuantifierPrefix=function(W,O){return W.eat(42)||W.eat(43)||W.eat(63)||this.regexp_eatBracedQuantifier(W,O)};g.regexp_eatBracedQuantifier=function(W,O){var M=W.pos;if(W.eat(123)){var L=0,$=-1;if(this.regexp_eatDecimalDigits(W)){if(L=W.lastIntValue,W.eat(44)&&this.regexp_eatDecimalDigits(W))$=W.lastIntValue;if(W.eat(125)){if($!==-1&&$<L&&!O)W.raise("numbers out of order in {} quantifier");return!0}}if(W.switchU&&!O)W.raise("Incomplete quantifier");W.pos=M}return!1};g.regexp_eatAtom=function(W){return this.regexp_eatPatternCharacters(W)||W.eat(46)||this.regexp_eatReverseSolidusAtomEscape(W)||this.regexp_eatCharacterClass(W)||this.regexp_eatUncapturingGroup(W)||this.regexp_eatCapturingGroup(W)};g.regexp_eatReverseSolidusAtomEscape=function(W){var O=W.pos;if(W.eat(92)){if(this.regexp_eatAtomEscape(W))return!0;W.pos=O}return!1};g.regexp_eatUncapturingGroup=function(W){var O=W.pos;if(W.eat(40)){if(W.eat(63)){if(this.options.ecmaVersion>=16){var M=this.regexp_eatModifiers(W),L=W.eat(45);if(M||L){for(var $=0;$<M.length;$++){var Y=M.charAt($);if(M.indexOf(Y,$+1)>-1)W.raise("Duplicate regular expression modifiers")}if(L){var J=this.regexp_eatModifiers(W);if(!M&&!J&&W.current()===58)W.raise("Invalid regular expression modifiers");for(var A=0;A<J.length;A++){var Z=J.charAt(A);if(J.indexOf(Z,A+1)>-1||M.indexOf(Z)>-1)W.raise("Duplicate regular expression modifiers")}}}}if(W.eat(58)){if(this.regexp_disjunction(W),W.eat(41))return!0;W.raise("Unterminated group")}}W.pos=O}return!1};g.regexp_eatCapturingGroup=function(W){if(W.eat(40)){if(this.options.ecmaVersion>=9)this.regexp_groupSpecifier(W);else if(W.current()===63)W.raise("Invalid group");if(this.regexp_disjunction(W),W.eat(41))return W.numCapturingParens+=1,!0;W.raise("Unterminated group")}return!1};g.regexp_eatModifiers=function(W){var O="",M=0;while((M=W.current())!==-1&&lK(M))O+=kO(M),W.advance();return O};function lK(W){return W===105||W===109||W===115}g.regexp_eatExtendedAtom=function(W){return W.eat(46)||this.regexp_eatReverseSolidusAtomEscape(W)||this.regexp_eatCharacterClass(W)||this.regexp_eatUncapturingGroup(W)||this.regexp_eatCapturingGroup(W)||this.regexp_eatInvalidBracedQuantifier(W)||this.regexp_eatExtendedPatternCharacter(W)};g.regexp_eatInvalidBracedQuantifier=function(W){if(this.regexp_eatBracedQuantifier(W,!0))W.raise("Nothing to repeat");return!1};g.regexp_eatSyntaxCharacter=function(W){var O=W.current();if(VA(O))return W.lastIntValue=O,W.advance(),!0;return!1};function VA(W){return W===36||W>=40&&W<=43||W===46||W===63||W>=91&&W<=94||W>=123&&W<=125}g.regexp_eatPatternCharacters=function(W){var O=W.pos,M=0;while((M=W.current())!==-1&&!VA(M))W.advance();return W.pos!==O};g.regexp_eatExtendedPatternCharacter=function(W){var O=W.current();if(O!==-1&&O!==36&&!(O>=40&&O<=43)&&O!==46&&O!==63&&O!==91&&O!==94&&O!==124)return W.advance(),!0;return!1};g.regexp_groupSpecifier=function(W){if(W.eat(63)){if(!this.regexp_eatGroupName(W))W.raise("Invalid group");var O=this.options.ecmaVersion>=16,M=W.groupNames[W.lastStringValue];if(M)if(O)for(var L=0,$=M;L<$.length;L+=1){var Y=$[L];if(!Y.separatedFrom(W.branchID))W.raise("Duplicate capture group name")}else W.raise("Duplicate capture group name");if(O)(M||(W.groupNames[W.lastStringValue]=[])).push(W.branchID);else W.groupNames[W.lastStringValue]=!0}};g.regexp_eatGroupName=function(W){if(W.lastStringValue="",W.eat(60)){if(this.regexp_eatRegExpIdentifierName(W)&&W.eat(62))return!0;W.raise("Invalid capture group name")}return!1};g.regexp_eatRegExpIdentifierName=function(W){if(W.lastStringValue="",this.regexp_eatRegExpIdentifierStart(W)){W.lastStringValue+=kO(W.lastIntValue);while(this.regexp_eatRegExpIdentifierPart(W))W.lastStringValue+=kO(W.lastIntValue);return!0}return!1};g.regexp_eatRegExpIdentifierStart=function(W){var O=W.pos,M=this.options.ecmaVersion>=11,L=W.current(M);if(W.advance(M),L===92&&this.regexp_eatRegExpUnicodeEscapeSequence(W,M))L=W.lastIntValue;if(pK(L))return W.lastIntValue=L,!0;return W.pos=O,!1};function pK(W){return KO(W,!0)||W===36||W===95}g.regexp_eatRegExpIdentifierPart=function(W){var O=W.pos,M=this.options.ecmaVersion>=11,L=W.current(M);if(W.advance(M),L===92&&this.regexp_eatRegExpUnicodeEscapeSequence(W,M))L=W.lastIntValue;if(mK(L))return W.lastIntValue=L,!0;return W.pos=O,!1};function mK(W){return eO(W,!0)||W===36||W===95||W===8204||W===8205}g.regexp_eatAtomEscape=function(W){if(this.regexp_eatBackReference(W)||this.regexp_eatCharacterClassEscape(W)||this.regexp_eatCharacterEscape(W)||W.switchN&&this.regexp_eatKGroupName(W))return!0;if(W.switchU){if(W.current()===99)W.raise("Invalid unicode escape");W.raise("Invalid escape")}return!1};g.regexp_eatBackReference=function(W){var O=W.pos;if(this.regexp_eatDecimalEscape(W)){var M=W.lastIntValue;if(W.switchU){if(M>W.maxBackReference)W.maxBackReference=M;return!0}if(M<=W.numCapturingParens)return!0;W.pos=O}return!1};g.regexp_eatKGroupName=function(W){if(W.eat(107)){if(this.regexp_eatGroupName(W))return W.backReferenceNames.push(W.lastStringValue),!0;W.raise("Invalid named reference")}return!1};g.regexp_eatCharacterEscape=function(W){return this.regexp_eatControlEscape(W)||this.regexp_eatCControlLetter(W)||this.regexp_eatZero(W)||this.regexp_eatHexEscapeSequence(W)||this.regexp_eatRegExpUnicodeEscapeSequence(W,!1)||!W.switchU&&this.regexp_eatLegacyOctalEscapeSequence(W)||this.regexp_eatIdentityEscape(W)};g.regexp_eatCControlLetter=function(W){var O=W.pos;if(W.eat(99)){if(this.regexp_eatControlLetter(W))return!0;W.pos=O}return!1};g.regexp_eatZero=function(W){if(W.current()===48&&!SL(W.lookahead()))return W.lastIntValue=0,W.advance(),!0;return!1};g.regexp_eatControlEscape=function(W){var O=W.current();if(O===116)return W.lastIntValue=9,W.advance(),!0;if(O===110)return W.lastIntValue=10,W.advance(),!0;if(O===118)return W.lastIntValue=11,W.advance(),!0;if(O===102)return W.lastIntValue=12,W.advance(),!0;if(O===114)return W.lastIntValue=13,W.advance(),!0;return!1};g.regexp_eatControlLetter=function(W){var O=W.current();if(HA(O))return W.lastIntValue=O%32,W.advance(),!0;return!1};function HA(W){return W>=65&&W<=90||W>=97&&W<=122}g.regexp_eatRegExpUnicodeEscapeSequence=function(W,O){if(O===void 0)O=!1;var M=W.pos,L=O||W.switchU;if(W.eat(117)){if(this.regexp_eatFixedHexDigits(W,4)){var $=W.lastIntValue;if(L&&$>=55296&&$<=56319){var Y=W.pos;if(W.eat(92)&&W.eat(117)&&this.regexp_eatFixedHexDigits(W,4)){var J=W.lastIntValue;if(J>=56320&&J<=57343)return W.lastIntValue=($-55296)*1024+(J-56320)+65536,!0}W.pos=Y,W.lastIntValue=$}return!0}if(L&&W.eat(123)&&this.regexp_eatHexDigits(W)&&W.eat(125)&&dK(W.lastIntValue))return!0;if(L)W.raise("Invalid unicode escape");W.pos=M}return!1};function dK(W){return W>=0&&W<=1114111}g.regexp_eatIdentityEscape=function(W){if(W.switchU){if(this.regexp_eatSyntaxCharacter(W))return!0;if(W.eat(47))return W.lastIntValue=47,!0;return!1}var O=W.current();if(O!==99&&(!W.switchN||O!==107))return W.lastIntValue=O,W.advance(),!0;return!1};g.regexp_eatDecimalEscape=function(W){W.lastIntValue=0;var O=W.current();if(O>=49&&O<=57){do W.lastIntValue=10*W.lastIntValue+(O-48),W.advance();while((O=W.current())>=48&&O<=57);return!0}return!1};var KA=0,bO=1,MO=2;g.regexp_eatCharacterClassEscape=function(W){var O=W.current();if(cK(O))return W.lastIntValue=-1,W.advance(),bO;var M=!1;if(W.switchU&&this.options.ecmaVersion>=9&&((M=O===80)||O===112)){W.lastIntValue=-1,W.advance();var L;if(W.eat(123)&&(L=this.regexp_eatUnicodePropertyValueExpression(W))&&W.eat(125)){if(M&&L===MO)W.raise("Invalid property name");return L}W.raise("Invalid property name")}return KA};function cK(W){return W===100||W===68||W===115||W===83||W===119||W===87}g.regexp_eatUnicodePropertyValueExpression=function(W){var O=W.pos;if(this.regexp_eatUnicodePropertyName(W)&&W.eat(61)){var M=W.lastStringValue;if(this.regexp_eatUnicodePropertyValue(W)){var L=W.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(W,M,L),bO}}if(W.pos=O,this.regexp_eatLoneUnicodePropertyNameOrValue(W)){var $=W.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(W,$)}return KA};g.regexp_validateUnicodePropertyNameAndValue=function(W,O,M){if(!p0(W.unicodeProperties.nonBinary,O))W.raise("Invalid property name");if(!W.unicodeProperties.nonBinary[O].test(M))W.raise("Invalid property value")};g.regexp_validateUnicodePropertyNameOrValue=function(W,O){if(W.unicodeProperties.binary.test(O))return bO;if(W.switchV&&W.unicodeProperties.binaryOfStrings.test(O))return MO;W.raise("Invalid property name")};g.regexp_eatUnicodePropertyName=function(W){var O=0;W.lastStringValue="";while(TA(O=W.current()))W.lastStringValue+=kO(O),W.advance();return W.lastStringValue!==""};function TA(W){return HA(W)||W===95}g.regexp_eatUnicodePropertyValue=function(W){var O=0;W.lastStringValue="";while(iK(O=W.current()))W.lastStringValue+=kO(O),W.advance();return W.lastStringValue!==""};function iK(W){return TA(W)||SL(W)}g.regexp_eatLoneUnicodePropertyNameOrValue=function(W){return this.regexp_eatUnicodePropertyValue(W)};g.regexp_eatCharacterClass=function(W){if(W.eat(91)){var O=W.eat(94),M=this.regexp_classContents(W);if(!W.eat(93))W.raise("Unterminated character class");if(O&&M===MO)W.raise("Negated character class may contain strings");return!0}return!1};g.regexp_classContents=function(W){if(W.current()===93)return bO;if(W.switchV)return this.regexp_classSetExpression(W);return this.regexp_nonEmptyClassRanges(W),bO};g.regexp_nonEmptyClassRanges=function(W){while(this.regexp_eatClassAtom(W)){var O=W.lastIntValue;if(W.eat(45)&&this.regexp_eatClassAtom(W)){var M=W.lastIntValue;if(W.switchU&&(O===-1||M===-1))W.raise("Invalid character class");if(O!==-1&&M!==-1&&O>M)W.raise("Range out of order in character class")}}};g.regexp_eatClassAtom=function(W){var O=W.pos;if(W.eat(92)){if(this.regexp_eatClassEscape(W))return!0;if(W.switchU){var M=W.current();if(M===99||qA(M))W.raise("Invalid class escape");W.raise("Invalid escape")}W.pos=O}var L=W.current();if(L!==93)return W.lastIntValue=L,W.advance(),!0;return!1};g.regexp_eatClassEscape=function(W){var O=W.pos;if(W.eat(98))return W.lastIntValue=8,!0;if(W.switchU&&W.eat(45))return W.lastIntValue=45,!0;if(!W.switchU&&W.eat(99)){if(this.regexp_eatClassControlLetter(W))return!0;W.pos=O}return this.regexp_eatCharacterClassEscape(W)||this.regexp_eatCharacterEscape(W)};g.regexp_classSetExpression=function(W){var O=bO,M;if(this.regexp_eatClassSetRange(W));else if(M=this.regexp_eatClassSetOperand(W)){if(M===MO)O=MO;var L=W.pos;while(W.eatChars([38,38])){if(W.current()!==38&&(M=this.regexp_eatClassSetOperand(W))){if(M!==MO)O=bO;continue}W.raise("Invalid character in character class")}if(L!==W.pos)return O;while(W.eatChars([45,45])){if(this.regexp_eatClassSetOperand(W))continue;W.raise("Invalid character in character class")}if(L!==W.pos)return O}else W.raise("Invalid character in character class");for(;;){if(this.regexp_eatClassSetRange(W))continue;if(M=this.regexp_eatClassSetOperand(W),!M)return O;if(M===MO)O=MO}};g.regexp_eatClassSetRange=function(W){var O=W.pos;if(this.regexp_eatClassSetCharacter(W)){var M=W.lastIntValue;if(W.eat(45)&&this.regexp_eatClassSetCharacter(W)){var L=W.lastIntValue;if(M!==-1&&L!==-1&&M>L)W.raise("Range out of order in character class");return!0}W.pos=O}return!1};g.regexp_eatClassSetOperand=function(W){if(this.regexp_eatClassSetCharacter(W))return bO;return this.regexp_eatClassStringDisjunction(W)||this.regexp_eatNestedClass(W)};g.regexp_eatNestedClass=function(W){var O=W.pos;if(W.eat(91)){var M=W.eat(94),L=this.regexp_classContents(W);if(W.eat(93)){if(M&&L===MO)W.raise("Negated character class may contain strings");return L}W.pos=O}if(W.eat(92)){var $=this.regexp_eatCharacterClassEscape(W);if($)return $;W.pos=O}return null};g.regexp_eatClassStringDisjunction=function(W){var O=W.pos;if(W.eatChars([92,113])){if(W.eat(123)){var M=this.regexp_classStringDisjunctionContents(W);if(W.eat(125))return M}else W.raise("Invalid escape");W.pos=O}return null};g.regexp_classStringDisjunctionContents=function(W){var O=this.regexp_classString(W);while(W.eat(124))if(this.regexp_classString(W)===MO)O=MO;return O};g.regexp_classString=function(W){var O=0;while(this.regexp_eatClassSetCharacter(W))O++;return O===1?bO:MO};g.regexp_eatClassSetCharacter=function(W){var O=W.pos;if(W.eat(92)){if(this.regexp_eatCharacterEscape(W)||this.regexp_eatClassSetReservedPunctuator(W))return!0;if(W.eat(98))return W.lastIntValue=8,!0;return W.pos=O,!1}var M=W.current();if(M<0||M===W.lookahead()&&sK(M))return!1;if(nK(M))return!1;return W.advance(),W.lastIntValue=M,!0};function sK(W){return W===33||W>=35&&W<=38||W>=42&&W<=44||W===46||W>=58&&W<=64||W===94||W===96||W===126}function nK(W){return W===40||W===41||W===45||W===47||W>=91&&W<=93||W>=123&&W<=125}g.regexp_eatClassSetReservedPunctuator=function(W){var O=W.current();if(rK(O))return W.lastIntValue=O,W.advance(),!0;return!1};function rK(W){return W===33||W===35||W===37||W===38||W===44||W===45||W>=58&&W<=62||W===64||W===96||W===126}g.regexp_eatClassControlLetter=function(W){var O=W.current();if(SL(O)||O===95)return W.lastIntValue=O%32,W.advance(),!0;return!1};g.regexp_eatHexEscapeSequence=function(W){var O=W.pos;if(W.eat(120)){if(this.regexp_eatFixedHexDigits(W,2))return!0;if(W.switchU)W.raise("Invalid escape");W.pos=O}return!1};g.regexp_eatDecimalDigits=function(W){var O=W.pos,M=0;W.lastIntValue=0;while(SL(M=W.current()))W.lastIntValue=10*W.lastIntValue+(M-48),W.advance();return W.pos!==O};function SL(W){return W>=48&&W<=57}g.regexp_eatHexDigits=function(W){var O=W.pos,M=0;W.lastIntValue=0;while(FA(M=W.current()))W.lastIntValue=16*W.lastIntValue+EA(M),W.advance();return W.pos!==O};function FA(W){return W>=48&&W<=57||W>=65&&W<=70||W>=97&&W<=102}function EA(W){if(W>=65&&W<=70)return 10+(W-65);if(W>=97&&W<=102)return 10+(W-97);return W-48}g.regexp_eatLegacyOctalEscapeSequence=function(W){if(this.regexp_eatOctalDigit(W)){var O=W.lastIntValue;if(this.regexp_eatOctalDigit(W)){var M=W.lastIntValue;if(O<=3&&this.regexp_eatOctalDigit(W))W.lastIntValue=O*64+M*8+W.lastIntValue;else W.lastIntValue=O*8+M}else W.lastIntValue=O;return!0}return!1};g.regexp_eatOctalDigit=function(W){var O=W.current();if(qA(O))return W.lastIntValue=O-48,W.advance(),!0;return W.lastIntValue=0,!1};function qA(W){return W>=48&&W<=55}g.regexp_eatFixedHexDigits=function(W,O){var M=W.pos;W.lastIntValue=0;for(var L=0;L<O;++L){var $=W.current();if(!FA($))return W.pos=M,!1;W.lastIntValue=16*W.lastIntValue+EA($),W.advance()}return!0};var K8=function(O){if(this.type=O.type,this.value=O.value,this.start=O.start,this.end=O.end,O.options.locations)this.loc=new ZL(O,O.startLoc,O.endLoc);if(O.options.ranges)this.range=[O.start,O.end]},r=VW.prototype;r.next=function(W){if(!W&&this.type.keyword&&this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword);if(this.options.onToken)this.options.onToken(new K8(this));this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};r.getToken=function(){return this.next(),new K8(this)};if(typeof Symbol<"u")r[Symbol.iterator]=function(){var W=this;return{next:function(){var O=W.getToken();return{done:O.type===z.eof,value:O}}}};r.nextToken=function(){var W=this.curContext();if(!W||!W.preserveSpace)this.skipSpace();if(this.start=this.pos,this.options.locations)this.startLoc=this.curPosition();if(this.pos>=this.input.length)return this.finishToken(z.eof);if(W.override)return W.override(this);else this.readToken(this.fullCharCodeAtPos())};r.readToken=function(W){if(KO(W,this.options.ecmaVersion>=6)||W===92)return this.readWord();return this.getTokenFromCode(W)};r.fullCharCodeAtPos=function(){var W=this.input.charCodeAt(this.pos);if(W<=55295||W>=56320)return W;var O=this.input.charCodeAt(this.pos+1);return O<=56319||O>=57344?W:(W<<10)+O-56613888};r.skipBlockComment=function(){var W=this.options.onComment&&this.curPosition(),O=this.pos,M=this.input.indexOf("*/",this.pos+=2);if(M===-1)this.raise(this.pos-2,"Unterminated comment");if(this.pos=M+2,this.options.locations)for(var L=void 0,$=O;(L=i4(this.input,$,this.pos))>-1;)++this.curLine,$=this.lineStart=L;if(this.options.onComment)this.options.onComment(!0,this.input.slice(O+2,M),O,this.pos,W,this.curPosition())};r.skipLineComment=function(W){var O=this.pos,M=this.options.onComment&&this.curPosition(),L=this.input.charCodeAt(this.pos+=W);while(this.pos<this.input.length&&!l0(L))L=this.input.charCodeAt(++this.pos);if(this.options.onComment)this.options.onComment(!1,this.input.slice(O+W,this.pos),O,this.pos,M,this.curPosition())};r.skipSpace=function(){W:while(this.pos<this.input.length){var W=this.input.charCodeAt(this.pos);switch(W){case 32:case 160:++this.pos;break;case 13:if(this.input.charCodeAt(this.pos+1)===10)++this.pos;case 10:case 8232:case 8233:if(++this.pos,this.options.locations)++this.curLine,this.lineStart=this.pos;break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break W}break;default:if(W>8&&W<14||W>=5760&&s4.test(String.fromCharCode(W)))++this.pos;else break W}}};r.finishToken=function(W,O){if(this.end=this.pos,this.options.locations)this.endLoc=this.curPosition();var M=this.type;this.type=W,this.value=O,this.updateContext(M)};r.readToken_dot=function(){var W=this.input.charCodeAt(this.pos+1);if(W>=48&&W<=57)return this.readNumber(!0);var O=this.input.charCodeAt(this.pos+2);if(this.options.ecmaVersion>=6&&W===46&&O===46)return this.pos+=3,this.finishToken(z.ellipsis);else return++this.pos,this.finishToken(z.dot)};r.readToken_slash=function(){var W=this.input.charCodeAt(this.pos+1);if(this.exprAllowed)return++this.pos,this.readRegexp();if(W===61)return this.finishOp(z.assign,2);return this.finishOp(z.slash,1)};r.readToken_mult_modulo_exp=function(W){var O=this.input.charCodeAt(this.pos+1),M=1,L=W===42?z.star:z.modulo;if(this.options.ecmaVersion>=7&&W===42&&O===42)++M,L=z.starstar,O=this.input.charCodeAt(this.pos+2);if(O===61)return this.finishOp(z.assign,M+1);return this.finishOp(L,M)};r.readToken_pipe_amp=function(W){var O=this.input.charCodeAt(this.pos+1);if(O===W){if(this.options.ecmaVersion>=12){var M=this.input.charCodeAt(this.pos+2);if(M===61)return this.finishOp(z.assign,3)}return this.finishOp(W===124?z.logicalOR:z.logicalAND,2)}if(O===61)return this.finishOp(z.assign,2);return this.finishOp(W===124?z.bitwiseOR:z.bitwiseAND,1)};r.readToken_caret=function(){var W=this.input.charCodeAt(this.pos+1);if(W===61)return this.finishOp(z.assign,2);return this.finishOp(z.bitwiseXOR,1)};r.readToken_plus_min=function(W){var O=this.input.charCodeAt(this.pos+1);if(O===W){if(O===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||uW.test(this.input.slice(this.lastTokEnd,this.pos))))return this.skipLineComment(3),this.skipSpace(),this.nextToken();return this.finishOp(z.incDec,2)}if(O===61)return this.finishOp(z.assign,2);return this.finishOp(z.plusMin,1)};r.readToken_lt_gt=function(W){var O=this.input.charCodeAt(this.pos+1),M=1;if(O===W){if(M=W===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+M)===61)return this.finishOp(z.assign,M+1);return this.finishOp(z.bitShift,M)}if(O===33&&W===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45)return this.skipLineComment(4),this.skipSpace(),this.nextToken();if(O===61)M=2;return this.finishOp(z.relational,M)};r.readToken_eq_excl=function(W){var O=this.input.charCodeAt(this.pos+1);if(O===61)return this.finishOp(z.equality,this.input.charCodeAt(this.pos+2)===61?3:2);if(W===61&&O===62&&this.options.ecmaVersion>=6)return this.pos+=2,this.finishToken(z.arrow);return this.finishOp(W===61?z.eq:z.prefix,1)};r.readToken_question=function(){var W=this.options.ecmaVersion;if(W>=11){var O=this.input.charCodeAt(this.pos+1);if(O===46){var M=this.input.charCodeAt(this.pos+2);if(M<48||M>57)return this.finishOp(z.questionDot,2)}if(O===63){if(W>=12){var L=this.input.charCodeAt(this.pos+2);if(L===61)return this.finishOp(z.assign,3)}return this.finishOp(z.coalesce,2)}}return this.finishOp(z.question,1)};r.readToken_numberSign=function(){var W=this.options.ecmaVersion,O=35;if(W>=13){if(++this.pos,O=this.fullCharCodeAtPos(),KO(O,!0)||O===92)return this.finishToken(z.privateId,this.readWord1())}this.raise(this.pos,"Unexpected character '"+kO(O)+"'")};r.getTokenFromCode=function(W){switch(W){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(z.parenL);case 41:return++this.pos,this.finishToken(z.parenR);case 59:return++this.pos,this.finishToken(z.semi);case 44:return++this.pos,this.finishToken(z.comma);case 91:return++this.pos,this.finishToken(z.bracketL);case 93:return++this.pos,this.finishToken(z.bracketR);case 123:return++this.pos,this.finishToken(z.braceL);case 125:return++this.pos,this.finishToken(z.braceR);case 58:return++this.pos,this.finishToken(z.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(z.backQuote);case 48:var O=this.input.charCodeAt(this.pos+1);if(O===120||O===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(O===111||O===79)return this.readRadixNumber(8);if(O===98||O===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(W);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(W);case 124:case 38:return this.readToken_pipe_amp(W);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(W);case 60:case 62:return this.readToken_lt_gt(W);case 61:case 33:return this.readToken_eq_excl(W);case 63:return this.readToken_question();case 126:return this.finishOp(z.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+kO(W)+"'")};r.finishOp=function(W,O){var M=this.input.slice(this.pos,this.pos+O);return this.pos+=O,this.finishToken(W,M)};r.readRegexp=function(){var W,O,M=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(M,"Unterminated regular expression");var L=this.input.charAt(this.pos);if(uW.test(L))this.raise(M,"Unterminated regular expression");if(!W){if(L==="[")O=!0;else if(L==="]"&&O)O=!1;else if(L==="/"&&!O)break;W=L==="\\"}else W=!1;++this.pos}var $=this.input.slice(M,this.pos);++this.pos;var Y=this.pos,J=this.readWord1();if(this.containsEsc)this.unexpected(Y);var A=this.regexpState||(this.regexpState=new FO(this));A.reset(M,$,J),this.validateRegExpFlags(A),this.validateRegExpPattern(A);var Z=null;try{Z=new RegExp($,J)}catch(G){}return this.finishToken(z.regexp,{pattern:$,flags:J,value:Z})};r.readInt=function(W,O,M){var L=this.options.ecmaVersion>=12&&O===void 0,$=M&&this.input.charCodeAt(this.pos)===48,Y=this.pos,J=0,A=0;for(var Z=0,G=O==null?1/0:O;Z<G;++Z,++this.pos){var X=this.input.charCodeAt(this.pos),Q=void 0;if(L&&X===95){if($)this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals");if(A===95)this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore");if(Z===0)this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits");A=X;continue}if(X>=97)Q=X-97+10;else if(X>=65)Q=X-65+10;else if(X>=48&&X<=57)Q=X-48;else Q=1/0;if(Q>=W)break;A=X,J=J*W+Q}if(L&&A===95)this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits");if(this.pos===Y||O!=null&&this.pos-Y!==O)return null;return J};function aK(W,O){if(O)return parseInt(W,8);return parseFloat(W.replace(/_/g,""))}function BA(W){if(typeof BigInt!=="function")return null;return BigInt(W.replace(/_/g,""))}r.readRadixNumber=function(W){var O=this.pos;this.pos+=2;var M=this.readInt(W);if(M==null)this.raise(this.start+2,"Expected number in radix "+W);if(this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110)M=BA(this.input.slice(O,this.pos)),++this.pos;else if(KO(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(z.num,M)};r.readNumber=function(W){var O=this.pos;if(!W&&this.readInt(10,void 0,!0)===null)this.raise(O,"Invalid number");var M=this.pos-O>=2&&this.input.charCodeAt(O)===48;if(M&&this.strict)this.raise(O,"Invalid number");var L=this.input.charCodeAt(this.pos);if(!M&&!W&&this.options.ecmaVersion>=11&&L===110){var $=BA(this.input.slice(O,this.pos));if(++this.pos,KO(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(z.num,$)}if(M&&/[89]/.test(this.input.slice(O,this.pos)))M=!1;if(L===46&&!M)++this.pos,this.readInt(10),L=this.input.charCodeAt(this.pos);if((L===69||L===101)&&!M){if(L=this.input.charCodeAt(++this.pos),L===43||L===45)++this.pos;if(this.readInt(10)===null)this.raise(O,"Invalid number")}if(KO(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");var Y=aK(this.input.slice(O,this.pos),M);return this.finishToken(z.num,Y)};r.readCodePoint=function(){var W=this.input.charCodeAt(this.pos),O;if(W===123){if(this.options.ecmaVersion<6)this.unexpected();var M=++this.pos;if(O=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,O>1114111)this.invalidStringToken(M,"Code point out of bounds")}else O=this.readHexChar(4);return O};r.readString=function(W){var O="",M=++this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated string constant");var L=this.input.charCodeAt(this.pos);if(L===W)break;if(L===92)O+=this.input.slice(M,this.pos),O+=this.readEscapedChar(!1),M=this.pos;else if(L===8232||L===8233){if(this.options.ecmaVersion<10)this.raise(this.start,"Unterminated string constant");if(++this.pos,this.options.locations)this.curLine++,this.lineStart=this.pos}else{if(l0(L))this.raise(this.start,"Unterminated string constant");++this.pos}}return O+=this.input.slice(M,this.pos++),this.finishToken(z.string,O)};var CA={};r.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(W){if(W===CA)this.readInvalidTemplateToken();else throw W}this.inTemplateElement=!1};r.invalidStringToken=function(W,O){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw CA;else this.raise(W,O)};r.readTmplToken=function(){var W="",O=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated template");var M=this.input.charCodeAt(this.pos);if(M===96||M===36&&this.input.charCodeAt(this.pos+1)===123){if(this.pos===this.start&&(this.type===z.template||this.type===z.invalidTemplate))if(M===36)return this.pos+=2,this.finishToken(z.dollarBraceL);else return++this.pos,this.finishToken(z.backQuote);return W+=this.input.slice(O,this.pos),this.finishToken(z.template,W)}if(M===92)W+=this.input.slice(O,this.pos),W+=this.readEscapedChar(!0),O=this.pos;else if(l0(M)){switch(W+=this.input.slice(O,this.pos),++this.pos,M){case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:W+=`
19
19
  `;break;default:W+=String.fromCharCode(M);break}if(this.options.locations)++this.curLine,this.lineStart=this.pos;O=this.pos}else++this.pos}};r.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(z.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":if(this.input[this.pos+1]===`
20
20
  `)++this.pos;case`
21
21
  `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};r.readEscapedChar=function(W){var O=this.input.charCodeAt(++this.pos);switch(++this.pos,O){case 110:return`
22
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return DO(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:if(this.options.locations)this.lineStart=this.pos,++this.curLine;return"";case 56:case 57:if(this.strict)this.invalidStringToken(this.pos-1,"Invalid escape sequence");if(W){var M=this.pos-1;this.invalidStringToken(M,"Invalid escape sequence in template string")}default:if(O>=48&&O<=55){var L=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],$=parseInt(L,8);if($>255)L=L.slice(0,-1),$=parseInt(L,8);if(this.pos+=L.length-1,O=this.input.charCodeAt(this.pos),(L!=="0"||O===56||O===57)&&(this.strict||W))this.invalidStringToken(this.pos-1-L.length,W?"Octal literal in template string":"Octal literal in strict mode");return String.fromCharCode($)}if(f0(O)){if(this.options.locations)this.lineStart=this.pos,++this.curLine;return""}return String.fromCharCode(O)}};r.readHexChar=function(W){var O=this.pos,M=this.readInt(16,W);if(M===null)this.invalidStringToken(O,"Bad character escape sequence");return M};r.readWord1=function(){this.containsEsc=!1;var W="",O=!0,M=this.pos,L=this.options.ecmaVersion>=6;while(this.pos<this.input.length){var $=this.fullCharCodeAtPos();if(rO($,L))this.pos+=$<=65535?1:2;else if($===92){this.containsEsc=!0,W+=this.input.slice(M,this.pos);var Y=this.pos;if(this.input.charCodeAt(++this.pos)!==117)this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX");++this.pos;var J=this.readCodePoint();if(!(O?VO:rO)(J,L))this.invalidStringToken(Y,"Invalid Unicode escape");W+=DO(J),M=this.pos}else break;O=!1}return W+this.input.slice(M,this.pos)};r.readWord=function(){var W=this.readWord1(),O=z.name;if(this.keywords.test(W))O=G8[W];return this.finishToken(O,W)};var rK="8.15.0";HW.acorn={Parser:HW,version:rK,defaultOptions:J8,Position:b1,SourceLocation:AL,getLineInfo:i6,Node:QL,TokenType:WW,tokTypes:z,keywordTypes:G8,TokContext:XO,tokContexts:JW,isIdentifierChar:rO,isIdentifierStart:VO,Token:V8,isNewLine:f0,lineBreak:uW,lineBreakG:KK,nonASCIIwhitespace:d6};function g1(W,O){return HW.parse(W,O)}class h1 extends Error{diagnostic;constructor(W){super(W.message);this.name="WomlDiagnosticError",this.diagnostic=W}}class H8 extends h1{constructor(W){super(W);this.name="WomlParseError"}}class oO extends h1{constructor(W){super(W);this.name="WomlValidationError"}}class GO extends h1{constructor(W){super(W);this.name="WomlCompileError"}}class n{path;text;#W;constructor(W,O){this.path=W,this.text=O;let M=[0];for(let L=0;L<O.length;L+=1)if(O.charCodeAt(L)===10)M.push(L+1);this.#W=M}positionAt(W){let O=Math.max(0,Math.min(W,this.text.length)),M=0,L=this.#W.length;while(M+1<L){let $=Math.floor((M+L)/2);if(this.#W[$]<=O)M=$;else L=$}return{line:M+1,column:O-this.#W[M]+1,offset:O}}offsetAt(W,O){let M=Math.max(1,Math.min(W,this.#W.length)),L=this.#W[M-1],$=M<this.#W.length?this.#W[M]:this.text.length;return Math.max(L,Math.min(L+Math.max(O-1,0),$))}span(W,O){return{start:this.positionAt(W),end:this.positionAt(O)}}parseError(W,O,M,L=M+1,$){return new H8({code:W,phase:"parse",message:O,file:this.path,location:this.span(M,L),...$===void 0?{}:{hint:$}})}}function aK(W){return W.kind==="element"}var q4=/^[A-Z][A-Z0-9_]*$/,oK=/^\{\{secrets\.([A-Z][A-Z0-9_]*)\}\}$/;function TO(W){return q4.test(W)}function RL(W){let O=oK.exec(W);if(O===null)return;return{kind:"secretReference",name:O[1]}}function RW(W,O){let M=RL(O.value);if(M!==void 0)return M;let L=O.value.includes("{{secrets.");throw new oO({code:L?"WOML_SECRET_REFERENCE_INVALID":"WOML_SECRET_LITERAL_FORBIDDEN",phase:"validation",message:L?"Secret references must use the exact form {{secrets.NAME}}, where NAME starts with A-Z and contains only A-Z, 0-9, or underscore.":`Attribute "${O.name}" accepts a secret reference, never a literal credential.`,file:W.file,location:O.valueSpan,hint:`Use ${O.name}="{{secrets.SECRET_NAME}}" and store the value with woml secrets set SECRET_NAME.`})}var l1=`async function __woml_script(context, lifecycle, attempt, services, secrets) {
23
- `,tK=`
24
- }`,eK=new Set(["lifecycle","services","secrets","fetch"]),W3=new Set(["connect","listen","serve","udpSocket"]),O3=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,K8=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/,M3=/^([1-9][0-9]*)(ms|s|m|h|d)$/,L3=/^[0-9]{17,20}$/,$3=/^[1-9][0-9]{5,19}$/,Y3=/^[1-9][0-9]{7,15}$/,J3=/^[a-z0-9_]+$/,A3=/^[a-z]{2,3}(?:_[A-Z]{2})?$/,Z3={ms:1,s:1000,m:60000,h:3600000,d:86400000},B4=86400000;function f(W){return typeof W==="object"&&W!==null&&typeof W.type==="string"&&typeof W.start==="number"&&typeof W.end==="number"}function T8(W,O){let M=W.start-l1.length,L=W.end-l1.length,$=Math.max(0,Math.min(M,O)),Y=Math.max($+($<O?1:0),Math.min(L,O));return{start:$,end:Math.min(Y,O)}}function D(W,O,M,L,$){return{code:M,message:L,...T8(W,O),...$===void 0?{}:{hint:$}}}function FO(W){if(!f(W))return[];switch(W.type){case"Identifier":return[W];case"ObjectPattern":return(W.properties??[]).flatMap((O)=>{if(!f(O))return[];if(O.type==="RestElement")return FO(O.argument);return FO(O.value)});case"ArrayPattern":return(W.elements??[]).flatMap(FO);case"AssignmentPattern":return FO(W.left);case"RestElement":return FO(W.argument);default:return[]}}function w4(W){switch(W.type){case"VariableDeclarator":return FO(W.id);case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":return[...FO(W.id),...(W.params??[]).flatMap(FO)];case"ClassDeclaration":case"ClassExpression":return FO(W.id);case"CatchClause":return FO(W.param);default:return[]}}function X3(W,O){if(O===void 0)return!1;return w4(O).includes(W)}function G3(W,O){if(O===void 0)return!1;if(X3(W,O))return!0;if(O.type==="MemberExpression"&&O.property===W&&O.computed!==!0)return!0;if((O.type==="Property"||O.type==="PropertyDefinition")&&O.key===W&&O.computed!==!0&&O.shorthand!==!0)return!0;if((O.type==="MethodDefinition"||O.type==="LabeledStatement")&&(O.key===W||O.label===W))return!0;if((O.type==="BreakStatement"||O.type==="ContinueStatement")&&O.label===W)return!0;return!1}function Q3(W){let O=[];for(let[M,L]of Object.entries(W)){if(M==="start"||M==="end"||M==="type")continue;if(f(L))O.push(L);else if(Array.isArray(L)){for(let $ of L)if(f($))O.push($)}}return O}function UL(W){if(W.type!=="MemberExpression")return;let O=W.property;if(!f(O))return;if(W.computed!==!0&&O.type==="Identifier")return O.name;return W.computed===!0&&O.type==="Literal"&&typeof O.value==="string"?O.value:void 0}function S0(W){let O=W;while(f(O)&&O.type==="MemberExpression")O=O.object;return f(O)&&O.type==="Identifier"?O:void 0}function u1(W){if(!f(W))return;if(W.type==="Identifier"&&W.name!==void 0)return[W.name];if(W.type!=="MemberExpression"||W.computed===!0)return;let O=u1(W.object),M=W.property;if(O===void 0||!f(M)||M.type!=="Identifier"||M.name===void 0)return;return[...O,M.name]}function EW(W){return f(W)&&W.type==="Literal"&&typeof W.value==="string"?W.value:void 0}function S3(W){if(W.type!=="Literal")return!0;if(typeof W.value==="number")return Number.isSafeInteger(W.value)&&W.value>0&&W.value<=B4;if(typeof W.value!=="string")return!1;let O=M3.exec(W.value);if(O===null)return!1;let L=Number(O[1])*Z3[O[2]];return Number.isSafeInteger(L)&&L>0&&L<=B4}function fO(W,O){return O?.type==="AssignmentExpression"&&O.left===W||O?.type==="UpdateExpression"&&O.argument===W||O?.type==="UnaryExpression"&&O.operator==="delete"&&O.argument===W}function R3(W,O){let M=W.pos??W.raisedAt??l1.length,L=Math.max(0,Math.min(M-l1.length,O));return{code:"WOML_SCRIPT_SYNTAX_INVALID",message:W.message.replace(/ \(\d+:\d+\)$/,""),start:L,end:Math.min(Math.max(L+1,L),O),hint:"Fix the JavaScript syntax inside this <script> body."}}function zL(W,O,M={}){let L;try{L=g1(`${l1}${W}${tK}`,{ecmaVersion:"latest",sourceType:"script",allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1})}catch(R){return{requiredSecrets:[],requiredServices:[],serviceReferences:[],usesServices:!1,usesNativeFetch:!1,issue:R3(R,W.length)}}let $=L.body?.find((R)=>f(R)&&R.type==="FunctionDeclaration"),Y=f($)?$:void 0,J=f(Y?.body)?Y.body:void 0;if(J===void 0)return{requiredSecrets:[],requiredServices:[],serviceReferences:[],usesServices:!1,usesNativeFetch:!1,issue:{code:"WOML_SCRIPT_SYNTAX_INVALID",message:"The script could not be parsed as an asynchronous function body.",start:0,end:Math.min(W.length,1)}};let A=new Set,Z=new Map,X=!1,G=!1,Q,S=(R)=>{if(Q===void 0||R.start<Q.start)Q=R},U=(R,K,T)=>{let F=T8(R,W.length);if(Q!==void 0&&F.start>Q.start)return;if(R.type==="ImportExpression")S(D(R,W.length,"WOML_SCRIPT_DYNAMIC_IMPORT_UNSUPPORTED","Dynamic import is unavailable in the current WOML script profile.","Use the future WOML module system when it becomes available."));if(R.type==="CallExpression"&&f(R.callee)){let N=R.callee,C=u1(N);if(C?.[0]==="services"&&C[1]==="workflows"){let w=C[2];if(C.length!==3||w!=="call"&&w!=="start")S(D(N,W.length,"WOML_WORKFLOW_OPERATION_UNSUPPORTED",`Workflow service operation "${C.slice(2).join(".")||""}" is unsupported.`,"Use services.workflows.call() when the result is needed or services.workflows.start() to continue after durable admission."));else{let B=R.arguments??[];if(B.length<2||B.length>3)S(D(R,W.length,"WOML_WORKFLOW_CALL_ARGUMENTS_INVALID",`services.workflows.${w}() requires workflowId, payload, and optional options.`,w==="call"?'Use services.workflows.call("workflow-id", { ... }, { name, timeout }).':'Use services.workflows.start("workflow-id", { ... }, { name }).'));else{let I=B[0],_=EW(I);if(f(I)&&I.type==="Literal"&&(_===void 0||_.length>256||!O3.test(_)))S(D(I,W.length,"WOML_WORKFLOW_TARGET_INVALID","A literal workflow target must use lowercase kebab-case.",`Example: services.workflows.${w}("calculate-risk", { ... }).`));let H=B[1];if(f(H)&&(H.type==="Literal"||H.type==="ArrayExpression"))S(D(H,W.length,"WOML_WORKFLOW_PAYLOAD_INVALID","A workflow call payload must be a top-level JSON object.","Pass an object literal or an expression that resolves to an object."));let q=B[2];if(f(q)&&(q.type==="Literal"||q.type==="ArrayExpression"))S(D(q,W.length,"WOML_WORKFLOW_CALL_OPTIONS_INVALID","Workflow call options must be an object.",'Use { name: "logical-call", timeout: "30s" }.'));else if(f(q)&&q.type==="ObjectExpression")for(let j of q.properties??[]){if(!f(j)||j.type!=="Property"){S(D(f(j)?j:q,W.length,"WOML_WORKFLOW_CALL_OPTIONS_INVALID","Workflow call options do not support spread or computed members.","Use only static name and timeout properties."));continue}let b=f(j.key)?j.key.type==="Identifier"?j.key.name:EW(j.key):void 0;if(b!=="name"&&(w!=="call"||b!=="timeout"))S(D(j,W.length,"WOML_WORKFLOW_CALL_OPTION_UNKNOWN",`Unknown workflow call option "${b??""}".`,w==="call"?"Workflow Call v1 options are name and timeout.":"Workflow Start v1 accepts only name."));if(b==="name"){let k=EW(j.value);if(f(j.value)&&j.value.type==="Literal"&&(k===void 0||k.length>128||!K8.test(k)))S(D(j.value,W.length,"WOML_WORKFLOW_CALL_NAME_INVALID","A literal workflow call name must use lowercase operation-name syntax.","Example: primary-risk"))}if(w==="call"&&b==="timeout"&&f(j.value)&&!S3(j.value))S(D(j.value,W.length,"WOML_WORKFLOW_CALL_OPTIONS_INVALID","A literal workflow call timeout must be a positive duration no greater than 24h.",'Use milliseconds or a whole duration such as "30s", "5m", or "24h".'))}}}}if(C?.[0]==="services"&&C[1]==="telegram"&&!M.shadowedServices?.includes("telegram"))if(C.length!==3||C[2]!=="send")S(D(N,W.length,"WOML_TELEGRAM_OPERATION_UNSUPPORTED",`Telegram service operation "${C.slice(2).join(".")||""}" is unsupported.`,"Use services.telegram.send({ botToken, conversationId, text })."));else{let w=R.arguments??[];if(w.length<1||w.length>2)S(D(R,W.length,"WOML_TELEGRAM_SEND_ARGUMENTS_INVALID","services.telegram.send() requires one request object and optional operation options.",'Use services.telegram.send({ botToken: secrets.TELEGRAM_BOT_TOKEN, conversationId, text }, { name: "reply" }).'));else{let B=w[0];if(!f(B)||B.type!=="ObjectExpression")S(D(f(B)?B:R,W.length,"WOML_TELEGRAM_SEND_INPUT_INVALID","A workflow script must pass a direct object to services.telegram.send().","Use the required botToken, conversationId, and text properties."));else{let _=new Set;for(let H of B.properties??[]){if(!f(H)||H.type!=="Property"||H.computed===!0||H.kind!=="init"){S(D(f(H)?H:B,W.length,"WOML_TELEGRAM_SEND_INPUT_INVALID","Telegram send input does not support spreads, computed keys, getters, or setters."));continue}let q=f(H.key)?H.key.type==="Identifier"?H.key.name:EW(H.key):void 0;if(q!=="botToken"&&q!=="conversationId"&&q!=="text"&&q!=="replyToMessageId"){S(D(H,W.length,"WOML_TELEGRAM_SEND_PROPERTY_UNKNOWN",`Unknown Telegram send property "${q??""}".`,"Telegram Send v1 accepts botToken, conversationId, text, and replyToMessageId."));continue}if(_.has(q))S(D(H,W.length,"WOML_TELEGRAM_SEND_PROPERTY_DUPLICATE",`Telegram send property "${q}" is declared more than once.`));if(_.add(q),q==="botToken"){let b=f(H.value)?u1(H.value):void 0;if(b?.length!==2||b[0]!=="secrets"||!TO(b[1]))S(D(f(H.value)?H.value:H,W.length,"WOML_TELEGRAM_CREDENTIAL_INVALID","Telegram botToken must be one direct secrets.NAME value.","Example: botToken: secrets.TELEGRAM_BOT_TOKEN"))}let j=EW(H.value);if(j!==void 0&&(j.length===0||j.length>(q==="text"?40000:320)))S(D(H.value,W.length,"WOML_TELEGRAM_SEND_VALUE_INVALID",`Telegram send property "${q}" has an invalid literal value.`))}for(let H of["botToken","conversationId","text"])if(!_.has(H))S(D(B,W.length,"WOML_TELEGRAM_SEND_PROPERTY_REQUIRED",`services.telegram.send() requires the "${H}" property.`))}let I=w[1];if(f(I))if(I.type!=="ObjectExpression")S(D(I,W.length,"WOML_TELEGRAM_SEND_OPTIONS_INVALID","Telegram send operation options must be an object containing an optional stable name."));else for(let _ of I.properties??[]){let H=f(_)&&_.type==="Property"&&f(_.key)?_.key.type==="Identifier"?_.key.name:EW(_.key):void 0;if(H!=="name")S(D(f(_)?_:I,W.length,"WOML_TELEGRAM_SEND_OPTION_UNKNOWN",`Unknown Telegram send option "${H??""}".`,"Telegram Send v1 accepts only the stable name option."))}}}if(C?.[0]==="services"&&C[1]==="discord"&&!M.shadowedServices?.includes("discord"))if(C.length!==3||C[2]!=="send")S(D(N,W.length,"WOML_DISCORD_OPERATION_UNSUPPORTED",`Discord service operation "${C.slice(2).join(".")||""}" is unsupported.`,"Use services.discord.send({ botToken, conversationId, text })."));else{let w=R.arguments??[];if(w.length<1||w.length>2)S(D(R,W.length,"WOML_DISCORD_SEND_ARGUMENTS_INVALID","services.discord.send() requires one request object and optional operation options.",'Use services.discord.send({ botToken: secrets.DISCORD_BOT_TOKEN, conversationId, text }, { name: "reply" }).'));else{let B=w[0];if(!f(B)||B.type!=="ObjectExpression")S(D(f(B)?B:R,W.length,"WOML_DISCORD_SEND_INPUT_INVALID","A workflow script must pass a direct object to services.discord.send().","Use the required botToken, conversationId, and text properties."));else{let _=new Set;for(let H of B.properties??[]){if(!f(H)||H.type!=="Property"||H.computed===!0||H.kind!=="init"){S(D(f(H)?H:B,W.length,"WOML_DISCORD_SEND_INPUT_INVALID","Discord send input does not support spreads, computed keys, getters, or setters."));continue}let q=f(H.key)?H.key.type==="Identifier"?H.key.name:EW(H.key):void 0;if(q!=="botToken"&&q!=="conversationId"&&q!=="text"&&q!=="replyToMessageId"){S(D(H,W.length,"WOML_DISCORD_SEND_PROPERTY_UNKNOWN",`Unknown Discord send property "${q??""}".`,"Discord Send v1 accepts botToken, conversationId, text, and replyToMessageId."));continue}if(_.has(q))S(D(H,W.length,"WOML_DISCORD_SEND_PROPERTY_DUPLICATE",`Discord send property "${q}" is declared more than once.`));if(_.add(q),q==="botToken"){let b=f(H.value)?u1(H.value):void 0;if(b?.length!==2||b[0]!=="secrets"||!TO(b[1]))S(D(f(H.value)?H.value:H,W.length,"WOML_DISCORD_CREDENTIAL_INVALID","Discord botToken must be one direct secrets.NAME value.","Example: botToken: secrets.DISCORD_BOT_TOKEN"))}let j=EW(H.value);if(j!==void 0&&(j.length===0||j.length>(q==="text"?2000:320)))S(D(H.value,W.length,"WOML_DISCORD_SEND_VALUE_INVALID",`Discord send property "${q}" has an invalid literal value.`));if(j!==void 0&&(q==="conversationId"||q==="replyToMessageId")&&!L3.test(j))S(D(H.value,W.length,"WOML_DISCORD_SEND_VALUE_INVALID",`Discord send property "${q}" must be a numeric Discord snowflake containing 17 to 20 digits when written as a literal.`))}for(let H of["botToken","conversationId","text"])if(!_.has(H))S(D(B,W.length,"WOML_DISCORD_SEND_PROPERTY_REQUIRED",`services.discord.send() requires the "${H}" property.`))}let I=w[1];if(f(I))if(I.type!=="ObjectExpression")S(D(I,W.length,"WOML_DISCORD_SEND_OPTIONS_INVALID","Discord send operation options must be an object containing an optional stable name."));else{let _=new Set;for(let H of I.properties??[]){if(!f(H)||H.type!=="Property"||H.computed===!0||H.kind!=="init"){S(D(f(H)?H:I,W.length,"WOML_DISCORD_SEND_OPTIONS_INVALID","Discord send options do not support spreads, computed keys, getters, or setters."));continue}let q=f(H.key)?H.key.type==="Identifier"?H.key.name:EW(H.key):void 0;if(q!=="name"){S(D(H,W.length,"WOML_DISCORD_SEND_OPTION_UNKNOWN",`Unknown Discord send option "${q??""}".`,"Discord Send v1 accepts only the stable name option."));continue}if(_.has(q))S(D(H,W.length,"WOML_DISCORD_SEND_OPTION_DUPLICATE",'Discord send option "name" is declared more than once.'));_.add(q);let j=EW(H.value);if(f(H.value)&&H.value.type==="Literal"&&(j===void 0||j.length>128||!K8.test(j)))S(D(H.value,W.length,"WOML_DISCORD_SEND_NAME_INVALID","A literal Discord send name must use lowercase operation-name syntax.","Example: reply-to-message"))}}}}if(C?.[0]==="services"&&C[1]==="whatsapp"&&!M.shadowedServices?.includes("whatsapp"))if(C.length!==3||C[2]!=="send")S(D(N,W.length,"WOML_WHATSAPP_OPERATION_UNSUPPORTED",`WhatsApp service operation "${C.slice(2).join(".")||""}" is unsupported.`,"Use services.whatsapp.send({ accessToken, phoneNumberId, conversationId, template })."));else{let w=R.arguments??[],B=w[0];if(w.length<1||w.length>2)S(D(R,W.length,"WOML_WHATSAPP_SEND_ARGUMENTS_INVALID","services.whatsapp.send() requires one request object and optional operation options."));else if(!f(B)||B.type!=="ObjectExpression")S(D(f(B)?B:R,W.length,"WOML_WHATSAPP_SEND_INPUT_INVALID","A workflow script must pass a direct object to services.whatsapp.send()."));else{let I=new Set;for(let H of B.properties??[]){if(!f(H)||H.type!=="Property"||H.computed===!0||H.kind!=="init"){S(D(f(H)?H:B,W.length,"WOML_WHATSAPP_SEND_INPUT_INVALID","WhatsApp send input does not support spreads, computed keys, getters, or setters."));continue}let q=f(H.key)?H.key.type==="Identifier"?H.key.name:EW(H.key):void 0;if(q!=="accessToken"&&q!=="phoneNumberId"&&q!=="conversationId"&&q!=="template"){S(D(H,W.length,"WOML_WHATSAPP_SEND_PROPERTY_UNKNOWN",`Unknown WhatsApp send property "${q??""}".`,"WhatsApp Send v1 accepts accessToken, phoneNumberId, conversationId, and template."));continue}if(I.has(q))S(D(H,W.length,"WOML_WHATSAPP_SEND_PROPERTY_DUPLICATE",`WhatsApp send property "${q}" is declared more than once.`));if(I.add(q),q==="accessToken"){let b=f(H.value)?u1(H.value):void 0;if(b?.length!==2||b[0]!=="secrets"||!TO(b[1]))S(D(f(H.value)?H.value:H,W.length,"WOML_WHATSAPP_CREDENTIAL_INVALID","WhatsApp accessToken must be one direct secrets.NAME value.","Example: accessToken: secrets.WHATSAPP_ACCESS_TOKEN"))}let j=EW(H.value);if(j!==void 0&&q==="phoneNumberId"&&!$3.test(j))S(D(H.value,W.length,"WOML_WHATSAPP_SEND_VALUE_INVALID","WhatsApp phoneNumberId must be the numeric Meta Phone Number ID."));if(j!==void 0&&q==="conversationId"&&!Y3.test(j))S(D(H.value,W.length,"WOML_WHATSAPP_SEND_VALUE_INVALID","WhatsApp conversationId must be an international phone number containing 8 to 16 digits without a plus sign."));if(q==="template"){if(!f(H.value)||H.value.type!=="ObjectExpression"){S(D(f(H.value)?H.value:H,W.length,"WOML_WHATSAPP_TEMPLATE_INVALID","WhatsApp template must be a direct object with name, language, and parameters."));continue}let b=new Set;for(let k of H.value.properties??[]){if(!f(k)||k.type!=="Property"||k.computed===!0||k.kind!=="init"){S(D(f(k)?k:H.value,W.length,"WOML_WHATSAPP_TEMPLATE_INVALID","WhatsApp template does not support spreads, computed keys, getters, or setters."));continue}let p=f(k.key)?k.key.type==="Identifier"?k.key.name:EW(k.key):void 0;if(p!=="name"&&p!=="language"&&p!=="parameters"){S(D(k,W.length,"WOML_WHATSAPP_TEMPLATE_PROPERTY_UNKNOWN",`Unknown WhatsApp template property "${p??""}".`));continue}if(b.has(p))S(D(k,W.length,"WOML_WHATSAPP_TEMPLATE_PROPERTY_DUPLICATE",`WhatsApp template property "${p}" is declared more than once.`));b.add(p);let ZW=EW(k.value);if(p==="name"&&(ZW===void 0||!J3.test(ZW)))S(D(k.value,W.length,"WOML_WHATSAPP_TEMPLATE_INVALID","WhatsApp template name must be a literal containing lowercase letters, digits, and underscores only."));if(p==="language"&&(ZW===void 0||!A3.test(ZW)))S(D(k.value,W.length,"WOML_WHATSAPP_LANGUAGE_INVALID","WhatsApp template language must be a literal such as en, en_US, or pt_BR."));if(p==="parameters"&&f(k.value))if(k.value.type!=="ArrayExpression")S(D(k.value,W.length,"WOML_WHATSAPP_TEMPLATE_PARAMETERS_INVALID","WhatsApp template parameters must be a direct array."));else{let MW=k.value.elements??[];if(MW.length>32||MW.some((GW)=>f(GW)&&(EW(GW)?.length??0)>1024))S(D(k.value,W.length,"WOML_WHATSAPP_TEMPLATE_PARAMETERS_INVALID","WhatsApp templates accept at most 32 parameters of at most 1024 characters each."))}}for(let k of["name","language","parameters"])if(!b.has(k))S(D(H.value,W.length,"WOML_WHATSAPP_TEMPLATE_PROPERTY_REQUIRED",`WhatsApp template requires the "${k}" property.`))}}for(let H of["accessToken","phoneNumberId","conversationId","template"])if(!I.has(H))S(D(B,W.length,"WOML_WHATSAPP_SEND_PROPERTY_REQUIRED",`services.whatsapp.send() requires the "${H}" property.`));let _=w[1];if(f(_))if(_.type!=="ObjectExpression")S(D(_,W.length,"WOML_WHATSAPP_SEND_OPTIONS_INVALID","WhatsApp send operation options must be an object containing an optional stable name."));else{let H=new Set;for(let q of _.properties??[]){if(!f(q)||q.type!=="Property"||q.computed===!0||q.kind!=="init"){S(D(f(q)?q:_,W.length,"WOML_WHATSAPP_SEND_OPTIONS_INVALID","WhatsApp send options do not support spreads, computed keys, getters, or setters."));continue}let j=f(q.key)?q.key.type==="Identifier"?q.key.name:EW(q.key):void 0;if(j!=="name"){S(D(q,W.length,"WOML_WHATSAPP_SEND_OPTION_UNKNOWN",`Unknown WhatsApp send option "${j??""}".`,"WhatsApp Send v1 accepts only the stable name option."));continue}if(H.has(j))S(D(q,W.length,"WOML_WHATSAPP_SEND_OPTION_DUPLICATE",'WhatsApp send option "name" is declared more than once.'));H.add(j);let b=EW(q.value);if(f(q.value)&&q.value.type==="Literal"&&(b===void 0||b.length>128||!K8.test(b)))S(D(q.value,W.length,"WOML_WHATSAPP_SEND_NAME_INVALID","A literal WhatsApp send name must use lowercase operation-name syntax.","Example: send-template"))}}}}if(N.type==="Identifier"&&N.name==="require")S(D(R,W.length,"WOML_SCRIPT_MODULE_REQUIRE_UNSUPPORTED","Runtime module loading is unavailable in the current WOML script profile.","Use the future WOML module system when it becomes available."));if(N.type==="MemberExpression"&&S0(N)?.name==="Bun"&&W3.has(UL(N)??""))S(D(R,W.length,"WOML_SCRIPT_RAW_NETWORK_UNSUPPORTED","Raw Bun networking is unavailable in the tracked WOML script profile.","Use native fetch() or a managed services operation."))}if((R.type==="CallExpression"||R.type==="NewExpression")&&f(R.callee)&&R.callee.type==="Identifier"&&R.callee.name==="WebSocket")S(D(R,W.length,"WOML_SCRIPT_RAW_NETWORK_UNSUPPORTED","WebSocket networking is unavailable in the tracked WOML script profile.","Use native fetch() or a managed services operation."));for(let N of w4(R))if(N.name!==void 0&&(eK.has(N.name)||(O==="reusable-step"||O==="notification-provider")&&(N.name==="props"||O==="notification-provider"&&N.name==="notification")))S(D(N,W.length,"WOML_SCRIPT_BINDING_SHADOWED",`The reserved WOML binding "${N.name}" cannot be redeclared or shadowed.`,`Rename this local binding; WOML provides ${N.name} at runtime.`));if(R.type==="MemberExpression"&&S0(R)?.name==="services"){if(R.computed===!0)S(D(R,W.length,"WOML_SCRIPT_SERVICE_ACCESS_DYNAMIC","Computed service access is not executable in Script Bindings v1.","Use static service and operation names such as services.http.request."));else if(R.optional===!0)S(D(R,W.length,"WOML_SCRIPT_SERVICE_ACCESS_UNSUPPORTED","Optional access is not supported for the services binding.","Use a static service operation such as services.http.request."));else if(fO(R,K))S(D(R,W.length,"WOML_SCRIPT_SERVICE_WRITE_UNSUPPORTED","The services binding is read-only.","Call a service operation; do not replace or delete service members."))}if(R.type==="MemberExpression"&&S0(R)?.name==="lifecycle"&&fO(R,K))S(D(R,W.length,"WOML_LIFECYCLE_BINDING_READ_ONLY","The lifecycle binding is read-only.","Read lifecycle event data without replacing or deleting it."));if((O==="reusable-step"||O==="notification-provider")&&R.type==="MemberExpression"&&(S0(R)?.name==="props"||O==="notification-provider"&&S0(R)?.name==="notification")&&fO(R,K))S(D(R,W.length,S0(R)?.name==="props"?"WOML_REUSABLE_PROPS_READ_ONLY":"WOML_PROVIDER_NOTIFICATION_READ_ONLY",S0(R)?.name==="props"?"The reusable props binding is immutable.":"The provider notification binding is immutable.","Read provider bindings without replacing, deleting, or updating them."));if(R.type==="Identifier"&&R.name!==void 0&&!G3(R,K)){if(R.name==="lifecycle"){if(O!=="lifecycle")S(D(R,W.length,"WOML_LIFECYCLE_BINDING_UNAVAILABLE","The lifecycle binding is available only inside <lifecycle> scripts.","Use context inside a normal workflow step, or move this observer into <lifecycle>."));else if(fO(R,K))S(D(R,W.length,"WOML_LIFECYCLE_BINDING_READ_ONLY","The lifecycle binding is read-only."))}else if(R.name==="props"&&(O==="reusable-step"||O==="notification-provider")){if(fO(R,K))S(D(R,W.length,"WOML_REUSABLE_PROPS_READ_ONLY","The reusable props binding is immutable."))}else if(R.name==="notification"&&O==="notification-provider"){if(fO(R,K))S(D(R,W.length,"WOML_PROVIDER_NOTIFICATION_READ_ONLY","The provider notification binding is immutable."))}else if(R.name==="context"&&O==="notification-provider")S(D(R,W.length,"WOML_PROVIDER_CONTEXT_UNAVAILABLE","Notification provider scripts cannot access workflow context directly.","Pass required business values through declared props."));else if(R.name==="secrets"){if(O==="reusable-step"||O==="notification-provider")S(D(R,W.length,"WOML_REUSABLE_SECRET_ACCESS_FORBIDDEN","Reusable definition scripts cannot access secrets directly.","Declare a secret prop and pass one exact {{secrets.NAME}} reference at the invocation."));if(K?.type==="MemberExpression"&&K.object===R)if(fO(K,T))S(D(K,W.length,"WOML_SCRIPT_SECRET_WRITE_UNSUPPORTED","The secrets binding is read-only.","Read the required value with secrets.SECRET_NAME; do not replace or delete it."));else if(K.optional===!0)S(D(K,W.length,"WOML_SCRIPT_SECRET_ACCESS_UNSUPPORTED","Optional access is not supported for the required secrets binding.","Use the exact form secrets.SECRET_NAME."));else if(K.computed===!0)S(D(K,W.length,"WOML_SCRIPT_SECRET_ACCESS_DYNAMIC","Computed secret access is not executable in Script Bindings v1.","Use the exact literal property form secrets.SECRET_NAME."));else{let N=UL(K);if(N===void 0||!TO(N))S(D(f(K.property)?K.property:K,W.length,"WOML_SCRIPT_SECRET_NAME_INVALID",`Invalid script secret name "${N??""}".`,"Secret names must start with A-Z and contain only A-Z, 0-9, or underscore."));else A.add(N)}else S(D(R,W.length,"WOML_SCRIPT_SECRET_ACCESS_UNSUPPORTED","The secrets binding cannot be enumerated, aliased, returned, or passed as a whole object.","Access only the exact value needed with secrets.SECRET_NAME."))}else if(R.name==="services")if(K?.type==="MemberExpression"&&K.object===R)if(K.optional===!0)S(D(K,W.length,"WOML_SCRIPT_SERVICE_ACCESS_UNSUPPORTED","Optional access is not supported for the services binding.","Use a static service name such as services.http."));else if(K.computed===!0)S(D(K,W.length,"WOML_SCRIPT_SERVICE_ACCESS_DYNAMIC","Computed service access is not executable in Script Bindings v1.","Use a static service name such as services.http."));else{X=!0;let N=UL(K);if(N!==void 0&&!Z.has(N))Z.set(N,{name:N,...T8(K,W.length)})}else S(D(R,W.length,"WOML_SCRIPT_SERVICE_ACCESS_UNSUPPORTED","The services binding cannot be enumerated, aliased, returned, or passed as a whole object.","Call a static service namespace such as services.http."));else if(R.name==="fetch")if(fO(R,K))S(D(R,W.length,"WOML_SCRIPT_FETCH_WRITE_UNSUPPORTED","The tracked native fetch binding cannot be replaced or deleted.","Call fetch() directly without modifying the runtime binding."));else G=!0;else if((R.name==="globalThis"||R.name==="self")&&K?.type==="MemberExpression"&&K.object===R&&UL(K)==="fetch")if(fO(K,T))S(D(K,W.length,"WOML_SCRIPT_FETCH_WRITE_UNSUPPORTED","The tracked native fetch binding cannot be replaced or deleted.","Call fetch() directly without modifying the runtime binding."));else G=!0}for(let N of Q3(R))U(N,R,K)};for(let R of J.body??[])if(f(R))U(R);let V=[...A].sort();if(V.length>64)Q=D(J,W.length,"WOML_SCRIPT_SECRET_LIMIT_EXCEEDED","One script may reference at most 64 distinct secrets.","Split the operation into smaller steps with explicit secret dependencies.");return{requiredSecrets:V,requiredServices:[...Z.keys()].sort(),serviceReferences:[...Z.values()].sort((R,K)=>R.name.localeCompare(K.name)),usesServices:X,usesNativeFetch:G,...Q===void 0?{}:{issue:Q}}}function F8(W,O={}){return zL(W,"step",O)}function VL(W,O={}){return zL(W,"lifecycle",O)}function E8(W){return zL(W,"reusable-step")}function q8(W){return zL(W,"notification-provider")}var U3=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",z3="[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]["+U3+"]*",V3=new RegExp("^"+z3+"$");function HL(W,O){let M=[],L=O.exec(W);while(L){let $=[];$.startIndex=O.lastIndex-L[0].length;let Y=L.length;for(let J=0;J<Y;J++)$.push(L[J]);M.push($),L=O.exec(W)}return M}var B8=function(W){let O=V3.exec(W);return!(O===null||typeof O>"u")};function C4(W){return typeof W<"u"}var p1=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],KL=["__proto__","constructor","prototype"];var H3={allowBooleanAttributes:!1,unpairedTags:[]};function TL(W,O){O=Object.assign({},H3,O);let M=[],L=!1,$=!1;if(W[0]==="\uFEFF")W=W.substr(1);for(let Y=0;Y<W.length;Y++)if(W[Y]==="<"&&W[Y+1]==="?"){if(Y+=2,Y=P4(W,Y),Y.err)return Y}else if(W[Y]==="<"){let J=Y;if(Y++,W[Y]==="!"){Y=_4(W,Y);continue}else{let A=!1;if(W[Y]==="/")A=!0,Y++;let Z="";for(;Y<W.length&&W[Y]!==">"&&W[Y]!==" "&&W[Y]!=="\t"&&W[Y]!==`
25
- `&&W[Y]!=="\r";Y++)Z+=W[Y];if(Z=Z.trim(),Z[Z.length-1]==="/")Z=Z.substring(0,Z.length-1),Y--;if(!C3(Z)){let Q;if(Z.trim().length===0)Q="Invalid space after '<'.";else Q="Tag '"+Z+"' is an invalid name.";return UW("InvalidTag",Q,yW(W,Y))}let X=F3(W,Y);if(X===!1)return UW("InvalidAttr","Attributes for '"+Z+"' have open quote.",yW(W,Y));let G=X.value;if(Y=X.index,G[G.length-1]==="/"){let Q=Y-G.length;G=G.substring(0,G.length-1);let S=j4(G,O);if(S===!0)L=!0;else return UW(S.err.code,S.err.msg,yW(W,Q+S.err.line))}else if(A)if(!X.tagClosed)return UW("InvalidTag","Closing tag '"+Z+"' doesn't have proper closing.",yW(W,Y));else if(G.trim().length>0)return UW("InvalidTag","Closing tag '"+Z+"' can't have attributes or invalid starting.",yW(W,J));else if(M.length===0)return UW("InvalidTag","Closing tag '"+Z+"' has not been opened.",yW(W,J));else{let Q=M.pop();if(Z!==Q.tagName){let S=yW(W,Q.tagStartPos);return UW("InvalidTag","Expected closing tag '"+Q.tagName+"' (opened in line "+S.line+", col "+S.col+") instead of closing tag '"+Z+"'.",yW(W,J))}if(M.length==0)$=!0}else{let Q=j4(G,O);if(Q!==!0)return UW(Q.err.code,Q.err.msg,yW(W,Y-G.length+Q.err.line));if($===!0)return UW("InvalidXml","Multiple possible root nodes found.",yW(W,Y));else if(O.unpairedTags.indexOf(Z)!==-1);else M.push({tagName:Z,tagStartPos:J});L=!0}for(Y++;Y<W.length;Y++)if(W[Y]==="<")if(W[Y+1]==="!"){Y++,Y=_4(W,Y);continue}else if(W[Y+1]==="?"){if(Y=P4(W,++Y),Y.err)return Y}else break;else if(W[Y]==="&"){let Q=B3(W,Y);if(Q==-1)return UW("InvalidChar","char '&' is not expected.",yW(W,Y));Y=Q}else if($===!0&&!N4(W[Y]))return UW("InvalidXml","Extra text at the end",yW(W,Y));if(W[Y]==="<")Y--}}else{if(N4(W[Y]))continue;return UW("InvalidChar","char '"+W[Y]+"' is not expected.",yW(W,Y))}if(!L)return UW("InvalidXml","Start tag expected.",1);else if(M.length==1)return UW("InvalidTag","Unclosed tag '"+M[0].tagName+"'.",yW(W,M[0].tagStartPos));else if(M.length>0)return UW("InvalidXml","Invalid '"+JSON.stringify(M.map((Y)=>Y.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1});return!0}function N4(W){return W===" "||W==="\t"||W===`
26
- `||W==="\r"}function P4(W,O){let M=O;for(;O<W.length;O++)if(W[O]=="?"||W[O]==" "){let L=W.substr(M,O-M);if(O>5&&L==="xml")return UW("InvalidXml","XML declaration allowed only at the start of the document.",yW(W,O));else if(W[O]=="?"&&W[O+1]==">"){O++;break}else continue}return O}function _4(W,O){if(W.length>O+5&&W[O+1]==="-"&&W[O+2]==="-"){for(O+=3;O<W.length;O++)if(W[O]==="-"&&W[O+1]==="-"&&W[O+2]===">"){O+=2;break}}else if(W.length>O+8&&W[O+1]==="D"&&W[O+2]==="O"&&W[O+3]==="C"&&W[O+4]==="T"&&W[O+5]==="Y"&&W[O+6]==="P"&&W[O+7]==="E"){let M=1;for(O+=8;O<W.length;O++)if(W[O]==="<")M++;else if(W[O]===">"){if(M--,M===0)break}}else if(W.length>O+9&&W[O+1]==="["&&W[O+2]==="C"&&W[O+3]==="D"&&W[O+4]==="A"&&W[O+5]==="T"&&W[O+6]==="A"&&W[O+7]==="["){for(O+=8;O<W.length;O++)if(W[O]==="]"&&W[O+1]==="]"&&W[O+2]===">"){O+=2;break}}return O}var K3='"',T3="'";function F3(W,O){let M="",L="",$=!1;for(;O<W.length;O++){if(W[O]===K3||W[O]===T3)if(L==="")L=W[O];else if(L!==W[O]);else L="";else if(W[O]===">"){if(L===""){$=!0;break}}M+=W[O]}if(L!=="")return!1;return{value:M,index:O,tagClosed:$}}var E3=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function j4(W,O){let M=HL(W,E3),L={};for(let $=0;$<M.length;$++){if(M[$][1].length===0)return UW("InvalidAttr","Attribute '"+M[$][2]+"' has no space in starting.",m1(M[$]));else if(M[$][3]!==void 0&&M[$][4]===void 0)return UW("InvalidAttr","Attribute '"+M[$][2]+"' is without value.",m1(M[$]));else if(M[$][3]===void 0&&!O.allowBooleanAttributes)return UW("InvalidAttr","boolean attribute '"+M[$][2]+"' is not allowed.",m1(M[$]));let Y=M[$][2];if(!w3(Y))return UW("InvalidAttr","Attribute '"+Y+"' is an invalid name.",m1(M[$]));if(!Object.prototype.hasOwnProperty.call(L,Y))L[Y]=1;else return UW("InvalidAttr","Attribute '"+Y+"' is repeated.",m1(M[$]))}return!0}function q3(W,O){let M=/\d/;if(W[O]==="x")O++,M=/[\da-fA-F]/;for(;O<W.length;O++){if(W[O]===";")return O;if(!W[O].match(M))break}return-1}function B3(W,O){if(O++,W[O]===";")return-1;if(W[O]==="#")return O++,q3(W,O);let M=0;for(;O<W.length;O++,M++){if(W[O].match(/\w/)&&M<20)continue;if(W[O]===";")break;return-1}return O}function UW(W,O,M){return{err:{code:W,msg:O,line:M.line||M,col:M.col}}}function w3(W){return B8(W)}function C3(W){return B8(W)}function yW(W,O){let M=W.substring(0,O).split(/\r?\n/);return{line:M.length,col:M[M.length-1].length+1}}function m1(W){return W.startIndex+W[1].length}var w8={cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",euro:"\u20AC",dollar:"$",fnof:"\u0192",inr:"\u20B9",af:"\u060B",birr:"\u1265\u122D",peso:"\u20B1",rub:"\u20BD",won:"\u20A9",yuan:"\xA5",cedil:"\xB8"};var d1={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},C8={nbsp:"\xA0",copy:"\xA9",reg:"\xAE",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xAB",raquo:"\xBB",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",bull:"\u2022",para:"\xB6",sect:"\xA7",deg:"\xB0",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE"};var h0=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),N3=new Set("!?\\\\/[]$%{}^&*()<>|+");function I4(W){if(W[0]==="#")throw Error(`[EntityReplacer] Invalid character '#' in entity name: "${W}"`);for(let O of W)if(N3.has(O))throw Error(`[EntityReplacer] Invalid character '${O}' in entity name: "${W}"`);return W}function c1(...W){let O=Object.create(null);for(let M of W){if(!M)continue;for(let L of Object.keys(M)){let $=M[L];if(typeof $==="string")O[L]=$;else if($&&typeof $==="object"&&$.val!==void 0){let Y=$.val;if(typeof Y==="string")O[L]=Y}}}return O}var R0="external",FL="base",N8="all";function P3(W){if(!W||W===R0)return new Set([R0]);if(W===N8)return new Set([N8]);if(W===FL)return new Set([FL]);if(Array.isArray(W))return new Set(W);return new Set([R0])}var lW=Object.freeze({allow:0,leave:1,remove:2,throw:3}),_3=new Set([9,10,13]);function j3(W){if(!W)return{xmlVersion:1,onLevel:lW.allow,nullLevel:lW.remove};let O=W.xmlVersion===1.1?1.1:1,M=lW[W.onNCR]??lW.allow,L=lW[W.nullNCR]??lW.remove,$=Math.max(L,lW.remove);return{xmlVersion:O,onLevel:M,nullLevel:$}}class i1{constructor(W={}){this._limit=W.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof W.postCheck==="function"?W.postCheck:(M)=>M,this._limitTiers=P3(this._limit.applyLimitsTo??R0),this._numericAllowed=W.numericAllowed??!0,this._baseMap=c1(d1,W.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(W.remove&&Array.isArray(W.remove)?W.remove:[]),this._leaveSet=new Set(W.leave&&Array.isArray(W.leave)?W.leave:[]);let O=j3(W.ncr);this._ncrXmlVersion=O.xmlVersion,this._ncrOnLevel=O.onLevel,this._ncrNullLevel=O.nullLevel,this._onExternalEntity=typeof W.onExternalEntity==="function"?W.onExternalEntity:null,this._onInputEntity=typeof W.onInputEntity==="function"?W.onInputEntity:null}_applyRegistrationHook(W,O,M,L){if(!W)return!0;let $=W(O,M);if($===h0.BLOCK)return!1;if($===h0.THROW)throw Error(`[EntityDecoder] Registration of ${L} entity "&${O};" was rejected by hook`);return!0}setExternalEntities(W){if(W)for(let L of Object.keys(W))I4(L);if(!this._onExternalEntity){this._externalMap=c1(W);return}let O=c1(W),M=Object.create(null);for(let[L,$]of Object.entries(O))if(this._applyRegistrationHook(this._onExternalEntity,L,$,"external"))M[L]=$;this._externalMap=M}addExternalEntity(W,O){if(I4(W),typeof O==="string"&&O.indexOf("&")===-1){if(this._applyRegistrationHook(this._onExternalEntity,W,O,"external"))this._externalMap[W]=O}}addInputEntities(W){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity){this._inputMap=c1(W);return}let O=c1(W),M=Object.create(null);for(let[L,$]of Object.entries(O))if(this._applyRegistrationHook(this._onInputEntity,L,$,"input"))M[L]=$;this._inputMap=M}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(W){this._ncrXmlVersion=W===1.1?1.1:1}decode(W){if(typeof W!=="string"||W.length===0)return W;if(W.indexOf("&")===-1)return W;let O=W,M=[],L=W.length,$=0,Y=0,J=this._maxTotalExpansions>0,A=this._maxExpandedLength>0,Z=J||A;while(Y<L){if(W.charCodeAt(Y)!==38){Y++;continue}let G=Y+1;while(G<L&&W.charCodeAt(G)!==59&&G-Y<=32)G++;if(G>=L||W.charCodeAt(G)!==59){Y++;continue}let Q=W.slice(Y+1,G);if(Q.length===0){Y++;continue}let S,U;if(this._removeSet.has(Q)){if(S="",U===void 0)U=R0}else if(this._leaveSet.has(Q)){Y++;continue}else if(Q.charCodeAt(0)===35){let V=this._resolveNCR(Q);if(V===void 0){Y++;continue}S=V,U=FL}else{let V=this._resolveName(Q);S=V?.value,U=V?.tier}if(S===void 0){Y++;continue}if(Y>$)M.push(W.slice($,Y));if(M.push(S),$=G+1,Y=$,Z&&this._tierCounts(U)){if(J){if(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions)throw Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`)}if(A){let V=S.length-(Q.length+2);if(V>0){if(this._expandedLength+=V,this._expandedLength>this._maxExpandedLength)throw Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}}if($<L)M.push(W.slice($));let X=M.length===0?W:M.join("");return this._postCheck(X,O)}_tierCounts(W){if(this._limitTiers.has(N8))return!0;return this._limitTiers.has(W)}_resolveName(W){if(W in this._inputMap)return{value:this._inputMap[W],tier:R0};if(W in this._externalMap)return{value:this._externalMap[W],tier:R0};if(W in this._baseMap)return{value:this._baseMap[W],tier:FL};return}_classifyNCR(W){if(W===0)return this._ncrNullLevel;if(W>=55296&&W<=57343)return lW.remove;if(this._ncrXmlVersion===1){if(W>=1&&W<=31&&!_3.has(W))return lW.remove}return-1}_applyNCRAction(W,O,M){switch(W){case lW.allow:return String.fromCodePoint(M);case lW.remove:return"";case lW.leave:return;case lW.throw:throw Error(`[EntityDecoder] Prohibited numeric character reference &${O}; (U+${M.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(M)}}_resolveNCR(W){let O=W.charCodeAt(1),M;if(O===120||O===88)M=parseInt(W.slice(2),16);else M=parseInt(W.slice(1),10);if(Number.isNaN(M)||M<0||M>1114111)return;let L=this._classifyNCR(M);if(!this._numericAllowed&&L<lW.remove)return;let $=L===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,L);return this._applyNCRAction($,W,M)}}var y4=(W)=>{if(p1.includes(W))return"__"+W;return W},I3={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(W,O){return O},attributeValueProcessor:function(W,O){return O},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(W,O,M){return W},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:y4};function y3(W,O){if(typeof W!=="string")return;let M=W.toLowerCase();if(p1.some((L)=>M===L.toLowerCase()))throw Error(`[SECURITY] Invalid ${O}: "${W}" is a reserved JavaScript keyword that could cause prototype pollution`);if(KL.some((L)=>M===L.toLowerCase()))throw Error(`[SECURITY] Invalid ${O}: "${W}" is a reserved JavaScript keyword that could cause prototype pollution`)}function D4(W,O){if(typeof W==="boolean")return{enabled:W,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1000,allowedTags:null,tagFilter:null,appliesTo:"all"};if(typeof W==="object"&&W!==null)return{enabled:W.enabled!==!1,maxEntitySize:Math.max(1,W.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,W.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,W.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,W.maxExpandedLength??1e5),maxEntityCount:Math.max(1,W.maxEntityCount??1000),allowedTags:W.allowedTags??null,tagFilter:W.tagFilter??null,appliesTo:W.appliesTo??"all"};return D4(!0)}var k4=function(W){let O=Object.assign({},I3,W),M=[{value:O.attributeNamePrefix,name:"attributeNamePrefix"},{value:O.attributesGroupName,name:"attributesGroupName"},{value:O.textNodeName,name:"textNodeName"},{value:O.cdataPropName,name:"cdataPropName"},{value:O.commentPropName,name:"commentPropName"}];for(let{value:L,name:$}of M)if(L)y3(L,$);if(O.onDangerousProperty===null)O.onDangerousProperty=y4;if(O.processEntities=D4(O.processEntities,O.htmlEntities),O.unpairedTagsSet=new Set(O.unpairedTags),O.stopNodes&&Array.isArray(O.stopNodes))O.stopNodes=O.stopNodes.map((L)=>{if(typeof L==="string"&&L.startsWith("*."))return".."+L.substring(2);return L});return O};var EL;if(typeof Symbol!=="function")EL="@@xmlMetadata";else EL=Symbol("XML Node Metadata");class iW{constructor(W){this.tagname=W,this.child=[],this[":@"]=Object.create(null)}add(W,O){if(W==="__proto__")W="#__proto__";this.child.push({[W]:O})}addChild(W,O){if(W.tagname==="__proto__")W.tagname="#__proto__";if(W[":@"]&&Object.keys(W[":@"]).length>0)this.child.push({[W.tagname]:W.child,[":@"]:W[":@"]});else this.child.push({[W.tagname]:W.child});if(O!==void 0)this.child[this.child.length-1][EL]={startIndex:O}}static getMetaDataSymbol(){return EL}}var b4=":A-Za-z_"+"\xC0-\xD6\xD8-\xF6\xF8-\u02FF"+"\u0370-\u037D"+"\u037F-\u0486\u0488-\u1FFF"+"\u200C-\u200D"+"\u2070-\u218F"+"\u2C00-\u2FEF"+"\u3001-\uD7FF"+"\uF900-\uFDCF"+"\uFDF0-\uFFFD",D3=b4+"\\-\\.\\d"+"\xB7"+"\u0300-\u036F"+"\u203F-\u2040",f4=":A-Za-z_"+"\xC0-\u02FF"+"\u0370-\u037D"+"\u037F-\u0486\u0488-\u1FFF"+"\u200C-\u200D"+"\u2070-\u218F"+"\u2C00-\u2FEF"+"\u3001-\uD7FF"+"\uF900-\uFDCF"+"\uFDF0-\uFFFD"+"\uD800\uDC00-\uDB7F\uDFFF",k3=f4+"\\-\\.\\d"+"\xB7"+"\u0300-\u036F"+"\u0487"+"\u203F-\u2040",P8=(W,O,M="")=>{let L=W.replace(":",""),$=O.replace(":",""),Y=`[${L}][${$}]*`;return{name:new RegExp(`^[${W}][${O}]*$`,M),ncName:new RegExp(`^${Y}$`,M),qName:new RegExp(`^${Y}(?::${Y})?$`,M),nmToken:new RegExp(`^[${O}]+$`,M),nmTokens:new RegExp(`^[${O}]+(?:\\s+[${O}]+)*$`,M)}},b3=P8(b4,D3),f3=P8(f4,k3,"u");var v3=":A-Za-z_\\-\\.\\d",x3=P8(":A-Za-z_",v3),g3=(W="1.0",O=!1)=>{if(O)return x3;return W==="1.1"?f3:b3};var _8=(W,{xmlVersion:O="1.0",asciiOnly:M=!1}={})=>g3(O,M).qName.test(W);class qL{constructor(W,O){this.suppressValidationErr=!W,this.options=W,this.xmlVersion=O||1}setXmlVersion(W=1){this.xmlVersion=W}readDocType(W,O){let M=Object.create(null),L=0;if(W[O+3]==="O"&&W[O+4]==="C"&&W[O+5]==="T"&&W[O+6]==="Y"&&W[O+7]==="P"&&W[O+8]==="E"){O=O+9;let $=1,Y=!1,J=!1,A="";for(;O<W.length;O++)if(W[O]==="<"&&!J){if(Y&&U0(W,"!ENTITY",O)){O+=7;let Z,X;if([Z,X,O]=this.readEntityExp(W,O+1,this.suppressValidationErr),X.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&L>=this.options.maxEntityCount)throw Error(`Entity count (${L+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);M[Z]=X,L++}}else if(Y&&U0(W,"!ELEMENT",O)){O+=8;let{index:Z}=this.readElementExp(W,O+1);O=Z}else if(Y&&U0(W,"!ATTLIST",O))O+=8;else if(Y&&U0(W,"!NOTATION",O)){O+=9;let{index:Z}=this.readNotationExp(W,O+1,this.suppressValidationErr);O=Z}else if(U0(W,"!--",O))J=!0;else throw Error("Invalid DOCTYPE");$++,A=""}else if(W[O]===">"){if(J){if(W[O-1]==="-"&&W[O-2]==="-")J=!1,$--}else $--;if($===0)break}else if(W[O]==="[")Y=!0;else A+=W[O];if($!==0)throw Error("Unclosed DOCTYPE")}else throw Error("Invalid Tag instead of DOCTYPE");return{entities:M,i:O}}readEntityExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O])&&W[O]!=='"'&&W[O]!=="'")O++;let L=W.substring(M,O);if(s1(L,{xmlVersion:this.xmlVersion}),O=pW(W,O),!this.suppressValidationErr){if(W.substring(O,O+6).toUpperCase()==="SYSTEM")throw Error("External entities are not supported");else if(W[O]==="%")throw Error("Parameter entities are not supported")}let $="";if([O,$]=this.readIdentifierVal(W,O,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&$.length>this.options.maxEntitySize)throw Error(`Entity "${L}" size (${$.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return O--,[L,$,O]}readNotationExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let L=W.substring(M,O);!this.suppressValidationErr&&s1(L,{xmlVersion:this.xmlVersion}),O=pW(W,O);let $=W.substring(O,O+6).toUpperCase();if(!this.suppressValidationErr&&$!=="SYSTEM"&&$!=="PUBLIC")throw Error(`Expected SYSTEM or PUBLIC, found "${$}"`);O+=$.length,O=pW(W,O);let Y=null,J=null;if($==="PUBLIC"){if([O,Y]=this.readIdentifierVal(W,O,"publicIdentifier"),O=pW(W,O),W[O]==='"'||W[O]==="'")[O,J]=this.readIdentifierVal(W,O,"systemIdentifier")}else if($==="SYSTEM"){if([O,J]=this.readIdentifierVal(W,O,"systemIdentifier"),!this.suppressValidationErr&&!J)throw Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:L,publicIdentifier:Y,systemIdentifier:J,index:--O}}readIdentifierVal(W,O,M){let L="",$=W[O];if($!=='"'&&$!=="'")throw Error(`Expected quoted string, found "${$}"`);O++;let Y=O;while(O<W.length&&W[O]!==$)O++;if(L=W.substring(Y,O),W[O]!==$)throw Error(`Unterminated ${M} value`);return O++,[O,L]}readElementExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let L=W.substring(M,O);if(!this.suppressValidationErr&&!_8(L,{xmlVersion:this.xmlVersion}))throw Error(`Invalid element name: "${L}"`);O=pW(W,O);let $="";if(W[O]==="E"&&U0(W,"MPTY",O))O+=4;else if(W[O]==="A"&&U0(W,"NY",O))O+=2;else if(W[O]==="("){O++;let Y=O;while(O<W.length&&W[O]!==")")O++;if($=W.substring(Y,O),W[O]!==")")throw Error("Unterminated content model")}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${W[O]}"`);return{elementName:L,contentModel:$.trim(),index:O}}readAttlistExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let L=W.substring(M,O);s1(L,{xmlVersion:this.xmlVersion}),O=pW(W,O),M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let $=W.substring(M,O);if(!s1($,{xmlVersion:this.xmlVersion}))throw Error(`Invalid attribute name: "${$}"`);O=pW(W,O);let Y="";if(W.substring(O,O+8).toUpperCase()==="NOTATION"){if(Y="NOTATION",O+=8,O=pW(W,O),W[O]!=="(")throw Error(`Expected '(', found "${W[O]}"`);O++;let A=[];while(O<W.length&&W[O]!==")"){let Z=O;while(O<W.length&&W[O]!=="|"&&W[O]!==")")O++;let X=W.substring(Z,O);if(X=X.trim(),!s1(X,{xmlVersion:this.xmlVersion}))throw Error(`Invalid notation name: "${X}"`);if(A.push(X),W[O]==="|")O++,O=pW(W,O)}if(W[O]!==")")throw Error("Unterminated list of notations");O++,Y+=" ("+A.join("|")+")"}else{let A=O;while(O<W.length&&!/\s/.test(W[O]))O++;Y+=W.substring(A,O);let Z=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!Z.includes(Y.toUpperCase()))throw Error(`Invalid attribute type: "${Y}"`)}O=pW(W,O);let J="";if(W.substring(O,O+8).toUpperCase()==="#REQUIRED")J="#REQUIRED",O+=8;else if(W.substring(O,O+7).toUpperCase()==="#IMPLIED")J="#IMPLIED",O+=7;else[O,J]=this.readIdentifierVal(W,O,"ATTLIST");return{elementName:L,attributeName:$,attributeType:Y,defaultValue:J,index:O}}}var pW=(W,O)=>{while(O<W.length&&/\s/.test(W[O]))O++;return O};function U0(W,O,M){for(let L=0;L<O.length;L++)if(O[L]!==W[M+L+1])return!1;return!0}function s1(W,O){if(_8(W,{xmlVersion:O}))return W;else throw Error(`Invalid entity name ${W}`)}var h3=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],j8=255,BL=new Map;var n1=1632;var wL=new Uint8Array(63904).fill(255);for(let W of h3)for(let O=0;O<10;O++){let M=W+O;if(M<=65535)wL[M-1632]=O;else BL.set(M,O)}var v4=48,x4=57,g4=45,CL=new Set([8722,65293,65123]);function u3(W){if(typeof W!=="string")return W;let O=W.length;if(O===0)return W;let M=-1;for(let $=0;$<O;$++){let Y=W.charCodeAt($);if(Y>=v4&&Y<=x4||Y===g4)continue;if(Y<n1){if(CL.has(Y)){M=$;break}continue}if(Y>=55296&&Y<=56319){if($+1<O){let J=W.charCodeAt($+1);if(J>=56320&&J<=57343){let A=65536+(Y-55296<<10)+(J-56320);if(BL.has(A)){M=$;break}}}continue}if(wL[Y-n1]!==j8||CL.has(Y)){M=$;break}}if(M===-1)return W;let L=[];if(M>0)L.push(W.slice(0,M));for(let $=M;$<O;$++){let Y=W.charCodeAt($);if(Y>=v4&&Y<=x4||Y===g4){L.push(W[$]);continue}if(Y<n1){L.push(CL.has(Y)?"-":W[$]);continue}if(Y>=55296&&Y<=56319){if($+1<O){let A=W.charCodeAt($+1);if(A>=56320&&A<=57343){let Z=65536+(Y-55296<<10)+(A-56320),X=BL.get(Z);if(X!==void 0){L.push(String.fromCharCode(X+48)),$++;continue}}}L.push(W[$]);continue}if(CL.has(Y)){L.push("-");continue}let J=wL[Y-n1];L.push(J!==j8?String.fromCharCode(J+48):W[$])}return L.join("")}var h4=u3;var l3=/^[-+]?0x[a-fA-F0-9]+$/,p3=/^0b[01]+$/,m3=/^0o[0-7]+$/,d3=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,c3={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function y8(W,O={}){if(O=Object.assign({},c3,O),!W||typeof W!=="string")return W;let M=W.trim();if(M.length===0)return W;else if(O.skipLike!==void 0&&O.skipLike.test(M))return W;else if(M==="0")return 0;if(O.unicode){if(M=h4(M),M==="0")return 0}if(O.hex&&l3.test(M))return I8(M,16);else if(O.binary&&p3.test(M))return I8(M,2);else if(O.octal&&m3.test(M))return I8(M,8);else if(!isFinite(M))return r3(W,Number(M),O);else if(M.includes("e")||M.includes("E"))return s3(W,M,O);else{let L=d3.exec(M);if(L){let $=L[1]||"",Y=L[2],J=n3(L[3]),A=$?W[Y.length+1]===".":W[Y.length]===".";if(!O.leadingZeros&&(Y.length>1||Y.length===1&&!A))return W;else{let Z=Number(M),X=String(Z);if(Z===0)return Z;if(X.search(/[eE]/)!==-1)if(O.eNotation)return Z;else return W;else if(M.indexOf(".")!==-1)if(X==="0")return Z;else if(X===J)return Z;else if(X===`${$}${J}`)return Z;else return W;let G=Y?J:M;if(Y)return G===X||$+G===X?Z:W;else return G===X||G===$+X?Z:W}}else return W}}var i3=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function s3(W,O,M){if(!M.eNotation)return W;let L=O.match(i3);if(L){let $=L[1]||"",Y=L[3].indexOf("e")===-1?"E":"e",J=L[2],A=$?W[J.length+1]===Y:W[J.length]===Y;if(J.length>1&&A)return W;else if(J.length===1&&(L[3].startsWith(`.${Y}`)||L[3][0]===Y))return Number(O);else if(J.length>0)if(M.leadingZeros&&!A)return O=(L[1]||"")+L[3],Number(O);else return W;else return Number(O)}else return W}function n3(W){if(W&&W.indexOf(".")!==-1){let O=W.length;while(O>0&&W.charCodeAt(O-1)===48)O--;if(W=W.slice(0,O),W===".")W="0";else if(W[0]===".")W="0"+W;else if(W[W.length-1]===".")W=W.substring(0,W.length-1);return W}return W}function I8(W,O){let M=W.trim();if(O===2||O===8)W=M.substring(2);if(parseInt)return parseInt(W,O);else if(Number.parseInt)return Number.parseInt(W,O);else if(window&&window.parseInt)return window.parseInt(W,O);else throw Error("parseInt, Number.parseInt, window.parseInt are not supported")}function r3(W,O,M){let L=O===1/0;switch(M.infinity.toLowerCase()){case"null":return null;case"infinity":return O;case"string":return L?"Infinity":"-Infinity";case"original":default:return W}}function D8(W){if(typeof W==="function")return W;if(Array.isArray(W))return(O)=>{for(let M of W){if(typeof M==="string"&&O===M)return!0;if(M instanceof RegExp&&M.test(O))return!0}};return()=>!1}class u0{constructor(W,O={},M){this.pattern=W,this.separator=O.separator||".",this.segments=this._parse(W),this.data=M,this._hasDeepWildcard=this.segments.some((L)=>L.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some((L)=>L.attrName!==void 0),this._hasPositionSelector=this.segments.some((L)=>L.position!==void 0)}_parse(W){let O=[],M=0,L="";while(M<W.length)if(W[M]===this.separator)if(M+1<W.length&&W[M+1]===this.separator){if(L.trim())O.push(this._parseSegment(L.trim())),L="";O.push({type:"deep-wildcard"}),M+=2}else{if(L.trim())O.push(this._parseSegment(L.trim()));L="",M++}else L+=W[M],M++;if(L.trim())O.push(this._parseSegment(L.trim()));return O}_parseSegment(W){let O={type:"tag"},M=null,L=W,$=W.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if($){if(L=$[1]+$[3],$[2]){let X=$[2].slice(1,-1);if(X)M=X}}let Y=void 0,J=L;if(L.includes("::")){let X=L.indexOf("::");if(Y=L.substring(0,X).trim(),J=L.substring(X+2).trim(),!Y)throw Error(`Invalid namespace in pattern: ${W}`)}let A=void 0,Z=null;if(J.includes(":")){let X=J.lastIndexOf(":"),G=J.substring(0,X).trim(),Q=J.substring(X+1).trim();if(["first","last","odd","even"].includes(Q)||/^nth\(\d+\)$/.test(Q))A=G,Z=Q;else A=J}else A=J;if(!A)throw Error(`Invalid segment pattern: ${W}`);if(O.tag=A,Y)O.namespace=Y;if(M)if(M.includes("=")){let X=M.indexOf("=");O.attrName=M.substring(0,X).trim(),O.attrValue=M.substring(X+1).trim()}else O.attrName=M.trim();if(Z){let X=Z.match(/^nth\((\d+)\)$/);if(X)O.position="nth",O.positionValue=parseInt(X[1],10);else O.position=Z}return O}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class r1{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(W){if(this._sealed)throw TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(W.pattern))return this;if(this._patterns.add(W.pattern),W.hasDeepWildcard()){let $=W.segments[W.segments.length-1];if($&&$.type!=="deep-wildcard"&&$.tag!=="*"){let Y=$.tag;if(!this._deepByTerminalTag.has(Y))this._deepByTerminalTag.set(Y,[]);this._deepByTerminalTag.get(Y).push(W)}else this._deepWildcards.push(W);return this}let O=W.length,L=W.segments[W.segments.length-1]?.tag;if(!L||L==="*"){if(!this._wildcardByDepth.has(O))this._wildcardByDepth.set(O,[]);this._wildcardByDepth.get(O).push(W)}else{let $=`${O}:${L}`;if(!this._byDepthAndTag.has($))this._byDepthAndTag.set($,[]);this._byDepthAndTag.get($).push(W)}return this}addAll(W){for(let O of W)this.add(O);return this}has(W){return this._patterns.has(W.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(W){return this.findMatch(W)!==null}findMatch(W){let O=W.getDepth(),M=W.getCurrentTag(),L=`${O}:${M}`,$=this._byDepthAndTag.get(L);if($){for(let A=0;A<$.length;A++)if(W.matches($[A]))return $[A]}let Y=this._wildcardByDepth.get(O);if(Y){for(let A=0;A<Y.length;A++)if(W.matches(Y[A]))return Y[A]}let J=this._deepByTerminalTag.get(M);if(J){for(let A=0;A<J.length;A++)if(W.matches(J[A]))return J[A]}for(let A=0;A<this._deepWildcards.length;A++)if(W.matches(this._deepWildcards[A]))return this._deepWildcards[A];return null}}class u4{constructor(W){this._matcher=W}get separator(){return this._matcher.separator}getCurrentTag(){let W=this._matcher.path;return W.length>0?W[W.length-1].tag:void 0}getCurrentNamespace(){let W=this._matcher.path;return W.length>0?W[W.length-1].namespace:void 0}getAttrValue(W){let O=this._matcher.path;if(O.length===0)return;return O[O.length-1].values?.[W]}hasAttr(W){let O=this._matcher.path;if(O.length===0)return!1;let M=O[O.length-1];return M.values!==void 0&&W in M.values}getAnyParentAttr(W){return this._matcher.getAnyParentAttr(W)}hasAnyParentAttr(W){return this._matcher.hasAnyParentAttr(W)}getPosition(){let W=this._matcher.path;if(W.length===0)return-1;return W[W.length-1].position??0}getCounter(){let W=this._matcher.path;if(W.length===0)return-1;return W[W.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(W,O=!0){return this._matcher.toString(W,O)}toArray(){return this._matcher.path.map((W)=>W.tag)}matches(W){return this._matcher.matches(W)}matchesAny(W){return W.matchesAny(this._matcher)}}class a1{constructor(W={}){this.separator=W.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new u4(this),this._keptAttrs=[]}push(W,O=null,M=null,L=null){if(this._pathStringCache=null,this.path.length>0)this.path[this.path.length-1].values=void 0;let $=this.path.length,Y=this.siblingStacks[$];if(!Y)Y={counts:new Map,total:0},this.siblingStacks[$]=Y;let J=M?`${M}:${W}`:W,A=Y.counts.get(J)||0,Z=Y.total;Y.counts.set(J,A+1),Y.total++;let X={tag:W,position:Z,counter:A};if(M!==null&&M!==void 0)X.namespace=M;if(O!==null&&O!==void 0)X.values=O;this.path.push(X);let G=this.path.length,Q=L!==null?L.keep:null;if(Q!==null&&Q!==void 0&&Q.length>0&&O)for(let S=0;S<Q.length;S++){let U=Q[S];if(O[U]!==void 0)this._keptAttrs.push({depth:G,name:U,value:O[U]})}}pop(){if(this.path.length===0)return;this._pathStringCache=null;let W=this.path.pop();if(this.siblingStacks.length>this.path.length+1)this.siblingStacks.length=this.path.length+1;let O=this.path.length+1;while(this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=O)this._keptAttrs.pop();return W}updateCurrent(W){if(this.path.length>0){let O=this.path[this.path.length-1];if(W!==null&&W!==void 0)O.values=W}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(W){if(this.path.length===0)return;return this.path[this.path.length-1].values?.[W]}hasAttr(W){if(this.path.length===0)return!1;let O=this.path[this.path.length-1];return O.values!==void 0&&W in O.values}getAnyParentAttr(W){let O=this._keptAttrs;for(let M=O.length-1;M>=0;M--)if(O[M].name===W)return O[M].value;return}hasAnyParentAttr(W){let O=this._keptAttrs;for(let M=O.length-1;M>=0;M--)if(O[M].name===W)return!0;return!1}getPosition(){if(this.path.length===0)return-1;return this.path[this.path.length-1].position??0}getCounter(){if(this.path.length===0)return-1;return this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(W,O=!0){let M=W||this.separator;if(M===this.separator&&O===!0){if(this._pathStringCache!==null)return this._pathStringCache;let $=this.path.map((Y)=>Y.namespace?`${Y.namespace}:${Y.tag}`:Y.tag).join(M);return this._pathStringCache=$,$}return this.path.map(($)=>O&&$.namespace?`${$.namespace}:${$.tag}`:$.tag).join(M)}toArray(){return this.path.map((W)=>W.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(W){let O=W.segments;if(O.length===0)return!1;if(W.hasDeepWildcard())return this._matchWithDeepWildcard(O);return this._matchSimple(O)}_matchSimple(W){if(this.path.length!==W.length)return!1;for(let O=0;O<W.length;O++)if(!this._matchSegment(W[O],this.path[O],O===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(W){let O=this.path.length-1,M=W.length-1;while(M>=0&&O>=0){let L=W[M];if(L.type==="deep-wildcard"){if(M--,M<0)return!0;let $=W[M],Y=!1;for(let J=O;J>=0;J--)if(this._matchSegment($,this.path[J],J===this.path.length-1)){O=J-1,M--,Y=!0;break}if(!Y)return!1}else{if(!this._matchSegment(L,this.path[O],O===this.path.length-1))return!1;O--,M--}}return M<0}_matchSegment(W,O,M){if(W.tag!=="*"&&W.tag!==O.tag)return!1;if(W.namespace!==void 0){if(W.namespace!=="*"&&W.namespace!==O.namespace)return!1}if(W.attrName!==void 0){if(!M)return!1;if(!O.values||!(W.attrName in O.values))return!1;if(W.attrValue!==void 0){if(String(O.values[W.attrName])!==String(W.attrValue))return!1}}if(W.position!==void 0){if(!M)return!1;let L=O.counter??0;if(W.position==="first"&&L!==0)return!1;else if(W.position==="odd"&&L%2!==1)return!1;else if(W.position==="even"&&L%2!==0)return!1;else if(W.position==="nth"&&L!==W.positionValue)return!1}return!0}matchesAny(W){return W.matchesAny(this)}snapshot(){return{path:this.path.map((W)=>({...W})),siblingStacks:this.siblingStacks.map((W)=>W?{counts:new Map(W.counts),total:W.total}:W),keptAttrs:this._keptAttrs.map((W)=>({...W}))}}restore(W){this._pathStringCache=null,this.path=W.path.map((O)=>({...O})),this.siblingStacks=W.siblingStacks.map((O)=>O?{counts:new Map(O.counts),total:O.total}:O),this._keptAttrs=(W.keptAttrs||[]).map((O)=>({...O}))}readOnly(){return this._view}}var a3=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"</script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI \u2014 can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI \u2014 can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial \u2014 catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() \u2014 IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= \u2014 can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" \u2014 can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes \u2014 embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag \u2014 can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],l0=a3;var o3=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content \u2014 can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword \u2014 used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword \u2014 used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration \u2014 defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection \u2014 can redefine namespaces to confuse parsers",pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"<!-- comment injection \u2014 can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--> closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],p0=o3;var t3=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: \u2014 classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG \u2014 can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" \u2014 can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." \u2014 sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= \u2014 filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],k8=t3;var e3=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ \u2014 unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT \u2014 most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE \u2014 destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE \u2014 destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO \u2014 data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM \u2014 data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET \u2014 data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ \u2014 MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:`Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function \u2014 used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA \u2014 reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],o1=e3;var WT=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ \u2014 climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ \u2014 climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 \u2014 truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} \u2014 can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r \u2014 can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? \u2014 can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags \u2014 can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],b8=WT;var OT=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ \u2014 catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) \u2014 guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ \u2014 ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern \u2014 triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} \u2014 repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} \u2014 denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches \u2014 polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],f8=OT;var MT=[{id:"nosql-where-operator",description:"$where \u2014 executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where["'\\s]*:`,"i")},{id:"nosql-ne-operator",description:'$ne \u2014 "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne["'\\s]*:`,"i")},{id:"nosql-gt-operator",description:'$gt \u2014 "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?["'\\s]*:`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte \u2014 "less than" bypass variants',pattern:new RegExp(`\\$lte?["'\\s]*:`,"i")},{id:"nosql-regex-operator",description:"$regex \u2014 can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex["'\\s]*:`,"i")},{id:"nosql-or-operator",description:"$or \u2014 logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or["'\\s]*:\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and \u2014 logical AND operator injection",pattern:new RegExp(`\\$and["'\\s]*:\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor \u2014 logical NOR operator injection",pattern:new RegExp(`\\$nor["'\\s]*:\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists \u2014 can enumerate fields to determine schema",pattern:new RegExp(`\\$exists["'\\s]*:`,"i")},{id:"nosql-in-operator",description:"$in \u2014 matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in["'\\s]*:\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr \u2014 allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr["'\\s]*:`,"i")},{id:"nosql-function-operator",description:"$function \u2014 executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function["'\\s]*:`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator \u2014 custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator["'\\s]*:`,"i")},{id:"nosql-proto-pollution",description:"__proto__ \u2014 prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype \u2014 alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] \u2014 bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],v8=MT;var LT=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A \u2014 decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} \u2014 data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} \u2014 Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} \u2014 Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} \u2014 JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> \u2014 Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 \u2014 can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ \u2014 can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}],x8=LT;var $T=[{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],YT=[...o1,...$T],g8=YT;l0.label="HTML";p0.label="XML";k8.label="SVG";o1.label="SQL";g8.label="SQL-STRICT";b8.label="SHELL";f8.label="REDOS";v8.label="NOSQL";x8.label="LOG";var FN=Object.freeze({HTML:l0,XML:p0,SVG:k8,SQL:o1,"SQL-STRICT":g8,SHELL:b8,REDOS:f8,NOSQL:v8,LOG:x8});function JT(W){if(typeof W!=="string")throw TypeError(`is-unsafe: first argument must be a string, got ${typeof W}`)}function AT(W){if(W instanceof RegExp)return;if(Array.isArray(W)){if(W.length===0)throw TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(W[0])){for(let O of W)if(!Array.isArray(O)||O.length===0)throw TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}return}throw TypeError(`is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof W}`)}function ZT(W){if(W instanceof RegExp)return{lists:null,regex:W};if(Array.isArray(W[0]))return{lists:W,regex:null};return{lists:[W],regex:null}}function XT(W,O){let M=O.label??"CUSTOM";for(let L of O)if(L.pattern.test(W))return{context:M,id:L.id,description:L.description,pattern:L.pattern};return null}function l4(W,O){JT(W),AT(O);let{lists:M,regex:L}=ZT(O);if(L)return L.test(W);for(let $ of M)if(XT(W,$)!==null)return!0;return!1}function GT(W,O){if(!W)return{};let M=O.attributesGroupName?W[O.attributesGroupName]:W;if(!M)return{};let L={};for(let $ in M)if($.startsWith(O.attributeNamePrefix)){let Y=$.substring(O.attributeNamePrefix.length);L[Y]=M[$]}else L[$]=M[$];return L}function QT(W){if(!W||typeof W!=="string")return;let O=W.indexOf(":");if(O!==-1&&O>0){let M=W.substring(0,O);if(M!=="xmlns")return M}return}class NL{constructor(W,O){this.options=W,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=VT,this.parseTextData=ST,this.resolveNameSpace=RT,this.buildAttributesMap=zT,this.isItStopNode=FT,this.replaceEntitiesValue=KT,this.readStopNodeData=BT,this.saveTextToParentTag=TT,this.addChild=HT,this.ignoreAttributesFn=D8(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let M={...d1};if(this.options.entityDecoder)this.entityDecoder=this.options.entityDecoder;else{if(typeof this.options.htmlEntities==="object")M=this.options.htmlEntities;else if(this.options.htmlEntities===!0)M={...C8,...w8};this.entityDecoder=new i1({namedEntities:{...M,...O},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:($,Y)=>l4(Y,[l0,p0])?h0.BLOCK:h0.ALLOW})}this.matcher=new a1,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new r1;let L=this.options.stopNodes;if(L&&L.length>0){for(let $=0;$<L.length;$++){let Y=L[$];if(typeof Y==="string")this.stopNodeExpressionsSet.add(new u0(Y));else if(Y instanceof u0)this.stopNodeExpressionsSet.add(Y)}this.stopNodeExpressionsSet.seal()}}}function ST(W,O,M,L,$,Y,J){let A=this.options;if(W!==void 0){if(A.trimValues&&!L)W=W.trim();if(W.length>0){if(!J)W=this.replaceEntitiesValue(W,O,M);let Z=A.jPath?M.toString():M,X=A.tagValueProcessor(O,W,Z,$,Y);if(X===null||X===void 0)return W;else if(typeof X!==typeof W||X!==W)return X;else if(A.trimValues)return l8(W,A.parseTagValue,A.numberParseOptions);else if(W.trim()===W)return l8(W,A.parseTagValue,A.numberParseOptions);else return W}}}function RT(W){if(this.options.removeNSPrefix){let O=W.split(":"),M=W.charAt(0)==="/"?"/":"";if(O[0]==="xmlns")return"";if(O.length===2)W=M+O[1]}return W}var UT=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function zT(W,O,M,L=!1){let $=this.options;if(L===!0||$.ignoreAttributes!==!0&&typeof W==="string"){let Y=HL(W,UT),J=Y.length,A={},Z=Array(J),X=!1,G={};for(let U=0;U<J;U++){let V=this.resolveNameSpace(Y[U][1]),R=Y[U][4];if(V.length&&R!==void 0){let K=R;if($.trimValues)K=K.trim();K=this.replaceEntitiesValue(K,M,this.readonlyMatcher),Z[U]=K,G[V]=K,X=!0}}if(X&&typeof O==="object"&&O.updateCurrent)O.updateCurrent(G);let Q=$.jPath?O.toString():this.readonlyMatcher,S=!1;for(let U=0;U<J;U++){let V=this.resolveNameSpace(Y[U][1]);if(this.ignoreAttributesFn(V,Q))continue;let R=$.attributeNamePrefix+V;if(V.length){if($.transformAttributeName)R=$.transformAttributeName(R);if(R=p4(R,$),Y[U][4]!==void 0){let K=Z[U],T=$.attributeValueProcessor(V,K,Q);if(T===null||T===void 0)A[R]=K;else if(typeof T!==typeof K||T!==K)A[R]=T;else A[R]=l8(K,$.parseAttributeValue,$.numberParseOptions);S=!0}else if($.allowBooleanAttributes)A[R]=!0,S=!0}}if(!S)return;if($.attributesGroupName&&!$.preserveOrder){let U={};return U[$.attributesGroupName]=A,U}return A}}var VT=function(W){W=W.replace(/\r\n?/g,`
27
- `);let O=new iW("!xml"),M=O,L="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let $=this.options,Y=new qL($.processEntities),J=W.length;for(let A=0;A<J;A++)if(W[A]==="<"){let X=W.charCodeAt(A+1);if(X===47){let G=m0(W,">",A,"Closing Tag is not closed."),Q=W.substring(A+2,G).trim();if($.removeNSPrefix){let U=Q.indexOf(":");if(U!==-1)Q=Q.substr(U+1)}if(Q=h8($.transformTagName,Q,"",$).tagName,M)L=this.saveTextToParentTag(L,M,this.readonlyMatcher);let S=this.matcher.getCurrentTag();if(Q&&$.unpairedTagsSet.has(Q))throw Error(`Unpaired tag can not be used as closing tag: </${Q}>`);if(S&&$.unpairedTagsSet.has(S))this.matcher.pop(),this.tagsNodeStack.pop();this.matcher.pop(),this.isCurrentNodeStopNode=!1,M=this.tagsNodeStack.pop(),L="",A=G}else if(X===63){let G=u8(W,A,!1,"?>");if(!G)throw Error("Pi Tag is not closed.");L=this.saveTextToParentTag(L,M,this.readonlyMatcher);let Q=this.buildAttributesMap(G.tagExp,this.matcher,G.tagName,!0);if(Q){let S=Q[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(S)||1),Y.setXmlVersion(Number(S)||1)}if($.ignoreDeclaration&&G.tagName==="?xml"||$.ignorePiTags);else{let S=new iW(G.tagName);if(S.add($.textNodeName,""),G.tagName!==G.tagExp&&G.attrExpPresent&&$.ignoreAttributes!==!0)S[":@"]=Q;this.addChild(M,S,this.readonlyMatcher,A)}A=G.closeIndex+1}else if(X===33&&W.charCodeAt(A+2)===45&&W.charCodeAt(A+3)===45){let G=m0(W,"-->",A+4,"Comment is not closed.");if($.commentPropName){let Q=W.substring(A+4,G-2);L=this.saveTextToParentTag(L,M,this.readonlyMatcher),M.add($.commentPropName,[{[$.textNodeName]:Q}])}A=G}else if(X===33&&W.charCodeAt(A+2)===68){if(this.doctypefound)throw Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;let G=Y.readDocType(W,A);this.entityDecoder.addInputEntities(G.entities),A=G.i}else if(X===33&&W.charCodeAt(A+2)===91){let G=m0(W,"]]>",A,"CDATA is not closed.")-2,Q=W.substring(A+9,G);L=this.saveTextToParentTag(L,M,this.readonlyMatcher);let S=this.parseTextData(Q,M.tagname,this.readonlyMatcher,!0,!1,!0,!0);if(S==null)S="";if($.cdataPropName)M.add($.cdataPropName,[{[$.textNodeName]:Q}]);else M.add($.textNodeName,S);A=G+2}else{let G=u8(W,A,$.removeNSPrefix);if(!G){let B=W.substring(Math.max(0,A-50),Math.min(J,A+50));throw Error(`readTagExp returned undefined at position ${A}. Context: "${B}"`)}let{tagName:Q,rawTagName:S,tagExp:U,attrExpPresent:V,closeIndex:R}=G;if({tagName:Q,tagExp:U}=h8($.transformTagName,Q,U,$),$.strictReservedNames&&(Q===$.commentPropName||Q===$.cdataPropName||Q===$.textNodeName||Q===$.attributesGroupName))throw Error(`Invalid tag name: ${Q}`);if(M&&L){if(M.tagname!=="!xml")L=this.saveTextToParentTag(L,M,this.readonlyMatcher,!1)}let K=M;if(K&&$.unpairedTagsSet.has(K.tagname))M=this.tagsNodeStack.pop(),this.matcher.pop();let T=!1;if(U.length>0&&U.lastIndexOf("/")===U.length-1){if(T=!0,Q[Q.length-1]==="/")Q=Q.substr(0,Q.length-1),U=Q;else U=U.substr(0,U.length-1);V=Q!==U}let F=null,N={},C=void 0;if(C=QT(S),Q!==O.tagname)this.matcher.push(Q,{},C);if(Q!==U&&V){if(F=this.buildAttributesMap(U,this.matcher,Q),F)N=GT(F,$)}if(Q!==O.tagname)this.isCurrentNodeStopNode=this.isItStopNode();let w=A;if(this.isCurrentNodeStopNode){let B="";if(T)A=G.closeIndex;else if($.unpairedTagsSet.has(Q))A=G.closeIndex;else{let _=this.readStopNodeData(W,S,R+1);if(!_)throw Error(`Unexpected end of ${S}`);A=_.i,B=_.tagContent}let I=new iW(Q);if(F)I[":@"]=F;I.add($.textNodeName,B),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(M,I,this.readonlyMatcher,w)}else{if(T){({tagName:Q,tagExp:U}=h8($.transformTagName,Q,U,$));let B=new iW(Q);if(F)B[":@"]=F;this.addChild(M,B,this.readonlyMatcher,w),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if($.unpairedTagsSet.has(Q)){let B=new iW(Q);if(F)B[":@"]=F;this.addChild(M,B,this.readonlyMatcher,w),this.matcher.pop(),this.isCurrentNodeStopNode=!1,A=G.closeIndex;continue}else{let B=new iW(Q);if(this.tagsNodeStack.length>$.maxNestedTags)throw Error("Maximum nested tags exceeded");if(this.tagsNodeStack.push(M),F)B[":@"]=F;this.addChild(M,B,this.readonlyMatcher,w),M=B}L="",A=R}}}else L+=W[A];return O.child};function HT(W,O,M,L){if(!this.options.captureMetaData)L=void 0;let $=this.options.jPath?M.toString():M,Y=this.options.updateTag(O.tagname,$,O[":@"]);if(Y===!1);else if(typeof Y==="string")O.tagname=Y,W.addChild(O,L);else W.addChild(O,L)}function KT(W,O,M){let L=this.options.processEntities;if(!L||!L.enabled)return W;if(L.allowedTags){let $=this.options.jPath?M.toString():M;if(!(Array.isArray(L.allowedTags)?L.allowedTags.includes(O):L.allowedTags(O,$)))return W}if(L.tagFilter){let $=this.options.jPath?M.toString():M;if(!L.tagFilter(O,$))return W}return this.entityDecoder.decode(W)}function TT(W,O,M,L){if(W){if(L===void 0)L=O.child.length===0;if(W=this.parseTextData(W,O.tagname,M,!1,O[":@"]?Object.keys(O[":@"]).length!==0:!1,L),W!==void 0&&W!=="")O.add(this.options.textNodeName,W);W=""}return W}function FT(){if(this.stopNodeExpressionsSet.size===0)return!1;return this.matcher.matchesAny(this.stopNodeExpressionsSet)}function ET(W,O,M=">"){let L=0,$=W.length,Y=M.charCodeAt(0),J=M.length>1?M.charCodeAt(1):-1,A="",Z=O;for(let X=O;X<$;X++){let G=W.charCodeAt(X);if(L){if(G===L)L=0}else if(G===34||G===39)L=G;else if(G===Y)if(J!==-1){if(W.charCodeAt(X+1)===J)return A+=W.substring(Z,X),{data:A,index:X}}else return A+=W.substring(Z,X),{data:A,index:X};else if(G===9&&!L)A+=W.substring(Z,X)+" ",Z=X+1}}function m0(W,O,M,L){let $=W.indexOf(O,M);if($===-1)throw Error(L);else return $+O.length-1}function qT(W,O,M,L){let $=W.indexOf(O,M);if($===-1)throw Error(L);return $}function u8(W,O,M,L=">"){let $=ET(W,O+1,L);if(!$)return;let{data:Y,index:J}=$,A=Y.search(/\s/),Z=Y,X=!0;if(A!==-1)Z=Y.substring(0,A),Y=Y.substring(A+1).trimStart();let G=Z;if(M){let Q=Z.indexOf(":");if(Q!==-1)Z=Z.substr(Q+1),X=Z!==$.data.substr(Q+1)}return{tagName:Z,tagExp:Y,closeIndex:J,attrExpPresent:X,rawTagName:G}}function BT(W,O,M){let L=M,$=1,Y=W.length;for(;M<Y;M++)if(W[M]==="<"){let J=W.charCodeAt(M+1);if(J===47){let A=qT(W,">",M,`${O} is not closed`);if(W.substring(M+2,A).trim()===O){if($--,$===0)return{tagContent:W.substring(L,M),i:A}}M=A}else if(J===63)M=m0(W,"?>",M+1,"StopNode is not closed.");else if(J===33&&W.charCodeAt(M+2)===45&&W.charCodeAt(M+3)===45)M=m0(W,"-->",M+3,"StopNode is not closed.");else if(J===33&&W.charCodeAt(M+2)===91)M=m0(W,"]]>",M,"StopNode is not closed.")-2;else{let A=u8(W,M,!1);if(A){if((A&&A.tagName)===O&&A.tagExp[A.tagExp.length-1]!=="/")$++;M=A.closeIndex}}}}function l8(W,O,M){if(O&&typeof W==="string"){let L=W.trim();if(L==="true")return!0;else if(L==="false")return!1;else return y8(W,M)}else if(C4(W))return W;else return""}function h8(W,O,M,L){if(W){let $=W(O);if(M===O)M=$;O=$}return O=p4(O,L),{tagName:O,tagExp:M}}function p4(W,O){if(KL.includes(W))throw Error(`[SECURITY] Invalid name: "${W}" is a reserved JavaScript keyword that could cause prototype pollution`);else if(p1.includes(W))return O.onDangerousProperty(W);return W}var p8=iW.getMetaDataSymbol();function wT(W,O){if(!W||typeof W!=="object")return{};if(!O)return W;let M={};for(let L in W)if(L.startsWith(O)){let $=L.substring(O.length);M[$]=W[L]}else M[L]=W[L];return M}function m8(W,O,M,L){return m4(W,O,M,L)}function m4(W,O,M,L){let $,Y={};for(let J=0;J<W.length;J++){let A=W[J],Z=CT(A);if(Z!==void 0&&Z!==O.textNodeName){let X=wT(A[":@"]||{},O.attributeNamePrefix);M.push(Z,X)}if(Z===O.textNodeName)if($===void 0)$=A[Z];else $+=""+A[Z];else if(Z===void 0)continue;else if(A[Z]){let X=m4(A[Z],O,M,L),G=PT(X,O);if(Object.keys(X).length===0&&O.alwaysCreateTextNode)X[O.textNodeName]="";if(A[":@"])NT(X,A[":@"],L,O);else if(Object.keys(X).length===1&&X[O.textNodeName]!==void 0&&!O.alwaysCreateTextNode)X=X[O.textNodeName];else if(Object.keys(X).length===0)if(O.alwaysCreateTextNode)X[O.textNodeName]="";else X="";if(A[p8]!==void 0&&typeof X==="object"&&X!==null)X[p8]=A[p8];if(Y[Z]!==void 0&&Object.prototype.hasOwnProperty.call(Y,Z)){if(!Array.isArray(Y[Z]))Y[Z]=[Y[Z]];Y[Z].push(X)}else{let Q=O.jPath?L.toString():L;if(O.isArray(Z,Q,G))Y[Z]=[X];else Y[Z]=X}if(Z!==void 0&&Z!==O.textNodeName)M.pop()}}if(typeof $==="string"){if($.length>0)Y[O.textNodeName]=$}else if($!==void 0)Y[O.textNodeName]=$;return Y}function CT(W){let O=Object.keys(W);for(let M=0;M<O.length;M++){let L=O[M];if(L!==":@")return L}}function NT(W,O,M,L){if(O){let $=Object.keys(O),Y=$.length;for(let J=0;J<Y;J++){let A=$[J],Z=A.startsWith(L.attributeNamePrefix)?A.substring(L.attributeNamePrefix.length):A,X=L.jPath?M.toString()+"."+Z:M;if(L.isArray(A,X,!0,!0))W[A]=[O[A]];else W[A]=O[A]}}}function PT(W,O){let{textNodeName:M}=O,L=Object.keys(W).length;if(L===0)return!0;if(L===1&&(W[M]||typeof W[M]==="boolean"||W[M]===0))return!0;return!1}class t1{constructor(W){this.externalEntities={},this.options=k4(W)}parse(W,O){if(typeof W!=="string"&&W.toString)W=W.toString();else if(typeof W!=="string")throw Error("XML data is accepted in String or Bytes[] form.");if(O){if(O===!0)O={};let $=TL(W,O);if($!==!0)throw Error(`${$.err.msg}:${$.err.line}:${$.err.col}`)}let M=new NL(this.options,this.externalEntities),L=M.parseXml(W);if(this.options.preserveOrder||L===void 0)return L;else return m8(L,this.options,M.matcher,M.readonlyMatcher)}addEntity(W,O){if(O.indexOf("&")!==-1)throw Error("Entity value can't have '&'");else if(W.indexOf("&")!==-1||W.indexOf(";")!==-1)throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");else if(O==="&")throw Error("An entity with value '&' is not permitted");else this.externalEntities[W]=O}static getMetaDataSymbol(){return iW.getMetaDataSymbol()}}var d4={validate:TL};function _T(W,O){let M;for(let L=O+1;L<W.length;L+=1){let $=W[L];if(M!==void 0){if($===M)M=void 0;continue}if($==='"'||$==="'"){M=$;continue}if($===">")return L+1}return W.length}function jT(W,O){if(W.startsWith("<!--",O)){let X=W.indexOf("-->",O+4);return{start:O,end:X===-1?W.length:X+3,closing:!1,selfClosing:!1,declaration:!1}}let M=_T(W,O),L=O+1,$=W[L]==="?"||W[L]==="!",Y=W[L]==="/";if(Y)L+=1;while(/\s/.test(W[L]??""))L+=1;let J=L;while(/[A-Za-z0-9:_.-]/.test(W[L]??""))L+=1;let A=L===J?void 0:W.slice(J,L),Z=W.slice(O,M);return{start:O,end:M,name:A,closing:Y,selfClosing:/\/\s*>$/.test(Z),declaration:$}}function IT(W){return W.replace(/[^\r\n\t]/g," ")}function c4(W){let O=W.text,M=[],L=[],$=[],Y=0,J=0;while(Y<O.length){let Z=O.indexOf("<",Y);if(Z===-1)break;let X=jT(O,Z);if(X.declaration)$.push(X.start);if(X.name==="script"&&!X.closing&&!X.selfClosing&&!X.declaration){let G=X.end,Q=O.indexOf("</script>",G);if(Q===-1)throw W.parseError("WOML_UNCLOSED_RAW_BODY","The <script> body is not closed by the required literal </script> terminator.",X.start,X.end,"Add </script>. The terminator is case-sensitive in WOML v0.1.");let S=O.slice(G,Q);M.push(O.slice(J,G),IT(S)),L.push({index:L.length,openingTagOffset:X.start,value:S,span:W.span(G,Q)}),J=Q,Y=Q+9;continue}Y=Math.max(X.end,Z+1)}M.push(O.slice(J));let A=M.join("");if(A.length!==O.length)throw Error("Internal WOML raw-content masking changed source length.");return{source:A,scripts:L,declarationOffsets:$}}var yT={preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",parseTagValue:!1,parseAttributeValue:!1,trimValues:!1,allowBooleanAttributes:!1,commentPropName:!1},DT=new t1(yT);function c8(W){return Object.keys(W).find((O)=>O!==":@")}function n4(W){let O=c8(W);return O!==void 0&&!O.startsWith("#")&&!O.startsWith("?")}function kT(W,O){if(W==="InvalidAttr")return O.includes("is repeated")?"WOML_DUPLICATE_ATTRIBUTE":"WOML_INVALID_ATTRIBUTE";return"WOML_MALFORMED_MARKUP"}function bT(W,O){if(O>0&&W.includes("closing tag 'script'"))return"The first literal </script> ends a script body in WOML v0.1. Do not place that exact sequence inside JavaScript text or comments.";return}function d8(W,O){let M;for(let L=O+1;L<W.length;L+=1){let $=W[L];if(M!==void 0){if($===M)M=void 0}else if($==='"'||$==="'")M=$;else if($===">")return L+1}return W.length}function fT(W,O,M,L){let $=W.text,Y=[],J=L;while(J<M-1){while(/\s/.test($[J]??""))J+=1;if($[J]===">"||$[J]==="/")break;let A=J;while(/[^\s=/>]/.test($[J]??""))J+=1;let Z=J,X=$.slice(A,Z);while(/\s/.test($[J]??""))J+=1;if($[J]!=="=")break;J+=1;while(/\s/.test($[J]??""))J+=1;let G=$[J];if(G!=='"'&&G!=="'")break;J+=1;let Q=J;while(J<M&&$[J]!==G)J+=1;let S=J;if($[J]===G)J+=1;Y.push({name:X,span:W.span(A,J),nameSpan:W.span(A,Z),valueSpan:W.span(Q,S)})}return Y}function vT(W,O){let M=[],L=[],$=0;while($<O.length){let Y=O.indexOf("<",$);if(Y===-1)break;if(O.startsWith("<!--",Y)){let V=O.indexOf("-->",Y+4);$=V===-1?O.length:V+3;continue}if(O[Y+1]==="?"||O[Y+1]==="!"){$=d8(O,Y);continue}let J=d8(O,Y),A=Y+1,Z=O[A]==="/";if(Z)A+=1;while(/\s/.test(O[A]??""))A+=1;let X=A;while(/[A-Za-z0-9:_.-]/.test(O[X]??""))X+=1;let G=O.slice(A,X);if(Z){let V=L.pop();if(V!==void 0)V.closeStart=Y,V.end=J;$=J;continue}let Q=/\/\s*>$/.test(O.slice(Y,J)),S={name:G,start:Y,openEnd:J,closeStart:J,end:J,selfClosing:Q,attributes:fT(W,Y,J,X),children:[]},U=L[L.length-1];if(U===void 0)M.push(S);else U.children.push(S);if(!Q)L.push(S);$=J}return M}function xT(W){let O=c8(W);if(O===void 0)return[];let M=W[O];if(!Array.isArray(M))return[];return M.filter((L)=>typeof L==="object"&&L!==null&&n4(L))}function i4(W,O,M){let L=[],$=O;while($<M){let Y=W.text.indexOf("<!--",$),J=Y===-1||Y>=M?M:Y,A=W.text.slice($,J);if(A.trim().length>0)L.push({kind:"text",value:A,span:W.span($,J)});if(J===M)break;let Z=W.text.indexOf("-->",Y+4);$=Z===-1?M:Math.min(Z+3,M)}return L}function r4(W,O,M,L){let $=c8(O);if($!==M.name)throw Error(`Internal WOML parser location mismatch: expected ${$}, found ${M.name}.`);let Y=O[":@"]??{},J={};for(let X of M.attributes){let G=Y[X.name];J[X.name]={name:X.name,value:typeof G==="string"?G:String(G??""),span:X.span,nameSpan:X.nameSpan,valueSpan:X.valueSpan}}let A=L.get(M.start),Z=[];if(A!==void 0)Z.push({kind:"raw",value:A.value,span:A.span});else if(!M.selfClosing){let X=xT(O),G=M.openEnd;for(let Q=0;Q<M.children.length;Q+=1){let S=M.children[Q];Z.push(...i4(W,G,S.start));let U=X[Q];if(U===void 0)throw Error(`Internal WOML parser lost child <${S.name}>.`);Z.push(r4(W,U,S,L)),G=S.end}Z.push(...i4(W,G,M.closeStart))}return{kind:"element",name:M.name,attributes:J,children:Z,span:W.span(M.start,M.end),openTagSpan:W.span(M.start,M.openEnd)}}function s4(W,O,M){let L=O;while(L<M){if(/\s/.test(W[L])){L+=1;continue}if(W.startsWith("<!--",L)){let $=W.indexOf("-->",L+4);if($===-1||$>=M)return;L=$+3;continue}return L}return}function e1(W,O={}){let M=new n(O.file??"<memory>",W),L=c4(M);if(L.declarationOffsets.length>0){let U=L.declarationOffsets[0];throw M.parseError("WOML_DECLARATION_NOT_ALLOWED","WOML does not allow XML declarations, doctypes, CDATA, or processing instructions.",U,d8(W,U))}let $=d4.validate(L.source,{allowBooleanAttributes:!1});if($!==!0){let U=$.err.line??1,V=$.err.col??1,R=M.offsetAt(U,V);throw M.parseError(kT($.err.code,$.err.msg),$.err.msg,R,R+1,bT($.err.msg,L.scripts.length))}let Y;try{Y=DT.parse(L.source)}catch(U){throw M.parseError("WOML_MALFORMED_MARKUP",U instanceof Error?U.message:"Unable to parse WOML markup.",0)}let J=Y.filter(n4),A=vT(M,L.source);if(J.length!==1||A.length!==1){let U=A[1],V=U?.start??0;throw M.parseError("WOML_MULTIPLE_ROOTS","A WOML file must contain exactly one root element.",V,U?.openEnd??V+1)}let Z=A[0],X=s4(W,0,Z.start);if(X!==void 0)throw M.parseError("WOML_TEXT_OUTSIDE_ROOT","Text is not allowed before the WOML root element.",X);let G=s4(W,Z.end,W.length);if(G!==void 0)throw M.parseError("WOML_TEXT_OUTSIDE_ROOT","Text is not allowed after the WOML root element.",G);let Q=new Map(L.scripts.map((U)=>[U.openingTagOffset,U])),S=r4(M,J[0],Z,Q);return{kind:"document",file:M.path,source:W,root:S,span:M.span(0,W.length)}}var gT=[{name:"minute",minimum:0,maximum:59},{name:"hour",minimum:0,maximum:23},{name:"day-of-month",minimum:1,maximum:31},{name:"month",minimum:1,maximum:12},{name:"day-of-week",minimum:0,maximum:7,normalize:(W)=>W===7?0:W}];var hT=new Set(Intl.supportedValuesOf("timeZone"));class sW extends Error{reason;constructor(W){super(W);this.reason=W;this.name="ScheduleCronSyntaxError"}}function PL(W){if(!/^[0-9]+$/.test(W))return;let O=Number(W);return Number.isSafeInteger(O)?O:void 0}function i8(W,O){return W>=O.minimum&&W<=O.maximum}function uT(W,O){if(W.length===0)throw new sW(`${O.name} must not be empty`);let M=new Set;for(let $ of W.split(",")){if($.length===0)throw new sW(`${O.name} contains an empty list item`);let Y=$.split("/");if(Y.length>2||Y.some((G)=>G.length===0))throw new sW(`${O.name} contains an invalid step`);let J=Y[0],A=Y[1]===void 0?1:PL(Y[1]);if(A===void 0||A<1)throw new sW(`${O.name} step must be a positive integer`);let Z,X;if(J==="*")Z=O.minimum,X=O.maximum;else if(J.includes("-")){let G=J.split("-");if(G.length!==2)throw new sW(`${O.name} contains an invalid range`);let Q=PL(G[0]),S=PL(G[1]);if(Q===void 0||S===void 0||!i8(Q,O)||!i8(S,O)||Q>S)throw new sW(`${O.name} range is outside ${O.minimum}-${O.maximum}`);Z=Q,X=S}else{let G=PL(J);if(G===void 0||!i8(G,O))throw new sW(`${O.name} value is outside ${O.minimum}-${O.maximum}`);Z=G,X=Y[1]===void 0?G:O.maximum}for(let G=Z;G<=X;G+=A)M.add(O.normalize?.(G)??G)}let L=new Set;for(let $=O.minimum;$<=O.maximum;$+=1)L.add(O.normalize?.($)??$);return{values:M,unrestricted:M.size===L.size&&[...L].every(($)=>M.has($))}}function a4(W){if(W.length>256)throw new sW("cron must not exceed 256 characters");if(W!==W.trim()||/\s/.test(W.replace(/ /g,"")))throw new sW("cron must use single ASCII spaces between fields");let O=W.split(" ");if(O.length!==5||O.some((L)=>L.length===0))throw new sW("cron must contain exactly five fields separated by single spaces");let M=O.map((L,$)=>uT(L,gT[$]));return{dialect:"woml-cron-v1",source:W,minute:M[0],hour:M[1],dayOfMonth:M[2],month:M[3],dayOfWeek:M[4]}}function o4(W){return hT.has(W)}import{createHash as lT}from"crypto";import{readFileSync as OZ,realpathSync as jL,statSync as MZ}from"fs";import{dirname as n8,isAbsolute as LZ,relative as r8,resolve as IL,sep as a8}from"path";var $Z=/^[a-z][A-Za-z0-9]*$/,YZ=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,pT=/^(?:\.\/|\.\.\/)(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\.(?:js|ts)$/,mT=/^(?:\.\/|\.\.\/)(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\.woml$/,t4=/^\{\{secrets\.([A-Z][A-Z0-9_]*)\}\}$/,dT=/^\{\{context\.(?:payload(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|steps\.[a-z][A-Za-z0-9]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*)\}\}$/,cT=new Set(["__proto__","prototype","constructor"]),iT=new Set(["woml","imports","module","props","prop","workflow","config","lifecycle","on-start","on-step-start","on-step-success","on-step-failure","on-step-complete","on-success","on-error","on-failure","on-cancel","on-complete","triggers","manual","webhook","slack","schedule","interval","event","schema","steps","step","script","choose","switch","case","default","when","otherwise","result","parallel","fork","branch","approval","notify","provider","when-approved","when-rejected"]);function JZ(W,O,M,L,$,Y){return{phase:O,code:M,message:L,file:W.file,location:$,...Y===void 0?{}:{hint:Y}}}function m(W,O,M,L,$){throw new oO(JZ(W,"validation",O,M,L,$))}function d0(W,O,M,L,$){throw new GO(JZ(W,"compile",O,M,L,$))}function c0(W,O){let M=[];for(let L of O.children){if(L.kind!=="element")m(W,"WOML_UNEXPECTED_CONTENT",`<${O.name}> may contain WOML elements only.`,L.span);M.push(L)}return M}function i0(W,O){let M=Object.values(O.attributes)[0];if(M!==void 0)m(W,"WOML_UNKNOWN_ATTRIBUTE",`<${O.name}> does not accept attribute "${M.name}".`,M.nameSpan)}function yL(W,O,M){let L=Object.values(O.attributes).find(($)=>!M.has($.name));if(L!==void 0)m(W,"WOML_UNKNOWN_ATTRIBUTE",`Unknown attribute "${L.name}" on <${O.name}>.`,L.nameSpan)}function sT(W,O){if(O.children.length>0)m(W,"WOML_REUSABLE_TAG_CHILDREN_UNSUPPORTED",`<${O.name}> must be empty; reusable structural children are not supported in this release.`,O.children[0].span,"Pass declared props as attributes. General custom structural tags are postponed.")}function WM(W,O,M){let L=O.attributes[M];if(L===void 0)m(W,"WOML_MISSING_ATTRIBUTE",`<${O.name}> requires the "${M}" attribute.`,O.openTagSpan);return L}function e4(W,O,M){let L=O.attributes[M];if(L===void 0)return!1;if(L.value!=="true"&&L.value!=="false")m(W,"WOML_PROP_BOOLEAN_INVALID",`Prop attribute "${M}" must be exactly "true" or "false".`,L.valueSpan);return L.value==="true"}function nT(W){return W.replace(/-([a-z0-9])/g,(O,M)=>M.toUpperCase())}function rT(W,O){if(O===void 0)return[];i0(W,O);let M=c0(W,O);if(M.length===0)m(W,"WOML_PROPS_EMPTY","<props> requires at least one <prop> declaration.",O.openTagSpan,"Remove the empty <props> block when the reusable definition has no props.");let L=new Set,$=new Set;return M.map((Y)=>{if(Y.name!=="prop")m(W,"WOML_PROPS_INVALID_CHILD",`<props> accepts <prop> declarations only; found <${Y.name}>.`,Y.openTagSpan);if(yL(W,Y,new Set(["name","required","secret"])),Y.children.length>0)m(W,"WOML_PROP_NOT_EMPTY","<prop> is an empty declaration and cannot contain child content.",Y.children[0].span);let J=WM(W,Y,"name"),A=J.value,Z=nT(A);if(A.length>128||!YZ.test(A))m(W,"WOML_PROP_NAME_INVALID",`Prop name "${A}" must use lowercase kebab-case.`,J.valueSpan,"Example: customer-id");if(cT.has(Z))m(W,"WOML_PROP_NAME_RESERVED",`Prop name "${A}" maps to reserved JavaScript key "${Z}".`,J.valueSpan);if(L.has(A)||$.has(Z))m(W,"WOML_PROP_DUPLICATE",`Prop "${A}" duplicates an existing source or JavaScript binding name.`,J.valueSpan);return L.add(A),$.add(Z),{name:A,bindingName:Z,required:e4(W,Y,"required"),secret:e4(W,Y,"secret"),element:Y}})}function WZ(W,O){if(O===void 0)return[];i0(W,O);let M=c0(W,O);if(M.length===0)m(W,"WOML_IMPORTS_EMPTY","<imports> requires at least one <module> declaration.",O.openTagSpan);let L=new Set,$=new Set;return M.map((Y)=>{if(Y.name!=="module")m(W,"WOML_IMPORTS_INVALID_CHILD",`<imports> accepts <module> declarations only; found <${Y.name}>.`,Y.openTagSpan);if(yL(W,Y,new Set(["name","from"])),Y.children.length>0)m(W,"WOML_INVALID_STRUCTURE","<module> cannot contain child content.",Y.children[0].span);let J=WM(W,Y,"name"),A=WM(W,Y,"from"),Z=J.value,X=A.value,G=X.endsWith(".woml"),Q=G?YZ.test(Z):$Z.test(Z);if(Z.length>128||!Q)m(W,"WOML_MODULE_ALIAS_INVALID",G?`Reusable definition name "${Z}" must use lowercase kebab-case.`:`Module name "${Z}" must be a JavaScript-safe lower-camel alias.`,J.valueSpan,G?"Example: calculate-discount":"Example: spreadsheet or customerTools");if(G&&iT.has(Z))m(W,"WOML_REUSABLE_ALIAS_RESERVED",`Reusable definition name "${Z}" is reserved by WOML.`,J.valueSpan);if(L.has(Z))m(W,"WOML_MODULE_ALIAS_DUPLICATE",`Import name "${Z}" is declared more than once.`,J.valueSpan);if($.has(X))m(W,"WOML_MODULE_SOURCE_DUPLICATE",`Import source "${X}" is already declared under another name.`,A.valueSpan);if(!(G?mT.test(X):pT.test(X))||X.includes("\\")||X.includes("\x00")||X.includes("?")||X.includes("#"))m(W,"WOML_MODULE_PATH_INVALID",`Import source "${X}" must be an explicit relative POSIX path ending in .js, .ts, or .woml.`,A.valueSpan);return L.add(Z),$.add(X),{name:Z,from:X,kind:G?"reusable-definition":"script-module",element:Y}})}function AZ(W,O){if(W.name===O)return W;for(let M of W.children){if(M.kind!=="element")continue;let L=AZ(M,O);if(L!==void 0)return L}return}function aT(W,O,M){if(M==="reusable-step")yL(W,O,new Set(["name","description"]));else{yL(W,O,new Set(["kind"]));let $=WM(W,O,"kind");if($.value!=="notification")m(W,"WOML_PROVIDER_KIND_UNSUPPORTED",`Provider kind "${$.value}" is not executable in this release.`,$.valueSpan,$.value==="trigger"?"Custom trigger providers are reserved for a future reviewed inbound-provider contract.":'Use kind="notification".')}let L=c0(W,O);if(L.length!==1||L[0].name!=="script")m(W,M==="reusable-step"?"WOML_REUSABLE_STEP_OPERATION_REQUIRED":"WOML_PROVIDER_OPERATION_REQUIRED",`<${O.name}> must contain exactly one <script>.`,L[1]?.openTagSpan??L[0]?.openTagSpan??O.openTagSpan);if(i0(W,L[0]),L[0].children.length!==1||L[0].children[0].kind!=="raw")m(W,"WOML_SCRIPT_BODY_REQUIRED","<script> requires one raw JavaScript body.",L[0].openTagSpan)}function oT(W,O){if(O===void 0)return;i0(W,O);let M=c0(W,O);if(M.length===0)m(W,"WOML_LIFECYCLE_ACTION_REQUIRED","<lifecycle> requires at least one reusable lifecycle hook.",O.openTagSpan);let L=["on-success","on-error","on-complete"],$=new Set;for(let Y of M){if(L.indexOf(Y.name)===-1)m(W,Y.name.startsWith("on-step-")?"WOML_REUSABLE_STEP_HOOK_UNSUPPORTED":"WOML_REUSABLE_LIFECYCLE_HOOK_INVALID",`<${Y.name}> is not available in a reusable definition lifecycle.`,Y.openTagSpan,"Use <on-success>, <on-error>, and <on-complete> only.");if($.has(Y.name))m(W,"WOML_LIFECYCLE_DUPLICATE",`<${Y.name}> may appear only once.`,Y.openTagSpan);i0(W,Y);let A=c0(W,Y);if(A.length===0)m(W,"WOML_LIFECYCLE_ACTION_REQUIRED",`<${Y.name}> requires at least one <script> action.`,Y.openTagSpan);for(let Z of A){if(Z.name==="notify")m(W,"WOML_REUSABLE_LIFECYCLE_NOTIFY_UNSUPPORTED","Reusable definition lifecycle hooks support script actions only in v1.",Z.openTagSpan,"Use the custom provider from a workflow lifecycle <notify> action, where notification delivery is durable and recoverable.");if(Z.name!=="script")m(W,"WOML_LIFECYCLE_ACTION_INVALID",`<${Y.name}> supports <script> actions only.`,Z.openTagSpan)}$.add(Y.name)}}function z0(W){let O=W.root;if(O.name!=="woml")m(W,"WOML_EXPECTED_DOCUMENT_ROOT",`Expected <woml> as the document root, found <${O.name}>.`,O.openTagSpan);i0(W,O);let M=c0(W,O),L=M.find((U)=>U.name==="workflow"),$=M.find((U)=>U.name==="step"),Y=M.find((U)=>U.name==="provider"),J=[L,$,Y].filter(Boolean).length;if(J!==1){if(J===0&&M.every((U)=>U.name==="imports"||U.name==="props"))m(W,"WOML_DOCUMENT_STRUCTURE_INVALID","<woml> requires exactly one <workflow>, reusable <step>, or <provider> definition.",M[0]?.openTagSpan??O.openTagSpan);m(W,"WOML_DOCUMENT_PROFILE_INVALID","<woml> must contain exactly one <workflow>, reusable <step>, or <provider> definition.",(L??$??Y??M[0]??O).openTagSpan)}let A=M[0]?.name==="imports"?M[0]:void 0,Z=M.find((U)=>U.name==="props"),X=M.find((U)=>U.name==="lifecycle");if(L!==void 0){let U=AZ(O,"props");if(U!==void 0)m(W,"WOML_PROPS_WORKFLOW_FORBIDDEN","<props> is available only in reusable step or provider definition files, never in a workflow document.",U.openTagSpan);let V=[A,L].filter((R)=>R!==void 0);if(M.length!==V.length||M.some((R,K)=>R!==V[K]))m(W,"WOML_DOCUMENT_STRUCTURE_INVALID","<woml> workflow documents require optional <imports> followed by exactly one <workflow>.",M.find((R,K)=>R!==V[K])?.openTagSpan??O.openTagSpan);return{kind:"workflow",sourcePath:W.file,imports:WZ(W,A),props:[],definition:L}}let G=$??Y,Q=[A,Z,G,X].filter((U)=>U!==void 0);if(M.length!==Q.length||M.some((U,V)=>U!==Q[V]))m(W,"WOML_DOCUMENT_STRUCTURE_INVALID","Reusable documents require optional <imports>, optional <props>, one <step> or <provider>, then optional <lifecycle>.",M.find((U,V)=>U!==Q[V])?.openTagSpan??O.openTagSpan);let S=$===void 0?"notification-provider":"reusable-step";return aT(W,G,S),oT(W,X),{kind:S,sourcePath:W.file,imports:WZ(W,A),props:rT(W,Z),definition:G,...X===void 0?{}:{lifecycle:X}}}function tT(W,O,M){if(O.secret){if(!t4.test(M.value))m(W,"WOML_REUSABLE_SECRET_PROP_INVALID",`Secret prop "${O.name}" requires exactly {{secrets.SECRET_NAME}}.`,M.valueSpan);return}if(t4.test(M.value))m(W,"WOML_REUSABLE_SECRET_PROP_UNDECLARED",`Prop "${O.name}" is not declared secret="true".`,M.valueSpan);if((M.value.includes("{{")||M.value.includes("}}"))&&!dT.test(M.value))m(W,"WOML_REUSABLE_PROP_VALUE_INVALID",`Prop "${O.name}" must be a literal string or one exact context reference.`,M.valueSpan,"Mixed interpolation is not supported in reusable props v1.")}function eT(W,O,M,L,$){let Y=L.get(O.name);if(Y===void 0)return;if(M?.name==="triggers"&&["slack","telegram","discord","whatsapp"].includes(O.name))return;let J=new Set(["steps","when","otherwise","branch","parallel","when-approved","when-rejected","case","default"]);if(Y.kind==="reusable-step"&&!J.has(M?.name??""))m(W,"WOML_REUSABLE_STEP_PLACEMENT_INVALID",`Reusable step <${O.name}> is valid only where an ordinary <step> is allowed.`,O.openTagSpan);if(Y.kind==="notification-provider"&&M?.name!=="notify")m(W,"WOML_REUSABLE_PROVIDER_PLACEMENT_INVALID",`Notification provider <${O.name}> is valid only as a direct child of <notify>.`,O.openTagSpan);if(Y.kind==="notification-provider"&&$.some((X)=>X.name.startsWith("on-"))&&O.attributes.message===void 0)m(W,"WOML_REUSABLE_PROVIDER_MESSAGE_REQUIRED",`Informational provider <${O.name}> requires the "message" attribute.`,O.openTagSpan);sT(W,O);let A=Y.kind==="reusable-step"?new Set(["id","name","description","retry","retry-delay","retry-backoff","retry-max-delay"]):new Set(["message"]);if(Y.kind==="reusable-step"){let X=WM(W,O,"id");if(!$Z.test(X.value))m(W,"WOML_INVALID_ID",`Custom step ID "${X.value}" must be a JavaScript-safe lower-camel identifier.`,X.valueSpan)}let Z=new Map(Y.props.map((X)=>[X.name,X]));for(let X of Object.values(O.attributes)){if(A.has(X.name))continue;let G=Z.get(X.name);if(G===void 0)m(W,"WOML_REUSABLE_PROP_UNKNOWN",`<${O.name}> does not declare prop "${X.name}".`,X.nameSpan);tT(W,G,X)}for(let X of Y.props)if(X.required&&O.attributes[X.name]===void 0)m(W,"WOML_REUSABLE_PROP_REQUIRED",`<${O.name}> requires prop "${X.name}".`,O.openTagSpan)}function s8(W,O,M,L,$=[]){eT(W,O,L,M,$);for(let Y of O.children)if(Y.kind==="element")s8(W,Y,M,O,[...$,O])}function eO(W,O){return r8(W,O).split(a8).join("/")}function _L(W){return`sha256:${lT("sha256").update(W).digest("hex")}`}function tO(W,O,M,L,$,Y){let J=new n(eO(W,O),M),A=Y===void 0?0:Math.max(0,M.indexOf(Y));throw new GO({phase:"compile",code:L,message:$,file:J.path,location:J.span(A,A+Math.max(Y?.length??1,1))})}function ZZ(W,O,M,L=[]){if(M.has(W))return;let $;try{$=OZ(W,"utf8")}catch{tO(O,W,"","WOML_MODULE_FILE_NOT_READABLE",`Module source "${eO(O,W)}" could not be read.`)}let Y;try{let J=W.endsWith(".ts")?"ts":"js";Y=new Bun.Transpiler({loader:J}).scan($).imports}catch(J){tO(O,W,$,"WOML_MODULE_SYNTAX_INVALID",`Cannot parse module source: ${J instanceof Error?J.message:String(J)}`)}for(let J of Y){if(J.kind!=="import-statement")tO(O,W,$,J.kind==="dynamic-import"?"WOML_MODULE_DYNAMIC_IMPORT_UNSUPPORTED":"WOML_MODULE_IMPORT_UNSUPPORTED",`Import form "${J.kind}" is unsupported in Module profile v1.`,J.path);if(!J.path.startsWith("./")&&!J.path.startsWith("../"))tO(O,W,$,"WOML_MODULE_PACKAGE_IMPORT_UNAVAILABLE",`Package import "${J.path}" is unavailable until the postponed package milestone.`,J.path);if(!/\.(?:js|ts)$/.test(J.path))tO(O,W,$,"WOML_MODULE_IMPORT_EXTENSION_REQUIRED",`Static import "${J.path}" requires an explicit .js or .ts extension.`,J.path);let A=IL(n8(W),J.path),Z;try{if(Z=jL(A),!MZ(Z).isFile())throw Error("not a file")}catch{tO(O,W,$,"WOML_MODULE_FILE_NOT_FOUND",`Module dependency "${J.path}" does not resolve to a readable file.`,J.path)}let X=r8(O,Z);if(X===".."||X.startsWith(`..${a8}`)||LZ(X))tO(O,W,$,"WOML_MODULE_SYMLINK_ESCAPE",`Module dependency "${J.path}" resolves outside the project boundary.`,J.path);if(L.includes(Z))tO(O,W,$,"WOML_MODULE_GRAPH_CYCLE",`Module dependency graph contains a cycle through "${J.path}".`,J.path);ZZ(Z,O,M,[...L,W])}M.set(W,{path:eO(O,W),digest:_L($),kind:"script-module"})}function WF(W,O,M){let{from:L}=O,$=IL(n8(W.file),L),Y;try{if(!MZ($).isFile())throw Error("not a file");Y=jL($)}catch{d0(W,O.kind==="reusable-definition"?"WOML_REUSABLE_SOURCE_NOT_FOUND":"WOML_MODULE_FILE_NOT_FOUND",`Import source "${L}" does not exist or is not a file.`,O.element.attributes.from?.valueSpan??O.element.openTagSpan)}let J=r8(M,Y);if(J===".."||J.startsWith(`..${a8}`)||LZ(J))d0(W,"WOML_MODULE_PROJECT_BOUNDARY",`Import source "${L}" resolves outside the project boundary.`,O.element.attributes.from?.valueSpan??O.element.openTagSpan);return Y}function OF(W,O={}){let M=jL(IL(O.sourcePath??W.file)),L=jL(IL(O.projectRoot??n8(M))),$={...W,file:M},Y=z0($),J=[],A=new Map;A.set(M,{path:eO(L,M),digest:_L($.source),kind:Y.kind});let Z=(U,V,R)=>{let K=new Map,T=new Set;for(let F of V.imports){let N=WF(U,F,L);if(T.has(N))d0(U,"WOML_MODULE_SOURCE_DUPLICATE",`Import source "${F.from}" resolves to a file already imported by this document.`,F.element.attributes.from?.valueSpan??F.element.openTagSpan);T.add(N);let C=OZ(N,"utf8");if(F.kind==="script-module"){ZZ(N,L,A);continue}if(R.includes(N))d0(U,"WOML_REUSABLE_IMPORT_CYCLE",`Reusable definition import cycle detected: ${[...R,N].map((H)=>eO(L,H)).join(" -> ")}.`,F.element.openTagSpan);let w=e1(C,{file:N}),B=z0(w);if(B.kind==="workflow")d0(U,"WOML_REUSABLE_WORKFLOW_IMPORT_FORBIDDEN",`Import "${F.name}" points to a runnable workflow, not a reusable step or provider.`,F.element.openTagSpan,"Use services.workflows.call() or services.workflows.start() for workflow-to-workflow communication.");K.set(F.name,B);let I=_L(C);A.set(N,{path:eO(L,N),digest:I,kind:B.kind}),J.push({alias:F.name,sourcePath:eO(L,N),digest:I,kind:B.kind,props:B.props.map(({element:H,...q})=>q)});let _=Z(w,B,[...R,N]);s8(w,w.root,_)}return K},X=Z($,Y,[M]);s8($,$.root,X);let G=[...A.values()].sort((U,V)=>U.path.localeCompare(V.path)),Q=[...J].sort((U,V)=>`${U.alias}\x00${U.sourcePath}`.localeCompare(`${V.alias}\x00${V.sourcePath}`)),S=_L(JSON.stringify({root:eO(L,M),sources:G,definitions:Q}));return{root:Y,definitions:Q,sources:G,rootHash:S}}function o8(W){let O=z0(W);if(O.kind!=="workflow")d0(W,"WOML_DEFINITION_NOT_RUNNABLE",`This file defines a ${O.kind==="reusable-step"?"reusable step":"notification provider"} and cannot be run independently.`,O.definition.openTagSpan,'Import it from a workflow with <module name="custom-tag" from="./definition.woml" />.')}function MF(W){let O=W.definitions.map((M)=>({name:M.alias,description:M.kind==="reusable-step"?`Reusable WOML step from ${M.sourcePath}`:`Reusable WOML notification provider from ${M.sourcePath}`,attributes:[...M.kind==="reusable-step"?[{name:"id",description:"Required workflow-wide step identity."},{name:"name",description:"Optional invocation display name."},{name:"description",description:"Optional invocation description."},{name:"retry",description:"Optional total attempt count."}]:[{name:"message",description:"Required for informational lifecycle notifications."}],...M.props.map((L)=>({name:L.name,description:`${L.required?"Required":"Optional"}${L.secret?" secret":""} prop; available as props.${L.bindingName}.`}))]}));return`${JSON.stringify({version:1.1,tags:O},null,2)}
28
- `}var $F={insideForkBranch:!1,shadowedServices:[]},YF=new Set(["woml","imports","module","workflow","config","lifecycle","on-start","on-step-start","on-step-success","on-step-failure","on-step-complete","on-success","on-error","on-cancel","on-complete","triggers","manual","webhook","schema","steps","step","script","branch","choose","switch","case","default","fork","parallel","when","otherwise","result","approval","notify","slack","telegram","discord","whatsapp","schedule","interval","event","when-approved","when-rejected"]),JF=new Set,AF={woml:{attributes:new Set},imports:{attributes:new Set},module:{attributes:new Set(["name","from"])},workflow:{attributes:new Set(["id","name","description","version"]),stagedAttributes:new Set(["tags"])},config:{attributes:new Set(["concurrency","timeout","rate-limit","queue"])},lifecycle:{attributes:new Set},"on-start":{attributes:new Set},"on-step-start":{attributes:new Set(["steps"])},"on-step-success":{attributes:new Set(["steps"])},"on-step-failure":{attributes:new Set(["steps"])},"on-step-complete":{attributes:new Set(["steps"])},"on-success":{attributes:new Set},"on-error":{attributes:new Set},"on-cancel":{attributes:new Set},"on-complete":{attributes:new Set},triggers:{attributes:new Set},manual:{attributes:new Set(["id"])},webhook:{attributes:new Set(["id","path","method","auth","secret"])},schema:{attributes:new Set},steps:{attributes:new Set},step:{attributes:new Set(["id","name","description","retry","retry-backoff","retry-delay","retry-max-delay"]),stagedAttributes:new Set(["timeout"])},script:{attributes:new Set},branch:{attributes:new Set(["id","name","description"])},choose:{attributes:new Set(["id","name","description"])},switch:{attributes:new Set(["id","name","description","value"])},case:{attributes:new Set(["value"])},default:{attributes:new Set},fork:{attributes:new Set(["id","join"])},parallel:{attributes:new Set(["id","name","description","concurrency","on-error"])},when:{attributes:new Set(["test"])},otherwise:{attributes:new Set},result:{attributes:new Set(["value"])},approval:{attributes:new Set(["id","name","description","timeout","on-timeout"])},notify:{attributes:new Set},slack:{attributes:new Set(["id","events","channels","message","bot-token","app-token"])},telegram:{attributes:new Set(["id","events","chats","message","bot-token"])},discord:{attributes:new Set(["id","events","channels","message","bot-token"])},whatsapp:{attributes:new Set(["id","events","recipients","message","access-token","phone-number-id","verify-token","app-secret","template","language"])},schedule:{attributes:new Set(["id","cron","timezone","on-missed"])},interval:{attributes:new Set(["id","every","on-missed"])},event:{attributes:new Set(["id","name","secret"])},"when-approved":{attributes:new Set},"when-rejected":{attributes:new Set}},ZF=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,M9=/^[a-z][A-Za-z0-9]*$/,XF=/^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?$/,GF=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)+$/,QF=/^[a-z][A-Za-z0-9]*$/,SF=/^(?:\.\/|\.\.\/)(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\.(?:js|ts)$/,RF=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/,XZ=/^sha256:[0-9a-f]{64}$/,UF=/^[A-Za-z_$][A-Za-z0-9_$]*$/,GZ=1e6,QZ=1e6,zF=31536000000,VF=new Set(["http","db","storage","cache","events","queue","workflows","state","context","attempt","services","secrets"]);function EZ(W,O,M,L,$,Y){return{code:M,phase:O,message:L,file:W.file,location:$,...Y===void 0?{}:{hint:Y}}}function E(W,O,M,L,$){throw new oO(EZ(W,"validation",O,M,L,$))}function wW(W,O,M,L,$){throw new GO(EZ(W,"compile",O,M,L,$))}function qZ(W,O,M){if(!YF.has(O.name)){if(M?.name==="lifecycle"&&O.name==="on-failure")E(W,"WOML_LIFECYCLE_HOOK_INVALID","WOML lifecycle uses <on-error>, not <on-failure>.",O.openTagSpan,"Replace <on-failure> with <on-error>; the same hook name is used in workflows and reusable definitions.");if(M?.name==="notify")E(W,"WOML_NOTIFY_UNSUPPORTED_PROVIDER",`<notify> supports built-in <slack>, <telegram>, <discord>, and imported custom providers; found <${O.name}>.`,O.openTagSpan);if(JF.has(O.name))E(W,"WOML_FEATURE_NOT_EXECUTABLE",`<${O.name}> is designed but is not executable in the first WOML CLI profile.`,O.openTagSpan);E(W,"WOML_UNKNOWN_ELEMENT",`Unknown WOML element <${O.name}>.`,O.openTagSpan)}let L=AF[O.name];for(let $ of Object.values(O.attributes)){if(L.stagedAttributes?.has($.name)===!0)E(W,"WOML_FEATURE_NOT_EXECUTABLE",`Attribute "${$.name}" on <${O.name}> is designed but is not executable in the first WOML CLI profile.`,$.nameSpan);if(!L.attributes.has($.name)){let Y=$.name==="steps"&&O.name.startsWith("on-")&&!O.name.startsWith("on-step-");E(W,Y?"WOML_LIFECYCLE_STEP_FILTER_INVALID":$.name==="retry"||$.name.startsWith("retry-")?"WOML_RETRY_HANDLER_UNSUPPORTED":O.name==="slack"?"WOML_SLACK_UNKNOWN_ATTRIBUTE":O.name==="telegram"?"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE":O.name==="discord"?"WOML_DISCORD_UNKNOWN_ATTRIBUTE":O.name==="whatsapp"?"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE":O.name==="config"?"WOML_CONFIG_ATTRIBUTE_UNKNOWN":"WOML_UNKNOWN_ATTRIBUTE",Y?'Attribute "steps" is valid only on step lifecycle hooks.':$.name==="retry"||$.name.startsWith("retry-")?`Retry attributes are valid only on <step>; found "${$.name}" on <${O.name}>.`:`Unknown attribute "${$.name}" on <${O.name}>.`,$.nameSpan,$.name==="retry"||$.name.startsWith("retry-")?"Move the retry policy to a script-bearing <step>.":void 0)}}for(let $ of O.children)if($.kind==="element")qZ(W,$,O)}function BZ(W,O){for(let M of Object.values(O.attributes)){let L=O.name==="slack"&&(M.name==="bot-token"||M.name==="app-token"),$=O.name==="telegram"&&M.name==="bot-token",Y=O.name==="discord"&&M.name==="bot-token",J=O.name==="whatsapp"&&(M.name==="access-token"||M.name==="verify-token"||M.name==="app-secret"),A=O.name==="webhook"&&M.name==="secret",Z=O.name==="event"&&M.name==="secret";if(L||$||Y||J||A||Z){RW(W,M);continue}if(RL(M.value)!==void 0||M.value.includes("{{secrets."))E(W,"WOML_SECRET_SINK_UNSUPPORTED","Secret references are allowed only in reviewed secret-bearing attributes. Direct script access and arbitrary attribute interpolation are unavailable.",M.valueSpan)}for(let M of O.children)if(M.kind==="element")BZ(W,M)}function OW(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_MISSING_ATTRIBUTE",`<${O.name}> requires the "${M}" attribute.`,O.openTagSpan);return L}function XW(W,O){let M=[];for(let L of O.children){if(L.kind!=="element")E(W,"WOML_UNEXPECTED_CONTENT",`<${O.name}> may contain WOML elements only.`,L.span);M.push(L)}return M}function OO(W,O){if(O.children.length>0)E(W,"WOML_INVALID_STRUCTURE",`<${O.name}> cannot contain child content in the first WOML CLI profile.`,O.children[0].span)}function HF(W,O){if(O.value.length>256||!ZF.test(O.value))E(W,"WOML_INVALID_ID",`Workflow ID "${O.value}" must use lowercase kebab-case.`,O.valueSpan,"Example: content-moderator");return O.value}function QO(W,O,M){if(O.value.length>256||!M9.test(O.value))E(W,"WOML_INVALID_ID",`${M==="trigger"?"Trigger":M==="branch"?"Branch":M==="choose"?"Choice":M==="switch"?"Switch":M==="fork"?"Fork":M==="parallel"?"Parallel":M==="approval"?"Approval":"Step"} ID "${O.value}" must be a JavaScript-safe lower-camel identifier.`,O.valueSpan,"Use letters and numbers, start with a lowercase letter, and do not use hyphens.");return O.value}function YM(W,O,M){let L=O.attributes[M];if(L===void 0)return;if(L.value.trim().length===0)E(W,"WOML_EMPTY_METADATA",`Attribute "${M}" on <${O.name}> must not be empty.`,L.valueSpan);return L.value}function KF(W,O){let M=YM(W,O,"name"),L=YM(W,O,"description"),$=YM(W,O,"version");if(M===void 0&&L===void 0&&$===void 0)return;return{...M===void 0?{}:{name:M},...L===void 0?{}:{description:L},...$===void 0?{}:{version:$}}}function AM(W,O){let M=YM(W,O,"name"),L=YM(W,O,"description");if(M===void 0&&L===void 0)return;return{...M===void 0?{}:{name:M},...L===void 0?{}:{description:L}}}function TF(W,O){let M=XW(W,O),L=M.filter((U)=>U.name==="config"),$=M.filter((U)=>U.name==="lifecycle"),Y=M.filter((U)=>U.name==="triggers"),J=M.filter((U)=>U.name==="steps");if(L.length>1)E(W,"WOML_CONFIG_DUPLICATE",`<workflow> accepts at most one <config> element; found ${L.length}.`,L[1]?.openTagSpan??O.openTagSpan);if($.length>1)E(W,"WOML_LIFECYCLE_DUPLICATE",`<workflow> accepts at most one <lifecycle> container; found ${$.length}.`,$[1]?.openTagSpan??O.openTagSpan);if(Y.length>1)E(W,"WOML_TRIGGER_CONTAINER_COUNT",`<workflow> accepts at most one <triggers> container; found ${Y.length}.`,Y[1]?.openTagSpan??O.openTagSpan);if(J.length!==1)E(W,"WOML_STEPS_CONTAINER_COUNT",`<workflow> requires exactly one <steps> container; found ${J.length}.`,J[1]?.openTagSpan??O.openTagSpan);let A=Y[0],Z=L[0],X=$[0],G=J[0],Q=new Set(["config","lifecycle","triggers","steps"]),S=M.find((U)=>!Q.has(U.name));if(S!==void 0)E(W,"WOML_INVALID_STRUCTURE",`<workflow> cannot contain <${S.name}> directly.`,S.openTagSpan,"Use optional <config>, <lifecycle>, and <triggers> containers plus exactly one <steps> container, in any order.");return[Z,X,A,G]}function SZ(W,O,M){let L=/^(?:(?:[1-9][0-9]*)(?:\.[0-9]+)?|0\.[0-9]*[1-9][0-9]*)(ms|s|m|h|d)$/.exec(O.value);if(L===null)E(W,M,`Policy duration "${O.value}" must be positive and include ms, s, m, h, or d.`,O.valueSpan,"Examples: 500ms, 10s, 5m, 2h, 1d");let J=Number(O.value.slice(0,-L[1].length))*{ms:1,s:1000,m:60000,h:3600000,d:86400000}[L[1]];if(!Number.isSafeInteger(J)||J<1||J>zF)E(W,M,`Policy duration "${O.value}" must resolve to a whole number of milliseconds from 1ms through 365d.`,O.valueSpan);return J}function FF(W,O){if(O.children.length>0)E(W,"WOML_CONFIG_CHILD_NOT_ALLOWED","<config> is data-only and cannot contain text or child elements.",O.children[0].span,"Declare workflow runtime policy through <config> attributes only.");if(Object.keys(O.attributes).length===0)E(W,"WOML_CONFIG_EMPTY","<config> requires at least one runtime-policy attribute.",O.openTagSpan,"Add concurrency, timeout, rate-limit, or queue; otherwise remove <config>.");let M=O.attributes.concurrency,L;if(M!==void 0){if(!/^[1-9][0-9]*$/.test(M.value))E(W,"WOML_CONFIG_CONCURRENCY_INVALID",`Workflow concurrency "${M.value}" must be a positive integer.`,M.valueSpan);if(L=Number(M.value),!Number.isSafeInteger(L)||L>GZ)E(W,"WOML_CONFIG_CONCURRENCY_INVALID",`Workflow concurrency must be between 1 and ${GZ}.`,M.valueSpan)}let $=O.attributes.timeout,Y=$===void 0?void 0:SZ(W,$,"WOML_CONFIG_TIMEOUT_INVALID"),J=O.attributes["rate-limit"],A;if(J!==void 0){let G=J.value.indexOf("/"),Q=J.value.slice(0,G),S=J.value.slice(G+1);if(G<=0||J.value.indexOf("/",G+1)!==-1||!/^[1-9][0-9]*$/.test(Q)||S.length===0)E(W,"WOML_CONFIG_RATE_LIMIT_INVALID",`Rate limit "${J.value}" must use positive-integer/duration syntax.`,J.valueSpan,"Example: 100/1m");let U=Number(Q);if(!Number.isSafeInteger(U)||U>QZ)E(W,"WOML_CONFIG_RATE_LIMIT_INVALID",`Rate-limit count must be between 1 and ${QZ}.`,J.valueSpan);let V=new n(W.file,W.source),R=J.valueSpan.start.offset+G+1,K={name:J.name,value:S,nameSpan:J.nameSpan,valueSpan:V.span(R,J.valueSpan.end.offset),span:J.span};A={count:U,windowMs:SZ(W,K,"WOML_CONFIG_RATE_LIMIT_INVALID"),algorithm:"rolling_window"}}let Z=O.attributes.queue,X;if(Z!==void 0){if(Z.value.length>128||!RF.test(Z.value))E(W,"WOML_CONFIG_QUEUE_INVALID",`Queue name "${Z.value}" must be a lowercase dot, underscore, or kebab identifier.`,Z.valueSpan,"Examples: orders, moderation-high, agents.inbound");X={name:Z.value,discipline:"work_conserving_fifo"}}return{element:O,value:{profileVersion:1,...L===void 0?{}:{concurrency:L},...Y===void 0?{}:{timeoutMs:Y},...A===void 0?{}:{rateLimit:A},...X===void 0?{}:{queue:X}}}}function wZ(W,O,M){let L=M==="webhook"?"webhook":"event",$=M==="webhook"?"WOML_WEBHOOK":"WOML_EVENT";if(Object.keys(O.attributes).length>0){let U=Object.values(O.attributes)[0];E(W,"WOML_UNKNOWN_ATTRIBUTE",`Unknown attribute "${U.name}" on <schema>.`,U.nameSpan)}let Y=O.children.find((U)=>U.kind!=="text");if(Y!==void 0)E(W,`${$}_SCHEMA_STRUCTURE_INVALID`,"<schema> must contain inline JSON only.",Y.span);let A=O.children.filter((U)=>U.kind==="text").map((U)=>U.value).join(""),Z=O.children[0]?.span??O.openTagSpan,X;try{X=JSON.parse(A)}catch(U){let V=U instanceof SyntaxError?/position\s+(\d+)/i.exec(U.message)?.[1]:void 0,R=V===void 0?0:Number(V),K=new n(W.file,W.source),T=Math.min(Z.start.offset+R,Z.end.offset);E(W,`${$}_SCHEMA_JSON_INVALID`,"<schema> must contain valid JSON.",K.span(T,Math.min(T+1,Z.end.offset)))}if(X===null||typeof X!=="object"||Array.isArray(X))E(W,`${$}_SCHEMA_INVALID`,"<schema> must contain a JSON Schema object.",Z);let G=new FZ.default({allErrors:!0,strict:!1}),Q=!1,S;try{if(Q=G.validateSchema(X)===!0,Q)G.compile(X)}catch(U){Q=!1,S=U instanceof Error?U.message:void 0}if(!Q){let V=G.errors?.[0]?.message??S;E(W,`${$}_SCHEMA_INVALID`,`Inline ${L} JSON Schema is invalid${V===void 0?".":`: ${V}.`}`,Z)}return X}function EF(W,O){let M=QO(W,OW(W,O,"id"),"trigger"),L=OW(W,O,"path");if(L.value.length>2048||!XF.test(L.value)||L.value==="/_woml"||L.value.startsWith("/_woml/"))E(W,"WOML_WEBHOOK_PATH_INVALID",`Webhook path "${L.value}" must be an exact absolute route without parameters, wildcards, repeated slashes, or the reserved /_woml prefix.`,L.valueSpan);let $=O.attributes.method;if($!==void 0&&$.value!=="POST")E(W,"WOML_WEBHOOK_METHOD_UNSUPPORTED",`Webhook method "${$.value}" is not executable in Webhook HTTP v1; use POST.`,$.valueSpan);let Y=OW(W,O,"auth"),J;if(Y.value==="none"){let X=O.attributes.secret;if(X!==void 0)E(W,"WOML_WEBHOOK_AUTH_INVALID",'A webhook with auth="none" must not declare a secret.',X.nameSpan);J={kind:"none"}}else if(Y.value==="bearer")J={kind:"bearer",secret:RW(W,OW(W,O,"secret"))};else E(W,"WOML_WEBHOOK_AUTH_INVALID",`Webhook auth "${Y.value}" must be "bearer" or "none".`,Y.valueSpan);let A=XW(W,O);if(A.length>1||A.length===1&&A[0].name!=="schema"){let X=A.find((G)=>G.name!=="schema")??A[1];E(W,"WOML_WEBHOOK_STRUCTURE_INVALID","<webhook> may contain at most one inline <schema>.",X?.openTagSpan??O.openTagSpan)}let Z=A[0]===void 0?void 0:wZ(W,A[0],"webhook");return{kind:"webhook",id:M,path:L.value,method:"POST",authentication:J,...Z===void 0?{}:{schema:Z}}}function qF(W,O){OO(W,O);let M=QO(W,OW(W,O,"id"),"trigger"),L=OW(W,O,"cron");try{a4(L.value)}catch(J){let A=J instanceof sW?J.reason:"cron does not match WOML Cron v1";E(W,"WOML_SCHEDULE_CRON_INVALID",`Schedule cron is invalid: ${A}.`,L.valueSpan,"Use five numeric fields: minute hour day-of-month month day-of-week. Lists, ranges, and /steps are supported.")}let $=O.attributes.timezone?.value??"UTC";if(!o4($))E(W,"WOML_SCHEDULE_TIMEZONE_INVALID",`Schedule timezone "${$}" is not a canonical IANA timezone identifier.`,O.attributes.timezone?.valueSpan??O.openTagSpan,"Examples: UTC, Europe/Berlin, America/New_York");let Y=O.attributes["on-missed"]?.value??"skip";if(Y!=="skip"&&Y!=="run-once")E(W,"WOML_TRIGGER_MISFIRE_INVALID",`Schedule on-missed must be "skip" or "run-once", found "${Y}".`,O.attributes["on-missed"].valueSpan);return{kind:"schedule",id:M,cron:L.value,timezone:$,onMissed:Y}}function BF(W,O){OO(W,O);let M=QO(W,OW(W,O,"id"),"trigger"),L=OW(W,O,"every"),$=/^([1-9][0-9]*)(ms|s|m|h|d)$/.exec(L.value);if($===null)E(W,"WOML_INTERVAL_INVALID",`Interval every="${L.value}" must be one positive whole duration using ms, s, m, h, or d.`,L.valueSpan,"Examples: 1s, 5m, 24h, 30d");let Y=Number($[1])*n0[$[2]];if(!Number.isSafeInteger(Y)||Y<n0.s||Y>n0.d*30)E(W,"WOML_INTERVAL_INVALID",`Interval every="${L.value}" must resolve to a whole duration from 1s through 30d.`,L.valueSpan);let J=O.attributes["on-missed"]?.value??"skip";if(J!=="skip"&&J!=="run-once")E(W,"WOML_TRIGGER_MISFIRE_INVALID",`Interval on-missed must be "skip" or "run-once", found "${J}".`,O.attributes["on-missed"].valueSpan);return{kind:"interval",id:M,everyMs:Y,onMissed:J}}function wF(W,O){let M=QO(W,OW(W,O,"id"),"trigger"),L=OW(W,O,"name"),$=O.attributes.secret,Y=$===void 0?void 0:RW(W,$);if(L.value.length>256||!GF.test(L.value))E(W,"WOML_EVENT_NAME_INVALID",`Event name "${L.value}" must start with a lowercase letter and contain at least two lowercase alphanumeric segments separated by one dot, underscore, or hyphen.`,L.valueSpan,"Examples: order.created, payment_failed, agent-response");let J=XW(W,O);if(J.length>1||J.length===1&&J[0].name!=="schema"){let Z=J.find((X)=>X.name!=="schema")??J[1];E(W,"WOML_EVENT_STRUCTURE_INVALID","<event> may contain at most one inline <schema>.",Z?.openTagSpan??O.openTagSpan)}let A=J[0]===void 0?void 0:wZ(W,J[0],"event");return{kind:"event",id:M,name:L.value,...Y===void 0?{}:{secret:Y},...A===void 0?{}:{schema:A}}}function CF(W,O){let M=XW(W,O);if(M.length===0)E(W,"WOML_TRIGGER_REQUIRED","<triggers> requires at least one executable trigger.",O.openTagSpan);if(M.length>64)E(W,"WOML_MODULE_ALIAS_LIMIT_EXCEEDED",`<imports> declares ${M.length} modules; Module profile v1 allows at most 64.`,M[64].openTagSpan);let L=M.map((Y)=>{if(Y.name==="manual")return OO(W,Y),{kind:"manual",id:QO(W,OW(W,Y,"id"),"trigger")};if(Y.name==="webhook")return EF(W,Y);if(Y.name==="slack")return fF(W,Y);if(Y.name==="telegram")return xF(W,Y);if(Y.name==="discord")return hF(W,Y);if(Y.name==="whatsapp")return dF(W,Y);if(Y.name==="schedule")return qF(W,Y);if(Y.name==="interval")return BF(W,Y);if(Y.name==="event")return wF(W,Y);E(W,"WOML_TRIGGER_UNSUPPORTED",`<${Y.name}> is not an executable trigger in this release.`,Y.openTagSpan)}),$=new Set;for(let Y=0;Y<L.length;Y+=1){let J=L[Y];if($.has(J.id))E(W,"WOML_TRIGGER_ID_DUPLICATE",`Trigger ID "${J.id}" is already used in this workflow.`,OW(W,M[Y],"id").valueSpan);$.add(J.id)}return L}function CZ(W,O){let M=O.children.filter((L)=>L.kind==="raw");if(O.children.some((L)=>L.kind!=="raw")||M.length>1)E(W,"WOML_INVALID_STRUCTURE","<script> must contain one raw JavaScript body and no WOML child elements.",O.children[0]?.span??O.openTagSpan);return{source:M[0]?.value??"",span:M[0]?.span??O.openTagSpan}}function NF(W,O,M=[]){let L=F8(O.source,{shadowedServices:M});if(L.issue===void 0)return L;let $=new n(W.file,W.source),Y=O.span.start.offset+L.issue.start,J=O.span.start.offset+L.issue.end;E(W,L.issue.code,L.issue.message,$.span(Y,Math.max(Y+1,J)),L.issue.hint)}function PF(W,O,M){let L=O.value.indexOf(M,16),$=O.valueSpan.start.offset+L;return new n(W.file,W.source).span($,$+M.length)}function JM(W,O){let M=/^\{\{(context\.(?:(?:payload|trigger)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|steps\.([a-z][A-Za-z0-9]*)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*))\}\}$/.exec(O.value);if(M===null)E(W,"WOML_INVALID_REFERENCE",`Attribute "${O.name}" must contain exactly one WOML context reference.`,O.valueSpan,"Example: {{context.steps.checkContent.needsReview}}");let L=M[2],$=L===void 0?O.valueSpan:PF(W,O,L);return{path:M[1].split(".").slice(1).map((Y,J)=>J===0&&Y==="payload"?"trigger":Y),...L===void 0?{}:{structuralId:L},span:$}}function o0(W,O,M,L){let $=QO(W,M,L);if(O.has($))E(W,"WOML_DUPLICATE_ID",`Structural ID "${$}" is duplicated across workflow steps, choices, forks, parallel groups, and approvals.`,M.valueSpan);return O.add($),$}var n0={ms:1,s:1000,m:60000,h:3600000,d:86400000},_F=n0.h*24;function RZ(W,O,M){let L=/^(?:(?:[1-9][0-9]*)(?:\.[0-9]+)?|0\.[0-9]*[1-9][0-9]*)(ms|s|m|h|d)$/.exec(O.value);if(L===null)E(W,M,`Retry duration "${O.value}" must be a positive duration using ms, s, m, h, or d.`,O.valueSpan,"Examples: 500ms, 1s, 30m, 24h");let Y=Number(O.value.slice(0,-L[1].length))*n0[L[1]];if(!Number.isSafeInteger(Y)||Y<1||Y>_F)E(W,M,`Retry duration "${O.value}" must resolve to a whole number of milliseconds from 1ms through 24h.`,O.valueSpan);return Y}function jF(W,O){let M=O.attributes.retry,L=O.attributes["retry-backoff"],$=O.attributes["retry-delay"],Y=O.attributes["retry-max-delay"],J=L??$??Y;if(M===void 0){if(J!==void 0)E(W,"WOML_RETRY_BACKOFF_REQUIRES_RETRY",`Attribute "${J.name}" requires retry greater than 1 on the same <step>.`,J.nameSpan);return}if(!/^[1-9][0-9]*$/.test(M.value))E(W,"WOML_RETRY_INVALID",`Retry "${M.value}" must be an integer from 1 through 10.`,M.valueSpan);let A=Number(M.value);if(!Number.isSafeInteger(A)||A>10)E(W,"WOML_RETRY_INVALID",`Retry "${M.value}" must be an integer from 1 through 10.`,M.valueSpan);if(A===1){if(J!==void 0)E(W,"WOML_RETRY_BACKOFF_REQUIRES_RETRY",`Attribute "${J.name}" requires retry greater than 1 on the same <step>.`,J.nameSpan);return}let Z=L?.value??"exponential";if(Z!=="fixed"&&Z!=="exponential")E(W,"WOML_RETRY_BACKOFF_INVALID",`Retry backoff must be "fixed" or "exponential", found "${Z}".`,L.valueSpan);let X=$===void 0?1000:RZ(W,$,"WOML_RETRY_DELAY_INVALID");if(Z==="fixed"){if(Y!==void 0)E(W,"WOML_RETRY_MAX_DELAY_NOT_ALLOWED",'Attribute "retry-max-delay" is available only with exponential retry backoff.',Y.nameSpan);return{maxAttempts:A,backoff:{kind:"fixed",delayMs:X}}}let G=Y===void 0?Math.max(30000,X):RZ(W,Y,"WOML_RETRY_MAX_DELAY_INVALID");if(G<X)E(W,"WOML_RETRY_MAX_DELAY_INVALID",'Attribute "retry-max-delay" must be greater than or equal to "retry-delay".',Y.valueSpan);return{maxAttempts:A,backoff:{kind:"exponential",initialDelayMs:X,multiplier:2,maximumDelayMs:G}}}function IF(W,O){let M=O.attributes.timeout,L=O.attributes["on-timeout"];if(M===void 0){if(L!==void 0)E(W,"WOML_APPROVAL_TIMEOUT_INVALID","<approval> cannot declare on-timeout without a timeout.",L.nameSpan);return}let $=/^(?:(?:[1-9][0-9]*)(?:\.[0-9]+)?|0\.[0-9]*[1-9][0-9]*)(ms|s|m|h|d)$/.exec(M.value);if($===null)E(W,"WOML_APPROVAL_TIMEOUT_INVALID",`Approval timeout "${M.value}" must be a positive duration using ms, s, m, h, or d.`,M.valueSpan,"Examples: 500ms, 30m, 24h");let J=Number(M.value.slice(0,-$[1].length))*n0[$[1]];if(!Number.isSafeInteger(J)||J<1)E(W,"WOML_APPROVAL_TIMEOUT_INVALID",`Approval timeout "${M.value}" must resolve to a positive safe integer number of milliseconds.`,M.valueSpan);return J}function UZ(W,O,M,L){return XW(W,O).map(($)=>t0(W,$,M,`<${O.name}>`,L))}var yF=/^#[a-z0-9][a-z0-9_-]{0,79}$/,DF=/^[CG][A-Z0-9]{8,31}$/,kF=/^[a-z0-9][a-z0-9_-]{0,79}$/,bF=/^[CGD][A-Z0-9]{8,31}$/;function vO(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_SLACK_ATTRIBUTE_REQUIRED",`<slack> requires the "${M}" attribute.`,O.openTagSpan);return L}function NZ(W,O){let M=new n(W.file,W.source),L=[...O.value.matchAll(/\S+/g)].map(($)=>{let Y=O.valueSpan.start.offset+($.index??0);return{value:$[0],span:M.span(Y,Y+$[0].length)}});if(L.length===0)E(W,"WOML_SLACK_CHANNELS_EMPTY","<slack> channels must contain at least one channel alias or conversation ID.",O.valueSpan);for(let $ of L)if(!yF.test($.value)&&!DF.test($.value))E(W,"WOML_SLACK_CHANNEL_INVALID",`Slack destination "${$.value}" must be a lowercase #channel alias or a Slack conversation ID.`,$.span,"Examples: #approvals or C0123456789");return L}function zZ(W,O,M){let L=new n(W.file,W.source),$=[],Y=0;for(let J of O.value.split(",")){let A=J.length-J.trimStart().length,Z=J.trim(),X=O.valueSpan.start.offset+Y+A;if(Z.length===0)E(W,"WOML_SLACK_TRIGGER_LIST_INVALID",`<slack> ${M} must be a comma-separated list without empty items.`,L.span(X,X));$.push({value:Z,span:L.span(X,X+Z.length)}),Y+=J.length+1}return $}function fF(W,O){if(OO(W,O),O.attributes.message!==void 0)E(W,"WOML_SLACK_UNKNOWN_ATTRIBUTE",'Attribute "message" is valid on lifecycle notifications, not a Slack trigger.',O.attributes.message.nameSpan);let M=QO(W,OW(W,O,"id"),"trigger"),L=zZ(W,OW(W,O,"events"),"events"),$=[],Y=new Set;for(let G of L){if(G.value!=="app-mention"&&G.value!=="direct-message")E(W,"WOML_SLACK_TRIGGER_EVENT_INVALID",`Unsupported Slack trigger event "${G.value}".`,G.span,"Use app-mention, direct-message, or both.");if(Y.has(G.value))E(W,"WOML_SLACK_TRIGGER_EVENT_DUPLICATE",`Slack trigger event "${G.value}" is listed more than once.`,G.span);Y.add(G.value),$.push(G.value)}let J=O.attributes.channels,A=J===void 0?[]:zZ(W,J,"channels"),Z=[],X=new Set;for(let G of A){if(!kF.test(G.value)&&!bF.test(G.value))E(W,"WOML_SLACK_TRIGGER_CHANNEL_INVALID",`Slack trigger channel "${G.value}" must be a lowercase channel name or Slack conversation ID.`,G.span,"Examples: woml-testing or C0123456789");if(X.has(G.value))E(W,"WOML_SLACK_TRIGGER_CHANNEL_DUPLICATE",`Slack trigger channel "${G.value}" is listed more than once.`,G.span);X.add(G.value),Z.push(G.value)}return{kind:"slack",id:M,events:$,channels:Z,botToken:RW(W,vO(W,O,"bot-token")),appToken:RW(W,vO(W,O,"app-token"))}}var vF=/^-?[1-9][0-9]{0,19}$/;function r0(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_TELEGRAM_ATTRIBUTE_REQUIRED",`<telegram> requires the "${M}" attribute.`,O.openTagSpan);return L}function PZ(W,O,M){let L=new n(W.file,W.source),$=[],Y=0;for(let J of O.value.split(",")){let A=J.length-J.trimStart().length,Z=J.trim(),X=O.valueSpan.start.offset+Y+A;if(Z.length===0)E(W,"WOML_TELEGRAM_LIST_INVALID",`<telegram> ${M} must be a comma-separated list without empty items.`,L.span(X,X));$.push({value:Z,span:L.span(X,X+Z.length)}),Y+=J.length+1}return $}function xF(W,O){OO(W,O);for(let $ of["chats","message"]){let Y=O.attributes[$];if(Y!==void 0)E(W,"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE",`Attribute "${$}" is valid on a Telegram notification, not a trigger.`,Y.nameSpan)}let M=QO(W,OW(W,O,"id"),"trigger"),L=PZ(W,r0(W,O,"events"),"events");if(L.length!==1||L[0].value!=="message"){let $=L.find((J)=>J.value!=="message"),Y=$??L[1];E(W,$===void 0?"WOML_TELEGRAM_TRIGGER_EVENT_DUPLICATE":"WOML_TELEGRAM_TRIGGER_EVENT_INVALID",$===void 0?'Telegram trigger event "message" is listed more than once.':`Unsupported Telegram trigger event "${$.value}".`,Y?.span??O.openTagSpan,'Telegram v1 supports events="message".')}return{kind:"telegram",id:M,events:["message"],botToken:RW(W,r0(W,O,"bot-token"))}}function _Z(W,O){let M=PZ(W,r0(W,O,"chats"),"chats"),L=new Set;for(let $ of M){if(!vF.test($.value))E(W,"WOML_TELEGRAM_CHAT_INVALID",`Telegram chat "${$.value}" must be a numeric Telegram chat ID.`,$.span,"Use the positive user/chat ID or negative group/channel ID returned by Telegram.");if(L.has($.value))E(W,"WOML_TELEGRAM_CHAT_DUPLICATE",`Telegram chat "${$.value}" is listed more than once.`,$.span);L.add($.value)}return M}var gF=/^[0-9]{17,20}$/;function a0(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_DISCORD_ATTRIBUTE_REQUIRED",`<discord> requires the "${M}" attribute.`,O.openTagSpan);return L}function jZ(W,O,M){let L=new n(W.file,W.source),$=[],Y=0;for(let J of O.value.split(",")){let A=J.length-J.trimStart().length,Z=J.trim(),X=O.valueSpan.start.offset+Y+A;if(Z.length===0)E(W,"WOML_DISCORD_LIST_INVALID",`<discord> ${M} must be a comma-separated list without empty items.`,L.span(X,X));$.push({value:Z,span:L.span(X,X+Z.length)}),Y+=J.length+1}return $}function L9(W,O,M){let L=O.attributes.channels;if(L===void 0){if(M)a0(W,O,"channels");return[]}let $=jZ(W,L,"channels"),Y=new Set;for(let J of $){if(!gF.test(J.value))E(W,"WOML_DISCORD_CHANNEL_INVALID",`Discord channel "${J.value}" must be a numeric Discord channel ID containing 17 to 20 digits.`,J.span,"Enable Discord Developer Mode and copy the channel ID; channel names are not durable routing identities.");if(Y.has(J.value))E(W,"WOML_DISCORD_CHANNEL_DUPLICATE",`Discord channel "${J.value}" is listed more than once.`,J.span);Y.add(J.value)}return $}function hF(W,O){OO(W,O);let M=O.attributes.message;if(M!==void 0)E(W,"WOML_DISCORD_UNKNOWN_ATTRIBUTE",'Attribute "message" is valid on a Discord lifecycle notification, not a trigger.',M.nameSpan);let L=QO(W,OW(W,O,"id"),"trigger"),$=jZ(W,a0(W,O,"events"),"events"),Y=[],J=new Set;for(let A of $){if(A.value!=="app-mention"&&A.value!=="direct-message")E(W,"WOML_DISCORD_TRIGGER_EVENT_INVALID",`Unsupported Discord trigger event "${A.value}".`,A.span,"Discord v1 supports app-mention and direct-message. Slash commands are deferred.");if(J.has(A.value))E(W,"WOML_DISCORD_TRIGGER_EVENT_DUPLICATE",`Discord trigger event "${A.value}" is listed more than once.`,A.span);J.add(A.value),Y.push(A.value)}return{kind:"discord",id:L,events:Y,channels:L9(W,O,!1).map((A)=>A.value),botToken:RW(W,a0(W,O,"bot-token"))}}var uF=/^[1-9][0-9]{5,19}$/,lF=/^[1-9][0-9]{7,15}$/,pF=/^[a-z0-9_]+$/,mF=/^[a-z]{2,3}(?:_[A-Z]{2})?$/;function EO(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_WHATSAPP_ATTRIBUTE_REQUIRED",`<whatsapp> requires the "${M}" attribute.`,O.openTagSpan);return L}function IZ(W,O){let M=EO(W,O,"template");if(!pF.test(M.value))E(W,"WOML_WHATSAPP_TEMPLATE_INVALID",`WhatsApp template "${M.value}" must contain lowercase letters, digits, and underscores only.`,M.valueSpan,"Use the exact approved Meta template name, for example woml_approval_v1.");let L=EO(W,O,"language");if(!mF.test(L.value))E(W,"WOML_WHATSAPP_LANGUAGE_INVALID",`WhatsApp template language "${L.value}" is invalid.`,L.valueSpan,"Use a language code such as en, en_US, or pt_BR.");return{templateName:M.value,language:L.value}}function yZ(W,O){let M=EO(W,O,"recipients"),L=new n(W.file,W.source),$=[],Y=new Set,J=0;for(let A of M.value.split(",")){let Z=A.length-A.trimStart().length,X=A.trim(),G=M.valueSpan.start.offset+J+Z,Q=L.span(G,G+X.length);if(!lF.test(X))E(W,"WOML_WHATSAPP_RECIPIENT_INVALID",`WhatsApp recipient "${X}" must be an international phone number containing 8 to 16 digits without a plus sign or spaces.`,Q,'Example: recipients="15551234567".');if(Y.has(X))E(W,"WOML_WHATSAPP_RECIPIENT_DUPLICATE",`WhatsApp recipient "${X}" is listed more than once.`,Q);Y.add(X),$.push({value:X,span:Q}),J+=A.length+1}return $}function $9(W,O){let M=EO(W,O,"phone-number-id");if(!uF.test(M.value))E(W,"WOML_WHATSAPP_PHONE_NUMBER_ID_INVALID","WhatsApp phone-number-id must be the numeric Meta Phone Number ID, not the display phone number.",M.valueSpan);return M.value}function dF(W,O){OO(W,O);for(let L of["recipients","message","access-token","template","language"]){let $=O.attributes[L];if($!==void 0)E(W,"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE",`Attribute "${L}" is valid on a WhatsApp notification, not a trigger.`,$.nameSpan)}let M=EO(W,O,"events");if(M.value!=="message")E(W,"WOML_WHATSAPP_TRIGGER_EVENT_INVALID",`Unsupported WhatsApp trigger event "${M.value}".`,M.valueSpan,'WhatsApp v1 supports events="message"; delivery-status callbacks never create workflow runs.');return{kind:"whatsapp",id:QO(W,OW(W,O,"id"),"trigger"),events:["message"],phoneNumberId:$9(W,O),verifyToken:RW(W,EO(W,O,"verify-token")),appSecret:RW(W,EO(W,O,"app-secret"))}}function cF(W,O,M){let L=XW(W,O);if(L.length===0)E(W,"WOML_NOTIFY_EMPTY","<notify> must contain at least one notification provider.",O.openTagSpan);let $=new Set,Y=[];return L.forEach((J,A)=>{if(J.name!=="slack"&&J.name!=="telegram"&&J.name!=="discord"&&J.name!=="whatsapp")E(W,"WOML_NOTIFY_UNSUPPORTED_PROVIDER",`<notify> supports built-in <slack>, <telegram>, <discord>, and <whatsapp> providers; found <${J.name}>.`,J.openTagSpan);OO(W,J);for(let Q of["id","events","message","verify-token","app-secret"]){let S=J.attributes[Q];if(S!==void 0)E(W,J.name==="telegram"?"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE":J.name==="discord"?"WOML_DISCORD_UNKNOWN_ATTRIBUTE":J.name==="whatsapp"?"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE":"WOML_SLACK_UNKNOWN_ATTRIBUTE",Q==="message"?'Attribute "message" is valid on a lifecycle notification, not an approval notification.':`Attribute "${Q}" is valid on a ${J.name==="telegram"?"Telegram":J.name==="discord"?"Discord":J.name==="whatsapp"?"WhatsApp":"Slack"} trigger, not a notification provider.`,S.nameSpan)}if(J.name==="telegram"){let Q=_Z(W,J),S=RW(W,r0(W,J,"bot-token"));Q.forEach((U,V)=>{let R=`telegram\x00${S.name}\x00${U.value}`;if($.has(R))E(W,"WOML_TELEGRAM_CHAT_DUPLICATE",`Telegram destination "${U.value}" is duplicated for the same credential.`,U.span);$.add(R),Y.push({deliveryId:`${M}:notify:${A}:chat:${V}`,provider:"telegram",destination:U.value,botToken:S})});return}if(J.name==="discord"){let Q=L9(W,J,!0),S=RW(W,a0(W,J,"bot-token"));Q.forEach((U,V)=>{let R=`discord\x00${S.name}\x00${U.value}`;if($.has(R))E(W,"WOML_DISCORD_CHANNEL_DUPLICATE",`Discord destination "${U.value}" is duplicated for the same credential.`,U.span);$.add(R),Y.push({deliveryId:`${M}:notify:${A}:channel:${V}`,provider:"discord",destination:U.value,botToken:S})});return}if(J.name==="whatsapp"){let Q=yZ(W,J),S=RW(W,EO(W,J,"access-token")),U=$9(W,J),{templateName:V,language:R}=IZ(W,J);Q.forEach((K,T)=>{let F=`whatsapp\x00${S.name}\x00${U}\x00${K.value}`;if($.has(F))E(W,"WOML_WHATSAPP_RECIPIENT_DUPLICATE",`WhatsApp recipient "${K.value}" is duplicated for the same credential and phone identity.`,K.span);$.add(F),Y.push({deliveryId:`${M}:notify:${A}:recipient:${T}`,provider:"whatsapp",destination:K.value,accessToken:S,phoneNumberId:U,templateName:V,language:R})});return}let Z=NZ(W,vO(W,J,"channels")),X=RW(W,vO(W,J,"bot-token")),G=RW(W,vO(W,J,"app-token"));Z.forEach((Q,S)=>{let U=`${X.name}\x00${G.name}\x00${Q.value}`;if($.has(U))E(W,"WOML_SLACK_CHANNEL_DUPLICATE",`Slack destination "${Q.value}" is duplicated for the same credential set.`,Q.span);$.add(U),Y.push({deliveryId:`${M}:notify:${A}:channel:${S}`,provider:"slack",destination:Q.value,botToken:X,appToken:G})})}),Y}function iF(W,O,M,L){let $=o0(W,M,OW(W,O,"id"),"approval"),Y=XW(W,O),J=Y.filter((S)=>S.name==="notify"),A=Y.filter((S)=>S.name==="when-approved"),Z=Y.filter((S)=>S.name==="when-rejected"),X=Y.find((S)=>S.name!=="notify"&&S.name!=="when-approved"&&S.name!=="when-rejected");if(X!==void 0)E(W,"WOML_APPROVAL_STRUCTURE_INVALID",`<approval id="${$}"> may contain optional <notify>, then <when-approved> and <when-rejected> only.`,X.openTagSpan);if(J.length>1||J.length===1&&Y[0]!==J[0])E(W,"WOML_NOTIFY_INVALID_ORDER","<notify> may appear once and must be the first child of <approval>.",J[1]?.openTagSpan??J[0]?.openTagSpan??O.openTagSpan);if(A.length!==1||Z.length!==1){let S=A[1]??Z[1];E(W,"WOML_APPROVAL_STRUCTURE_INVALID",`<approval id="${$}"> requires exactly one <when-approved> and one <when-rejected>.`,S?.openTagSpan??O.openTagSpan)}if(Y.length!==2+J.length||Y[J.length]!==A[0]||Y[J.length+1]!==Z[0])E(W,"WOML_APPROVAL_STRUCTURE_INVALID","<when-approved> must appear before <when-rejected> inside <approval>.",Y[0]?.openTagSpan??O.openTagSpan);let G=O.attributes["on-timeout"],Q=G?.value??"fail";if(Q!=="reject"&&Q!=="fail")E(W,"WOML_APPROVAL_TIMEOUT_INVALID",`Approval on-timeout must be "reject" or "fail", found "${Q}".`,G.valueSpan);return{kind:"approval",id:$,element:O,metadata:AM(W,O),timeoutMs:IF(W,O),onTimeout:Q,notifications:J.length===0?[]:cF(W,J[0],$),approvedItems:UZ(W,A[0],M,L),rejectedItems:UZ(W,Z[0],M,L)}}function DZ(W,O,M,L=[]){let $=o0(W,M,OW(W,O,"id"),"step"),Y=XW(W,O);if(Y.length!==1||Y[0].name!=="script")E(W,"WOML_STEP_OPERATION_COUNT",`<step id="${$}"> must contain exactly one <script> operation.`,Y[1]?.openTagSpan??Y[0]?.openTagSpan??O.openTagSpan);let J=CZ(W,Y[0]);return{kind:"step",id:$,source:J.source,scriptSpan:J.span,scriptAnalysis:NF(W,J,L),retryPolicy:jF(W,O),metadata:AM(W,O)}}var kZ={"on-start":"run_start","on-step-start":"step_start","on-step-success":"step_success","on-step-failure":"step_failure","on-step-complete":"step_complete","on-success":"run_success","on-error":"run_failure","on-cancel":"run_cancel","on-complete":"run_complete"},e8=Object.keys(kZ);function sF(W,O,M,L,$,Y){let A=new n(W.file,W.source).span(O.valueSpan.start.offset+L,O.valueSpan.start.offset+L+M.length),Z=/^context\.(payload(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+|steps\.([a-z][A-Za-z0-9]*)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+)$/.exec(M);if(Z!==null){if(Z[2]!==void 0&&!Y.has(Z[2]))E(W,"WOML_LIFECYCLE_STEP_UNKNOWN",`Lifecycle template references unknown executable step "${Z[2]}".`,A);return{kind:"contextReference",path:Z[1].split(".").map((U,V)=>V===0&&U==="payload"?"trigger":U)}}let X=/^lifecycle\.(event|workflow\.(?:id|outcome)|step\.(?:id|outcome|attempts)|failure\.(?:code|message))$/.exec(M);if(X===null)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Unsupported lifecycle template reference "${M}".`,A,"Use a scalar context.payload, context.steps, or reviewed lifecycle field.");let G=X[1].split("."),Q=$.startsWith("step_"),S=$==="step_success"||$==="step_failure"||$==="step_complete"||$==="run_success"||$==="run_failure"||$==="run_cancel"||$==="run_complete";if(G[0]==="step"&&!Q)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Reference "${M}" is unavailable for ${$}.`,A);if(G.at(-1)==="outcome"&&!S)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Reference "${M}" is unavailable before an outcome is decided.`,A);if(G[0]==="failure"&&$!=="step_failure"&&$!=="run_failure")E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Reference "${M}" is available only in failure hooks.`,A);return{kind:"lifecycleReference",path:G}}function nF(W,O,M,L){if(O.value.length===0||O.value.length>4096)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle notification messages must contain 1 through 4096 characters.",O.valueSpan);let $=[],Y=0,J=0;for(let Z of O.value.matchAll(/\{\{([^{}]+)\}\}/g)){let X=Z.index??0,G=O.value.slice(Y,X);if(G.includes("{{")||G.includes("}}"))E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle message contains an unmatched WOML template delimiter.",O.valueSpan);if(G.length>0)$.push({kind:"text",text:G});let Q=Z[1].trim(),S=X+Z[0].indexOf(Q);$.push(sF(W,O,Q,S,M,L)),J+=1,Y=X+Z[0].length}let A=O.value.slice(Y);if(A.includes("{{")||A.includes("}}"))E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle message contains an unmatched WOML template delimiter.",O.valueSpan);if(A.length>0)$.push({kind:"text",text:A});if(J>32)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle messages may contain at most 32 placeholders.",O.valueSpan);return{kind:"template",parts:$}}function rF(W,O,M,L,$,Y){let J=XW(W,O);if(J.length===0)E(W,"WOML_LIFECYCLE_ACTION_REQUIRED","<notify> must contain at least one notification provider.",O.openTagSpan);let A=new Set,Z=[];return J.forEach((X,G)=>{if(X.name!=="slack"&&X.name!=="telegram"&&X.name!=="discord"&&X.name!=="whatsapp")E(W,"WOML_NOTIFY_UNSUPPORTED_PROVIDER",`<notify> supports built-in <slack>, <telegram>, <discord>, and <whatsapp> providers; found <${X.name}>.`,X.openTagSpan);OO(W,X);for(let R of["id","events","verify-token","app-secret"]){let K=X.attributes[R];if(K!==void 0)E(W,X.name==="telegram"?"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE":X.name==="discord"?"WOML_DISCORD_UNKNOWN_ATTRIBUTE":X.name==="whatsapp"?"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE":"WOML_SLACK_UNKNOWN_ATTRIBUTE",`Attribute "${R}" is valid on a ${X.name==="telegram"?"Telegram":X.name==="discord"?"Discord":X.name==="whatsapp"?"WhatsApp":"Slack"} trigger, not a lifecycle notification.`,K.nameSpan)}let Q=nF(W,X.name==="telegram"?r0(W,X,"message"):X.name==="discord"?a0(W,X,"message"):X.name==="whatsapp"?EO(W,X,"message"):vO(W,X,"message"),M,Y);if(X.name==="telegram"){let R=_Z(W,X),K=RW(W,r0(W,X,"bot-token"));R.forEach((T,F)=>{let N=`telegram\x00${K.name}\x00${T.value}`;if(A.has(N))E(W,"WOML_TELEGRAM_CHAT_DUPLICATE",`Telegram destination "${T.value}" is duplicated for the same credential.`,T.span);A.add(N),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${G}:chat:${F}`,provider:"telegram",destination:T.value,botToken:K,message:Q})});return}if(X.name==="discord"){let R=L9(W,X,!0),K=RW(W,a0(W,X,"bot-token"));R.forEach((T,F)=>{let N=`discord\x00${K.name}\x00${T.value}`;if(A.has(N))E(W,"WOML_DISCORD_CHANNEL_DUPLICATE",`Discord destination "${T.value}" is duplicated for the same credential.`,T.span);A.add(N),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${G}:channel:${F}`,provider:"discord",destination:T.value,botToken:K,message:Q})});return}if(X.name==="whatsapp"){let R=yZ(W,X),K=RW(W,EO(W,X,"access-token")),T=$9(W,X),{templateName:F,language:N}=IZ(W,X);R.forEach((C,w)=>{let B=`whatsapp\x00${K.name}\x00${T}\x00${C.value}`;if(A.has(B))E(W,"WOML_WHATSAPP_RECIPIENT_DUPLICATE",`WhatsApp recipient "${C.value}" is duplicated for the same credential and phone identity.`,C.span);A.add(B),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${G}:recipient:${w}`,provider:"whatsapp",destination:C.value,accessToken:K,phoneNumberId:T,templateName:F,language:N,message:Q})});return}let S=NZ(W,vO(W,X,"channels")),U=RW(W,vO(W,X,"bot-token")),V=RW(W,vO(W,X,"app-token"));S.forEach((R,K)=>{let T=`${U.name}\x00${V.name}\x00${R.value}`;if(A.has(T))E(W,"WOML_SLACK_CHANNEL_DUPLICATE",`Slack destination "${R.value}" is duplicated for the same credential set.`,R.span);A.add(T),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${G}:channel:${K}`,provider:"slack",destination:R.value,botToken:U,appToken:V,message:Q})})}),{kind:"notify",deliveries:Z}}function aF(W,O,M,L=[]){let $=XW(W,O);if($.length===0)E(W,"WOML_LIFECYCLE_ACTION_REQUIRED","<lifecycle> must contain at least one lifecycle hook.",O.openTagSpan);let Y=W0(M.items),J=new Set(Y.map((G)=>G.id)),A=new Set;for(let G of $){if(e8.indexOf(G.name)===-1)E(W,"WOML_LIFECYCLE_ACTION_INVALID",`<lifecycle> cannot contain <${G.name}>.`,G.openTagSpan);if(A.has(G.name))E(W,"WOML_LIFECYCLE_DUPLICATE",`<${G.name}> may appear only once in <lifecycle>.`,G.openTagSpan);A.add(G.name)}return{hooks:[...$].sort((G,Q)=>e8.indexOf(G.name)-e8.indexOf(Q.name)).map((G,Q)=>{let S=kZ[G.name],U=G.attributes.steps,V=S.startsWith("step_"),R;if(U!==void 0){if(!V)E(W,"WOML_LIFECYCLE_STEP_FILTER_INVALID",'Attribute "steps" is valid only on step lifecycle hooks.',U.nameSpan);let F=U.value.trim().split(/\s+/).filter(Boolean);if(F.length===0||new Set(F).size!==F.length)E(W,"WOML_LIFECYCLE_STEP_FILTER_INVALID","Lifecycle step filters must be a non-empty list of unique step IDs.",U.valueSpan);for(let N of F){if(!M9.test(N))E(W,"WOML_LIFECYCLE_STEP_FILTER_INVALID",`Lifecycle step filter "${N}" is not a valid step ID.`,U.valueSpan);if(!J.has(N))E(W,"WOML_LIFECYCLE_STEP_UNKNOWN",`Lifecycle step filter names unknown executable step "${N}".`,U.valueSpan)}R=F}let K=XW(W,G);if(K.length===0)E(W,"WOML_LIFECYCLE_ACTION_REQUIRED",`<${G.name}> requires at least one <script> or <notify> action.`,G.openTagSpan);let T=K.map((F,N)=>{if(F.name==="script"){let C=CZ(W,F),w=VL(C.source,{shadowedServices:L});if(w.issue!==void 0){let B=new n(W.file,W.source),I=C.span.start.offset+w.issue.start;E(W,w.issue.code,w.issue.message,B.span(I,Math.max(I+1,C.span.start.offset+w.issue.end)),w.issue.hint)}return{kind:"script",source:C.source,scriptSpan:C.span,scriptAnalysis:w}}if(F.name==="notify")return rF(W,F,S,Q,N,J);E(W,"WOML_LIFECYCLE_ACTION_INVALID",`<${G.name}> supports <script> and <notify> actions only.`,F.openTagSpan)});return{event:S,...R===void 0?{}:{stepIds:R},actions:T}})}}function s0(W,O=new Map){for(let M of W){if(M.kind==="step"){O.set(M.id,M.scriptAnalysis);continue}if(M.kind==="parallel"){for(let L of M.children)O.set(L.id,L.scriptAnalysis);continue}if(M.kind==="branch"){for(let L of M.arms)s0(L.items,O);continue}if(M.kind==="controlChoice"||M.kind==="switch"){for(let L of M.arms)s0(L.items,O);continue}if(M.kind==="fork"){for(let L of M.branches)s0(L.items,O);continue}s0(M.approvedItems,O),s0(M.rejectedItems,O)}return O}var oF=new Set(["http","db","storage","cache","events","workflows","state","telegram","discord","whatsapp"]);function W0(W,O=[]){for(let M of W)if(M.kind==="step")O.push(M);else if(M.kind==="parallel")O.push(...M.children);else if(M.kind==="branch")for(let L of M.arms)W0(L.items,O);else if(M.kind==="controlChoice"||M.kind==="switch")for(let L of M.arms)W0(L.items,O);else if(M.kind==="fork")for(let L of M.branches)W0(L.items,O);else W0(M.approvedItems,O),W0(M.rejectedItems,O);return O}function $M(W,O=[]){for(let M of W)if(M.kind==="approval")O.push(...M.notifications),$M(M.approvedItems,O),$M(M.rejectedItems,O);else if(M.kind==="branch"||M.kind==="controlChoice"||M.kind==="switch")for(let L of M.arms)$M(L.items,O);else if(M.kind==="fork")for(let L of M.branches)$M(L.items,O);return O}function tF(W){let O=XM(W),M=O.lifecycle?.hooks.flatMap((Y)=>Y.actions.flatMap((J)=>J.kind==="script"?[J.scriptAnalysis]:[]))??[],L=[...new Set([...W0(O.flow.items).map((Y)=>Y.scriptAnalysis),...M].flatMap((Y)=>Y.requiredServices))].sort(),$=O.modules.map((Y)=>Y.name);return{referencedServices:L,referencedModules:L.filter((Y)=>$.includes(Y)),unusedModules:$.filter((Y)=>!L.includes(Y))}}var eF=["context","attempt","services","secrets"],WE=["context","lifecycle","attempt","services","secrets"];function VZ(W,O){return W.map((M)=>{if(M.handler!=="runtime.script")return M;let L={bindingVersion:1,bindings:eF,requiredSecrets:O.get(M.id)?.requiredSecrets??[]};return{...M,scriptRuntime:L}})}function OE(W){return{profileVersion:1,hooks:W.hooks.map((O)=>{let M=`lifecycle:${O.event}`,L=O.actions.map((Y,J)=>{let A=`${M}:action:${J}`;if(Y.kind==="script"){let Z={bindingVersion:2,bindings:WE,requiredSecrets:Y.scriptAnalysis.requiredSecrets};return{actionId:A,handler:"runtime.lifecycle-script",inputs:{kind:"object",fields:{source:{kind:"literal",value:Y.source}}},scriptRuntime:Z}}return{actionId:A,handler:"notification.informational",inputs:{kind:"object",fields:{deliveries:{kind:"array",items:Y.deliveries.map((Z)=>({kind:"object",fields:{deliveryId:{kind:"literal",value:Z.deliveryId},provider:{kind:"literal",value:Z.provider},destination:{kind:"literal",value:Z.destination},credentials:bZ(Z),...Z.provider==="whatsapp"?{templateName:{kind:"literal",value:Z.templateName},language:{kind:"literal",value:Z.language}}:{},message:Z.message}}))}}}}});return{hookId:M,event:O.event,...O.stepIds===void 0?{}:{stepIds:O.stepIds},actions:L}})}}function bZ(W){return W.provider==="slack"?{kind:"object",fields:{botToken:W.botToken,appToken:W.appToken}}:W.provider==="whatsapp"?{kind:"object",fields:{accessToken:W.accessToken,phoneNumberId:{kind:"literal",value:W.phoneNumberId}}}:{kind:"object",fields:{botToken:W.botToken}}}function ME(W,O,M,L,$){let Y=L==="choose"?"WOML_CHOOSE":"WOML_BRANCH",J=O.name==="when"?JM(W,OW(W,O,"test")):void 0,A=XW(W,O),Z=A.filter((U)=>U.name==="result");if(Z.length!==1)E(W,`${Y}_RESULT_REQUIRED`,`<${O.name}> must contain exactly one <result>.`,Z[1]?.openTagSpan??O.openTagSpan);let X=Z[0];if(A.at(-1)!==X)E(W,`${Y}_RESULT_ORDER`,`<result> must be the final child of its <${L}> arm.`,X.openTagSpan);OO(W,X);let G=A.slice(0,-1);if(G.length===0)E(W,"WOML_INVALID_STRUCTURE",`<${O.name}> must contain at least one step item before <result>.`,O.openTagSpan);let Q=G.map((U)=>t0(W,U,M,`<${O.name}>`,$)),S=JM(W,OW(W,X,"value"));if(O.name==="when")return{kind:"when",element:O,test:J,items:Q,result:S};return{kind:"otherwise",element:O,items:Q,result:S}}function HZ(W,O,M,L){let $=O.name,Y=$==="choose"?"WOML_CHOOSE":"WOML_BRANCH",J=o0(W,M,OW(W,O,"id"),$),A=AM(W,O),Z=XW(W,O);if(Z.filter((S)=>S.name==="when").length===0)E(W,`${Y}_WHEN_REQUIRED`,`<${$} id="${J}"> requires at least one <when>.`,O.openTagSpan);let G=Z.flatMap((S,U)=>S.name==="otherwise"?[U]:[]);if(G.length===0)E(W,`${Y}_OTHERWISE_REQUIRED`,`<${$} id="${J}"> requires exactly one final <otherwise>.`,O.openTagSpan);if(G.length>1)E(W,`${Y}_OTHERWISE_ORDER`,`<otherwise> may appear exactly once and must be the final <${$}> case.`,Z[G[1]].openTagSpan);let Q=G[0];if(Q!==Z.length-1)E(W,`${Y}_OTHERWISE_ORDER`,`<otherwise> must be the final child of <${$}>.`,Z[Q].openTagSpan);for(let S=0;S<Q;S+=1)if(Z[S].name!=="when")E(W,"WOML_INVALID_STRUCTURE",`<${$}> cannot contain <${Z[S].name}> outside a <when> or <otherwise> arm.`,Z[S].openTagSpan);return{kind:"branch",sourceElementName:$,id:J,element:O,metadata:A,arms:Z.map((S)=>ME(W,S,M,$,L))}}function LE(W,O,M,L){let $=O.name==="when"?JM(W,OW(W,O,"test")):void 0,Y=XW(W,O),J=Y.find((Z)=>Z.name==="result");if(J!==void 0)E(W,"WOML_CHOOSE_RESULT_REQUIRES_ID","A control-only <choose> must not contain <result>; add an id to the choice to publish a merged result.",J.openTagSpan,'Either remove every <result>, or add id="..." and end every arm with exactly one <result>.');if(Y.length===0)E(W,"WOML_CHOOSE_ARM_EMPTY",`<${O.name}> in a control-only <choose> must contain at least one flow item.`,O.openTagSpan);let A=Y.map((Z)=>t0(W,Z,M,`<${O.name}>`,L));return O.name==="when"?{kind:"when",element:O,test:$,items:A}:{kind:"otherwise",element:O,items:A}}function $E(W,O,M,L){let $=O.attributes.name??O.attributes.description;if($!==void 0)E(W,"WOML_CHOOSE_METADATA_REQUIRES_ID",`Attribute "${$.name}" is available only on a result-producing <choose id="...">.`,$.nameSpan,"Remove the display metadata or add an id and one final <result> to every arm.");let Y=XW(W,O);if(Y.filter((X)=>X.name==="when").length===0)E(W,"WOML_CHOOSE_WHEN_REQUIRED","<choose> requires at least one <when>.",O.openTagSpan);let A=Y.flatMap((X,G)=>X.name==="otherwise"?[G]:[]);if(A.length===0)E(W,"WOML_CHOOSE_OTHERWISE_REQUIRED","<choose> requires exactly one final <otherwise>.",O.openTagSpan);if(A.length>1)E(W,"WOML_CHOOSE_OTHERWISE_ORDER","<otherwise> may appear exactly once and must be the final <choose> case.",Y[A[1]].openTagSpan);let Z=A[0];if(Z!==Y.length-1)E(W,"WOML_CHOOSE_OTHERWISE_ORDER","<otherwise> must be the final child of <choose>.",Y[Z].openTagSpan);for(let X=0;X<Z;X+=1)if(Y[X].name!=="when")E(W,"WOML_INVALID_STRUCTURE",`<choose> cannot contain <${Y[X].name}> outside a <when> or <otherwise> arm.`,Y[X].openTagSpan);return{kind:"controlChoice",element:O,arms:Y.map((X)=>LE(W,X,M,L))}}function YE(W,O,M,L,$){let Y=XW(W,O),J=Y.filter((G)=>G.name==="result"),A,Z=Y;if($){if(J.length!==1)E(W,"WOML_SWITCH_RESULT_REQUIRED",`<${O.name}> must contain exactly one final <result> because its <switch> has an id.`,J[1]?.openTagSpan??O.openTagSpan);if(Y.at(-1)!==J[0])E(W,"WOML_SWITCH_RESULT_ORDER",`<result> must be the final child of <${O.name}>.`,J[0].openTagSpan);OO(W,J[0]),A=JM(W,OW(W,J[0],"value")),Z=Y.slice(0,-1)}else if(J.length>0)E(W,"WOML_SWITCH_RESULT_REQUIRES_ID","A control-only <switch> cannot contain <result>; add an id to publish one merged result.",J[0].openTagSpan);if(Z.length===0)E(W,"WOML_SWITCH_ARM_EMPTY",`<${O.name}> must contain at least one flow item${$?" before <result>":""}.`,O.openTagSpan);let X=Z.map((G)=>t0(W,G,M,`<${O.name}>`,L));if(O.name==="case"){let G=OW(W,O,"value");if(G.value.length===0)E(W,"WOML_SWITCH_CASE_VALUE_EMPTY",'<case value="..."> requires a non-empty string.',G.valueSpan);return{kind:"case",element:O,value:G.value,items:X,...A===void 0?{}:{result:A}}}return{kind:"default",element:O,items:X,...A===void 0?{}:{result:A}}}function JE(W,O,M,L){let $=O.attributes.id,Y=$===void 0?void 0:o0(W,M,$,"switch"),J=O.attributes.name??O.attributes.description;if(Y===void 0&&J!==void 0)E(W,"WOML_SWITCH_METADATA_REQUIRES_ID",`Attribute "${J.name}" is available only on a result-producing <switch id="...">.`,J.nameSpan);let A=JM(W,OW(W,O,"value")),Z=XW(W,O);if(Z.filter((S)=>S.name==="case").length===0)E(W,"WOML_SWITCH_CASE_REQUIRED","<switch> requires at least one <case>.",O.openTagSpan);let G=Z.flatMap((S,U)=>S.name==="default"?[U]:[]);if(G.length!==1||G[0]!==Z.length-1)E(W,"WOML_SWITCH_DEFAULT_ORDER","<switch> requires exactly one final <default>.",Z[G[1]??G[0]??0]?.openTagSpan??O.openTagSpan);let Q=new Set;for(let S=0;S<Z.length-1;S+=1){let U=Z[S];if(U.name!=="case")E(W,"WOML_SWITCH_STRUCTURE_INVALID",`<switch> accepts <case> children followed by one <default>; found <${U.name}>.`,U.openTagSpan);let V=OW(W,U,"value");if(Q.has(V.value))E(W,"WOML_SWITCH_CASE_DUPLICATE",`Switch case value "${V.value}" is declared more than once.`,V.valueSpan);Q.add(V.value)}return{kind:"switch",...Y===void 0?{}:{id:Y},element:O,...Y===void 0?{}:{metadata:AM(W,O)},selector:A,arms:Z.map((S)=>YE(W,S,M,L,Y!==void 0))}}function AE(W,O){let M=new n(W.file,W.source),L=[...O.value.matchAll(/[^\t\n\r ]+/g)].map(($)=>{let Y=O.valueSpan.start.offset+($.index??0);return{value:$[0],span:M.span(Y,Y+$[0].length)}});if(L.length===0)E(W,"WOML_FORK_JOIN_INVALID",'Fork join must be "all", "none", or one or more direct branch IDs.',O.valueSpan);return L}function ZE(W,O,M,L){let $=o0(W,M,OW(W,O,"id"),"fork"),Y=XW(W,O);if(Y.length===0)E(W,"WOML_FORK_EMPTY",`<fork id="${$}"> must contain at least one direct <branch>.`,O.openTagSpan);let J=Y.find((U)=>U.name!=="branch");if(J!==void 0)E(W,"WOML_FORK_CHILD_INVALID",`<fork id="${$}"> accepts direct <branch> children only; found <${J.name}>.`,J.openTagSpan);let A=new Set,Z={...L,insideForkBranch:!0},X=Y.map((U)=>{for(let T of Object.values(U.attributes))if(T.name!=="id")E(W,"WOML_FORK_BRANCH_ATTRIBUTE_UNSUPPORTED",`Fork branch <branch> accepts only "id"; found "${T.name}".`,T.nameSpan);let V=OW(W,U,"id"),R=QO(W,V,"branch");if(R==="all"||R==="none")E(W,"WOML_FORK_BRANCH_ID_RESERVED",`Fork branch ID "${R}" is reserved by the join grammar.`,V.valueSpan,"Choose a descriptive branch ID such as instagram or analytics.");if(A.has(R))E(W,"WOML_FORK_BRANCH_ID_DUPLICATE",`Fork branch ID "${R}" is duplicated inside <fork id="${$}">.`,V.valueSpan);A.add(R);let K=XW(W,U);if(K.length===0)E(W,"WOML_FORK_BRANCH_EMPTY",`<branch id="${R}"> must contain at least one flow item.`,U.openTagSpan);return{id:R,element:U,items:K.map((T)=>t0(W,T,M,`<branch id="${R}">`,Z))}}),G=O.attributes.join;if(G===void 0)return{kind:"fork",id:$,element:O,branches:X,joinedBranchIds:X.map((U)=>U.id)};let Q=AE(W,G);if(Q.length===1&&Q[0].value==="all")return{kind:"fork",id:$,element:O,branches:X,joinedBranchIds:X.map((U)=>U.id)};if(Q.length===1&&Q[0].value==="none")return{kind:"fork",id:$,element:O,branches:X,joinedBranchIds:[]};let S=new Set;for(let U of Q){if(U.value==="all"||U.value==="none")E(W,"WOML_FORK_JOIN_INVALID",`Reserved join value "${U.value}" cannot be mixed with branch IDs.`,U.span);if(!M9.test(U.value))E(W,"WOML_FORK_JOIN_INVALID",`Fork join item "${U.value}" must be a JavaScript-safe branch ID.`,U.span);if(!A.has(U.value))E(W,"WOML_FORK_JOIN_UNKNOWN_BRANCH",`Fork join names unknown direct branch "${U.value}".`,U.span);if(S.has(U.value))E(W,"WOML_FORK_JOIN_DUPLICATE",`Fork join lists branch "${U.value}" more than once.`,U.span);S.add(U.value)}return{kind:"fork",id:$,element:O,branches:X,joinedBranchIds:X.filter((U)=>S.has(U.id)).map((U)=>U.id)}}function XE(W,O,M,L){let $=o0(W,M,OW(W,O,"id"),"parallel"),Y=AM(W,O),J=XW(W,O);if(J.length===0)E(W,"WOML_PARALLEL_EMPTY",`<parallel id="${$}"> must contain at least one direct <step> child.`,O.openTagSpan);let A=J.find((U)=>U.name!=="step");if(A!==void 0){if(A.name==="approval")E(W,"WOML_APPROVAL_PLACEMENT_INVALID",`<approval> cannot be a direct child of <parallel id="${$}"> in this profile.`,A.openTagSpan,"Place the approval before or after the parallel group, or inside a selected branch arm.");E(W,"WOML_PARALLEL_CHILD_UNSUPPORTED",`<parallel id="${$}"> accepts direct <step> children only in this profile; found <${A.name}>.`,A.openTagSpan,"Move branching around the parallel group, or wait for a future explicit lane/sequence construct.")}let Z=J.map((U)=>DZ(W,U,M,L.shadowedServices)),X=O.attributes.concurrency,G=Z.length;if(X!==void 0){if(!/^[1-9][0-9]*$/.test(X.value))E(W,"WOML_PARALLEL_INVALID_CONCURRENCY",`Parallel concurrency "${X.value}" must be a positive integer.`,X.valueSpan);if(G=Number(X.value),!Number.isSafeInteger(G)||G>Z.length)E(W,"WOML_PARALLEL_INVALID_CONCURRENCY",`Parallel concurrency must not exceed its ${Z.length} direct child${Z.length===1?"":"ren"}.`,X.valueSpan)}let Q=O.attributes["on-error"],S=Q?.value??"fail-fast";if(S!=="fail-fast"&&S!=="wait-all")E(W,"WOML_PARALLEL_INVALID_POLICY",`Parallel on-error must be "fail-fast" or "wait-all", found "${S}".`,Q.valueSpan);return{kind:"parallel",id:$,element:O,metadata:Y,concurrency:G,onError:S,children:Z}}function t0(W,O,M,L,$){if(O.name==="step")return DZ(W,O,M,$.shadowedServices);if(O.name==="branch"){if($.insideForkBranch)E(W,"WOML_FORK_BRANCH_CHILD_INVALID","A fork-owned <branch> supports <step>, <choose>, <switch>, <parallel>, and <approval> flow items; nested conditional flow uses <choose> or <switch>.",O.openTagSpan);if(!O.children.some((J)=>J.kind==="element"&&(J.name==="when"||J.name==="otherwise")))E(W,"WOML_FORK_BRANCH_PLACEMENT_INVALID","A route <branch> is valid only as a direct child of <fork>. Conditional flow uses <choose>.",O.openTagSpan,"Wrap route branches in <fork>, or rename an intended conditional container to <choose>.");return HZ(W,O,M,$)}if(O.name==="choose")return O.attributes.id===void 0?$E(W,O,M,$):HZ(W,O,M,$);if(O.name==="switch")return JE(W,O,M,$);if(O.name==="case"||O.name==="default")E(W,"WOML_SWITCH_ARM_PLACEMENT_INVALID",`<${O.name}> is valid only as a direct child of <switch>.`,O.openTagSpan);if(O.name==="fork"){if($.insideForkBranch)E(W,"WOML_FORK_NESTED_UNSUPPORTED","A <fork> cannot appear anywhere inside a fork-owned branch in Fork v1.",O.openTagSpan,"Move the nested fan-out outside the branch or use <parallel> for direct concurrent steps.");return ZE(W,O,M,$)}if(O.name==="parallel")return XE(W,O,M,$);if(O.name==="approval")return iF(W,O,M,$);if(O.name==="when-approved"||O.name==="when-rejected")E(W,"WOML_APPROVAL_PLACEMENT_INVALID",`<${O.name}> is valid only as a direct child of <approval>.`,O.openTagSpan);if(O.name==="notify"||O.name==="slack"||O.name==="telegram"||O.name==="discord")E(W,"WOML_NOTIFY_INVALID_ORDER",O.name==="notify"?"<notify> is valid only as the first direct child of <approval>.":`<${O.name}> is valid only as a direct child of <notify>.`,O.openTagSpan);E(W,"WOML_INVALID_STRUCTURE",`${L} cannot contain <${O.name}> as a flow item.`,O.openTagSpan)}function MM(W,O,M,L,$){let Y=O.structuralId;if(Y===void 0)return;if(!M.has(Y))wW(W,"WOML_UNKNOWN_REFERENCE",`Reference names unknown structural ID "${Y}".`,O.span);if(!L.has(Y)){if($.has(Y))wW(W,"WOML_FORK_REFERENCE_NOT_VISIBLE",`Output "${Y}" belongs to an unjoined or sibling fork branch and is not visible on this route.`,O.span,"Reference an output from the current branch, or include the producing branch in the fork join before reading it on the continuation route.");wW(W,"WOML_REFERENCE_NOT_DOMINATING",`Output "${Y}" is not guaranteed to be available at this reference.`,O.span)}}function H0(W,O=new Set){for(let M of W)if(M.kind==="step")O.add(M.id);else if(M.kind==="parallel")for(let L of M.children)O.add(L.id);else if(M.kind==="branch"){O.add(M.id);for(let L of M.arms)H0(L.items,O)}else if(M.kind==="controlChoice"||M.kind==="switch"){if(M.kind==="switch"&&M.id!==void 0)O.add(M.id);for(let L of M.arms)H0(L.items,O)}else if(M.kind==="approval")O.add(M.id),H0(M.approvedItems,O),H0(M.rejectedItems,O);else for(let L of M.branches)H0(L.items,O);return O}function V0(W,O,M,L=new Set,$=new Set){let Y=new Set(L),J=new Set($);for(let A of O){if(A.kind==="step"){Y.add(A.id);continue}if(A.kind==="parallel"){for(let Z of A.children)Y.add(Z.id);continue}if(A.kind==="approval"){let Z=new Set(Y);Z.add(A.id),V0(W,A.approvedItems,M,Z,new Set(J)),V0(W,A.rejectedItems,M,Z,new Set(J)),Y.add(A.id);continue}if(A.kind==="fork"){let Z=new Map(A.branches.map((S)=>[S.id,H0(S.items)])),X=new Set([...Z.values()].flatMap((S)=>[...S])),G=new Map;for(let S of A.branches){let U=Z.get(S.id),V=new Set(J);for(let R of X)if(!U.has(R))V.add(R);G.set(S.id,V0(W,S.items,M,new Set(Y),V))}let Q=new Set(A.joinedBranchIds);for(let S of A.branches){let U=Z.get(S.id);if(Q.has(S.id)){let V=G.get(S.id);for(let R of U)if(V.has(R))Y.add(R)}else for(let V of U)J.add(V)}continue}if(A.kind==="controlChoice"){for(let Z of A.arms){if(Z.test!==void 0)MM(W,Z.test,M,Y,J);V0(W,Z.items,M,new Set(Y),new Set(J))}continue}if(A.kind==="switch"){MM(W,A.selector,M,Y,J);for(let Z of A.arms){let X=V0(W,Z.items,M,new Set(Y),new Set(J));if(Z.result!==void 0)MM(W,Z.result,M,X,J)}if(A.id!==void 0)Y.add(A.id);continue}for(let Z of A.arms){if(Z.test!==void 0)MM(W,Z.test,M,Y,J);let X=V0(W,Z.items,M,Y,new Set(J));MM(W,Z.result,M,X,J)}Y.add(A.id)}return Y}function GE(W,O,M=[]){let L=XW(W,O);if(L.length===0)E(W,"WOML_EMPTY_STEPS","<steps> must contain at least one step item.",O.openTagSpan);let $=new Set,Y=L.map((N)=>t0(W,N,$,"<steps>",{...$F,shadowedServices:M}));V0(W,Y,$);let J=Y.at(-1);if(J?.kind==="parallel")E(W,"WOML_PARALLEL_TERMINAL_UNSUPPORTED",`Root <parallel id="${J.id}"> cannot be the final workflow item because a parallel group has no aggregate result.`,J.element.openTagSpan,"Add a downstream <step> that builds the workflow result.");if(J?.kind==="fork"&&!Y.slice(0,-1).some((N)=>N.kind==="step"||N.kind==="branch"||N.kind==="approval"))E(W,"WOML_FORK_TERMINAL_RESULT_REQUIRED",`Terminal <fork id="${J.id}"> has no earlier value-producing main-route item to preserve as the workflow result.`,J.element.openTagSpan,"Add a value-producing <step> before the terminal fork or add a result-building step after it.");let A=(N)=>{for(let C of N){if(C.kind==="branch")return C.element;if(C.kind==="controlChoice"||C.kind==="switch")for(let w of C.arms){let B=A(w.items);if(B!==void 0)return B}if(C.kind==="fork")for(let w of C.branches){let B=A(w.items);if(B!==void 0)return B}if(C.kind==="approval"){let w=A(C.approvedItems);if(w!==void 0)return w;let B=A(C.rejectedItems);if(B!==void 0)return B}}return},Z=(N)=>{for(let C of N){if(C.kind==="parallel")return C.element;if(C.kind==="branch")for(let w of C.arms){let B=Z(w.items);if(B!==void 0)return B}if(C.kind==="controlChoice"||C.kind==="switch")for(let w of C.arms){let B=Z(w.items);if(B!==void 0)return B}if(C.kind==="fork")for(let w of C.branches){let B=Z(w.items);if(B!==void 0)return B}if(C.kind==="approval"){let w=Z(C.approvedItems);if(w!==void 0)return w;let B=Z(C.rejectedItems);if(B!==void 0)return B}}return},X=(N)=>{for(let C of N){if(C.kind==="approval")return C.element;if(C.kind==="branch")for(let w of C.arms){let B=X(w.items);if(B!==void 0)return B}if(C.kind==="controlChoice"||C.kind==="switch")for(let w of C.arms){let B=X(w.items);if(B!==void 0)return B}if(C.kind==="fork")for(let w of C.branches){let B=X(w.items);if(B!==void 0)return B}}return},G=(N)=>{for(let C of N){if(C.kind==="branch")for(let w of C.arms){let B=G(w.items);if(B!==void 0)return B}if(C.kind==="controlChoice"||C.kind==="switch")for(let w of C.arms){let B=G(w.items);if(B!==void 0)return B}if(C.kind==="fork")for(let w of C.branches){let B=G(w.items);if(B!==void 0)return B}if(C.kind==="approval"){if(C.notifications.length>0)return C.element;let w=G(C.approvedItems);if(w!==void 0)return w;let B=G(C.rejectedItems);if(B!==void 0)return B}}return},Q=A(Y),S=Z(Y),U=X(Y),V=G(Y),R=(N,C)=>{for(let w of N){if(w.kind===C)return w.element;if(w.kind==="branch"||w.kind==="controlChoice"||w.kind==="switch")for(let B of w.arms){let I=R(B.items,C);if(I!==void 0)return I}else if(w.kind==="approval"){let B=R(w.approvedItems,C);if(B!==void 0)return B;let I=R(w.rejectedItems,C);if(I!==void 0)return I}else if(w.kind==="fork")for(let B of w.branches){let I=R(B.items,C);if(I!==void 0)return I}}return},K=R(Y,"fork"),T=R(Y,"controlChoice"),F=R(Y,"switch");return{items:Y,...Q===void 0?{}:{firstBranch:Q},...S===void 0?{}:{firstParallel:S},...U===void 0?{}:{firstApproval:U},...V===void 0?{}:{firstNotification:V},...K===void 0?{}:{firstFork:K},...T===void 0?{}:{firstControlChoice:T},...F===void 0?{}:{firstSwitch:F}}}function Y9(W){let O={id:W.id,handler:"runtime.script",...W.metadata===void 0?{}:{metadata:W.metadata},...W.retryPolicy===void 0?{}:{retryPolicy:W.retryPolicy},inputs:{kind:"object",fields:{source:{kind:"literal",value:W.source}}}};return{entryId:W.id,exitId:W.id,nodes:[O],edges:[]}}function K0(W){return{kind:"contextReference",path:W.path}}function ZM(W,O){return{id:`${W}-to-${O}`,from:W,to:O,condition:{kind:"always"}}}function QE(W){let O=`__woml_branch__${W.id}__select`,M=W.arms.map((A)=>bL(A.items)),L=W.arms.map((A,Z)=>A.kind==="when"?`${W.id}:when:${Z}`:`${W.id}:otherwise`),$={id:O,handler:"engine.branch-select",inputs:{kind:"object",fields:{}},...W.metadata===void 0?{}:{metadata:W.metadata}},Y={id:W.id,handler:"engine.branch-result",inputs:{kind:"object",fields:Object.fromEntries(W.arms.map((A,Z)=>[L[Z],K0(A.result)]))}},J=W.arms.map((A,Z)=>({id:L[Z],from:O,to:M[Z].entryId,condition:A.kind==="when"?{kind:"boolean",value:K0(A.test)}:{kind:"always"},branchId:W.id}));return{entryId:O,exitId:W.id,nodes:[$,...M.flatMap((A)=>A.nodes),Y],edges:[...J,...M.flatMap((A)=>A.edges),...M.map((A)=>ZM(A.exitId,W.id))]}}function fZ(W){let O=`__woml_parallel__${W.id}__start`,M={id:O,handler:"engine.parallel-start",inputs:{kind:"object",fields:{concurrency:{kind:"literal",value:W.concurrency},onError:{kind:"literal",value:W.onError}}},...W.metadata===void 0?{}:{metadata:W.metadata}},L=W.children.map(Y9),$={id:W.id,handler:"engine.parallel-join",inputs:{kind:"object",fields:{}}},Y=L.map((A,Z)=>({id:`${W.id}:child:${Z}`,from:O,to:A.entryId,condition:{kind:"always"},parallelId:W.id})),J=L.map((A,Z)=>({id:`${W.id}:join:${Z}`,from:A.exitId,to:W.id,condition:{kind:"always"},parallelId:W.id}));return{entryId:O,exitId:W.id,nodes:[M,...L.flatMap((A)=>A.nodes),$],edges:[...Y,...L.flatMap((A)=>A.edges),...J]}}function kL(W,O,M){return{id:`${W}:${O}`,from:W,to:M,condition:{kind:"equals",left:{kind:"contextReference",path:["steps",W,"decision"]},right:{kind:"literal",value:O}},approvalId:W}}function vZ(W){let O=`__woml_approval__${W.id}__join`,M=W.approvedItems.length===0?void 0:bL(W.approvedItems),L=W.rejectedItems.length===0?void 0:bL(W.rejectedItems),$={...W.timeoutMs===void 0?{}:{timeoutMs:{kind:"literal",value:W.timeoutMs}},onTimeout:{kind:"literal",value:W.onTimeout},...W.notifications.length===0?{}:{notifications:{kind:"array",items:W.notifications.map((X)=>({kind:"object",fields:{deliveryId:{kind:"literal",value:X.deliveryId},provider:{kind:"literal",value:X.provider},destination:{kind:"literal",value:X.destination},credentials:bZ(X),...X.provider==="whatsapp"?{templateName:{kind:"literal",value:X.templateName},language:{kind:"literal",value:X.language}}:{}}}))}}},Y={id:W.id,handler:"engine.approval-wait",inputs:{kind:"object",fields:$},...W.metadata===void 0?{}:{metadata:W.metadata}},J={id:O,handler:"engine.approval-join",inputs:{kind:"object",fields:{}}},A=[kL(W.id,"approved",M?.entryId??O),kL(W.id,"rejected",L?.entryId??O)],Z=[...M===void 0?[]:[{id:`${W.id}:approved:join`,from:M.exitId,to:O,condition:{kind:"always"},approvalId:W.id}],...L===void 0?[]:[{id:`${W.id}:rejected:join`,from:L.exitId,to:O,condition:{kind:"always"},approvalId:W.id}]];return{entryId:W.id,exitId:O,nodes:[Y,...M?.nodes??[],...L?.nodes??[],J],edges:[...A,...M?.edges??[],...L?.edges??[],...Z]}}function SE(W){if(W.kind==="step")return Y9(W);if(W.kind==="branch")return QE(W);if(W.kind==="parallel")return fZ(W);if(W.kind==="approval")return vZ(W);throw Error("Model v13 flow reached legacy lowering before the FJ3 feature gate.")}function bL(W){let O=W.map(SE),M=[],L=[];for(let $=0;$<O.length;$+=1){let Y=O[$];if(M.push(...Y.nodes),$>0)L.push(ZM(O[$-1].exitId,Y.entryId));L.push(...Y.edges)}return{entryId:O[0].entryId,exitId:O.at(-1).exitId,nodes:M,edges:L}}function O0(W,O){return{id:W,handler:O,inputs:{kind:"object",fields:{}}}}function RE(W,O,M){return M.contextVisibility.push({nodeId:W.id,stepIds:[...O]}),{...Y9(W),visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function UE(W,O,M){for(let $ of W.children)M.contextVisibility.push({nodeId:$.id,stepIds:[...O]});return{...fZ(W),visibleAfter:new Set([...O,...W.children.map(($)=>$.id)])}}function zE(W,O,M,L){let $=`__woml_branch__${W.id}__select`,Y=W.arms.map((G,Q)=>T0(G.items,new Set(O),`${M}_arm_${Q}`,L)),J=W.arms.map((G,Q)=>G.kind==="when"?`${W.id}:when:${Q}`:`${W.id}:otherwise`),A={id:$,handler:"engine.branch-select",inputs:{kind:"object",fields:{}},...W.metadata===void 0?{}:{metadata:W.metadata}},Z={id:W.id,handler:"engine.branch-result",inputs:{kind:"object",fields:Object.fromEntries(W.arms.map((G,Q)=>[J[Q],K0(G.result)]))}},X=W.arms.map((G,Q)=>({id:J[Q],from:$,to:Y[Q].entryId,condition:G.kind==="when"?{kind:"boolean",value:K0(G.test)}:{kind:"always"},branchId:W.id}));return{entryId:$,exitId:W.id,nodes:[A,...Y.flatMap((G)=>G.nodes),Z],edges:[...X,...Y.flatMap((G)=>G.edges),...Y.map((G)=>ZM(G.exitId,W.id))],visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function VE(W,O,M,L){let $=`__woml_choice__${M}`,Y=`${$}__select`,J=`${$}__join`,A=W.arms.map((X,G)=>T0(X.items,new Set(O),`${M}_arm_${G}`,L)),Z=W.arms.map((X,G)=>X.kind==="when"?`${$}:when:${G}`:`${$}:otherwise`);return L.choices.push({choiceId:$,selectorNodeId:Y,joinNodeId:J,armIds:Z}),{entryId:Y,exitId:J,nodes:[O0(Y,"engine.choice-select"),...A.flatMap((X)=>X.nodes),O0(J,"engine.choice-join")],edges:[...W.arms.map((X,G)=>({id:Z[G],from:Y,to:A[G].entryId,condition:X.kind==="when"?{kind:"boolean",value:K0(X.test)}:{kind:"always"}})),...A.flatMap((X)=>X.edges),...A.map((X,G)=>({id:`${Z[G]}:join`,from:X.exitId,to:J,condition:{kind:"always"}}))],visibleAfter:new Set(O)}}function HE(W,O,M,L){let $=`__woml_choice__${M}_switch`,Y=`${$}__select`,J=`${$}__join`,A=W.arms.map((S,U)=>T0(S.items,new Set(O),`${M}_arm_${U}`,L)),Z=W.arms.map((S,U)=>S.kind==="case"?`${$}:case:${U}`:`${$}:default`),X=W.arms.findIndex((S)=>S.kind==="default"),G={choiceId:$,selectorNodeId:Y,joinNodeId:J,armIds:Z,stringSelector:K0(W.selector),stringCases:W.arms.flatMap((S,U)=>S.kind==="case"?[{armId:Z[U],value:S.value}]:[]),defaultArmId:Z[X],...W.id===void 0?{}:{resultNodeId:W.id}};L.choices.push(G);let Q=W.id===void 0?void 0:{id:W.id,handler:"engine.choice-result",inputs:{kind:"object",fields:Object.fromEntries(W.arms.map((S,U)=>[Z[U],K0(S.result)]))},...W.metadata===void 0?{}:{metadata:W.metadata}};return{entryId:Y,exitId:Q?.id??J,nodes:[O0(Y,"engine.choice-select"),...A.flatMap((S)=>S.nodes),O0(J,"engine.choice-join"),...Q===void 0?[]:[Q]],edges:[...W.arms.map((S,U)=>({id:Z[U],from:Y,to:A[U].entryId,condition:{kind:"always"}})),...A.flatMap((S)=>S.edges),...A.map((S,U)=>({id:`${Z[U]}:join`,from:S.exitId,to:J,condition:{kind:"always"}})),...Q===void 0?[]:[ZM(J,Q.id)]],visibleAfter:W.id===void 0?new Set(O):new Set([...O,W.id]),...W.id===void 0?{}:{lastResultNodeId:W.id}}}function KE(W,O,M,L){let $=`__woml_approval__${W.id}__join`,Y=new Set([...O,W.id]),J=W.approvedItems.length===0?void 0:T0(W.approvedItems,new Set(Y),`${M}_approved`,L),A=W.rejectedItems.length===0?void 0:T0(W.rejectedItems,new Set(Y),`${M}_rejected`,L),Z=vZ({...W,approvedItems:[],rejectedItems:[]}),X=Z.nodes[0],G=Z.nodes.at(-1),Q=[kL(W.id,"approved",J?.entryId??$),kL(W.id,"rejected",A?.entryId??$)],S=[...J===void 0?[]:[{id:`${W.id}:approved:join`,from:J.exitId,to:$,condition:{kind:"always"},approvalId:W.id}],...A===void 0?[]:[{id:`${W.id}:rejected:join`,from:A.exitId,to:$,condition:{kind:"always"},approvalId:W.id}]];return{entryId:W.id,exitId:$,nodes:[X,...J?.nodes??[],...A?.nodes??[],G],edges:[...Q,...J?.edges??[],...A?.edges??[],...S],visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function TE(W,O,M,L){let $=`__woml_fork__${W.id}__open`,Y=`__woml_fork__${W.id}__join`,J=W.branches.map((G,Q)=>({branch:G,fragment:T0(G.items,new Set(O),`${M}_branch_${Q}`,L),terminalNodeId:`__woml_fork__${W.id}__${G.id}__terminal`})),A=new Set(W.joinedBranchIds),Z={forkId:W.id,openNodeId:$,joinNodeId:Y,branches:J.map(({branch:G,fragment:Q,terminalNodeId:S})=>({branchId:G.id,entryNodeId:Q.entryId,terminalNodeId:S})),joinedBranchIds:W.joinedBranchIds};L.forks.push(Z),L.ownedBranchTerminalNodeIds.push(...Z.branches.map((G)=>G.terminalNodeId));let X=new Set(O);for(let{branch:G,fragment:Q}of J){if(!A.has(G.id))continue;let S=H0(G.items);for(let U of S)if(Q.visibleAfter.has(U))X.add(U)}return{entryId:$,exitId:Y,nodes:[O0($,"engine.fork-open"),...J.flatMap(({fragment:G,terminalNodeId:Q})=>[...G.nodes,O0(Q,"engine.fork-branch-terminal")]),O0(Y,"engine.fork-join")],edges:[...J.map(({branch:G,fragment:Q})=>({id:`${W.id}:branch:${G.id}`,from:$,to:Q.entryId,condition:{kind:"always"}})),...J.flatMap(({branch:G,fragment:Q,terminalNodeId:S})=>[...Q.edges,{id:`${W.id}:terminal:${G.id}`,from:Q.exitId,to:S,condition:{kind:"always"}}]),...W.joinedBranchIds.length===0?[{id:`${W.id}:join:none`,from:$,to:Y,condition:{kind:"always"}}]:W.joinedBranchIds.map((G)=>({id:`${W.id}:join:${G}`,from:Z.branches.find((Q)=>Q.branchId===G).terminalNodeId,to:Y,condition:{kind:"always"}}))],visibleAfter:X}}function FE(W,O,M,L){if(W.kind==="step")return RE(W,O,L);if(W.kind==="parallel")return UE(W,O,L);if(W.kind==="branch")return zE(W,O,M,L);if(W.kind==="controlChoice")return VE(W,O,M,L);if(W.kind==="switch")return HE(W,O,M,L);if(W.kind==="approval")return KE(W,O,M,L);return TE(W,O,M,L)}function T0(W,O,M,L){let $=[],Y=[],J=new Set(O),A,Z,X;for(let G=0;G<W.length;G+=1){let Q=FE(W[G],J,`${M}_${G}`,L);if(Z??=Q.entryId,X!==void 0)Y.push(ZM(X,Q.entryId));$.push(...Q.nodes),Y.push(...Q.edges),X=Q.exitId,J=new Set(Q.visibleAfter),A=Q.lastResultNodeId??A}if(Z===void 0||X===void 0)throw Error("Model v13 lowering requires a non-empty flow.");return{entryId:Z,exitId:X,nodes:$,edges:Y,visibleAfter:J,...A===void 0?{}:{lastResultNodeId:A}}}function EE(W){let O={forks:[],choices:[],contextVisibility:[],ownedBranchTerminalNodeIds:[]},M=T0(W,new Set,"root",O);if(M.lastResultNodeId===void 0)throw Error("Model v13 workflow has no deterministic value-producing main-route result.");let L="__woml_workflow__settlement",$=[{id:"__woml_workflow__:main:settlement",from:M.exitId,to:L,condition:{kind:"always"}},...O.ownedBranchTerminalNodeIds.map((Y)=>({id:`${Y}:settlement`,from:Y,to:L,condition:{kind:"always"}}))];return{fragment:M,graph:{entryNodeIds:[M.entryId],nodes:[...M.nodes,O0(L,"engine.workflow-settlement")],edges:[...M.edges,...$],forks:O.forks,choices:O.choices,contextVisibility:O.contextVisibility,settlement:{nodeId:L,mainResultNodeId:M.lastResultNodeId,ownedBranchTerminalNodeIds:O.ownedBranchTerminalNodeIds}}}}function qE(W){if(W.kind==="manual")return{id:W.id,handler:"trigger.manual",config:{kind:"object",fields:{}}};if(W.kind==="slack")return{id:W.id,handler:"trigger.slack",config:{kind:"object",fields:{events:{kind:"array",items:W.events.map((M)=>({kind:"literal",value:M}))},channels:{kind:"array",items:W.channels.map((M)=>({kind:"literal",value:M}))},botToken:W.botToken,appToken:W.appToken}}};if(W.kind==="telegram")return{id:W.id,handler:"trigger.telegram",config:{kind:"object",fields:{events:{kind:"array",items:[{kind:"literal",value:"message"}]},botToken:W.botToken}}};if(W.kind==="discord")return{id:W.id,handler:"trigger.discord",config:{kind:"object",fields:{events:{kind:"array",items:W.events.map((M)=>({kind:"literal",value:M}))},...W.channels.length===0?{}:{channels:{kind:"array",items:W.channels.map((M)=>({kind:"literal",value:M}))}},botToken:W.botToken}}};if(W.kind==="whatsapp")return{id:W.id,handler:"trigger.whatsapp",config:{kind:"object",fields:{events:{kind:"array",items:[{kind:"literal",value:"message"}]},phoneNumberId:{kind:"literal",value:W.phoneNumberId},verifyToken:W.verifyToken,appSecret:W.appSecret}}};if(W.kind==="schedule")return{id:W.id,handler:"trigger.schedule",config:{kind:"object",fields:{cron:{kind:"literal",value:W.cron},timezone:{kind:"literal",value:W.timezone},onMissed:{kind:"literal",value:W.onMissed}}}};if(W.kind==="interval")return{id:W.id,handler:"trigger.interval",config:{kind:"object",fields:{everyMs:{kind:"literal",value:W.everyMs},onMissed:{kind:"literal",value:W.onMissed}}}};if(W.kind==="event")return{id:W.id,handler:"trigger.event",config:{kind:"object",fields:{name:{kind:"literal",value:W.name},...W.secret===void 0?{}:{secret:W.secret},...W.schema===void 0?{}:{schema:{kind:"literal",value:W.schema}}}}};let O=W.authentication.kind==="none"?{kind:"object",fields:{kind:{kind:"literal",value:"none"}}}:{kind:"object",fields:{kind:{kind:"literal",value:"bearer"},secret:W.authentication.secret}};return{id:W.id,handler:"trigger.webhook",config:{kind:"object",fields:{path:{kind:"literal",value:W.path},method:{kind:"literal",value:W.method},authentication:O,...W.schema===void 0?{}:{schema:{kind:"literal",value:W.schema}}}}}}function BE(W,O){let M=XW(W,O);if(M.length===0)E(W,"WOML_IMPORTS_EMPTY","<imports> requires at least one <module> declaration.",O.openTagSpan,"Remove the empty <imports> container when the workflow has no modules.");let L=[],$=new Set,Y=new Set;for(let J of M){if(J.name!=="module")E(W,"WOML_IMPORTS_INVALID_CHILD",`<imports> accepts <module> declarations only; found <${J.name}>.`,J.openTagSpan);OO(W,J);let A=OW(W,J,"name"),Z=OW(W,J,"from"),X=A.value,G=Z.value;if(X.length>128||!QF.test(X))E(W,"WOML_MODULE_ALIAS_INVALID",`Module name "${X}" must be a JavaScript-safe lower-camel alias.`,A.valueSpan,"Example: spreadsheet or customerTools");if(VF.has(X))E(W,"WOML_MODULE_ALIAS_RESERVED",`Module name "${X}" is reserved by WOML.`,A.valueSpan,"Choose a workflow-specific module name.");if($.has(X))E(W,"WOML_MODULE_ALIAS_DUPLICATE",`Module name "${X}" is declared more than once.`,A.valueSpan);if($.add(X),G.endsWith(".woml"))E(W,"WOML_MODULE_WORKFLOW_UNSUPPORTED","<module> imports JavaScript or TypeScript code, not .woml workflows.",Z.valueSpan,"Use services.events.emit() for one-to-many workflow triggers. Durable services.workflows.call() is the next roadmap milestone.");if(G.includes("\\")||G.includes("\x00")||G.includes("?")||G.includes("#")||!SF.test(G))E(W,"WOML_MODULE_PATH_INVALID",`Module source "${G}" must be an explicit relative POSIX path ending in .js or .ts.`,Z.valueSpan,"Example: ./modules/spreadsheet.ts");if(Y.has(G))E(W,"WOML_MODULE_SOURCE_DUPLICATE",`Module source "${G}" is already declared under another name.`,Z.valueSpan,"Declare one stable services alias for each module entry point.");Y.add(G),L.push({name:X,from:G,element:J,nameAttribute:A,fromAttribute:Z})}return L}function XM(W){let O=W.root;if(O.name!=="woml")E(W,"WOML_EXPECTED_DOCUMENT_ROOT",`Expected <woml> as the document root, found <${O.name}>.`,O.openTagSpan,O.name==="workflow"?"Wrap the existing <workflow> with <woml>...</woml>.":"A WOML document contains optional <imports> followed by exactly one <workflow>.");BZ(W,O),qZ(W,O);let M=XW(W,O),L,$;if(M.length===1&&M[0].name==="workflow")$=M[0];else if(M.length===2&&M[0].name==="imports"&&M[1].name==="workflow")L=M[0],$=M[1];else{let T=M.find((F)=>F.name!=="imports"&&F.name!=="workflow")??M[0]??O;E(W,"WOML_DOCUMENT_STRUCTURE_INVALID","<woml> requires optional <imports> followed by exactly one <workflow>.",T.openTagSpan,"Use <woml><imports>...</imports><workflow ...>...</workflow></woml>.")}let Y=L===void 0?[]:BE(W,L);if($===void 0)throw Error("validated WOML document did not contain a workflow");let J=HF(W,OW(W,$,"id")),A=KF(W,$),[Z,X,G,Q]=TF(W,$),S=Z===void 0?void 0:FF(W,Z),U=G===void 0?[]:CF(W,G),V=Y.filter((T)=>T.name==="telegram"||T.name==="discord"||T.name==="whatsapp").map((T)=>T.name),R=GE(W,Q,V),K=X===void 0?void 0:aF(W,X,R,V);return{element:$,modules:Y,workflowId:J,...A===void 0?{}:{metadata:A},triggers:U,flow:R,...K===void 0?{}:{lifecycle:K},...S===void 0?{}:{runtimePolicy:S}}}function xZ(W){return XM(W)}function wE(W){XM(W);let O=[],M=z0(W);if(M.kind==="workflow"){for(let $ of M.imports)if($.name==="telegram"||$.name==="discord"||$.name==="whatsapp"){let Y=$.name==="telegram"?"Telegram":$.name==="discord"?"Discord":"WhatsApp";O.push({severity:"warning",code:"WOML_BUILTIN_SERVICE_SHADOWED",phase:"validation",message:`The local module alias "${$.name}" shadows the built-in services.${$.name} capability in this workflow.`,file:W.file,location:$.element.openTagSpan,hint:`Keep this name to preserve the local module, or rename it when you want services.${$.name}.send() from the built-in ${Y} provider.`})}}let L=($,Y)=>{if($.name==="branch"&&Y!=="fork")O.push({severity:"warning",code:"WOML_DEPRECATED_CONDITIONAL_BRANCH",phase:"validation",message:"Conditional <branch> is deprecated; use <choose> for mutually exclusive conditions.",file:W.file,location:$.openTagSpan,hint:"Rename the opening <branch> tag to <choose> and the matching closing </branch> tag to </choose>. The id, cases, result, and runtime behavior stay unchanged."});for(let J of $.children)if(J.kind==="element")L(J,$.name)};return L(W.root,void 0),O}function DL(W,O,M){return{name:O,value:M,span:W.openTagSpan,nameSpan:W.openTagSpan,valueSpan:W.openTagSpan}}function gZ(W,O){if(O.root.kind!=="workflow")return;let M=new Map(O.definitions.map((Y)=>[Y.alias,Y.kind])),L=(Y,J=[])=>{let A=M.get(Y.name);if(A==="reusable-step"){let X=Object.fromEntries(Object.entries(Y.attributes).filter(([S])=>new Set(["id","name","description","retry","retry-delay","retry-backoff","retry-max-delay"]).has(S))),G={kind:"raw",value:"return null;",span:Y.openTagSpan},Q={kind:"element",name:"script",attributes:{},children:[G],span:Y.span,openTagSpan:Y.openTagSpan};return{...Y,name:"step",attributes:X,children:[Q]}}if(A==="notification-provider"){if(J.at(-1)==="triggers")return Y;let X=J.some((Q)=>Q.startsWith("on-")),G={channels:DL(Y,"channels","#custom-provider"),"bot-token":DL(Y,"bot-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}"),"app-token":DL(Y,"app-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}")};if(X)G.message=Y.attributes.message??DL(Y,"message","Custom notification");return{...Y,name:"slack",attributes:G,children:[]}}let Z=Y.children.map((X)=>X.kind==="element"?L(X,[...J,Y.name]):X);if(Y.name==="imports")Z=Z.filter((X)=>X.kind!=="element"||X.attributes.from?.value.endsWith(".woml")!==!0);return{...Y,children:Z}},$=L(W.root);$={...$,children:$.children.filter((Y)=>Y.kind!=="element"||Y.name!=="imports"||Y.children.length>0)},XM({...W,root:$})}function CE(W,O){let M=(L)=>L.split("-").filter(Boolean).map(($)=>`${$[0]?.toUpperCase()??""}${$.slice(1)}`).join("");return`reusable${M(W)}${M(O)}`}function NE(W,O){let M=W9(W,O).split(O9).join("/");return M.startsWith(".")?M:`./${M}`}function LM(W,O,M){return{name:W,value:O,span:M,nameSpan:M,valueSpan:M}}function KZ(W,O){if(O===void 0)return;let M={};for(let L of O.children){if(L.kind!=="element")continue;let $=L.children.filter((Y)=>Y.kind==="element").map((Y,J)=>`${W}:${L.name}:${J}`);if(L.name==="on-success")M.onSuccess=$;if(L.name==="on-error")M.onError=$;if(L.name==="on-complete")M.onComplete=$}return Object.keys(M).length===0?void 0:M}function PE(W,O){if(O.value.length===0||O.value.length>16384)E(W,"WOML_PROVIDER_MESSAGE_INVALID","Custom provider messages must contain 1 through 16384 characters.",O.valueSpan);let M=[],L=0,$=0;for(let J of O.value.matchAll(/\{\{([^{}]+)\}\}/g)){let A=J.index??0,Z=O.value.slice(L,A);if(Z.includes("{{")||Z.includes("}}"))E(W,"WOML_PROVIDER_MESSAGE_INVALID","Custom provider message contains an unmatched WOML template delimiter.",O.valueSpan);if(Z.length>0)M.push({kind:"text",text:Z});let X=J[1].trim(),G=/^context\.(payload(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+|steps\.[a-z][A-Za-z0-9]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+)$/.exec(X);if(G===null)E(W,"WOML_PROVIDER_MESSAGE_INVALID",`Unsupported custom provider message reference "${X}".`,O.valueSpan,"Use scalar context.payload or context.steps references only.");M.push({kind:"contextReference",path:G[1].split(".").map((Q,S)=>S===0&&Q==="payload"?"trigger":Q)}),$+=1,L=A+J[0].length}let Y=O.value.slice(L);if(Y.includes("{{")||Y.includes("}}")||$>32)E(W,"WOML_PROVIDER_MESSAGE_INVALID",$>32?"Custom provider messages may contain at most 32 placeholders.":"Custom provider message contains an unmatched WOML template delimiter.",O.valueSpan);if(Y.length>0)M.push({kind:"text",text:Y});return{kind:"template",parts:M}}function TZ(W,O){return W.flatMap((M)=>{let L=O.attributes[M.name];if(L===void 0)return[];let $=/^\{\{secrets\.([A-Z][A-Z0-9_]*)\}\}$/.exec(L.value),Y=/^\{\{context\.(.+)\}\}$/.exec(L.value);return[{name:M.name,bindingName:M.bindingName,secret:M.secret,expression:$!==null?{kind:"secret",name:$[1]}:Y!==null?{kind:"context",path:Y[1]}:{kind:"literal",value:L.value}}]})}function J9(W,O,M){if(O.root.kind!=="workflow")wW(W,"WOML_DEFINITION_NOT_RUNNABLE","Only a workflow document can be lowered into a reusable-step workflow.",O.root.definition.openTagSpan);gZ(W,O);let L=t8(OM(W.file)),$=new Map(O.root.imports.filter((R)=>R.kind==="reusable-definition").map((R)=>[R.name,W9(M.projectRoot,OM(t8(W.file),R.from)).split(O9).join("/")])),Y=new Map;for(let R of O.definitions){if($.get(R.alias)!==R.sourcePath||Y.has(R.alias))continue;let K=OM(M.projectRoot,R.sourcePath),T=e1(LF(K,"utf8"),{file:K}),F=z0(T);if(F.kind==="workflow")continue;let N=F.definition.children.find((k)=>k.kind==="element"&&k.name==="script"),C=N.children[0],w=C?.kind==="raw"?C.value:"",B=F.kind==="reusable-step"?E8(w):q8(w);if(B.issue!==void 0){let k=new n(T.file,T.source),p=N.children[0].span.start.offset+B.issue.start;throw new GO({phase:"compile",code:B.issue.code,message:B.issue.message,file:T.file,location:k.span(p,p+Math.max(1,B.issue.end-B.issue.start)),...B.issue.hint===void 0?{}:{hint:B.issue.hint}})}let I=F.imports.filter((k)=>k.kind==="script-module").map((k)=>({name:k.name,runtimeName:CE(R.alias,k.name),from:NE(L,OM(t8(K),k.from))})),_=(k)=>{let p=k;for(let ZW of I)p=p.replace(new RegExp(`\\bservices\\.${ZW.name}\\b`,"g"),`services.${ZW.runtimeName}`);return p},H=_(w),q=`reusable_${R.alias.replaceAll("-","_")}_${R.digest.slice(7,23)}`,j=F.lifecycle?.children.flatMap((k)=>{if(k.kind!=="element")return[];return k.children.flatMap((p,ZW)=>{if(p.kind!=="element"||p.name!=="script")return[];let MW=p.children[0],GW=MW?.kind==="raw"?MW.value:"",g=VL(GW);if(g.issue!==void 0){let VW=new n(T.file,T.source),_O=(MW?.span.start.offset??p.openTagSpan.start.offset)+g.issue.start;throw new GO({phase:"compile",code:g.issue.code,message:g.issue.message,file:T.file,location:VW.span(_O,_O+Math.max(1,g.issue.end-g.issue.start)),...g.issue.hint===void 0?{}:{hint:g.issue.hint}})}return[{hook:k.name,index:ZW,source:_(GW)}]})})??[],b={kind:F.kind,alias:R.alias,source:R.sourcePath,digest:R.digest,scriptArtifactId:q,scriptSource:H,lifecycleScripts:j,imports:I,props:F.props};Y.set(R.alias,{prepared:b,inspection:F,script:N})}let J=[],A=[],Z=[],X=new Map,G=(R,K=[])=>{let T=Y.get(R.name);if(T?.inspection.kind==="notification-provider"){if(K.at(-1)?.name==="triggers")return R;let F=K.at(-1),N=F?.children.filter((b)=>b.kind==="element").indexOf(R)??-1,C=[...K].reverse().find((b)=>b.name==="approval"),w=K.find((b)=>b.name==="lifecycle"),B=w===void 0?void 0:K.find((b)=>b.name.startsWith("on-")),I=C===void 0?"informational":"approval",_,H;if(C!==void 0)H=C.attributes.id.value,_=`${H}:notify:${N}:channel:0`;else{let b=w.children.filter((p)=>p.kind==="element").indexOf(B),k=B.children.filter((p)=>p.kind==="element").indexOf(F);_=`lifecycle:${b}:action:${k}:provider:${N}:channel:0`}let q=R.attributes.message;A.push({kind:"notification-provider",providerId:_,alias:T.prepared.alias,definitionDigest:T.prepared.digest,source:T.prepared.source,scriptArtifactId:T.prepared.scriptArtifactId,props:TZ(T.prepared.props,R),...T.inspection.lifecycle===void 0?{}:{lifecycle:KZ(_,T.inspection.lifecycle)}}),Z.push({providerId:_,domain:I,...H===void 0?{}:{ownerNodeId:H},...I==="approval"&&q!==void 0?{message:PE(W,q),messageAttribute:q}:{}});let j={channels:LM("channels","#custom-provider",R.openTagSpan),"bot-token":LM("bot-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}",R.openTagSpan),"app-token":LM("app-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}",R.openTagSpan)};if(I==="informational")j.message=q;return{...R,name:"slack",attributes:j,children:[]}}if(T?.inspection.kind==="reusable-step"){let F=R.attributes.id.value,N=T.inspection.definition.attributes,C={};for(let _ of["id","name","description","retry","retry-delay","retry-backoff","retry-max-delay"]){let H=R.attributes[_]??(_==="name"||_==="description"?N[_]:void 0);if(H!==void 0)C[_]=H}let w=TZ(T.prepared.props,R);J.push({kind:"step",invocationId:F,nodeId:F,alias:T.prepared.alias,definitionDigest:T.prepared.digest,source:T.prepared.source,scriptArtifactId:T.prepared.scriptArtifactId,props:w,...T.inspection.lifecycle===void 0?{}:{lifecycle:KZ(F,T.inspection.lifecycle)}}),X.set(F,R.attributes);let B={kind:"raw",value:T.prepared.scriptSource,span:T.script.children[0].span},I={...T.script,children:[B]};return{...R,name:"step",attributes:C,children:[I]}}return{...R,children:R.children.map((F)=>F.kind==="element"?G(F,[...K,R]):F)}},Q=G(W.root),S=Q.children.find((R)=>R.kind==="element"&&R.name==="imports"),U=[...S?.children.filter((R)=>R.kind==="element"&&R.attributes.from?.value.endsWith(".woml")!==!0)??[],...[...Y.values()].flatMap(({prepared:R,inspection:K})=>R.imports.map((T)=>{let F=K.imports.find((N)=>N.name===T.name);return{...F.element,attributes:{name:LM("name",T.runtimeName,F.element.openTagSpan),from:LM("from",T.from,F.element.openTagSpan)}}}))],V=Q.children.filter((R)=>R.kind!=="element"||R.name!=="imports");if(U.length>0){let R=S?.openTagSpan??Q.openTagSpan;V.unshift({kind:"element",name:"imports",attributes:{},children:U,span:R,openTagSpan:R})}return Q={...Q,children:V},{document:{...W,root:Q},rootSource:W9(M.projectRoot,OM(W.file)).split(O9).join("/"),definitions:[...Y.values()].map((R)=>R.prepared),invocations:J,providerInvocations:A,providerDeliveries:Z,invocationAttributes:X}}function A9(W,O,M=!1,L=[]){o8(W);let{element:$,modules:Y,workflowId:J,metadata:A,triggers:Z,flow:X,lifecycle:G,runtimePolicy:Q}=XM(W),S=s0(X.items),U=G?.hooks.flatMap((P)=>P.actions.flatMap((TW)=>TW.kind==="script"?[{analysis:TW.scriptAnalysis,span:TW.scriptSpan}]:[]))??[],V=$M(X.items),R=G?.hooks.flatMap((P)=>P.actions.flatMap((TW)=>TW.kind==="notify"?TW.deliveries:[]))??[],K=[...V,...R].filter((P)=>P.provider==="telegram"),T=[...V,...R].filter((P)=>P.provider==="discord"),F=[...V,...R].filter((P)=>P.provider==="whatsapp"),N=Y.some((P)=>P.name==="telegram"),C=Y.some((P)=>P.name==="discord"),w=Y.some((P)=>P.name==="whatsapp"),B=[...S.values(),...U.map((P)=>P.analysis)],I=L.includes("telegram"),_=L.includes("discord"),H=L.includes("whatsapp"),q=!N&&(I||B.some((P)=>P.requiredServices.includes("telegram"))),j=!C&&(_||B.some((P)=>P.requiredServices.includes("discord"))),b=!w&&(H||B.some((P)=>P.requiredServices.includes("whatsapp"))),k=Z.some((P)=>P.kind==="telegram")||Z.some((P)=>P.kind==="discord")||Z.some((P)=>P.kind==="whatsapp")||K.length>0||T.length>0||F.length>0||q||j||b,p=k||M||X.firstSwitch!==void 0,ZW=p||X.firstFork!==void 0||X.firstControlChoice!==void 0;if(Y.length>0&&O===void 0)wW(W,"WOML_MODULE_EXECUTION_UNAVAILABLE","The MS2 frontend can compile imported modules, but runtime module loading begins in MS3.",Y[0].element.openTagSpan,"Use `woml check <file>` to inspect the immutable module graph without running it.");if(Y.length===0&&O!==void 0)wW(W,"WOML_MODULE_RUNTIME_UNEXPECTED","A module runtime profile cannot be attached to a workflow with no <module> declarations.",$.openTagSpan);if(Z.length===0&&X.firstApproval!==void 0)wW(W,"WOML_WORKFLOW_CALL_WAIT_UNSUPPORTED","A call-only workflow cannot contain Human Approval in Workflow Calls v1.",X.firstApproval.openTagSpan,"Use terminal steps, branch, parallel, retry, modules, and managed services. Long approval-waiting child calls require the future engine suspension boundary.");if(O!==void 0){let P=Y.map((PW)=>PW.name).sort(),TW=O.modules.map((PW)=>PW.name);if(O.profileVersion!==1||O.modules.length===0||JSON.stringify(TW)!==JSON.stringify(P))wW(W,"WOML_MODULE_RUNTIME_MISMATCH","Compiled module bindings must match every declared module alias exactly.",$.openTagSpan);for(let PW of O.modules){let I9=Y.find((W$)=>W$.name===PW.name);if(!XZ.test(PW.bundleDigest)||!XZ.test(PW.sourceMapDigest))wW(W,"WOML_MODULE_ARTIFACT_DIGEST_INVALID",`Compiled module "${PW.name}" requires canonical bundle and source-map SHA-256 identities.`,I9.element.openTagSpan);if(PW.exports.length===0||new Set(PW.exports).size!==PW.exports.length||[...PW.exports].sort().join("\x00")!==PW.exports.join("\x00")||PW.exports.some((W$)=>!UF.test(W$)))wW(W,"WOML_MODULE_RUNTIME_EXPORTS_INVALID",`Compiled module "${PW.name}" requires sorted, unique JavaScript-safe function exports.`,I9.element.openTagSpan)}}if(ZW&&!X.items.some((P)=>P.kind==="step"||P.kind==="branch"||P.kind==="approval")){let P=X.firstFork??X.firstControlChoice??X.firstSwitch;wW(W,"WOML_WORKFLOW_RESULT_REQUIRED",`This Model v${k?"15":p?"14":"13"} workflow has no deterministic value-producing item on its main route.`,P.openTagSpan,'Add a main-route <step>, result-producing <choose id="..."> or <switch id="...">, or <approval> before the terminal control structure.')}let MW=ZW?EE(X.items):void 0,GW=MW?.fragment??bL(X.items),g=new Set([...oF,...Y.map((P)=>P.name)]),VW=[...W0(X.items).flatMap((P)=>P.scriptAnalysis.serviceReferences.map((TW)=>({span:P.scriptSpan,reference:TW}))),...U.flatMap((P)=>P.analysis.serviceReferences.map((TW)=>({span:P.span,reference:TW})))].find(({reference:P})=>!g.has(P.name));if(VW!==void 0){let P=new n(W.file,W.source),TW=VW.span.start.offset+VW.reference.start;wW(W,"WOML_MODULE_SERVICE_UNKNOWN",`Unknown service alias "${VW.reference.name}".`,P.span(TW,TW+Math.max(1,VW.reference.end-VW.reference.start)),"Use a built-in service or declare the local module in <imports>.")}let _O=ZW||G!==void 0||Q!==void 0||Z.length===0||O!==void 0||[...S.values()].some((P)=>P.requiredSecrets.length>0||P.usesServices||P.usesNativeFetch),A1=_O?VZ(GW.nodes,S):GW.nodes,hO=MW===void 0?{entryNodeIds:[GW.entryId],nodes:A1,edges:GW.edges}:{...MW.graph,nodes:VZ(MW.graph.nodes,S)},Z1=k?{profileVersion:1,providers:[...Z.some((P)=>P.kind==="whatsapp")||F.length>0||b?[{provider:"whatsapp",triggerIds:Z.filter((P)=>P.kind==="whatsapp").map((P)=>P.id),notificationDeliveryIds:F.map((P)=>P.deliveryId),messaging:b,credentialNames:[...new Set([...Z.flatMap((P)=>P.kind==="whatsapp"?[P.verifyToken.name,P.appSecret.name]:[]),...F.map((P)=>P.accessToken.name),...B.flatMap((P)=>P.requiredServices.includes("whatsapp")||H?P.requiredSecrets:[])])].sort()}]:[],...Z.some((P)=>P.kind==="discord")||T.length>0||j?[{provider:"discord",triggerIds:Z.filter((P)=>P.kind==="discord").map((P)=>P.id),notificationDeliveryIds:T.map((P)=>P.deliveryId),messaging:j,credentialNames:[...new Set([...Z.flatMap((P)=>P.kind==="discord"?[P.botToken.name]:[]),...T.map((P)=>P.botToken.name),...B.flatMap((P)=>P.requiredServices.includes("discord")||_?P.requiredSecrets:[])])].sort()}]:[],...Z.some((P)=>P.kind==="telegram")||K.length>0||q?[{provider:"telegram",triggerIds:Z.filter((P)=>P.kind==="telegram").map((P)=>P.id),notificationDeliveryIds:K.map((P)=>P.deliveryId),messaging:q,credentialNames:[...new Set([...Z.flatMap((P)=>P.kind==="telegram"?[P.botToken.name]:[]),...K.map((P)=>P.botToken.name),...B.flatMap((P)=>P.requiredServices.includes("telegram")||I?P.requiredSecrets:[])])].sort()}]:[]].sort((P,TW)=>P.provider.localeCompare(TW.provider))}:void 0,NW=Z1?.providers.find((P)=>P.credentialNames.length===0);if(NW!==void 0){let P=NW.provider==="telegram"?"Telegram":NW.provider==="discord"?"Discord":"WhatsApp";wW(W,`WOML_${NW.provider.toUpperCase()}_CREDENTIAL_UNRESOLVED`,`${P} usage requires at least one explicit symbolic secret reference in the workflow.`,$.openTagSpan,NW.provider==="whatsapp"?"Pass secrets.WHATSAPP_ACCESS_TOKEN from the WOML script into the imported module that calls services.whatsapp.send().":`Pass secrets.${NW.provider==="telegram"?"TELEGRAM":"DISCORD"}_BOT_TOKEN from the WOML script into the imported module that calls services.${NW.provider}.send().`)}let QW={workflowId:J,...A===void 0?{}:{metadata:A},triggers:Z.map(qE),graph:hO,...O===void 0?{}:{moduleRuntime:O},...G===void 0?{}:{lifecycle:OE(G)},...Q===void 0?{}:{runtimePolicy:Q.value}},_9=ZW?k?{schemaVersion:15,...QW,communication:Z1,graph:hO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1}}:p?{schemaVersion:14,...QW,graph:hO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1}}:{schemaVersion:13,...QW,graph:hO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1}}:Q!==void 0?{schemaVersion:12,...QW,runtimePolicy:Q.value}:G!==void 0?{schemaVersion:11,...QW}:Z.length===0?{schemaVersion:10,...QW}:O!==void 0?{schemaVersion:9,...QW,moduleRuntime:O}:_O?{schemaVersion:8,...QW}:Z.length>1||Z.some((P)=>P.kind!=="manual")?{schemaVersion:7,...QW}:GW.nodes.some((P)=>P.retryPolicy!==void 0)?{schemaVersion:6,...QW}:X.firstNotification!==void 0?{schemaVersion:5,...QW}:X.firstApproval!==void 0?{schemaVersion:4,...QW}:X.firstParallel!==void 0?{schemaVersion:3,...QW}:X.firstBranch===void 0?{schemaVersion:1,...QW}:{schemaVersion:2,...QW},j9=M8(_9.graph,{requireSingleTerminal:!0});if(j9.length>0)wW(W,"WOML_INVALID_DAG",j9[0].message,$.openTagSpan);return _9}function Z9(W,O){let M=A9(W.document,O,!0);if(M.schemaVersion!==14&&M.schemaVersion!==15)throw Error("reusable-step lowering did not produce Model v14 or v15");let L=new Map(W.invocations.map((V)=>[V.nodeId,V])),$=M.graph.nodes.map((V)=>{let R=L.get(V.id);if(R===void 0)return V;let K=R.props.flatMap((T)=>T.expression.kind==="secret"?[T.expression.name]:[]).sort();return{...V,scriptRuntime:{bindingVersion:3,bindings:["props","context","attempt","services"],requiredSecrets:K},metadata:{...V.metadata??{},reusableDefinition:{alias:R.alias,invocationSource:W.rootSource,definitionSource:R.source,definitionDigest:R.definitionDigest}}}}),Y=new Map((M.graph.contextVisibility??[]).map((V)=>[V.nodeId,V.stepIds])),J=new Map(W.providerInvocations.map((V)=>[V.providerId,V])),A=new Map(W.providerDeliveries.map((V)=>[V.providerId,V])),Z=new Map(M.graph.nodes.map((V)=>[V.id,V])),X=new Map,G=(V)=>{let R=Y.get(V);if(R!==void 0)return new Set(R);let K=X.get(V);if(K!==void 0)return K;X.set(V,new Set);let T=M.graph.edges.filter((C)=>C.to===V).map((C)=>C.from);if(T.length===0)return new Set;let F=T.map((C)=>{let w=new Set(G(C)),B=Z.get(C);if(B?.handler==="runtime.script"||B?.handler==="engine.branch-result"||B?.handler==="engine.choice-result"||B?.handler==="engine.approval-join")w.add(C);return w}),N=new Set([...F[0]].filter((C)=>F.every((w)=>w.has(C))));return X.set(V,N),N},Q=(V)=>{if(V.kind==="array")return{...V,items:V.items.map(Q)};if(V.kind!=="object")return V;let R=V.fields.deliveryId;if(R?.kind==="literal"&&typeof R.value==="string"&&A.has(R.value)){let K=A.get(R.value),T=J.get(K.providerId);return{kind:"object",fields:{deliveryId:R,provider:{kind:"literal",value:"custom"},destination:{kind:"literal",value:T.alias},credentials:{kind:"object",fields:{}},providerId:{kind:"literal",value:T.providerId},domain:{kind:"literal",value:K.domain},...K.message===void 0?V.fields.message===void 0?{}:{message:V.fields.message}:{message:K.message}}}}return{...V,fields:Object.fromEntries(Object.entries(V.fields).map(([K,T])=>[K,Q(T)]))}};for(let V of W.invocations){let R=new Set(Y.get(V.nodeId)??[]);for(let K of V.props){if(K.expression.kind!=="context"||!K.expression.path.startsWith("steps."))continue;let T=K.expression.path.split(".")[1];if(R.has(T))continue;let F=W.invocationAttributes.get(V.invocationId)?.[K.name];wW(W.document,"WOML_REUSABLE_PROP_CONTEXT_UNAVAILABLE",`Prop "${K.name}" on <${V.alias}> cannot read step "${T}" from this graph position.`,F?.valueSpan??W.document.root.openTagSpan,"Reference context.payload or a step that is guaranteed to be visible before this invocation.")}}for(let V of W.providerInvocations){let R=A.get(V.providerId),K=new Set(R.ownerNodeId===void 0?M.graph.nodes.filter((F)=>F.handler==="runtime.script").map((F)=>F.id):G(R.ownerNodeId)),T=[...V.props.flatMap((F)=>F.expression.kind==="context"?[F.expression.path]:[]),...R.message?.kind==="template"?R.message.parts.flatMap((F)=>F.kind==="contextReference"?[F.path.join(".")]:[]):[]];for(let F of T){if(!F.startsWith("steps."))continue;let N=F.split(".")[1];if(K.has(N))continue;wW(W.document,"WOML_REUSABLE_PROP_CONTEXT_UNAVAILABLE",`Custom provider <${V.alias}> cannot read step "${N}" from this notification position.`,R.messageAttribute?.valueSpan??W.document.root.openTagSpan,"Pass context.payload or a step output available before this notification.")}}let S=$.map((V)=>({...V,inputs:Q(V.inputs)})),U=M.lifecycle===void 0?void 0:{...M.lifecycle,hooks:M.lifecycle.hooks.map((V)=>({...V,actions:V.actions.map((R)=>({...R,inputs:Q(R.inputs)}))}))};return{...M,graph:{...M.graph,nodes:S},...U===void 0?{}:{lifecycle:U},reusableDefinitions:[...W.invocations,...W.providerInvocations]}}function _E(W){return A9(W)}function X9(W,O,M={}){let L=A9(W,O,!1,M.forcedCommunicationServices??(M.forceModelV15===!0?["telegram"]:[]));if(L.schemaVersion!==9&&L.schemaVersion!==10&&L.schemaVersion!==11&&L.schemaVersion!==12&&L.schemaVersion!==13&&L.schemaVersion!==14&&L.schemaVersion!==15)throw Error("module compilation did not produce Model v9, v10, v11, v12, v13, v14, or v15");return L}import{mkdtempSync as jE,readFileSync as G9,realpathSync as F0,rmSync as IE,statSync as lZ}from"fs";import{tmpdir as yE}from"os";import{dirname as M0,extname as pZ,isAbsolute as DE,join as hZ,relative as fL,resolve as DW,sep as vL}from"path";var mZ="woml.definition-package/v1",xL="woml.module-resolver/v1",dZ="woml.definition-package/v2",cZ="woml.definition-package/v3",iZ="woml.definition-package/v4",sZ="woml.definition-package/v5",nZ="woml.definition-package/v6",rZ="woml.definition-package/v7",aZ="woml.definition-package/v8",Q9="woml.definition-package/v9",S9="woml.definition-package/v10";function kE(W,O){let M=O==="text/typescript"?new Bun.Transpiler({loader:"ts"}).transformSync(W):W,L=g1(M,{ecmaVersion:"latest",sourceType:"module"}),$=new Set,Y=!1,J=(A)=>{if(Array.isArray(A)){for(let X of A)J(X);return}if(typeof A!=="object"||A===null)return;let Z=A;if(Z.type==="MemberExpression"&&typeof Z.object==="object"&&Z.object!==null&&Z.object.type==="Identifier"&&Z.object.name==="services"&&Z.computed===!0)Y=!0;else if(Z.type==="MemberExpression"&&Z.computed!==!0&&typeof Z.object==="object"&&Z.object!==null&&Z.object.type==="Identifier"&&Z.object.name==="services"&&typeof Z.property==="object"&&Z.property!==null&&Z.property.type==="Identifier"&&typeof Z.property.name==="string")$.add(Z.property.name);for(let[X,G]of Object.entries(Z))if(X!=="start"&&X!=="end")J(G)};return J(L),{references:[...$].sort(),dynamic:Y}}function oZ(W,O={}){let M=SM(W,O),L=DW(O.sourcePath??W.file),$=F0(DW(O.projectRoot??M0(L))),Y=new Set,J=[];for(let A of M.sources){if(A.mediaType==="application/woml+xml")continue;let Z=G9(DW($,A.path),"utf8"),X=kE(Z,A.mediaType);if(X.dynamic){let Q=new n(A.path,Z),S=Math.max(0,Z.indexOf("services"));throw e(A.path,"WOML_SCRIPT_SERVICE_ACCESS_DYNAMIC","Computed service access is not supported in a WOML local module.",Q.span(S,Math.min(Z.length,S+8)),"Use a static service name such as services.state.")}let G=X.references;for(let Q of G)Y.add(Q);if(G.includes("state"))J.push(A.path)}return{referencedServices:[...Y].sort(),durableStateSources:J.sort()}}var uZ=512,bE=16777216;function BO(W){return typeof W==="object"&&W!==null&&typeof W.type==="string"&&typeof W.start==="number"&&typeof W.end==="number"}function fE(W){let O=[];for(let[M,L]of Object.entries(W)){if(M==="type"||M==="start"||M==="end")continue;if(BO(L))O.push(L);else if(Array.isArray(L)){for(let $ of L)if(BO($))O.push($)}}return O}function vE(W){let O=[W];while(O.length>0){let M=O.pop();if(M.type==="CallExpression"){let L=M.callee;if(BO(L)&&L.type==="Identifier"&&L.name==="require")return M}if(M.type==="MemberExpression"){let{object:L,property:$}=M,Y=BO(L)&&L.type==="Identifier"&&L.name==="exports",J=BO(L)&&L.type==="Identifier"&&L.name==="module"&&BO($)&&($.type==="Identifier"&&$.name==="exports"||$.type==="Literal"&&$.value==="exports");if(Y||J)return M}O.push(...fE(M))}return}function KW(W){if(W===null||typeof W==="boolean"||typeof W==="string")return JSON.stringify(W);if(typeof W==="number"){if(!Number.isFinite(W))throw TypeError("Canonical WOML package values must be finite JSON numbers.");return JSON.stringify(W)}if(Array.isArray(W))return`[${W.map(KW).join(",")}]`;if(typeof W==="object"&&W!==null){let O=W;return`{${Object.keys(O).sort().map((M)=>`${JSON.stringify(M)}:${KW(O[M])}`).join(",")}}`}throw TypeError("Canonical WOML package values must be JSON-compatible.")}function AW(W){return`sha256:${new Bun.CryptoHasher("sha256").update(W).digest("hex")}`}function GM(W,O){let M=fL(W,O).split(vL).join("/");return M.length===0?".":M}function QM(W,O){let M=fL(W,O);return M===""||!M.startsWith(`..${vL}`)&&M!==".."&&!DE(M)}function e(W,O,M,L,$){let Y={code:O,phase:"compile",message:M,file:W,location:L,...$===void 0?{}:{hint:$}};return new GO(Y)}function qO(W,O,M,L,$){throw e(W.file,M,L,O.fromAttribute.valueSpan,$)}function MO(W,O,M){let L=M===void 0?0:Math.max(0,O.indexOf(M));return W.span(L,Math.min(O.length,L+Math.max(1,M?.length??1)))}function xE(W,O,M,L){if(!QM(O,W))qO(M,L,"WOML_MODULE_PATH_ESCAPE",`Module source "${L.from}" escapes the project boundary.`,`Project boundary: ${O}`);let $;try{if(!lZ(W).isFile())throw Error("not a file");$=F0(W)}catch{qO(M,L,"WOML_MODULE_FILE_NOT_FOUND",`Module source "${L.from}" does not resolve to a readable file.`)}if(!QM(O,$))qO(M,L,"WOML_MODULE_SYMLINK_ESCAPE",`Module source "${L.from}" resolves outside the project boundary.`,"Move the source into the project instead of following an external symlink.");return $}function gE(W,O,M){let L=GM(O,W),$=new n(L,M),Y=pZ(W)===".ts"?"ts":"js",J=new Bun.Transpiler({loader:Y}),A,Z;try{A=J.scan(M),Z=J.transformSync(M)}catch(S){throw e(L,"WOML_MODULE_SYNTAX_INVALID",`Cannot parse module source: ${S instanceof Error?S.message:String(S)}`,MO($,M))}let X;try{let S=g1(Z,{ecmaVersion:"latest",sourceType:"module",allowHashBang:!0});if(!BO(S))throw Error("module parser returned no program");X=S}catch(S){throw e(L,"WOML_MODULE_SYNTAX_INVALID",`Cannot parse transpiled module: ${S instanceof Error?S.message:String(S)}`,MO($,M))}let G=[],Q=X.body??[];for(let S of Q){if(!BO(S))continue;if(S.type==="ExportDefaultDeclaration")throw e(L,"WOML_MODULE_DEFAULT_EXPORT_UNSUPPORTED","WOML modules expose named function exports only; default exports are unsupported.",MO($,M,"export default"));if(S.type!=="ExportNamedDeclaration")continue;let U=S.declaration;if(BO(U)&&U.type==="FunctionDeclaration"){if(U.generator===!0)throw e(L,"WOML_MODULE_GENERATOR_EXPORT_UNSUPPORTED","Generator functions are not part of the Module v1 public surface.",MO($,M,"export"));let V=U.id;if(BO(V)&&V.type==="Identifier"&&V.name!==void 0)G.push(V.name);continue}throw e(L,"WOML_MODULE_EXPORT_UNSUPPORTED","Export runtime functions directly with `export function name(...)` or `export async function name(...)`.",MO($,M,"export"),"Default exports, export lists, re-exports, classes, constants, and CommonJS exports are outside Module profile v1.")}if(vE(X)!==void 0)throw e(L,"WOML_MODULE_COMMONJS_UNSUPPORTED","CommonJS require/exports are unsupported; use static ESM imports and direct named function exports.",MO($,M,M.includes("module.exports")?"module.exports":M.includes("require")?"require":"exports"));for(let S of A.imports){if(S.kind==="dynamic-import")throw e(L,"WOML_MODULE_DYNAMIC_IMPORT_UNSUPPORTED",`Dynamic import of "${S.path}" is unsupported.`,MO($,M,S.path),"Use a static relative import statement so the dependency can be hashed before activation.");if(S.kind!=="import-statement")throw e(L,"WOML_MODULE_IMPORT_UNSUPPORTED",`Import form "${S.kind}" is unsupported in Module profile v1.`,MO($,M,S.path))}return{imports:A.imports,runtimeExports:[...A.exports].sort(),functionExports:G.sort()}}function SM(W,O={}){let M=xZ(W),L=DW(O.sourcePath??W.file),$=DW(O.projectRoot??M0(L)),Y;try{Y=F0($)}catch{throw e(W.file,"WOML_MODULE_PROJECT_ROOT_INVALID",`Module project root "${$}" is not a readable directory.`,W.root.openTagSpan)}if(!QM(Y,L))throw e(W.file,"WOML_MODULE_DOCUMENT_ESCAPE","The importing WOML document is outside the configured project boundary.",W.root.openTagSpan);try{let K=F0(L);if(!lZ(K).isFile()||!QM(Y,K))throw Error("outside project boundary")}catch{throw e(W.file,"WOML_MODULE_DOCUMENT_INVALID","The importing WOML document must be a readable file inside the project boundary.",W.root.openTagSpan)}let J=new Map,A=[],Z=new Map,X=0,G=(K,T)=>{let F=xE(K,Y,W,T),N=J.get(F);if(N!==void 0)return N;let C=A.indexOf(F);if(C!==-1){let k=[...A.slice(C),F].map((p)=>GM(Y,p)).join(" -> ");qO(W,T,"WOML_MODULE_GRAPH_CYCLE",`Module dependency graph contains a cycle: ${k}.`)}let w=GM(Y,F),B=w.toLocaleLowerCase("en-US"),I=Z.get(B);if(I!==void 0&&I!==w)qO(W,T,"WOML_MODULE_PATH_CASE_COLLISION",`Module paths "${I}" and "${w}" differ by case only.`);Z.set(B,w);let _=pZ(F);if(_!==".js"&&_!==".ts")qO(W,T,"WOML_MODULE_EXTENSION_UNSUPPORTED",`Module dependency "${w}" must end in .js or .ts.`);let H;try{H=G9(F,"utf8")}catch{qO(W,T,"WOML_MODULE_FILE_NOT_READABLE",`Module source "${w}" could not be read.`)}if(J.size+A.length>=uZ)qO(W,T,"WOML_MODULE_GRAPH_LIMIT_EXCEEDED",`Module graph exceeds the ${uZ}-source limit.`);if(X+=Buffer.byteLength(H),X>bE)qO(W,T,"WOML_MODULE_SIZE_LIMIT_EXCEEDED","Module graph exceeds the 16 MiB source limit.");let q=gE(F,Y,H);A.push(F);let j=[];for(let k of q.imports){if(!k.path.startsWith("./")&&!k.path.startsWith("../")){let ZW=new n(w,H);throw e(w,"WOML_MODULE_PACKAGE_IMPORT_UNAVAILABLE",`Package import "${k.path}" is unavailable until MS5.`,MO(ZW,H,k.path),"Use an explicit relative .js or .ts dependency in the local-module slice.")}if(!/\.(?:js|ts)$/.test(k.path)){let ZW=new n(w,H);throw e(w,"WOML_MODULE_IMPORT_EXTENSION_REQUIRED",`Static import "${k.path}" requires an explicit .js or .ts extension.`,MO(ZW,H,k.path))}let p=G(DW(M0(F),k.path),T);j.push(p.portablePath)}A.pop();let b={absolutePath:F,portablePath:w,source:H,mediaType:_===".ts"?"text/typescript":"text/javascript",digest:AW(H),dependencies:[...new Set(j)].sort(),functionExports:q.functionExports,runtimeExports:q.runtimeExports};return J.set(F,b),b},Q=[],S=new Map;for(let K of M.modules){let T=G(DW(M0(L),K.from),K),F=S.get(T.absolutePath);if(F!==void 0)qO(W,K,"WOML_MODULE_SOURCE_DUPLICATE",`Module source "${K.from}" is already exposed as "${F}".`,"Declare one stable services alias for each module entry point.");S.set(T.absolutePath,K.name);let N=T.runtimeExports.filter((C)=>!T.functionExports.includes(C));if(N.length>0){let C=new n(T.portablePath,T.source);throw e(T.portablePath,"WOML_MODULE_EXPORT_UNSUPPORTED",`Module runtime export "${N[0]}" is not a direct named function export.`,MO(C,T.source,N[0]))}if(T.functionExports.length===0){let C=new n(T.portablePath,T.source);throw e(T.portablePath,"WOML_MODULE_EXPORTS_EMPTY","A declared WOML module requires at least one named function export.",MO(C,T.source))}Q.push({name:K.name,entrypoint:T.portablePath,exports:T.functionExports})}let U=GM(Y,L),V=[{path:U,mediaType:"application/woml+xml",digest:AW(W.source),dependencies:Q.map((K)=>K.entrypoint).sort()},...[...J.values()].sort((K,T)=>K.portablePath.localeCompare(T.portablePath)).map((K)=>({path:K.portablePath,mediaType:K.mediaType,digest:K.digest,dependencies:K.dependencies}))],R={schemaVersion:1,profile:mZ,executable:!1,workflow:{id:M.workflowId,source:U},modules:Q.sort((K,T)=>K.name.localeCompare(T.name)),sources:V,compiler:{name:"woml",version:"0.1.0",resolverProfile:xL},permissions:{secrets:[],networkOrigins:[]}};return{...R,rootHash:AW(KW(R))}}function hE(W,O,M){let L=new Map;for(let $ of M){if($.mediaType==="application/woml+xml")continue;let Y=DW(O,$.path);for(let J of[Y,fL(process.cwd(),Y),$.path])L.set(J.split(vL).join("/"),$.path)}return W.replace(/^\/\/ (.+)$/gm,($,Y)=>{let J=L.get(Y.replaceAll("\\","/"));return J===void 0?$:`// ${J}`}).replace(/^\/\/# debugId=.*(?:\n|$)/gm,"").replace(/\n+$/,`
29
- `)}function uE(W,O,M,L){let $;try{$=JSON.parse(W)}catch{throw e("module-source-map","WOML_MODULE_SOURCE_MAP_INVALID","Bun produced an invalid JSON source map.",new n("module-source-map",W).span(0,1))}let{sources:Y,sourcesContent:J}=$;if(!Array.isArray(Y)||!Array.isArray(J))throw e("module-source-map","WOML_MODULE_SOURCE_MAP_INVALID","The module source map must retain source names and source content.",new n("module-source-map",W).span(0,1));let A=new Map(L.map((X)=>[X.path,X])),Z=[];for(let X=0;X<Y.length;X+=1){let G=Y[X],Q=J[X];if(typeof G!=="string"||typeof Q!=="string")throw e("module-source-map","WOML_MODULE_SOURCE_MAP_INVALID","The module source map contains a non-text source entry.",new n("module-source-map",W).span(0,1));let S;try{S=F0(DW(M0(O),G))}catch{throw e("module-source-map","WOML_MODULE_SOURCE_MAP_SOURCE_UNKNOWN",`The module source map references an unknown source "${G}".`,new n("module-source-map",W).span(0,1))}if(!QM(M,S))throw e("module-source-map","WOML_MODULE_SOURCE_MAP_ESCAPE","The module source map references a file outside the project boundary.",new n("module-source-map",W).span(0,1));let U=GM(M,S),V=A.get(U);if(V===void 0||V.digest!==AW(Q))throw e(U,"WOML_MODULE_SOURCE_CHANGED_DURING_BUILD",`Module source "${U}" changed while its immutable bundle was being built.`,new n(U,Q).span(0,1),"Run the build again after the source editor has finished writing.");Z.push(U)}return $.sources=Z,delete $.debugId,delete $.sourceRoot,delete $.file,KW($)}function lE(W,O){let M=O[0],L=M?.message??"Bun could not compile the module.",$=M?.position?.file,Y=$===void 0?W.entrypoint:$,J="";try{J=G9(Y,"utf8")}catch{}let A=new n(Y,J),Z=Math.max(1,M?.position?.line??1),X=Math.max(1,M?.position?.column??1),G=A.offsetAt(Z,X);return e(Y,"WOML_MODULE_BUILD_FAILED",`Cannot compile module "${W.name}": ${L}`,A.span(G,Math.min(J.length,G+1)))}function pE(W){let O=["// Generated by WOML Module System MS2. Do not edit.","export interface WomlImportedServices {"];for(let M of W){O.push(` readonly ${JSON.stringify(M.name)}: Readonly<{`);for(let L of M.exports)O.push(` readonly ${JSON.stringify(L)}: (...args: readonly unknown[]) => unknown | Promise<unknown>;`);O.push(" }>;")}return O.push("}","","declare const services: WomlImportedServices;",""),O.join(`
30
- `)}async function R9(W,O={}){let M=SM(W,O);if(M.modules.length===0)throw e(W.file,"WOML_MODULES_REQUIRED","Definition Package v2 is reserved for workflows that declare at least one module.",W.root.openTagSpan);let L=DW(O.sourcePath??W.file),$=F0(DW(O.projectRoot??M0(L))),Y=jE(hZ(yE(),"woml-ms2-build-")),J=[],A=[];try{for(let F of M.modules){let N=hZ(Y,F.name),C=await Bun.build({entrypoints:[DW($,F.entrypoint)],root:$,outdir:N,naming:"[name].[ext]",target:"bun",format:"esm",splitting:!1,sourcemap:"external",packages:"bundle",allowUnresolved:[],env:"disable",minify:!1});if(!C.success)throw lE(F,C.logs);let w=C.outputs.find((k)=>k.kind==="entry-point"),B=C.outputs.find((k)=>k.kind==="sourcemap");if(w===void 0||B===void 0)throw e(F.entrypoint,"WOML_MODULE_BUILD_OUTPUT_MISSING",`Bun did not produce both an ESM bundle and source map for module "${F.name}".`,new n(F.entrypoint,"").span(0,0));let I=hE(await w.text(),$,M.sources),_=uE(await B.text(),B.path,$,M.sources);if(I.includes($)||_.includes($))throw e(F.entrypoint,"WOML_MODULE_ARTIFACT_PATH_LEAK","A compiled module artifact contains an absolute developer-machine path.",new n(F.entrypoint,"").span(0,0));let H=`modules/${F.name}.mjs`,q=`modules/${F.name}.mjs.map`,j=AW(I),b=AW(_);J.push({path:H,kind:"module-bundle",mediaType:"text/javascript",digest:j,content:I},{path:q,kind:"source-map",mediaType:"application/source-map+json",digest:b,content:_}),A.push({...F,bundle:{path:H,digest:j},sourceMap:{path:q,digest:b}})}}finally{IE(Y,{recursive:!0,force:!0})}if(SM(W,O).rootHash!==M.rootHash)throw e(W.file,"WOML_MODULE_SOURCE_CHANGED_DURING_BUILD","The WOML source or module graph changed while the immutable package was being built.",W.root.openTagSpan,"Run the build again after the source editor has finished writing.");let X=A.map((F)=>({name:F.name,bundleDigest:F.bundle.digest,sourceMapDigest:F.sourceMap.digest,exports:F.exports})),G=oZ(W,O),Q=["telegram","discord","whatsapp"].filter((F)=>G.referencedServices.includes(F)&&!M.modules.some((N)=>N.name===F)),S=X9(W,{profileVersion:1,modules:X},{forcedCommunicationServices:Q}),U=KW(S),V=AW(U),R=pE(M.modules);J.unshift({path:`workflow.compiled.v${S.schemaVersion}.json`,kind:"workflow-model",mediaType:"application/json",digest:V,content:U}),J.push({path:"types/services.generated.d.ts",kind:"type-declarations",mediaType:"text/typescript",digest:AW(R),content:R});let K={executable:!0,runtimeReady:!1,workflow:{id:M.workflow.id,source:M.workflow.source,modelDigest:V,model:S},modules:A,sources:M.sources,artifacts:J,compiler:{name:"woml",version:"0.1.0",resolverProfile:xL,bundler:{name:"bun",version:Bun.version,target:"bun",format:"esm",sourceMap:"external"}},permissions:M.permissions};if(S.schemaVersion===15){let F={schemaVersion:10,profile:S9,...K,workflow:{...K.workflow,model:S},definitions:[]};return{...F,rootHash:AW(KW(F))}}if(S.schemaVersion===14){let F={schemaVersion:9,profile:Q9,...K,workflow:{...K.workflow,model:S},definitions:[]};return{...F,rootHash:AW(KW(F))}}if(S.schemaVersion===13){let F={schemaVersion:8,profile:aZ,...K,workflow:{...K.workflow,model:S}};return{...F,rootHash:AW(KW(F))}}if(S.schemaVersion===12){let F={schemaVersion:7,profile:rZ,...K,workflow:{...K.workflow,model:S}};return{...F,rootHash:AW(KW(F))}}if(S.schemaVersion===11){let F={schemaVersion:6,profile:nZ,...K,workflow:{...K.workflow,model:S}};return{...F,rootHash:AW(KW(F))}}if(S.schemaVersion===10){let F={schemaVersion:4,profile:iZ,...K,workflow:{...K.workflow,model:S}};return{...F,rootHash:AW(KW(F))}}let T={schemaVersion:2,profile:dZ,...K,workflow:{...K.workflow,model:S}};return{...T,rootHash:AW(KW(T))}}async function mE(W,O,M={}){if(O.root.kind!=="workflow")throw e(W.file,"WOML_DEFINITION_NOT_RUNNABLE","A reusable definition package requires a workflow entry document.",O.root.definition.openTagSpan);let L=DW(M.sourcePath??W.file),$=F0(DW(M.projectRoot??M0(L))),Y=J9(W,O,{projectRoot:$});if(Y.invocations.length===0&&Y.providerInvocations.length===0)throw e(W.file,"WOML_REUSABLE_STEP_USAGE_REQUIRED","Definition Package v9 requires at least one custom-step or custom-provider invocation.",O.root.definition.openTagSpan);let J=SM(Y.document,{sourcePath:L,projectRoot:$}),A=J.modules.length>0?await R9(Y.document,{sourcePath:L,projectRoot:$}):void 0,Z=A?.workflow.model.moduleRuntime,X=Z9(Y,Z),G=KW(X),Q=AW(G),S=new Map((A?.sources??J.sources).map((q)=>[q.path,q])),U=Y.definitions.map((q)=>q.source).sort(),V=new Map(Y.definitions.map((q)=>[q.source,q])),R=O.sources.map((q)=>{let j=S.get(q.path),b=V.get(q.path),k=q.path===Y.rootSource?[...new Set([...j?.dependencies??[],...U])].sort():b===void 0?j?.dependencies??[]:b.imports.map((p)=>fL($,DW(M0(L),p.from)).split(vL).join("/")).sort();return{path:q.path,mediaType:q.kind==="script-module"?q.path.endsWith(".ts")?"text/typescript":"text/javascript":"application/woml+xml",digest:q.digest,dependencies:k}}).sort((q,j)=>q.path.localeCompare(j.path)),K=(A?.artifacts??[]).filter((q)=>q.kind==="module-bundle"||q.kind==="source-map"),T=Y.definitions.map((q)=>({path:`definitions/${q.scriptArtifactId}.js`,kind:"module-bundle",mediaType:"text/javascript",digest:AW(q.scriptSource),content:q.scriptSource})),F=[...Y.invocations,...Y.providerInvocations].flatMap((q)=>{return Y.definitions.find((b)=>b.alias===q.alias).lifecycleScripts.map((b)=>({path:`definitions/${q.kind==="step"?q.invocationId:q.providerId}.${b.hook}.${b.index}.js`,kind:"module-bundle",mediaType:"text/javascript",digest:AW(b.source),content:b.source}))}),N=["// Generated by WOML reusable definitions SCP3. Do not edit.",...Y.definitions.flatMap((q)=>[`export interface ${q.alias.replace(/(^|-)([a-z0-9])/g,(j,b,k)=>k.toUpperCase())}Props {`,...q.props.map((j)=>` readonly ${JSON.stringify(j.bindingName)}${j.required?"":"?"}: string;`),"}"]),""].join(`
31
- `),C=[{path:`workflow.compiled.v${X.schemaVersion}.json`,kind:"workflow-model",mediaType:"application/json",digest:Q,content:G},...K,...T,...F,{path:"types/props.generated.d.ts",kind:"type-declarations",mediaType:"text/typescript",digest:AW(N),content:N}].sort((q,j)=>q.path.localeCompare(j.path)),w=Y.definitions.map((q)=>({alias:q.alias,kind:q.kind,source:q.source,digest:q.digest,dependencies:R.find((j)=>j.path===q.source)?.dependencies??[],props:q.props.map((j)=>({name:j.name,bindingName:j.bindingName,required:j.required,secret:j.secret}))})).sort((q,j)=>q.alias.localeCompare(j.alias)),B=[...new Set([...[...Y.invocations,...Y.providerInvocations].flatMap((q)=>q.props.flatMap((j)=>j.expression.kind==="secret"?[j.expression.name]:[])),...X.schemaVersion===15?X.communication.providers.flatMap((q)=>q.credentialNames):[],...A?.permissions.secrets??[]])].sort(),I={executable:!0,workflow:{id:X.workflowId,source:Y.rootSource,modelDigest:Q,model:X},definitions:w,modules:A?.modules??[],sources:R,artifacts:C,compiler:A?.compiler??{name:"woml",version:"0.1.0",resolverProfile:xL,bundler:{name:"bun",version:Bun.version,target:"bun",format:"esm",sourceMap:"external"}},permissions:{secrets:B,networkOrigins:A?.permissions.networkOrigins??[]}},_=X.schemaVersion!==15||X.communication.providers.every((q)=>q.provider==="telegram"||q.provider==="discord"||q.provider==="whatsapp"),H=X.schemaVersion===15?{schemaVersion:10,profile:S9,runtimeReady:_,...I,workflow:{...I.workflow,model:X}}:{schemaVersion:9,profile:Q9,runtimeReady:!0,...I,workflow:{...I.workflow,model:X}};return{...H,rootHash:AW(KW(H))}}async function dE(W,O={}){let M=await R9(W,O);if(M.schemaVersion===10){let $=M.workflow.model.communication.providers.find((Z)=>Z.provider!=="telegram"&&Z.provider!=="discord");if($!==void 0)throw e(W.file,"WOML_COMMUNICATION_RUNTIME_UNAVAILABLE",`The built-in ${$.provider} provider is not executable in this runtime.`,W.root.openTagSpan,"Use a currently supported built-in provider or a custom notification provider.");let{rootHash:Y,...J}=M,A={...J,runtimeReady:!0};return{...A,rootHash:AW(KW(A))}}if(M.schemaVersion===9){let{rootHash:$,...Y}=M,J={...Y,runtimeReady:!0};return{...J,rootHash:AW(KW(J))}}if(M.schemaVersion===8)throw e(W.file,"WOML_FORK_RUNTIME_UNAVAILABLE","Fork and control-choice syntax compiled successfully, but Model v13 execution begins in FJ5.",W.root.openTagSpan,"Use `woml check` to review Definition Package v8 during FJ3.");if(M.schemaVersion===7)throw e(W.file,"WOML_RUNTIME_POLICY_RUNTIME_UNAVAILABLE","Runtime-policy syntax compiled successfully, but Model v12 local-module runtime packaging is not available yet.",W.root.openTagSpan,"Use `woml check` to review Definition Package v7; runtime-package integration is scheduled for RP6.");if(M.schemaVersion===6)throw e(W.file,"WOML_LIFECYCLE_RUNTIME_UNAVAILABLE","Lifecycle syntax compiled successfully, but durable lifecycle execution begins in LEC2 and LEC3.",W.root.openTagSpan,"Use `woml check` to review the Model v11 definition during LEC1.");if(M.schemaVersion===4){let $={schemaVersion:5,profile:sZ,executable:M.executable,runtimeReady:!0,compilationRootHash:M.rootHash,workflow:M.workflow,modules:M.modules,sources:M.sources,artifacts:M.artifacts,compiler:M.compiler,permissions:M.permissions};return{...$,rootHash:AW(KW($))}}let L={schemaVersion:3,profile:cZ,executable:M.executable,runtimeReady:!0,compilationRootHash:M.rootHash,workflow:M.workflow,modules:M.modules,sources:M.sources,artifacts:M.artifacts,compiler:M.compiler,permissions:M.permissions};return{...L,rootHash:AW(KW(L))}}var cE="/callbacks/whatsapp";function tZ(W){return JSON.stringify(W)}function iE(W){let O=new Map;for(let L of W){let $=O.get(L.name)??new Set;for(let Y of L.exports)$.add(Y);O.set(L.name,$)}return`// Generated by WOML. Run \`woml types\` to refresh this file.
22
+ `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return kO(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:if(this.options.locations)this.lineStart=this.pos,++this.curLine;return"";case 56:case 57:if(this.strict)this.invalidStringToken(this.pos-1,"Invalid escape sequence");if(W){var M=this.pos-1;this.invalidStringToken(M,"Invalid escape sequence in template string")}default:if(O>=48&&O<=55){var L=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],$=parseInt(L,8);if($>255)L=L.slice(0,-1),$=parseInt(L,8);if(this.pos+=L.length-1,O=this.input.charCodeAt(this.pos),(L!=="0"||O===56||O===57)&&(this.strict||W))this.invalidStringToken(this.pos-1-L.length,W?"Octal literal in template string":"Octal literal in strict mode");return String.fromCharCode($)}if(l0(O)){if(this.options.locations)this.lineStart=this.pos,++this.curLine;return""}return String.fromCharCode(O)}};r.readHexChar=function(W){var O=this.pos,M=this.readInt(16,W);if(M===null)this.invalidStringToken(O,"Bad character escape sequence");return M};r.readWord1=function(){this.containsEsc=!1;var W="",O=!0,M=this.pos,L=this.options.ecmaVersion>=6;while(this.pos<this.input.length){var $=this.fullCharCodeAtPos();if(eO($,L))this.pos+=$<=65535?1:2;else if($===92){this.containsEsc=!0,W+=this.input.slice(M,this.pos);var Y=this.pos;if(this.input.charCodeAt(++this.pos)!==117)this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX");++this.pos;var J=this.readCodePoint();if(!(O?KO:eO)(J,L))this.invalidStringToken(Y,"Invalid Unicode escape");W+=kO(J),M=this.pos}else break;O=!1}return W+this.input.slice(M,this.pos)};r.readWord=function(){var W=this.readWord1(),O=z.name;if(this.keywords.test(W))O=R8[W];return this.finishToken(O,W)};var oK="8.15.0";VW.acorn={Parser:VW,version:oK,defaultOptions:Z8,Position:u1,SourceLocation:ZL,getLineInfo:r4,Node:RL,TokenType:OW,tokTypes:z,keywordTypes:R8,TokContext:QO,tokContexts:ZW,isIdentifierChar:eO,isIdentifierStart:KO,Token:K8,isNewLine:l0,lineBreak:uW,lineBreakG:FK,nonASCIIwhitespace:s4};function d1(W,O){return VW.parse(W,O)}class c1 extends Error{diagnostic;constructor(W){super(W.message);this.name="WomlDiagnosticError",this.diagnostic=W}}class T8 extends c1{constructor(W){super(W);this.name="WomlParseError"}}class O0 extends c1{constructor(W){super(W);this.name="WomlValidationError"}}class RO extends c1{constructor(W){super(W);this.name="WomlCompileError"}}class n{path;text;#W;constructor(W,O){this.path=W,this.text=O;let M=[0];for(let L=0;L<O.length;L+=1)if(O.charCodeAt(L)===10)M.push(L+1);this.#W=M}positionAt(W){let O=Math.max(0,Math.min(W,this.text.length)),M=0,L=this.#W.length;while(M+1<L){let $=Math.floor((M+L)/2);if(this.#W[$]<=O)M=$;else L=$}return{line:M+1,column:O-this.#W[M]+1,offset:O}}offsetAt(W,O){let M=Math.max(1,Math.min(W,this.#W.length)),L=this.#W[M-1],$=M<this.#W.length?this.#W[M]:this.text.length;return Math.max(L,Math.min(L+Math.max(O-1,0),$))}span(W,O){return{start:this.positionAt(W),end:this.positionAt(O)}}parseError(W,O,M,L=M+1,$){return new T8({code:W,phase:"parse",message:O,file:this.path,location:this.span(M,L),...$===void 0?{}:{hint:$}})}}function tK(W){return W.kind==="element"}var wA=/^[A-Z][A-Z0-9_]*$/,eK=/^\{\{secrets\.([A-Z][A-Z0-9_]*)\}\}$/;function EO(W){return wA.test(W)}function UL(W){let O=eK.exec(W);if(O===null)return;return{kind:"secretReference",name:O[1]}}function RW(W,O){let M=UL(O.value);if(M!==void 0)return M;let L=O.value.includes("{{secrets.");throw new O0({code:L?"WOML_SECRET_REFERENCE_INVALID":"WOML_SECRET_LITERAL_FORBIDDEN",phase:"validation",message:L?"Secret references must use the exact form {{secrets.NAME}}, where NAME starts with A-Z and contains only A-Z, 0-9, or underscore.":`Attribute "${O.name}" accepts a secret reference, never a literal credential.`,file:W.file,location:O.valueSpan,hint:`Use ${O.name}="{{secrets.SECRET_NAME}}" and store the value with woml secrets set SECRET_NAME.`})}var s1=`async function __woml_script(context, lifecycle, attempt, services, secrets) {
23
+ `,W3=`
24
+ }`,O3=new Set(["lifecycle","services","secrets","fetch"]),M3=new Set(["connect","listen","serve","udpSocket"]),L3=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,F8=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/,$3=/^([1-9][0-9]*)(ms|s|m|h|d)$/,Y3=/^[0-9]{17,20}$/,J3=/^[1-9][0-9]{5,19}$/,A3=/^[1-9][0-9]{7,15}$/,Z3=/^[a-z0-9_]+$/,G3=/^[a-z]{2,3}(?:_[A-Z]{2})?$/,X3={ms:1,s:1000,m:60000,h:3600000,d:86400000},PA=86400000;function f(W){return typeof W==="object"&&W!==null&&typeof W.type==="string"&&typeof W.start==="number"&&typeof W.end==="number"}function E8(W,O){let M=W.start-s1.length,L=W.end-s1.length,$=Math.max(0,Math.min(M,O)),Y=Math.max($+($<O?1:0),Math.min(L,O));return{start:$,end:Math.min(Y,O)}}function D(W,O,M,L,$){return{code:M,message:L,...E8(W,O),...$===void 0?{}:{hint:$}}}function qO(W){if(!f(W))return[];switch(W.type){case"Identifier":return[W];case"ObjectPattern":return(W.properties??[]).flatMap((O)=>{if(!f(O))return[];if(O.type==="RestElement")return qO(O.argument);return qO(O.value)});case"ArrayPattern":return(W.elements??[]).flatMap(qO);case"AssignmentPattern":return qO(W.left);case"RestElement":return qO(W.argument);default:return[]}}function NA(W){switch(W.type){case"VariableDeclarator":return qO(W.id);case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":return[...qO(W.id),...(W.params??[]).flatMap(qO)];case"ClassDeclaration":case"ClassExpression":return qO(W.id);case"CatchClause":return qO(W.param);default:return[]}}function Q3(W,O){if(O===void 0)return!1;return NA(O).includes(W)}function R3(W,O){if(O===void 0)return!1;if(Q3(W,O))return!0;if(O.type==="MemberExpression"&&O.property===W&&O.computed!==!0)return!0;if((O.type==="Property"||O.type==="PropertyDefinition")&&O.key===W&&O.computed!==!0&&O.shorthand!==!0)return!0;if((O.type==="MethodDefinition"||O.type==="LabeledStatement")&&(O.key===W||O.label===W))return!0;if((O.type==="BreakStatement"||O.type==="ContinueStatement")&&O.label===W)return!0;return!1}function S3(W){let O=[];for(let[M,L]of Object.entries(W)){if(M==="start"||M==="end"||M==="type")continue;if(f(L))O.push(L);else if(Array.isArray(L)){for(let $ of L)if(f($))O.push($)}}return O}function zL(W){if(W.type!=="MemberExpression")return;let O=W.property;if(!f(O))return;if(W.computed!==!0&&O.type==="Identifier")return O.name;return W.computed===!0&&O.type==="Literal"&&typeof O.value==="string"?O.value:void 0}function H0(W){let O=W;while(f(O)&&O.type==="MemberExpression")O=O.object;return f(O)&&O.type==="Identifier"?O:void 0}function i1(W){if(!f(W))return;if(W.type==="Identifier"&&W.name!==void 0)return[W.name];if(W.type!=="MemberExpression"||W.computed===!0)return;let O=i1(W.object),M=W.property;if(O===void 0||!f(M)||M.type!=="Identifier"||M.name===void 0)return;return[...O,M.name]}function FW(W){return f(W)&&W.type==="Literal"&&typeof W.value==="string"?W.value:void 0}function U3(W){if(W.type!=="Literal")return!0;if(typeof W.value==="number")return Number.isSafeInteger(W.value)&&W.value>0&&W.value<=PA;if(typeof W.value!=="string")return!1;let O=$3.exec(W.value);if(O===null)return!1;let L=Number(O[1])*X3[O[2]];return Number.isSafeInteger(L)&&L>0&&L<=PA}function vO(W,O){return O?.type==="AssignmentExpression"&&O.left===W||O?.type==="UpdateExpression"&&O.argument===W||O?.type==="UnaryExpression"&&O.operator==="delete"&&O.argument===W}function z3(W,O){let M=W.pos??W.raisedAt??s1.length,L=Math.max(0,Math.min(M-s1.length,O));return{code:"WOML_SCRIPT_SYNTAX_INVALID",message:W.message.replace(/ \(\d+:\d+\)$/,""),start:L,end:Math.min(Math.max(L+1,L),O),hint:"Fix the JavaScript syntax inside this <script> body."}}function VL(W,O,M={}){let L;try{L=d1(`${s1}${W}${W3}`,{ecmaVersion:"latest",sourceType:"script",allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1})}catch(S){return{requiredSecrets:[],requiredServices:[],serviceReferences:[],usesServices:!1,usesNativeFetch:!1,issue:z3(S,W.length)}}let $=L.body?.find((S)=>f(S)&&S.type==="FunctionDeclaration"),Y=f($)?$:void 0,J=f(Y?.body)?Y.body:void 0;if(J===void 0)return{requiredSecrets:[],requiredServices:[],serviceReferences:[],usesServices:!1,usesNativeFetch:!1,issue:{code:"WOML_SCRIPT_SYNTAX_INVALID",message:"The script could not be parsed as an asynchronous function body.",start:0,end:Math.min(W.length,1)}};let A=new Set,Z=new Map,G=!1,X=!1,Q,R=(S)=>{if(Q===void 0||S.start<Q.start)Q=S},U=(S,H,F)=>{let K=E8(S,W.length);if(Q!==void 0&&K.start>Q.start)return;if(S.type==="ImportExpression")R(D(S,W.length,"WOML_SCRIPT_DYNAMIC_IMPORT_UNSUPPORTED","Dynamic import is unavailable in the current WOML script profile.","Use the future WOML module system when it becomes available."));if(S.type==="CallExpression"&&f(S.callee)){let w=S.callee,P=i1(w);if(P?.[0]==="services"&&P[1]==="workflows"){let B=P[2];if(P.length!==3||B!=="call"&&B!=="start")R(D(w,W.length,"WOML_WORKFLOW_OPERATION_UNSUPPORTED",`Workflow service operation "${P.slice(2).join(".")||""}" is unsupported.`,"Use services.workflows.call() when the result is needed or services.workflows.start() to continue after durable admission."));else{let q=S.arguments??[];if(q.length<2||q.length>3)R(D(S,W.length,"WOML_WORKFLOW_CALL_ARGUMENTS_INVALID",`services.workflows.${B}() requires workflowId, payload, and optional options.`,B==="call"?'Use services.workflows.call("workflow-id", { ... }, { name, timeout }).':'Use services.workflows.start("workflow-id", { ... }, { name }).'));else{let N=q[0],_=FW(N);if(f(N)&&N.type==="Literal"&&(_===void 0||_.length>256||!L3.test(_)))R(D(N,W.length,"WOML_WORKFLOW_TARGET_INVALID","A literal workflow target must use lowercase kebab-case.",`Example: services.workflows.${B}("calculate-risk", { ... }).`));let V=q[1];if(f(V)&&(V.type==="Literal"||V.type==="ArrayExpression"))R(D(V,W.length,"WOML_WORKFLOW_PAYLOAD_INVALID","A workflow call payload must be a top-level JSON object.","Pass an object literal or an expression that resolves to an object."));let C=q[2];if(f(C)&&(C.type==="Literal"||C.type==="ArrayExpression"))R(D(C,W.length,"WOML_WORKFLOW_CALL_OPTIONS_INVALID","Workflow call options must be an object.",'Use { name: "logical-call", timeout: "30s" }.'));else if(f(C)&&C.type==="ObjectExpression")for(let I of C.properties??[]){if(!f(I)||I.type!=="Property"){R(D(f(I)?I:C,W.length,"WOML_WORKFLOW_CALL_OPTIONS_INVALID","Workflow call options do not support spread or computed members.","Use only static name and timeout properties."));continue}let b=f(I.key)?I.key.type==="Identifier"?I.key.name:FW(I.key):void 0;if(b!=="name"&&(B!=="call"||b!=="timeout"))R(D(I,W.length,"WOML_WORKFLOW_CALL_OPTION_UNKNOWN",`Unknown workflow call option "${b??""}".`,B==="call"?"Workflow Call v1 options are name and timeout.":"Workflow Start v1 accepts only name."));if(b==="name"){let k=FW(I.value);if(f(I.value)&&I.value.type==="Literal"&&(k===void 0||k.length>128||!F8.test(k)))R(D(I.value,W.length,"WOML_WORKFLOW_CALL_NAME_INVALID","A literal workflow call name must use lowercase operation-name syntax.","Example: primary-risk"))}if(B==="call"&&b==="timeout"&&f(I.value)&&!U3(I.value))R(D(I.value,W.length,"WOML_WORKFLOW_CALL_OPTIONS_INVALID","A literal workflow call timeout must be a positive duration no greater than 24h.",'Use milliseconds or a whole duration such as "30s", "5m", or "24h".'))}}}}if(P?.[0]==="services"&&P[1]==="telegram"&&!M.shadowedServices?.includes("telegram"))if(P.length!==3||P[2]!=="send")R(D(w,W.length,"WOML_TELEGRAM_OPERATION_UNSUPPORTED",`Telegram service operation "${P.slice(2).join(".")||""}" is unsupported.`,"Use services.telegram.send({ botToken, conversationId, text })."));else{let B=S.arguments??[];if(B.length<1||B.length>2)R(D(S,W.length,"WOML_TELEGRAM_SEND_ARGUMENTS_INVALID","services.telegram.send() requires one request object and optional operation options.",'Use services.telegram.send({ botToken: secrets.TELEGRAM_BOT_TOKEN, conversationId, text }, { name: "reply" }).'));else{let q=B[0];if(!f(q)||q.type!=="ObjectExpression")R(D(f(q)?q:S,W.length,"WOML_TELEGRAM_SEND_INPUT_INVALID","A workflow script must pass a direct object to services.telegram.send().","Use the required botToken, conversationId, and text properties."));else{let _=new Set;for(let V of q.properties??[]){if(!f(V)||V.type!=="Property"||V.computed===!0||V.kind!=="init"){R(D(f(V)?V:q,W.length,"WOML_TELEGRAM_SEND_INPUT_INVALID","Telegram send input does not support spreads, computed keys, getters, or setters."));continue}let C=f(V.key)?V.key.type==="Identifier"?V.key.name:FW(V.key):void 0;if(C!=="botToken"&&C!=="conversationId"&&C!=="text"&&C!=="replyToMessageId"){R(D(V,W.length,"WOML_TELEGRAM_SEND_PROPERTY_UNKNOWN",`Unknown Telegram send property "${C??""}".`,"Telegram Send v1 accepts botToken, conversationId, text, and replyToMessageId."));continue}if(_.has(C))R(D(V,W.length,"WOML_TELEGRAM_SEND_PROPERTY_DUPLICATE",`Telegram send property "${C}" is declared more than once.`));if(_.add(C),C==="botToken"){let b=f(V.value)?i1(V.value):void 0;if(b?.length!==2||b[0]!=="secrets"||!EO(b[1]))R(D(f(V.value)?V.value:V,W.length,"WOML_TELEGRAM_CREDENTIAL_INVALID","Telegram botToken must be one direct secrets.NAME value.","Example: botToken: secrets.TELEGRAM_BOT_TOKEN"))}let I=FW(V.value);if(I!==void 0&&(I.length===0||I.length>(C==="text"?40000:320)))R(D(V.value,W.length,"WOML_TELEGRAM_SEND_VALUE_INVALID",`Telegram send property "${C}" has an invalid literal value.`))}for(let V of["botToken","conversationId","text"])if(!_.has(V))R(D(q,W.length,"WOML_TELEGRAM_SEND_PROPERTY_REQUIRED",`services.telegram.send() requires the "${V}" property.`))}let N=B[1];if(f(N))if(N.type!=="ObjectExpression")R(D(N,W.length,"WOML_TELEGRAM_SEND_OPTIONS_INVALID","Telegram send operation options must be an object containing an optional stable name."));else for(let _ of N.properties??[]){let V=f(_)&&_.type==="Property"&&f(_.key)?_.key.type==="Identifier"?_.key.name:FW(_.key):void 0;if(V!=="name")R(D(f(_)?_:N,W.length,"WOML_TELEGRAM_SEND_OPTION_UNKNOWN",`Unknown Telegram send option "${V??""}".`,"Telegram Send v1 accepts only the stable name option."))}}}if(P?.[0]==="services"&&P[1]==="discord"&&!M.shadowedServices?.includes("discord"))if(P.length!==3||P[2]!=="send")R(D(w,W.length,"WOML_DISCORD_OPERATION_UNSUPPORTED",`Discord service operation "${P.slice(2).join(".")||""}" is unsupported.`,"Use services.discord.send({ botToken, conversationId, text })."));else{let B=S.arguments??[];if(B.length<1||B.length>2)R(D(S,W.length,"WOML_DISCORD_SEND_ARGUMENTS_INVALID","services.discord.send() requires one request object and optional operation options.",'Use services.discord.send({ botToken: secrets.DISCORD_BOT_TOKEN, conversationId, text }, { name: "reply" }).'));else{let q=B[0];if(!f(q)||q.type!=="ObjectExpression")R(D(f(q)?q:S,W.length,"WOML_DISCORD_SEND_INPUT_INVALID","A workflow script must pass a direct object to services.discord.send().","Use the required botToken, conversationId, and text properties."));else{let _=new Set;for(let V of q.properties??[]){if(!f(V)||V.type!=="Property"||V.computed===!0||V.kind!=="init"){R(D(f(V)?V:q,W.length,"WOML_DISCORD_SEND_INPUT_INVALID","Discord send input does not support spreads, computed keys, getters, or setters."));continue}let C=f(V.key)?V.key.type==="Identifier"?V.key.name:FW(V.key):void 0;if(C!=="botToken"&&C!=="conversationId"&&C!=="text"&&C!=="replyToMessageId"){R(D(V,W.length,"WOML_DISCORD_SEND_PROPERTY_UNKNOWN",`Unknown Discord send property "${C??""}".`,"Discord Send v1 accepts botToken, conversationId, text, and replyToMessageId."));continue}if(_.has(C))R(D(V,W.length,"WOML_DISCORD_SEND_PROPERTY_DUPLICATE",`Discord send property "${C}" is declared more than once.`));if(_.add(C),C==="botToken"){let b=f(V.value)?i1(V.value):void 0;if(b?.length!==2||b[0]!=="secrets"||!EO(b[1]))R(D(f(V.value)?V.value:V,W.length,"WOML_DISCORD_CREDENTIAL_INVALID","Discord botToken must be one direct secrets.NAME value.","Example: botToken: secrets.DISCORD_BOT_TOKEN"))}let I=FW(V.value);if(I!==void 0&&(I.length===0||I.length>(C==="text"?2000:320)))R(D(V.value,W.length,"WOML_DISCORD_SEND_VALUE_INVALID",`Discord send property "${C}" has an invalid literal value.`));if(I!==void 0&&(C==="conversationId"||C==="replyToMessageId")&&!Y3.test(I))R(D(V.value,W.length,"WOML_DISCORD_SEND_VALUE_INVALID",`Discord send property "${C}" must be a numeric Discord snowflake containing 17 to 20 digits when written as a literal.`))}for(let V of["botToken","conversationId","text"])if(!_.has(V))R(D(q,W.length,"WOML_DISCORD_SEND_PROPERTY_REQUIRED",`services.discord.send() requires the "${V}" property.`))}let N=B[1];if(f(N))if(N.type!=="ObjectExpression")R(D(N,W.length,"WOML_DISCORD_SEND_OPTIONS_INVALID","Discord send operation options must be an object containing an optional stable name."));else{let _=new Set;for(let V of N.properties??[]){if(!f(V)||V.type!=="Property"||V.computed===!0||V.kind!=="init"){R(D(f(V)?V:N,W.length,"WOML_DISCORD_SEND_OPTIONS_INVALID","Discord send options do not support spreads, computed keys, getters, or setters."));continue}let C=f(V.key)?V.key.type==="Identifier"?V.key.name:FW(V.key):void 0;if(C!=="name"){R(D(V,W.length,"WOML_DISCORD_SEND_OPTION_UNKNOWN",`Unknown Discord send option "${C??""}".`,"Discord Send v1 accepts only the stable name option."));continue}if(_.has(C))R(D(V,W.length,"WOML_DISCORD_SEND_OPTION_DUPLICATE",'Discord send option "name" is declared more than once.'));_.add(C);let I=FW(V.value);if(f(V.value)&&V.value.type==="Literal"&&(I===void 0||I.length>128||!F8.test(I)))R(D(V.value,W.length,"WOML_DISCORD_SEND_NAME_INVALID","A literal Discord send name must use lowercase operation-name syntax.","Example: reply-to-message"))}}}}if(P?.[0]==="services"&&P[1]==="whatsapp"&&!M.shadowedServices?.includes("whatsapp"))if(P.length!==3||P[2]!=="send")R(D(w,W.length,"WOML_WHATSAPP_OPERATION_UNSUPPORTED",`WhatsApp service operation "${P.slice(2).join(".")||""}" is unsupported.`,"Use services.whatsapp.send({ accessToken, phoneNumberId, conversationId, template })."));else{let B=S.arguments??[],q=B[0];if(B.length<1||B.length>2)R(D(S,W.length,"WOML_WHATSAPP_SEND_ARGUMENTS_INVALID","services.whatsapp.send() requires one request object and optional operation options."));else if(!f(q)||q.type!=="ObjectExpression")R(D(f(q)?q:S,W.length,"WOML_WHATSAPP_SEND_INPUT_INVALID","A workflow script must pass a direct object to services.whatsapp.send()."));else{let N=new Set;for(let V of q.properties??[]){if(!f(V)||V.type!=="Property"||V.computed===!0||V.kind!=="init"){R(D(f(V)?V:q,W.length,"WOML_WHATSAPP_SEND_INPUT_INVALID","WhatsApp send input does not support spreads, computed keys, getters, or setters."));continue}let C=f(V.key)?V.key.type==="Identifier"?V.key.name:FW(V.key):void 0;if(C!=="accessToken"&&C!=="phoneNumberId"&&C!=="conversationId"&&C!=="template"){R(D(V,W.length,"WOML_WHATSAPP_SEND_PROPERTY_UNKNOWN",`Unknown WhatsApp send property "${C??""}".`,"WhatsApp Send v1 accepts accessToken, phoneNumberId, conversationId, and template."));continue}if(N.has(C))R(D(V,W.length,"WOML_WHATSAPP_SEND_PROPERTY_DUPLICATE",`WhatsApp send property "${C}" is declared more than once.`));if(N.add(C),C==="accessToken"){let b=f(V.value)?i1(V.value):void 0;if(b?.length!==2||b[0]!=="secrets"||!EO(b[1]))R(D(f(V.value)?V.value:V,W.length,"WOML_WHATSAPP_CREDENTIAL_INVALID","WhatsApp accessToken must be one direct secrets.NAME value.","Example: accessToken: secrets.WHATSAPP_ACCESS_TOKEN"))}let I=FW(V.value);if(I!==void 0&&C==="phoneNumberId"&&!J3.test(I))R(D(V.value,W.length,"WOML_WHATSAPP_SEND_VALUE_INVALID","WhatsApp phoneNumberId must be the numeric Meta Phone Number ID."));if(I!==void 0&&C==="conversationId"&&!A3.test(I))R(D(V.value,W.length,"WOML_WHATSAPP_SEND_VALUE_INVALID","WhatsApp conversationId must be an international phone number containing 8 to 16 digits without a plus sign."));if(C==="template"){if(!f(V.value)||V.value.type!=="ObjectExpression"){R(D(f(V.value)?V.value:V,W.length,"WOML_WHATSAPP_TEMPLATE_INVALID","WhatsApp template must be a direct object with name, language, and parameters."));continue}let b=new Set;for(let k of V.value.properties??[]){if(!f(k)||k.type!=="Property"||k.computed===!0||k.kind!=="init"){R(D(f(k)?k:V.value,W.length,"WOML_WHATSAPP_TEMPLATE_INVALID","WhatsApp template does not support spreads, computed keys, getters, or setters."));continue}let p=f(k.key)?k.key.type==="Identifier"?k.key.name:FW(k.key):void 0;if(p!=="name"&&p!=="language"&&p!=="parameters"){R(D(k,W.length,"WOML_WHATSAPP_TEMPLATE_PROPERTY_UNKNOWN",`Unknown WhatsApp template property "${p??""}".`));continue}if(b.has(p))R(D(k,W.length,"WOML_WHATSAPP_TEMPLATE_PROPERTY_DUPLICATE",`WhatsApp template property "${p}" is declared more than once.`));b.add(p);let XW=FW(k.value);if(p==="name"&&(XW===void 0||!Z3.test(XW)))R(D(k.value,W.length,"WOML_WHATSAPP_TEMPLATE_INVALID","WhatsApp template name must be a literal containing lowercase letters, digits, and underscores only."));if(p==="language"&&(XW===void 0||!G3.test(XW)))R(D(k.value,W.length,"WOML_WHATSAPP_LANGUAGE_INVALID","WhatsApp template language must be a literal such as en, en_US, or pt_BR."));if(p==="parameters"&&f(k.value))if(k.value.type!=="ArrayExpression")R(D(k.value,W.length,"WOML_WHATSAPP_TEMPLATE_PARAMETERS_INVALID","WhatsApp template parameters must be a direct array."));else{let MW=k.value.elements??[];if(MW.length>32||MW.some((AW)=>f(AW)&&(FW(AW)?.length??0)>1024))R(D(k.value,W.length,"WOML_WHATSAPP_TEMPLATE_PARAMETERS_INVALID","WhatsApp templates accept at most 32 parameters of at most 1024 characters each."))}}for(let k of["name","language","parameters"])if(!b.has(k))R(D(V.value,W.length,"WOML_WHATSAPP_TEMPLATE_PROPERTY_REQUIRED",`WhatsApp template requires the "${k}" property.`))}}for(let V of["accessToken","phoneNumberId","conversationId","template"])if(!N.has(V))R(D(q,W.length,"WOML_WHATSAPP_SEND_PROPERTY_REQUIRED",`services.whatsapp.send() requires the "${V}" property.`));let _=B[1];if(f(_))if(_.type!=="ObjectExpression")R(D(_,W.length,"WOML_WHATSAPP_SEND_OPTIONS_INVALID","WhatsApp send operation options must be an object containing an optional stable name."));else{let V=new Set;for(let C of _.properties??[]){if(!f(C)||C.type!=="Property"||C.computed===!0||C.kind!=="init"){R(D(f(C)?C:_,W.length,"WOML_WHATSAPP_SEND_OPTIONS_INVALID","WhatsApp send options do not support spreads, computed keys, getters, or setters."));continue}let I=f(C.key)?C.key.type==="Identifier"?C.key.name:FW(C.key):void 0;if(I!=="name"){R(D(C,W.length,"WOML_WHATSAPP_SEND_OPTION_UNKNOWN",`Unknown WhatsApp send option "${I??""}".`,"WhatsApp Send v1 accepts only the stable name option."));continue}if(V.has(I))R(D(C,W.length,"WOML_WHATSAPP_SEND_OPTION_DUPLICATE",'WhatsApp send option "name" is declared more than once.'));V.add(I);let b=FW(C.value);if(f(C.value)&&C.value.type==="Literal"&&(b===void 0||b.length>128||!F8.test(b)))R(D(C.value,W.length,"WOML_WHATSAPP_SEND_NAME_INVALID","A literal WhatsApp send name must use lowercase operation-name syntax.","Example: send-template"))}}}}if(w.type==="Identifier"&&w.name==="require")R(D(S,W.length,"WOML_SCRIPT_MODULE_REQUIRE_UNSUPPORTED","Runtime module loading is unavailable in the current WOML script profile.","Use the future WOML module system when it becomes available."));if(w.type==="MemberExpression"&&H0(w)?.name==="Bun"&&M3.has(zL(w)??""))R(D(S,W.length,"WOML_SCRIPT_RAW_NETWORK_UNSUPPORTED","Raw Bun networking is unavailable in the tracked WOML script profile.","Use native fetch() or a managed services operation."))}if((S.type==="CallExpression"||S.type==="NewExpression")&&f(S.callee)&&S.callee.type==="Identifier"&&S.callee.name==="WebSocket")R(D(S,W.length,"WOML_SCRIPT_RAW_NETWORK_UNSUPPORTED","WebSocket networking is unavailable in the tracked WOML script profile.","Use native fetch() or a managed services operation."));for(let w of NA(S))if(w.name!==void 0&&(O3.has(w.name)||(O==="reusable-step"||O==="notification-provider")&&(w.name==="props"||O==="notification-provider"&&w.name==="notification")))R(D(w,W.length,"WOML_SCRIPT_BINDING_SHADOWED",`The reserved WOML binding "${w.name}" cannot be redeclared or shadowed.`,`Rename this local binding; WOML provides ${w.name} at runtime.`));if(S.type==="MemberExpression"&&H0(S)?.name==="services"){if(S.computed===!0)R(D(S,W.length,"WOML_SCRIPT_SERVICE_ACCESS_DYNAMIC","Computed service access is not executable in Script Bindings v1.","Use static service and operation names such as services.http.request."));else if(S.optional===!0)R(D(S,W.length,"WOML_SCRIPT_SERVICE_ACCESS_UNSUPPORTED","Optional access is not supported for the services binding.","Use a static service operation such as services.http.request."));else if(vO(S,H))R(D(S,W.length,"WOML_SCRIPT_SERVICE_WRITE_UNSUPPORTED","The services binding is read-only.","Call a service operation; do not replace or delete service members."))}if(S.type==="MemberExpression"&&H0(S)?.name==="lifecycle"&&vO(S,H))R(D(S,W.length,"WOML_LIFECYCLE_BINDING_READ_ONLY","The lifecycle binding is read-only.","Read lifecycle event data without replacing or deleting it."));if((O==="reusable-step"||O==="notification-provider")&&S.type==="MemberExpression"&&(H0(S)?.name==="props"||O==="notification-provider"&&H0(S)?.name==="notification")&&vO(S,H))R(D(S,W.length,H0(S)?.name==="props"?"WOML_REUSABLE_PROPS_READ_ONLY":"WOML_PROVIDER_NOTIFICATION_READ_ONLY",H0(S)?.name==="props"?"The reusable props binding is immutable.":"The provider notification binding is immutable.","Read provider bindings without replacing, deleting, or updating them."));if(S.type==="Identifier"&&S.name!==void 0&&!R3(S,H)){if(S.name==="lifecycle"){if(O!=="lifecycle")R(D(S,W.length,"WOML_LIFECYCLE_BINDING_UNAVAILABLE","The lifecycle binding is available only inside <lifecycle> scripts.","Use context inside a normal workflow step, or move this observer into <lifecycle>."));else if(vO(S,H))R(D(S,W.length,"WOML_LIFECYCLE_BINDING_READ_ONLY","The lifecycle binding is read-only."))}else if(S.name==="props"&&(O==="reusable-step"||O==="notification-provider")){if(vO(S,H))R(D(S,W.length,"WOML_REUSABLE_PROPS_READ_ONLY","The reusable props binding is immutable."))}else if(S.name==="notification"&&O==="notification-provider"){if(vO(S,H))R(D(S,W.length,"WOML_PROVIDER_NOTIFICATION_READ_ONLY","The provider notification binding is immutable."))}else if(S.name==="context"&&O==="notification-provider")R(D(S,W.length,"WOML_PROVIDER_CONTEXT_UNAVAILABLE","Notification provider scripts cannot access workflow context directly.","Pass required business values through declared props."));else if(S.name==="secrets"){if(O==="reusable-step"||O==="notification-provider")R(D(S,W.length,"WOML_REUSABLE_SECRET_ACCESS_FORBIDDEN","Reusable definition scripts cannot access secrets directly.","Declare a secret prop and pass one exact {{secrets.NAME}} reference at the invocation."));if(H?.type==="MemberExpression"&&H.object===S)if(vO(H,F))R(D(H,W.length,"WOML_SCRIPT_SECRET_WRITE_UNSUPPORTED","The secrets binding is read-only.","Read the required value with secrets.SECRET_NAME; do not replace or delete it."));else if(H.optional===!0)R(D(H,W.length,"WOML_SCRIPT_SECRET_ACCESS_UNSUPPORTED","Optional access is not supported for the required secrets binding.","Use the exact form secrets.SECRET_NAME."));else if(H.computed===!0)R(D(H,W.length,"WOML_SCRIPT_SECRET_ACCESS_DYNAMIC","Computed secret access is not executable in Script Bindings v1.","Use the exact literal property form secrets.SECRET_NAME."));else{let w=zL(H);if(w===void 0||!EO(w))R(D(f(H.property)?H.property:H,W.length,"WOML_SCRIPT_SECRET_NAME_INVALID",`Invalid script secret name "${w??""}".`,"Secret names must start with A-Z and contain only A-Z, 0-9, or underscore."));else A.add(w)}else R(D(S,W.length,"WOML_SCRIPT_SECRET_ACCESS_UNSUPPORTED","The secrets binding cannot be enumerated, aliased, returned, or passed as a whole object.","Access only the exact value needed with secrets.SECRET_NAME."))}else if(S.name==="services")if(H?.type==="MemberExpression"&&H.object===S)if(H.optional===!0)R(D(H,W.length,"WOML_SCRIPT_SERVICE_ACCESS_UNSUPPORTED","Optional access is not supported for the services binding.","Use a static service name such as services.http."));else if(H.computed===!0)R(D(H,W.length,"WOML_SCRIPT_SERVICE_ACCESS_DYNAMIC","Computed service access is not executable in Script Bindings v1.","Use a static service name such as services.http."));else{G=!0;let w=zL(H);if(w!==void 0&&!Z.has(w))Z.set(w,{name:w,...E8(H,W.length)})}else R(D(S,W.length,"WOML_SCRIPT_SERVICE_ACCESS_UNSUPPORTED","The services binding cannot be enumerated, aliased, returned, or passed as a whole object.","Call a static service namespace such as services.http."));else if(S.name==="fetch")if(vO(S,H))R(D(S,W.length,"WOML_SCRIPT_FETCH_WRITE_UNSUPPORTED","The tracked native fetch binding cannot be replaced or deleted.","Call fetch() directly without modifying the runtime binding."));else X=!0;else if((S.name==="globalThis"||S.name==="self")&&H?.type==="MemberExpression"&&H.object===S&&zL(H)==="fetch")if(vO(H,F))R(D(H,W.length,"WOML_SCRIPT_FETCH_WRITE_UNSUPPORTED","The tracked native fetch binding cannot be replaced or deleted.","Call fetch() directly without modifying the runtime binding."));else X=!0}for(let w of S3(S))U(w,S,H)};for(let S of J.body??[])if(f(S))U(S);let T=[...A].sort();if(T.length>64)Q=D(J,W.length,"WOML_SCRIPT_SECRET_LIMIT_EXCEEDED","One script may reference at most 64 distinct secrets.","Split the operation into smaller steps with explicit secret dependencies.");return{requiredSecrets:T,requiredServices:[...Z.keys()].sort(),serviceReferences:[...Z.values()].sort((S,H)=>S.name.localeCompare(H.name)),usesServices:G,usesNativeFetch:X,...Q===void 0?{}:{issue:Q}}}function q8(W,O={}){return VL(W,"step",O)}function HL(W,O={}){return VL(W,"lifecycle",O)}function B8(W){return VL(W,"reusable-step")}function C8(W){return VL(W,"notification-provider")}var V3=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",H3="[:A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]["+V3+"]*",K3=new RegExp("^"+H3+"$");function KL(W,O){let M=[],L=O.exec(W);while(L){let $=[];$.startIndex=O.lastIndex-L[0].length;let Y=L.length;for(let J=0;J<Y;J++)$.push(L[J]);M.push($),L=O.exec(W)}return M}var w8=function(W){let O=K3.exec(W);return!(O===null||typeof O>"u")};function _A(W){return typeof W<"u"}var n1=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],TL=["__proto__","constructor","prototype"];var T3={allowBooleanAttributes:!1,unpairedTags:[]};function FL(W,O){O=Object.assign({},T3,O);let M=[],L=!1,$=!1;if(W[0]==="\uFEFF")W=W.substr(1);for(let Y=0;Y<W.length;Y++)if(W[Y]==="<"&&W[Y+1]==="?"){if(Y+=2,Y=IA(W,Y),Y.err)return Y}else if(W[Y]==="<"){let J=Y;if(Y++,W[Y]==="!"){Y=yA(W,Y);continue}else{let A=!1;if(W[Y]==="/")A=!0,Y++;let Z="";for(;Y<W.length&&W[Y]!==">"&&W[Y]!==" "&&W[Y]!=="\t"&&W[Y]!==`
25
+ `&&W[Y]!=="\r";Y++)Z+=W[Y];if(Z=Z.trim(),Z[Z.length-1]==="/")Z=Z.substring(0,Z.length-1),Y--;if(!N3(Z)){let Q;if(Z.trim().length===0)Q="Invalid space after '<'.";else Q="Tag '"+Z+"' is an invalid name.";return SW("InvalidTag",Q,jW(W,Y))}let G=q3(W,Y);if(G===!1)return SW("InvalidAttr","Attributes for '"+Z+"' have open quote.",jW(W,Y));let X=G.value;if(Y=G.index,X[X.length-1]==="/"){let Q=Y-X.length;X=X.substring(0,X.length-1);let R=DA(X,O);if(R===!0)L=!0;else return SW(R.err.code,R.err.msg,jW(W,Q+R.err.line))}else if(A)if(!G.tagClosed)return SW("InvalidTag","Closing tag '"+Z+"' doesn't have proper closing.",jW(W,Y));else if(X.trim().length>0)return SW("InvalidTag","Closing tag '"+Z+"' can't have attributes or invalid starting.",jW(W,J));else if(M.length===0)return SW("InvalidTag","Closing tag '"+Z+"' has not been opened.",jW(W,J));else{let Q=M.pop();if(Z!==Q.tagName){let R=jW(W,Q.tagStartPos);return SW("InvalidTag","Expected closing tag '"+Q.tagName+"' (opened in line "+R.line+", col "+R.col+") instead of closing tag '"+Z+"'.",jW(W,J))}if(M.length==0)$=!0}else{let Q=DA(X,O);if(Q!==!0)return SW(Q.err.code,Q.err.msg,jW(W,Y-X.length+Q.err.line));if($===!0)return SW("InvalidXml","Multiple possible root nodes found.",jW(W,Y));else if(O.unpairedTags.indexOf(Z)!==-1);else M.push({tagName:Z,tagStartPos:J});L=!0}for(Y++;Y<W.length;Y++)if(W[Y]==="<")if(W[Y+1]==="!"){Y++,Y=yA(W,Y);continue}else if(W[Y+1]==="?"){if(Y=IA(W,++Y),Y.err)return Y}else break;else if(W[Y]==="&"){let Q=w3(W,Y);if(Q==-1)return SW("InvalidChar","char '&' is not expected.",jW(W,Y));Y=Q}else if($===!0&&!jA(W[Y]))return SW("InvalidXml","Extra text at the end",jW(W,Y));if(W[Y]==="<")Y--}}else{if(jA(W[Y]))continue;return SW("InvalidChar","char '"+W[Y]+"' is not expected.",jW(W,Y))}if(!L)return SW("InvalidXml","Start tag expected.",1);else if(M.length==1)return SW("InvalidTag","Unclosed tag '"+M[0].tagName+"'.",jW(W,M[0].tagStartPos));else if(M.length>0)return SW("InvalidXml","Invalid '"+JSON.stringify(M.map((Y)=>Y.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1});return!0}function jA(W){return W===" "||W==="\t"||W===`
26
+ `||W==="\r"}function IA(W,O){let M=O;for(;O<W.length;O++)if(W[O]=="?"||W[O]==" "){let L=W.substr(M,O-M);if(O>5&&L==="xml")return SW("InvalidXml","XML declaration allowed only at the start of the document.",jW(W,O));else if(W[O]=="?"&&W[O+1]==">"){O++;break}else continue}return O}function yA(W,O){if(W.length>O+5&&W[O+1]==="-"&&W[O+2]==="-"){for(O+=3;O<W.length;O++)if(W[O]==="-"&&W[O+1]==="-"&&W[O+2]===">"){O+=2;break}}else if(W.length>O+8&&W[O+1]==="D"&&W[O+2]==="O"&&W[O+3]==="C"&&W[O+4]==="T"&&W[O+5]==="Y"&&W[O+6]==="P"&&W[O+7]==="E"){let M=1;for(O+=8;O<W.length;O++)if(W[O]==="<")M++;else if(W[O]===">"){if(M--,M===0)break}}else if(W.length>O+9&&W[O+1]==="["&&W[O+2]==="C"&&W[O+3]==="D"&&W[O+4]==="A"&&W[O+5]==="T"&&W[O+6]==="A"&&W[O+7]==="["){for(O+=8;O<W.length;O++)if(W[O]==="]"&&W[O+1]==="]"&&W[O+2]===">"){O+=2;break}}return O}var F3='"',E3="'";function q3(W,O){let M="",L="",$=!1;for(;O<W.length;O++){if(W[O]===F3||W[O]===E3)if(L==="")L=W[O];else if(L!==W[O]);else L="";else if(W[O]===">"){if(L===""){$=!0;break}}M+=W[O]}if(L!=="")return!1;return{value:M,index:O,tagClosed:$}}var B3=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function DA(W,O){let M=KL(W,B3),L={};for(let $=0;$<M.length;$++){if(M[$][1].length===0)return SW("InvalidAttr","Attribute '"+M[$][2]+"' has no space in starting.",r1(M[$]));else if(M[$][3]!==void 0&&M[$][4]===void 0)return SW("InvalidAttr","Attribute '"+M[$][2]+"' is without value.",r1(M[$]));else if(M[$][3]===void 0&&!O.allowBooleanAttributes)return SW("InvalidAttr","boolean attribute '"+M[$][2]+"' is not allowed.",r1(M[$]));let Y=M[$][2];if(!P3(Y))return SW("InvalidAttr","Attribute '"+Y+"' is an invalid name.",r1(M[$]));if(!Object.prototype.hasOwnProperty.call(L,Y))L[Y]=1;else return SW("InvalidAttr","Attribute '"+Y+"' is repeated.",r1(M[$]))}return!0}function C3(W,O){let M=/\d/;if(W[O]==="x")O++,M=/[\da-fA-F]/;for(;O<W.length;O++){if(W[O]===";")return O;if(!W[O].match(M))break}return-1}function w3(W,O){if(O++,W[O]===";")return-1;if(W[O]==="#")return O++,C3(W,O);let M=0;for(;O<W.length;O++,M++){if(W[O].match(/\w/)&&M<20)continue;if(W[O]===";")break;return-1}return O}function SW(W,O,M){return{err:{code:W,msg:O,line:M.line||M,col:M.col}}}function P3(W){return w8(W)}function N3(W){return w8(W)}function jW(W,O){let M=W.substring(0,O).split(/\r?\n/);return{line:M.length,col:M[M.length-1].length+1}}function r1(W){return W.startIndex+W[1].length}var P8={cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",euro:"\u20AC",dollar:"$",fnof:"\u0192",inr:"\u20B9",af:"\u060B",birr:"\u1265\u122D",peso:"\u20B1",rub:"\u20BD",won:"\u20A9",yuan:"\xA5",cedil:"\xB8"};var a1={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},N8={nbsp:"\xA0",copy:"\xA9",reg:"\xAE",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xAB",raquo:"\xBB",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",bull:"\u2022",para:"\xB6",sect:"\xA7",deg:"\xB0",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE"};var c0=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),_3=new Set("!?\\\\/[]$%{}^&*()<>|+");function kA(W){if(W[0]==="#")throw Error(`[EntityReplacer] Invalid character '#' in entity name: "${W}"`);for(let O of W)if(_3.has(O))throw Error(`[EntityReplacer] Invalid character '${O}' in entity name: "${W}"`);return W}function o1(...W){let O=Object.create(null);for(let M of W){if(!M)continue;for(let L of Object.keys(M)){let $=M[L];if(typeof $==="string")O[L]=$;else if($&&typeof $==="object"&&$.val!==void 0){let Y=$.val;if(typeof Y==="string")O[L]=Y}}}return O}var K0="external",EL="base",_8="all";function j3(W){if(!W||W===K0)return new Set([K0]);if(W===_8)return new Set([_8]);if(W===EL)return new Set([EL]);if(Array.isArray(W))return new Set(W);return new Set([K0])}var lW=Object.freeze({allow:0,leave:1,remove:2,throw:3}),I3=new Set([9,10,13]);function y3(W){if(!W)return{xmlVersion:1,onLevel:lW.allow,nullLevel:lW.remove};let O=W.xmlVersion===1.1?1.1:1,M=lW[W.onNCR]??lW.allow,L=lW[W.nullNCR]??lW.remove,$=Math.max(L,lW.remove);return{xmlVersion:O,onLevel:M,nullLevel:$}}class t1{constructor(W={}){this._limit=W.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof W.postCheck==="function"?W.postCheck:(M)=>M,this._limitTiers=j3(this._limit.applyLimitsTo??K0),this._numericAllowed=W.numericAllowed??!0,this._baseMap=o1(a1,W.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(W.remove&&Array.isArray(W.remove)?W.remove:[]),this._leaveSet=new Set(W.leave&&Array.isArray(W.leave)?W.leave:[]);let O=y3(W.ncr);this._ncrXmlVersion=O.xmlVersion,this._ncrOnLevel=O.onLevel,this._ncrNullLevel=O.nullLevel,this._onExternalEntity=typeof W.onExternalEntity==="function"?W.onExternalEntity:null,this._onInputEntity=typeof W.onInputEntity==="function"?W.onInputEntity:null}_applyRegistrationHook(W,O,M,L){if(!W)return!0;let $=W(O,M);if($===c0.BLOCK)return!1;if($===c0.THROW)throw Error(`[EntityDecoder] Registration of ${L} entity "&${O};" was rejected by hook`);return!0}setExternalEntities(W){if(W)for(let L of Object.keys(W))kA(L);if(!this._onExternalEntity){this._externalMap=o1(W);return}let O=o1(W),M=Object.create(null);for(let[L,$]of Object.entries(O))if(this._applyRegistrationHook(this._onExternalEntity,L,$,"external"))M[L]=$;this._externalMap=M}addExternalEntity(W,O){if(kA(W),typeof O==="string"&&O.indexOf("&")===-1){if(this._applyRegistrationHook(this._onExternalEntity,W,O,"external"))this._externalMap[W]=O}}addInputEntities(W){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity){this._inputMap=o1(W);return}let O=o1(W),M=Object.create(null);for(let[L,$]of Object.entries(O))if(this._applyRegistrationHook(this._onInputEntity,L,$,"input"))M[L]=$;this._inputMap=M}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(W){this._ncrXmlVersion=W===1.1?1.1:1}decode(W){if(typeof W!=="string"||W.length===0)return W;if(W.indexOf("&")===-1)return W;let O=W,M=[],L=W.length,$=0,Y=0,J=this._maxTotalExpansions>0,A=this._maxExpandedLength>0,Z=J||A;while(Y<L){if(W.charCodeAt(Y)!==38){Y++;continue}let X=Y+1;while(X<L&&W.charCodeAt(X)!==59&&X-Y<=32)X++;if(X>=L||W.charCodeAt(X)!==59){Y++;continue}let Q=W.slice(Y+1,X);if(Q.length===0){Y++;continue}let R,U;if(this._removeSet.has(Q)){if(R="",U===void 0)U=K0}else if(this._leaveSet.has(Q)){Y++;continue}else if(Q.charCodeAt(0)===35){let T=this._resolveNCR(Q);if(T===void 0){Y++;continue}R=T,U=EL}else{let T=this._resolveName(Q);R=T?.value,U=T?.tier}if(R===void 0){Y++;continue}if(Y>$)M.push(W.slice($,Y));if(M.push(R),$=X+1,Y=$,Z&&this._tierCounts(U)){if(J){if(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions)throw Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`)}if(A){let T=R.length-(Q.length+2);if(T>0){if(this._expandedLength+=T,this._expandedLength>this._maxExpandedLength)throw Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}}if($<L)M.push(W.slice($));let G=M.length===0?W:M.join("");return this._postCheck(G,O)}_tierCounts(W){if(this._limitTiers.has(_8))return!0;return this._limitTiers.has(W)}_resolveName(W){if(W in this._inputMap)return{value:this._inputMap[W],tier:K0};if(W in this._externalMap)return{value:this._externalMap[W],tier:K0};if(W in this._baseMap)return{value:this._baseMap[W],tier:EL};return}_classifyNCR(W){if(W===0)return this._ncrNullLevel;if(W>=55296&&W<=57343)return lW.remove;if(this._ncrXmlVersion===1){if(W>=1&&W<=31&&!I3.has(W))return lW.remove}return-1}_applyNCRAction(W,O,M){switch(W){case lW.allow:return String.fromCodePoint(M);case lW.remove:return"";case lW.leave:return;case lW.throw:throw Error(`[EntityDecoder] Prohibited numeric character reference &${O}; (U+${M.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(M)}}_resolveNCR(W){let O=W.charCodeAt(1),M;if(O===120||O===88)M=parseInt(W.slice(2),16);else M=parseInt(W.slice(1),10);if(Number.isNaN(M)||M<0||M>1114111)return;let L=this._classifyNCR(M);if(!this._numericAllowed&&L<lW.remove)return;let $=L===-1?this._ncrOnLevel:Math.max(this._ncrOnLevel,L);return this._applyNCRAction($,W,M)}}var bA=(W)=>{if(n1.includes(W))return"__"+W;return W},D3={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(W,O){return O},attributeValueProcessor:function(W,O){return O},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(W,O,M){return W},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:bA};function k3(W,O){if(typeof W!=="string")return;let M=W.toLowerCase();if(n1.some((L)=>M===L.toLowerCase()))throw Error(`[SECURITY] Invalid ${O}: "${W}" is a reserved JavaScript keyword that could cause prototype pollution`);if(TL.some((L)=>M===L.toLowerCase()))throw Error(`[SECURITY] Invalid ${O}: "${W}" is a reserved JavaScript keyword that could cause prototype pollution`)}function fA(W,O){if(typeof W==="boolean")return{enabled:W,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1000,allowedTags:null,tagFilter:null,appliesTo:"all"};if(typeof W==="object"&&W!==null)return{enabled:W.enabled!==!1,maxEntitySize:Math.max(1,W.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,W.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,W.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,W.maxExpandedLength??1e5),maxEntityCount:Math.max(1,W.maxEntityCount??1000),allowedTags:W.allowedTags??null,tagFilter:W.tagFilter??null,appliesTo:W.appliesTo??"all"};return fA(!0)}var vA=function(W){let O=Object.assign({},D3,W),M=[{value:O.attributeNamePrefix,name:"attributeNamePrefix"},{value:O.attributesGroupName,name:"attributesGroupName"},{value:O.textNodeName,name:"textNodeName"},{value:O.cdataPropName,name:"cdataPropName"},{value:O.commentPropName,name:"commentPropName"}];for(let{value:L,name:$}of M)if(L)k3(L,$);if(O.onDangerousProperty===null)O.onDangerousProperty=bA;if(O.processEntities=fA(O.processEntities,O.htmlEntities),O.unpairedTagsSet=new Set(O.unpairedTags),O.stopNodes&&Array.isArray(O.stopNodes))O.stopNodes=O.stopNodes.map((L)=>{if(typeof L==="string"&&L.startsWith("*."))return".."+L.substring(2);return L});return O};var qL;if(typeof Symbol!=="function")qL="@@xmlMetadata";else qL=Symbol("XML Node Metadata");class sW{constructor(W){this.tagname=W,this.child=[],this[":@"]=Object.create(null)}add(W,O){if(W==="__proto__")W="#__proto__";this.child.push({[W]:O})}addChild(W,O){if(W.tagname==="__proto__")W.tagname="#__proto__";if(W[":@"]&&Object.keys(W[":@"]).length>0)this.child.push({[W.tagname]:W.child,[":@"]:W[":@"]});else this.child.push({[W.tagname]:W.child});if(O!==void 0)this.child[this.child.length-1][qL]={startIndex:O}}static getMetaDataSymbol(){return qL}}var gA=":A-Za-z_"+"\xC0-\xD6\xD8-\xF6\xF8-\u02FF"+"\u0370-\u037D"+"\u037F-\u0486\u0488-\u1FFF"+"\u200C-\u200D"+"\u2070-\u218F"+"\u2C00-\u2FEF"+"\u3001-\uD7FF"+"\uF900-\uFDCF"+"\uFDF0-\uFFFD",b3=gA+"\\-\\.\\d"+"\xB7"+"\u0300-\u036F"+"\u203F-\u2040",xA=":A-Za-z_"+"\xC0-\u02FF"+"\u0370-\u037D"+"\u037F-\u0486\u0488-\u1FFF"+"\u200C-\u200D"+"\u2070-\u218F"+"\u2C00-\u2FEF"+"\u3001-\uD7FF"+"\uF900-\uFDCF"+"\uFDF0-\uFFFD"+"\uD800\uDC00-\uDB7F\uDFFF",f3=xA+"\\-\\.\\d"+"\xB7"+"\u0300-\u036F"+"\u0487"+"\u203F-\u2040",j8=(W,O,M="")=>{let L=W.replace(":",""),$=O.replace(":",""),Y=`[${L}][${$}]*`;return{name:new RegExp(`^[${W}][${O}]*$`,M),ncName:new RegExp(`^${Y}$`,M),qName:new RegExp(`^${Y}(?::${Y})?$`,M),nmToken:new RegExp(`^[${O}]+$`,M),nmTokens:new RegExp(`^[${O}]+(?:\\s+[${O}]+)*$`,M)}},v3=j8(gA,b3),g3=j8(xA,f3,"u");var x3=":A-Za-z_\\-\\.\\d",h3=j8(":A-Za-z_",x3),u3=(W="1.0",O=!1)=>{if(O)return h3;return W==="1.1"?g3:v3};var I8=(W,{xmlVersion:O="1.0",asciiOnly:M=!1}={})=>u3(O,M).qName.test(W);class BL{constructor(W,O){this.suppressValidationErr=!W,this.options=W,this.xmlVersion=O||1}setXmlVersion(W=1){this.xmlVersion=W}readDocType(W,O){let M=Object.create(null),L=0;if(W[O+3]==="O"&&W[O+4]==="C"&&W[O+5]==="T"&&W[O+6]==="Y"&&W[O+7]==="P"&&W[O+8]==="E"){O=O+9;let $=1,Y=!1,J=!1,A="";for(;O<W.length;O++)if(W[O]==="<"&&!J){if(Y&&T0(W,"!ENTITY",O)){O+=7;let Z,G;if([Z,G,O]=this.readEntityExp(W,O+1,this.suppressValidationErr),G.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&L>=this.options.maxEntityCount)throw Error(`Entity count (${L+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);M[Z]=G,L++}}else if(Y&&T0(W,"!ELEMENT",O)){O+=8;let{index:Z}=this.readElementExp(W,O+1);O=Z}else if(Y&&T0(W,"!ATTLIST",O))O+=8;else if(Y&&T0(W,"!NOTATION",O)){O+=9;let{index:Z}=this.readNotationExp(W,O+1,this.suppressValidationErr);O=Z}else if(T0(W,"!--",O))J=!0;else throw Error("Invalid DOCTYPE");$++,A=""}else if(W[O]===">"){if(J){if(W[O-1]==="-"&&W[O-2]==="-")J=!1,$--}else $--;if($===0)break}else if(W[O]==="[")Y=!0;else A+=W[O];if($!==0)throw Error("Unclosed DOCTYPE")}else throw Error("Invalid Tag instead of DOCTYPE");return{entities:M,i:O}}readEntityExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O])&&W[O]!=='"'&&W[O]!=="'")O++;let L=W.substring(M,O);if(e1(L,{xmlVersion:this.xmlVersion}),O=pW(W,O),!this.suppressValidationErr){if(W.substring(O,O+6).toUpperCase()==="SYSTEM")throw Error("External entities are not supported");else if(W[O]==="%")throw Error("Parameter entities are not supported")}let $="";if([O,$]=this.readIdentifierVal(W,O,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize!=null&&$.length>this.options.maxEntitySize)throw Error(`Entity "${L}" size (${$.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return O--,[L,$,O]}readNotationExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let L=W.substring(M,O);!this.suppressValidationErr&&e1(L,{xmlVersion:this.xmlVersion}),O=pW(W,O);let $=W.substring(O,O+6).toUpperCase();if(!this.suppressValidationErr&&$!=="SYSTEM"&&$!=="PUBLIC")throw Error(`Expected SYSTEM or PUBLIC, found "${$}"`);O+=$.length,O=pW(W,O);let Y=null,J=null;if($==="PUBLIC"){if([O,Y]=this.readIdentifierVal(W,O,"publicIdentifier"),O=pW(W,O),W[O]==='"'||W[O]==="'")[O,J]=this.readIdentifierVal(W,O,"systemIdentifier")}else if($==="SYSTEM"){if([O,J]=this.readIdentifierVal(W,O,"systemIdentifier"),!this.suppressValidationErr&&!J)throw Error("Missing mandatory system identifier for SYSTEM notation")}return{notationName:L,publicIdentifier:Y,systemIdentifier:J,index:--O}}readIdentifierVal(W,O,M){let L="",$=W[O];if($!=='"'&&$!=="'")throw Error(`Expected quoted string, found "${$}"`);O++;let Y=O;while(O<W.length&&W[O]!==$)O++;if(L=W.substring(Y,O),W[O]!==$)throw Error(`Unterminated ${M} value`);return O++,[O,L]}readElementExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let L=W.substring(M,O);if(!this.suppressValidationErr&&!I8(L,{xmlVersion:this.xmlVersion}))throw Error(`Invalid element name: "${L}"`);O=pW(W,O);let $="";if(W[O]==="E"&&T0(W,"MPTY",O))O+=4;else if(W[O]==="A"&&T0(W,"NY",O))O+=2;else if(W[O]==="("){O++;let Y=O;while(O<W.length&&W[O]!==")")O++;if($=W.substring(Y,O),W[O]!==")")throw Error("Unterminated content model")}else if(!this.suppressValidationErr)throw Error(`Invalid Element Expression, found "${W[O]}"`);return{elementName:L,contentModel:$.trim(),index:O}}readAttlistExp(W,O){O=pW(W,O);let M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let L=W.substring(M,O);e1(L,{xmlVersion:this.xmlVersion}),O=pW(W,O),M=O;while(O<W.length&&!/\s/.test(W[O]))O++;let $=W.substring(M,O);if(!e1($,{xmlVersion:this.xmlVersion}))throw Error(`Invalid attribute name: "${$}"`);O=pW(W,O);let Y="";if(W.substring(O,O+8).toUpperCase()==="NOTATION"){if(Y="NOTATION",O+=8,O=pW(W,O),W[O]!=="(")throw Error(`Expected '(', found "${W[O]}"`);O++;let A=[];while(O<W.length&&W[O]!==")"){let Z=O;while(O<W.length&&W[O]!=="|"&&W[O]!==")")O++;let G=W.substring(Z,O);if(G=G.trim(),!e1(G,{xmlVersion:this.xmlVersion}))throw Error(`Invalid notation name: "${G}"`);if(A.push(G),W[O]==="|")O++,O=pW(W,O)}if(W[O]!==")")throw Error("Unterminated list of notations");O++,Y+=" ("+A.join("|")+")"}else{let A=O;while(O<W.length&&!/\s/.test(W[O]))O++;Y+=W.substring(A,O);let Z=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!Z.includes(Y.toUpperCase()))throw Error(`Invalid attribute type: "${Y}"`)}O=pW(W,O);let J="";if(W.substring(O,O+8).toUpperCase()==="#REQUIRED")J="#REQUIRED",O+=8;else if(W.substring(O,O+7).toUpperCase()==="#IMPLIED")J="#IMPLIED",O+=7;else[O,J]=this.readIdentifierVal(W,O,"ATTLIST");return{elementName:L,attributeName:$,attributeType:Y,defaultValue:J,index:O}}}var pW=(W,O)=>{while(O<W.length&&/\s/.test(W[O]))O++;return O};function T0(W,O,M){for(let L=0;L<O.length;L++)if(O[L]!==W[M+L+1])return!1;return!0}function e1(W,O){if(I8(W,{xmlVersion:O}))return W;else throw Error(`Invalid entity name ${W}`)}var l3=[48,1632,1776,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,65296,120782,120792,120802,120812,120822,66720,68912,69734,69872,69942,70096,70384,70736,70864,71248,71360,71472,71904,72016,72688,72784,73040,73120,73552,92768,92864,93008,123200,123632,124144,125264,130032],y8=255,CL=new Map;var WM=1632;var wL=new Uint8Array(63904).fill(255);for(let W of l3)for(let O=0;O<10;O++){let M=W+O;if(M<=65535)wL[M-1632]=O;else CL.set(M,O)}var hA=48,uA=57,lA=45,PL=new Set([8722,65293,65123]);function p3(W){if(typeof W!=="string")return W;let O=W.length;if(O===0)return W;let M=-1;for(let $=0;$<O;$++){let Y=W.charCodeAt($);if(Y>=hA&&Y<=uA||Y===lA)continue;if(Y<WM){if(PL.has(Y)){M=$;break}continue}if(Y>=55296&&Y<=56319){if($+1<O){let J=W.charCodeAt($+1);if(J>=56320&&J<=57343){let A=65536+(Y-55296<<10)+(J-56320);if(CL.has(A)){M=$;break}}}continue}if(wL[Y-WM]!==y8||PL.has(Y)){M=$;break}}if(M===-1)return W;let L=[];if(M>0)L.push(W.slice(0,M));for(let $=M;$<O;$++){let Y=W.charCodeAt($);if(Y>=hA&&Y<=uA||Y===lA){L.push(W[$]);continue}if(Y<WM){L.push(PL.has(Y)?"-":W[$]);continue}if(Y>=55296&&Y<=56319){if($+1<O){let A=W.charCodeAt($+1);if(A>=56320&&A<=57343){let Z=65536+(Y-55296<<10)+(A-56320),G=CL.get(Z);if(G!==void 0){L.push(String.fromCharCode(G+48)),$++;continue}}}L.push(W[$]);continue}if(PL.has(Y)){L.push("-");continue}let J=wL[Y-WM];L.push(J!==y8?String.fromCharCode(J+48):W[$])}return L.join("")}var pA=p3;var m3=/^[-+]?0x[a-fA-F0-9]+$/,d3=/^0b[01]+$/,c3=/^0o[0-7]+$/,i3=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,s3={hex:!0,binary:!1,octal:!1,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original",unicode:!1};function k8(W,O={}){if(O=Object.assign({},s3,O),!W||typeof W!=="string")return W;let M=W.trim();if(M.length===0)return W;else if(O.skipLike!==void 0&&O.skipLike.test(M))return W;else if(M==="0")return 0;if(O.unicode){if(M=pA(M),M==="0")return 0}if(O.hex&&m3.test(M))return D8(M,16);else if(O.binary&&d3.test(M))return D8(M,2);else if(O.octal&&c3.test(M))return D8(M,8);else if(!isFinite(M))return o3(W,Number(M),O);else if(M.includes("e")||M.includes("E"))return r3(W,M,O);else{let L=i3.exec(M);if(L){let $=L[1]||"",Y=L[2],J=a3(L[3]),A=$?W[Y.length+1]===".":W[Y.length]===".";if(!O.leadingZeros&&(Y.length>1||Y.length===1&&!A))return W;else{let Z=Number(M),G=String(Z);if(Z===0)return Z;if(G.search(/[eE]/)!==-1)if(O.eNotation)return Z;else return W;else if(M.indexOf(".")!==-1)if(G==="0")return Z;else if(G===J)return Z;else if(G===`${$}${J}`)return Z;else return W;let X=Y?J:M;if(Y)return X===G||$+X===G?Z:W;else return X===G||X===$+G?Z:W}}else return W}}var n3=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function r3(W,O,M){if(!M.eNotation)return W;let L=O.match(n3);if(L){let $=L[1]||"",Y=L[3].indexOf("e")===-1?"E":"e",J=L[2],A=$?W[J.length+1]===Y:W[J.length]===Y;if(J.length>1&&A)return W;else if(J.length===1&&(L[3].startsWith(`.${Y}`)||L[3][0]===Y))return Number(O);else if(J.length>0)if(M.leadingZeros&&!A)return O=(L[1]||"")+L[3],Number(O);else return W;else return Number(O)}else return W}function a3(W){if(W&&W.indexOf(".")!==-1){let O=W.length;while(O>0&&W.charCodeAt(O-1)===48)O--;if(W=W.slice(0,O),W===".")W="0";else if(W[0]===".")W="0"+W;else if(W[W.length-1]===".")W=W.substring(0,W.length-1);return W}return W}function D8(W,O){let M=W.trim();if(O===2||O===8)W=M.substring(2);if(parseInt)return parseInt(W,O);else if(Number.parseInt)return Number.parseInt(W,O);else if(window&&window.parseInt)return window.parseInt(W,O);else throw Error("parseInt, Number.parseInt, window.parseInt are not supported")}function o3(W,O,M){let L=O===1/0;switch(M.infinity.toLowerCase()){case"null":return null;case"infinity":return O;case"string":return L?"Infinity":"-Infinity";case"original":default:return W}}function b8(W){if(typeof W==="function")return W;if(Array.isArray(W))return(O)=>{for(let M of W){if(typeof M==="string"&&O===M)return!0;if(M instanceof RegExp&&M.test(O))return!0}};return()=>!1}class i0{constructor(W,O={},M){this.pattern=W,this.separator=O.separator||".",this.segments=this._parse(W),this.data=M,this._hasDeepWildcard=this.segments.some((L)=>L.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some((L)=>L.attrName!==void 0),this._hasPositionSelector=this.segments.some((L)=>L.position!==void 0)}_parse(W){let O=[],M=0,L="";while(M<W.length)if(W[M]===this.separator)if(M+1<W.length&&W[M+1]===this.separator){if(L.trim())O.push(this._parseSegment(L.trim())),L="";O.push({type:"deep-wildcard"}),M+=2}else{if(L.trim())O.push(this._parseSegment(L.trim()));L="",M++}else L+=W[M],M++;if(L.trim())O.push(this._parseSegment(L.trim()));return O}_parseSegment(W){let O={type:"tag"},M=null,L=W,$=W.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if($){if(L=$[1]+$[3],$[2]){let G=$[2].slice(1,-1);if(G)M=G}}let Y=void 0,J=L;if(L.includes("::")){let G=L.indexOf("::");if(Y=L.substring(0,G).trim(),J=L.substring(G+2).trim(),!Y)throw Error(`Invalid namespace in pattern: ${W}`)}let A=void 0,Z=null;if(J.includes(":")){let G=J.lastIndexOf(":"),X=J.substring(0,G).trim(),Q=J.substring(G+1).trim();if(["first","last","odd","even"].includes(Q)||/^nth\(\d+\)$/.test(Q))A=X,Z=Q;else A=J}else A=J;if(!A)throw Error(`Invalid segment pattern: ${W}`);if(O.tag=A,Y)O.namespace=Y;if(M)if(M.includes("=")){let G=M.indexOf("=");O.attrName=M.substring(0,G).trim(),O.attrValue=M.substring(G+1).trim()}else O.attrName=M.trim();if(Z){let G=Z.match(/^nth\((\d+)\)$/);if(G)O.position="nth",O.positionValue=parseInt(G[1],10);else O.position=Z}return O}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class OM{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._deepByTerminalTag=new Map,this._patterns=new Set,this._sealed=!1}add(W){if(this._sealed)throw TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(W.pattern))return this;if(this._patterns.add(W.pattern),W.hasDeepWildcard()){let $=W.segments[W.segments.length-1];if($&&$.type!=="deep-wildcard"&&$.tag!=="*"){let Y=$.tag;if(!this._deepByTerminalTag.has(Y))this._deepByTerminalTag.set(Y,[]);this._deepByTerminalTag.get(Y).push(W)}else this._deepWildcards.push(W);return this}let O=W.length,L=W.segments[W.segments.length-1]?.tag;if(!L||L==="*"){if(!this._wildcardByDepth.has(O))this._wildcardByDepth.set(O,[]);this._wildcardByDepth.get(O).push(W)}else{let $=`${O}:${L}`;if(!this._byDepthAndTag.has($))this._byDepthAndTag.set($,[]);this._byDepthAndTag.get($).push(W)}return this}addAll(W){for(let O of W)this.add(O);return this}has(W){return this._patterns.has(W.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(W){return this.findMatch(W)!==null}findMatch(W){let O=W.getDepth(),M=W.getCurrentTag(),L=`${O}:${M}`,$=this._byDepthAndTag.get(L);if($){for(let A=0;A<$.length;A++)if(W.matches($[A]))return $[A]}let Y=this._wildcardByDepth.get(O);if(Y){for(let A=0;A<Y.length;A++)if(W.matches(Y[A]))return Y[A]}let J=this._deepByTerminalTag.get(M);if(J){for(let A=0;A<J.length;A++)if(W.matches(J[A]))return J[A]}for(let A=0;A<this._deepWildcards.length;A++)if(W.matches(this._deepWildcards[A]))return this._deepWildcards[A];return null}}class mA{constructor(W){this._matcher=W}get separator(){return this._matcher.separator}getCurrentTag(){let W=this._matcher.path;return W.length>0?W[W.length-1].tag:void 0}getCurrentNamespace(){let W=this._matcher.path;return W.length>0?W[W.length-1].namespace:void 0}getAttrValue(W){let O=this._matcher.path;if(O.length===0)return;return O[O.length-1].values?.[W]}hasAttr(W){let O=this._matcher.path;if(O.length===0)return!1;let M=O[O.length-1];return M.values!==void 0&&W in M.values}getAnyParentAttr(W){return this._matcher.getAnyParentAttr(W)}hasAnyParentAttr(W){return this._matcher.hasAnyParentAttr(W)}getPosition(){let W=this._matcher.path;if(W.length===0)return-1;return W[W.length-1].position??0}getCounter(){let W=this._matcher.path;if(W.length===0)return-1;return W[W.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(W,O=!0){return this._matcher.toString(W,O)}toArray(){return this._matcher.path.map((W)=>W.tag)}matches(W){return this._matcher.matches(W)}matchesAny(W){return W.matchesAny(this._matcher)}}class MM{constructor(W={}){this.separator=W.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new mA(this),this._keptAttrs=[]}push(W,O=null,M=null,L=null){if(this._pathStringCache=null,this.path.length>0)this.path[this.path.length-1].values=void 0;let $=this.path.length,Y=this.siblingStacks[$];if(!Y)Y={counts:new Map,total:0},this.siblingStacks[$]=Y;let J=M?`${M}:${W}`:W,A=Y.counts.get(J)||0,Z=Y.total;Y.counts.set(J,A+1),Y.total++;let G={tag:W,position:Z,counter:A};if(M!==null&&M!==void 0)G.namespace=M;if(O!==null&&O!==void 0)G.values=O;this.path.push(G);let X=this.path.length,Q=L!==null?L.keep:null;if(Q!==null&&Q!==void 0&&Q.length>0&&O)for(let R=0;R<Q.length;R++){let U=Q[R];if(O[U]!==void 0)this._keptAttrs.push({depth:X,name:U,value:O[U]})}}pop(){if(this.path.length===0)return;this._pathStringCache=null;let W=this.path.pop();if(this.siblingStacks.length>this.path.length+1)this.siblingStacks.length=this.path.length+1;let O=this.path.length+1;while(this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=O)this._keptAttrs.pop();return W}updateCurrent(W){if(this.path.length>0){let O=this.path[this.path.length-1];if(W!==null&&W!==void 0)O.values=W}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(W){if(this.path.length===0)return;return this.path[this.path.length-1].values?.[W]}hasAttr(W){if(this.path.length===0)return!1;let O=this.path[this.path.length-1];return O.values!==void 0&&W in O.values}getAnyParentAttr(W){let O=this._keptAttrs;for(let M=O.length-1;M>=0;M--)if(O[M].name===W)return O[M].value;return}hasAnyParentAttr(W){let O=this._keptAttrs;for(let M=O.length-1;M>=0;M--)if(O[M].name===W)return!0;return!1}getPosition(){if(this.path.length===0)return-1;return this.path[this.path.length-1].position??0}getCounter(){if(this.path.length===0)return-1;return this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(W,O=!0){let M=W||this.separator;if(M===this.separator&&O===!0){if(this._pathStringCache!==null)return this._pathStringCache;let $=this.path.map((Y)=>Y.namespace?`${Y.namespace}:${Y.tag}`:Y.tag).join(M);return this._pathStringCache=$,$}return this.path.map(($)=>O&&$.namespace?`${$.namespace}:${$.tag}`:$.tag).join(M)}toArray(){return this.path.map((W)=>W.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(W){let O=W.segments;if(O.length===0)return!1;if(W.hasDeepWildcard())return this._matchWithDeepWildcard(O);return this._matchSimple(O)}_matchSimple(W){if(this.path.length!==W.length)return!1;for(let O=0;O<W.length;O++)if(!this._matchSegment(W[O],this.path[O],O===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(W){let O=this.path.length-1,M=W.length-1;while(M>=0&&O>=0){let L=W[M];if(L.type==="deep-wildcard"){if(M--,M<0)return!0;let $=W[M],Y=!1;for(let J=O;J>=0;J--)if(this._matchSegment($,this.path[J],J===this.path.length-1)){O=J-1,M--,Y=!0;break}if(!Y)return!1}else{if(!this._matchSegment(L,this.path[O],O===this.path.length-1))return!1;O--,M--}}return M<0}_matchSegment(W,O,M){if(W.tag!=="*"&&W.tag!==O.tag)return!1;if(W.namespace!==void 0){if(W.namespace!=="*"&&W.namespace!==O.namespace)return!1}if(W.attrName!==void 0){if(!M)return!1;if(!O.values||!(W.attrName in O.values))return!1;if(W.attrValue!==void 0){if(String(O.values[W.attrName])!==String(W.attrValue))return!1}}if(W.position!==void 0){if(!M)return!1;let L=O.counter??0;if(W.position==="first"&&L!==0)return!1;else if(W.position==="odd"&&L%2!==1)return!1;else if(W.position==="even"&&L%2!==0)return!1;else if(W.position==="nth"&&L!==W.positionValue)return!1}return!0}matchesAny(W){return W.matchesAny(this)}snapshot(){return{path:this.path.map((W)=>({...W})),siblingStacks:this.siblingStacks.map((W)=>W?{counts:new Map(W.counts),total:W.total}:W),keptAttrs:this._keptAttrs.map((W)=>({...W}))}}restore(W){this._pathStringCache=null,this.path=W.path.map((O)=>({...O})),this.siblingStacks=W.siblingStacks.map((O)=>O?{counts:new Map(O.counts),total:O.total}:O),this._keptAttrs=(W.keptAttrs||[]).map((O)=>({...O}))}readOnly(){return this._view}}var t3=[{id:"html-script-open",description:"<script opening tag",pattern:/<script[\s>/]/i},{id:"html-script-close",description:"</script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI \u2014 can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI \u2014 can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded <script (e.g. &#x3C;script or &lt;script)",pattern:/(?:&#x0*3[Cc];?|&#0*60;?|&lt;)\s*script/i},{id:"html-entity-obfuscated-javascript",description:'HTML-entity-encoded javascript: (partial \u2014 catches common &#106; or &#x6a; for "j")',pattern:/(?:&#x0*6[Aa];?|&#0*106;?)\s*(?:&#x0*61;?|a)[\s\S]{0,80}script\s*:/i},{id:"html-style-expression",description:"CSS expression() \u2014 IE-era code execution in style attributes",pattern:/style[\s\S]{0,20}expression\s*\(/i},{id:"html-object-embed",description:"<object or <embed tags that can load active content",pattern:/<(?:object|embed)[\s>/]/i},{id:"html-base-tag",description:"<base href= \u2014 can hijack all relative URLs on a page",pattern:/<base[\s>]/i},{id:"html-meta-refresh",description:'<meta http-equiv="refresh" \u2014 can redirect users',pattern:/<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i},{id:"html-srcdoc",description:"srcdoc= attribute on iframes \u2014 embeds HTML that can run scripts",pattern:/srcdoc\s*=/i},{id:"html-iframe",description:"<iframe tag",pattern:/<iframe[\s>/]/i},{id:"html-form",description:"<form tag \u2014 can be used for phishing / credential harvesting injection",pattern:/<form[\s>/]/i}],s0=t3;var e3=[{id:"xml-cdata-injection",description:"CDATA section injection: <![CDATA[ breaks out of text node context",pattern:/<!\[CDATA\[/i},{id:"xml-cdata-close",description:"CDATA close sequence: ]]> can terminate an enclosing CDATA section",pattern:/\]\]>/},{id:"xml-processing-instruction",description:"XML processing instruction: <?xml-stylesheet or <?php etc.",pattern:/<\?(?:xml[\- ]|php|asp)/i},{id:"xml-doctype-injection",description:"DOCTYPE declaration embedded in content \u2014 can define entities",pattern:/<!DOCTYPE(?:[\s[]|$)/i},{id:"xml-entity-system",description:"SYSTEM keyword \u2014 used in external entity declarations (XXE)",pattern:/\bSYSTEM\s+["']/i},{id:"xml-entity-public",description:"PUBLIC keyword \u2014 used in external entity declarations (XXE)",pattern:/\bPUBLIC\s+["']/i},{id:"xml-entity-declaration",description:"<!ENTITY declaration \u2014 defines entities, potential XXE or entity expansion",pattern:/<!ENTITY[\s%]/i},{id:"xml-billion-laughs",description:"Entity reference chaining / billion laughs: repeated &eX; style references",pattern:/(?:&\w{1,20};){3,}/},{id:"xml-namespace-confusion",description:"xmlns: attribute injection \u2014 can redefine namespaces to confuse parsers",pattern:/\bxmlns\s*(?::\w{1,40})?\s*=/i},{id:"xml-comment-injection",description:"<!-- comment injection \u2014 can hide content from some parsers",pattern:/<!--/},{id:"xml-comment-close",description:"--> closes an enclosing XML comment",pattern:/-->/},{id:"xml-pi-close",description:"?> closes an enclosing processing instruction",pattern:/\?>/}],n0=e3;var WT=[{id:"svg-script-element",description:"<script element inside SVG executes JavaScript",pattern:/<script[\s>/]/i},{id:"svg-xlink-href-javascript",description:"xlink:href with javascript: \u2014 classic SVG XSS via <a> or <use>",pattern:/xlink\s*:\s*href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-href-javascript",description:"href= with javascript: in SVG context (<a>, <animate>, etc.)",pattern:/href\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-foreignobject",description:"<foreignObject embeds HTML inside SVG \u2014 can execute scripts",pattern:/<foreignObject[\s>/]/i},{id:"svg-use-external",description:"<use xlink:href or href pointing to external resource (non-fragment URL)",pattern:/<use[\s\S]{0,60}(?:xlink\s*:\s*)?href\s*=\s*(?:["'][^#]|[^"'#\s>])/i},{id:"svg-animate-href",description:'<animate attributeName="href" \u2014 can dynamically change href to javascript:',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*href["']/i},{id:"svg-animate-xlinkhref",description:'<animate attributeName="xlink:href"',pattern:/<animate[\s\S]{0,80}attributeName\s*=\s*["'][\s]*xlink\s*:\s*href["']/i},{id:"svg-set-javascript",description:'<set to="javascript:..." \u2014 sets an attribute to a javascript: URI',pattern:/<set[\s\S]{0,80}to\s*=\s*["']?\s*javascript\s*:/i},{id:"svg-event-handler",description:"SVG-specific event handler attributes: onload=, onerror=, onactivate=, etc.",pattern:/\bon(?:load|error|activate|begin|end|repeat|focus|blur|click|mouse\w{1,20}|key\w{1,20})\s*=/i},{id:"svg-handler-generic",description:"Generic on* handler catch-all for SVG attributes",pattern:/\bon\w{1,30}\s*=/i},{id:"svg-filter-feimage",description:"<feImage href= \u2014 filter primitive that can load external resources",pattern:/<feImage[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=/i},{id:"svg-image-external",description:"<image xlink:href with http/https or javascript protocol",pattern:/<image[\s\S]{0,80}(?:xlink\s*:\s*)?href\s*=\s*["']?\s*(?:https?|javascript)\s*:/i},{id:"svg-style-javascript",description:"style= attribute containing javascript: (e.g. background:url(javascript:...))",pattern:/style\s*=[\s\S]{0,60}javascript\s*:/i}],f8=WT;var OT=[{id:"sql-block-comment-open",description:"SQL block comment open: /* ... */ \u2014 unusual in legitimate user text",pattern:/\/\*/},{id:"sql-union-select",description:"UNION SELECT \u2014 most common SQL injection aggregation attack",pattern:/\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i},{id:"sql-drop-table",description:"DROP TABLE \u2014 destructive DDL injection",pattern:/\bDROP\s{1,20}TABLE\b/i},{id:"sql-drop-database",description:"DROP DATABASE \u2014 destructive DDL injection",pattern:/\bDROP\s{1,20}DATABASE\b/i},{id:"sql-insert-into",description:"INSERT INTO \u2014 data injection",pattern:/\bINSERT\s{1,20}INTO\b/i},{id:"sql-delete-from",description:"DELETE FROM \u2014 data deletion injection",pattern:/\bDELETE\s{1,20}FROM\b/i},{id:"sql-update-set",description:"UPDATE ... SET \u2014 data modification injection",pattern:/\bUPDATE\b[\s\S]{1,60}\bSET\b/i},{id:"sql-exec-xp",description:"EXEC xp_ \u2014 MSSQL extended stored procedure execution",pattern:/\bEXEC(?:UTE)?\s{1,20}xp_/i},{id:"sql-tautology-string",description:`Classic string tautology: ' OR '1'='1 or " OR "1"="1"`,pattern:/'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i},{id:"sql-tautology-numeric",description:"Numeric tautology: OR 1=1",pattern:/\bOR\s{1,10}1\s*=\s*1\b/i},{id:"sql-always-true-zero",description:"Numeric tautology: OR 0=0",pattern:/\bOR\s{1,10}0\s*=\s*0\b/i},{id:"sql-sleep-benchmark",description:"Time-based blind injection: SLEEP() or BENCHMARK()",pattern:/\b(?:SLEEP|BENCHMARK)\s*\(/i},{id:"sql-waitfor-delay",description:"MSSQL time-based blind injection: WAITFOR DELAY",pattern:/\bWAITFOR\s{1,20}DELAY\b/i},{id:"sql-char-function",description:"CHAR() function \u2014 used to obfuscate injected strings",pattern:/\bCHAR\s*\(\s*\d{1,3}/i},{id:"sql-information-schema",description:"INFORMATION_SCHEMA \u2014 reconnaissance query for table/column enumeration",pattern:/\bINFORMATION_SCHEMA\b/i}],LM=OT;var MT=[{id:"shell-path-traversal-unix",description:"Unix path traversal: ../ \u2014 climbing the directory tree",pattern:/\.\.\//},{id:"shell-path-traversal-windows",description:"Windows path traversal: ..\\ \u2014 climbing the directory tree",pattern:/\.\.\\/},{id:"shell-path-traversal-encoded",description:"URL-encoded path traversal: %2e%2e or %2f variants",pattern:/%2e%2e|%2f\.\.|\.\.%2f/i},{id:"shell-null-byte",description:"Null byte injection: \\x00 or %00 \u2014 truncates strings in C-backed functions",pattern:/\x00|%00/},{id:"shell-semicolon",description:"Semicolon command separator: cmd1; cmd2",pattern:/;/},{id:"shell-pipe",description:"Pipe operator: cmd1 | cmd2",pattern:/\|/},{id:"shell-and-operator",description:"AND operator: cmd1 && cmd2",pattern:/&&/},{id:"shell-or-operator",description:"OR operator: cmd1 || cmd2",pattern:/\|\|/},{id:"shell-backtick",description:"Backtick command substitution: `cmd`",pattern:/`/},{id:"shell-dollar-paren",description:"Dollar-paren command substitution: $(cmd)",pattern:/\$\(/},{id:"shell-dollar-brace",description:"Dollar-brace variable expansion: ${var} \u2014 can be abused for injection",pattern:/\$\{/},{id:"shell-redirect-out",description:"Output redirection: cmd > file or cmd >> file",pattern:/>{1,2}/},{id:"shell-redirect-in",description:"Input redirection: cmd < file",pattern:/</},{id:"shell-newline-injection",description:"Newline injection: \\n or \\r \u2014 can inject new shell commands",pattern:/[\n\r]/},{id:"shell-glob-star",description:"Glob expansion: * or ? \u2014 can expand to unintended files",pattern:/[/\\][*?]/},{id:"shell-absolute-root",description:"Absolute root path injection: string starting with / or \\ (Windows UNC)",pattern:/^(?:\/|\\\\)/},{id:"shell-windows-drive",description:"Windows drive letter path injection: C:\\ or D:/",pattern:/^[a-zA-Z]:[/\\]/},{id:"shell-curl-wget",description:"curl/wget with URL or flags \u2014 can exfiltrate data or download payloads",pattern:/\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i}],v8=MT;var LT=[{id:"redos-nested-quantifier-plus",description:"Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.",pattern:/\([^)]*\+[^)]*\)[+*]/},{id:"redos-nested-quantifier-star",description:"Nested * quantifier: (a*)* or (a*)+ \u2014 catastrophic backtracking",pattern:/\([^)]*\*[^)]*\)[*+]/},{id:"redos-nested-groups",description:"Doubly nested quantified groups: ((a+)+) \u2014 guaranteed catastrophic",pattern:/\(\([^)]{0,40}\)[+*]\)[+*]/},{id:"redos-alternation-overlap",description:"Overlapping alternation under quantifier: (a|a)+ \u2014 ambiguous NFA paths",pattern:/\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/},{id:"redos-star-plus-concat",description:"(x*x)+ pattern \u2014 triggers super-linear backtracking",pattern:/\([^)]{0,10}\*[^)]{0,10}\)[+*]/},{id:"redos-dot-star-greedy",description:"(.*){n,} or (.+){n,} \u2014 repeated greedy dot quantifiers",pattern:/\(\.[*+]\)\{?\d/},{id:"redos-large-repetition",description:"Very large fixed or range repetition count {1000,} or {1000,n} \u2014 denial of service via backtracking",pattern:/\{\d{4,}(?:,\d*)?\}/},{id:"redos-catastrophic-alternation",description:"Long alternation with many similar branches \u2014 polynomial backtracking risk",pattern:/\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/}],g8=LT;var $T=[{id:"nosql-where-operator",description:"$where \u2014 executes arbitrary JavaScript server-side in MongoDB",pattern:new RegExp(`\\$where["'\\s]*:`,"i")},{id:"nosql-ne-operator",description:'$ne \u2014 "not equal" operator used to bypass equality checks',pattern:new RegExp(`\\$ne["'\\s]*:`,"i")},{id:"nosql-gt-operator",description:'$gt \u2014 "greater than" used to bypass password/value checks',pattern:new RegExp(`\\$gte?["'\\s]*:`,"i")},{id:"nosql-lt-operator",description:'$lt / $lte \u2014 "less than" bypass variants',pattern:new RegExp(`\\$lte?["'\\s]*:`,"i")},{id:"nosql-regex-operator",description:"$regex \u2014 can be used to extract data character by character (blind injection)",pattern:new RegExp(`\\$regex["'\\s]*:`,"i")},{id:"nosql-or-operator",description:"$or \u2014 logical OR; used to create always-true conditions",pattern:new RegExp(`\\$or["'\\s]*:\\s*\\[`,"i")},{id:"nosql-and-operator",description:"$and \u2014 logical AND operator injection",pattern:new RegExp(`\\$and["'\\s]*:\\s*\\[`,"i")},{id:"nosql-nor-operator",description:"$nor \u2014 logical NOR operator injection",pattern:new RegExp(`\\$nor["'\\s]*:\\s*\\[`,"i")},{id:"nosql-exists-operator",description:"$exists \u2014 can enumerate fields to determine schema",pattern:new RegExp(`\\$exists["'\\s]*:`,"i")},{id:"nosql-in-operator",description:"$in \u2014 matches any value in a list; can enumerate values",pattern:new RegExp(`\\$in["'\\s]*:\\s*\\[`,"i")},{id:"nosql-expr-operator",description:"$expr \u2014 allows aggregation expressions in queries (MongoDB 3.6+)",pattern:new RegExp(`\\$expr["'\\s]*:`,"i")},{id:"nosql-function-operator",description:"$function \u2014 executes arbitrary JavaScript in MongoDB 4.4+",pattern:new RegExp(`\\$function["'\\s]*:`,"i")},{id:"nosql-accumulator-operator",description:"$accumulator \u2014 custom aggregation with arbitrary JS execution",pattern:new RegExp(`\\$accumulator["'\\s]*:`,"i")},{id:"nosql-proto-pollution",description:"__proto__ \u2014 prototype pollution via object key injection",pattern:/__proto__/},{id:"nosql-constructor-prototype",description:"constructor.prototype \u2014 alternative prototype pollution vector (dot notation or JSON key)",pattern:/constructor[\s"':.,{\[]*prototype/i},{id:"nosql-proto-bracket",description:'["__proto__"] \u2014 bracket-notation prototype pollution',pattern:/\[["']__proto__["']\]/}],x8=$T;var YT=[{id:"log-crlf-injection",description:"CRLF injection: literal \\r or \\n embeds fake log lines",pattern:/[\r\n]/},{id:"log-url-encoded-crlf",description:"URL-encoded CRLF: %0d, %0a, %0D, %0A \u2014 decoded by some log parsers",pattern:/%0[dDaA]/},{id:"log-unicode-newline",description:"Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)",pattern:/[\u2028\u2029]/},{id:"log-log4shell-jndi",description:"Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j",pattern:/\$\{jndi\s*:/i},{id:"log-log4shell-obfuscated",description:"Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection",pattern:/\$\{::-/},{id:"log-log4j-lookup",description:"Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} \u2014 data exfiltration",pattern:/\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i},{id:"log-ssti-double-brace",description:"SSTI double-brace: {{expression}} \u2014 Jinja2, Twig, Handlebars, etc.",pattern:/\{\{[\s\S]{0,80}\}\}/},{id:"log-ssti-hash-brace",description:"SSTI hash-brace: #{expression} \u2014 Thymeleaf, Velocity, Ruby ERB",pattern:/#\{[\s\S]{0,80}\}/},{id:"log-ssti-dollar-brace",description:"SSTI/EL injection: ${expression with operators or method calls} \u2014 JSP EL, Freemarker, SpEL",pattern:/\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i},{id:"log-ssti-percent-tag",description:"SSTI ERB/ASP tag: <%= expression %> \u2014 Ruby ERB, ASP",pattern:/<%=[\s\S]{0,80}%>/},{id:"log-null-byte",description:"Null byte: \\x00 or %00 \u2014 can truncate log entries in C-backed loggers",pattern:/\x00|%00/},{id:"log-ansi-escape",description:"ANSI escape sequence: ESC[ \u2014 can manipulate terminal output when logs are tailed",pattern:/\x1b\[/}],h8=YT;var JT=[{id:"sql-line-comment",description:"SQL line comment: -- followed by whitespace or end of string",pattern:/--(?:\s|$)/},{id:"sql-stacked-query",description:"Stacked queries: semicolon immediately followed by a SQL keyword",pattern:/;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i},{id:"sql-hex-encoding",description:"Hex-encoded string injection: 0x41414141 style (MySQL)",pattern:/\b0x[0-9a-f]{4,}/i}],AT=[...LM,...JT],u8=AT;s0.label="HTML";n0.label="XML";f8.label="SVG";LM.label="SQL";u8.label="SQL-STRICT";v8.label="SHELL";g8.label="REDOS";x8.label="NOSQL";h8.label="LOG";var CP=Object.freeze({HTML:s0,XML:n0,SVG:f8,SQL:LM,"SQL-STRICT":u8,SHELL:v8,REDOS:g8,NOSQL:x8,LOG:h8});function ZT(W){if(typeof W!=="string")throw TypeError(`is-unsafe: first argument must be a string, got ${typeof W}`)}function GT(W){if(W instanceof RegExp)return;if(Array.isArray(W)){if(W.length===0)throw TypeError("is-unsafe: context must not be an empty array");if(Array.isArray(W[0])){for(let O of W)if(!Array.isArray(O)||O.length===0)throw TypeError("is-unsafe: each context in the array must be a non-empty pattern array (PatternList)")}return}throw TypeError(`is-unsafe: second argument must be a PatternList (e.g. HTML), an array of PatternLists (e.g. [HTML, XML]), or a RegExp. Got: ${typeof W}`)}function XT(W){if(W instanceof RegExp)return{lists:null,regex:W};if(Array.isArray(W[0]))return{lists:W,regex:null};return{lists:[W],regex:null}}function QT(W,O){let M=O.label??"CUSTOM";for(let L of O)if(L.pattern.test(W))return{context:M,id:L.id,description:L.description,pattern:L.pattern};return null}function dA(W,O){ZT(W),GT(O);let{lists:M,regex:L}=XT(O);if(L)return L.test(W);for(let $ of M)if(QT(W,$)!==null)return!0;return!1}function RT(W,O){if(!W)return{};let M=O.attributesGroupName?W[O.attributesGroupName]:W;if(!M)return{};let L={};for(let $ in M)if($.startsWith(O.attributeNamePrefix)){let Y=$.substring(O.attributeNamePrefix.length);L[Y]=M[$]}else L[$]=M[$];return L}function ST(W){if(!W||typeof W!=="string")return;let O=W.indexOf(":");if(O!==-1&&O>0){let M=W.substring(0,O);if(M!=="xmlns")return M}return}class NL{constructor(W,O){this.options=W,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=KT,this.parseTextData=UT,this.resolveNameSpace=zT,this.buildAttributesMap=HT,this.isItStopNode=qT,this.replaceEntitiesValue=FT,this.readStopNodeData=wT,this.saveTextToParentTag=ET,this.addChild=TT,this.ignoreAttributesFn=b8(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let M={...a1};if(this.options.entityDecoder)this.entityDecoder=this.options.entityDecoder;else{if(typeof this.options.htmlEntities==="object")M=this.options.htmlEntities;else if(this.options.htmlEntities===!0)M={...N8,...P8};this.entityDecoder=new t1({namedEntities:{...M,...O},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo},onInputEntity:($,Y)=>dA(Y,[s0,n0])?c0.BLOCK:c0.ALLOW})}this.matcher=new MM,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new OM;let L=this.options.stopNodes;if(L&&L.length>0){for(let $=0;$<L.length;$++){let Y=L[$];if(typeof Y==="string")this.stopNodeExpressionsSet.add(new i0(Y));else if(Y instanceof i0)this.stopNodeExpressionsSet.add(Y)}this.stopNodeExpressionsSet.seal()}}}function UT(W,O,M,L,$,Y,J){let A=this.options;if(W!==void 0){if(A.trimValues&&!L)W=W.trim();if(W.length>0){if(!J)W=this.replaceEntitiesValue(W,O,M);let Z=A.jPath?M.toString():M,G=A.tagValueProcessor(O,W,Z,$,Y);if(G===null||G===void 0)return W;else if(typeof G!==typeof W||G!==W)return G;else if(A.trimValues)return m8(W,A.parseTagValue,A.numberParseOptions);else if(W.trim()===W)return m8(W,A.parseTagValue,A.numberParseOptions);else return W}}}function zT(W){if(this.options.removeNSPrefix){let O=W.split(":"),M=W.charAt(0)==="/"?"/":"";if(O[0]==="xmlns")return"";if(O.length===2)W=M+O[1]}return W}var VT=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function HT(W,O,M,L=!1){let $=this.options;if(L===!0||$.ignoreAttributes!==!0&&typeof W==="string"){let Y=KL(W,VT),J=Y.length,A={},Z=Array(J),G=!1,X={};for(let U=0;U<J;U++){let T=this.resolveNameSpace(Y[U][1]),S=Y[U][4];if(T.length&&S!==void 0){let H=S;if($.trimValues)H=H.trim();H=this.replaceEntitiesValue(H,M,this.readonlyMatcher),Z[U]=H,X[T]=H,G=!0}}if(G&&typeof O==="object"&&O.updateCurrent)O.updateCurrent(X);let Q=$.jPath?O.toString():this.readonlyMatcher,R=!1;for(let U=0;U<J;U++){let T=this.resolveNameSpace(Y[U][1]);if(this.ignoreAttributesFn(T,Q))continue;let S=$.attributeNamePrefix+T;if(T.length){if($.transformAttributeName)S=$.transformAttributeName(S);if(S=cA(S,$),Y[U][4]!==void 0){let H=Z[U],F=$.attributeValueProcessor(T,H,Q);if(F===null||F===void 0)A[S]=H;else if(typeof F!==typeof H||F!==H)A[S]=F;else A[S]=m8(H,$.parseAttributeValue,$.numberParseOptions);R=!0}else if($.allowBooleanAttributes)A[S]=!0,R=!0}}if(!R)return;if($.attributesGroupName&&!$.preserveOrder){let U={};return U[$.attributesGroupName]=A,U}return A}}var KT=function(W){W=W.replace(/\r\n?/g,`
27
+ `);let O=new sW("!xml"),M=O,L="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0,this.doctypefound=!1;let $=this.options,Y=new BL($.processEntities),J=W.length;for(let A=0;A<J;A++)if(W[A]==="<"){let G=W.charCodeAt(A+1);if(G===47){let X=r0(W,">",A,"Closing Tag is not closed."),Q=W.substring(A+2,X).trim();if($.removeNSPrefix){let U=Q.indexOf(":");if(U!==-1)Q=Q.substr(U+1)}if(Q=l8($.transformTagName,Q,"",$).tagName,M)L=this.saveTextToParentTag(L,M,this.readonlyMatcher);let R=this.matcher.getCurrentTag();if(Q&&$.unpairedTagsSet.has(Q))throw Error(`Unpaired tag can not be used as closing tag: </${Q}>`);if(R&&$.unpairedTagsSet.has(R))this.matcher.pop(),this.tagsNodeStack.pop();this.matcher.pop(),this.isCurrentNodeStopNode=!1,M=this.tagsNodeStack.pop(),L="",A=X}else if(G===63){let X=p8(W,A,!1,"?>");if(!X)throw Error("Pi Tag is not closed.");L=this.saveTextToParentTag(L,M,this.readonlyMatcher);let Q=this.buildAttributesMap(X.tagExp,this.matcher,X.tagName,!0);if(Q){let R=Q[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(R)||1),Y.setXmlVersion(Number(R)||1)}if($.ignoreDeclaration&&X.tagName==="?xml"||$.ignorePiTags);else{let R=new sW(X.tagName);if(R.add($.textNodeName,""),X.tagName!==X.tagExp&&X.attrExpPresent&&$.ignoreAttributes!==!0)R[":@"]=Q;this.addChild(M,R,this.readonlyMatcher,A)}A=X.closeIndex+1}else if(G===33&&W.charCodeAt(A+2)===45&&W.charCodeAt(A+3)===45){let X=r0(W,"-->",A+4,"Comment is not closed.");if($.commentPropName){let Q=W.substring(A+4,X-2);L=this.saveTextToParentTag(L,M,this.readonlyMatcher),M.add($.commentPropName,[{[$.textNodeName]:Q}])}A=X}else if(G===33&&W.charCodeAt(A+2)===68){if(this.doctypefound)throw Error("Multiple DOCTYPE declarations found.");this.doctypefound=!0;let X=Y.readDocType(W,A);this.entityDecoder.addInputEntities(X.entities),A=X.i}else if(G===33&&W.charCodeAt(A+2)===91){let X=r0(W,"]]>",A,"CDATA is not closed.")-2,Q=W.substring(A+9,X);L=this.saveTextToParentTag(L,M,this.readonlyMatcher);let R=this.parseTextData(Q,M.tagname,this.readonlyMatcher,!0,!1,!0,!0);if(R==null)R="";if($.cdataPropName)M.add($.cdataPropName,[{[$.textNodeName]:Q}]);else M.add($.textNodeName,R);A=X+2}else{let X=p8(W,A,$.removeNSPrefix);if(!X){let q=W.substring(Math.max(0,A-50),Math.min(J,A+50));throw Error(`readTagExp returned undefined at position ${A}. Context: "${q}"`)}let{tagName:Q,rawTagName:R,tagExp:U,attrExpPresent:T,closeIndex:S}=X;if({tagName:Q,tagExp:U}=l8($.transformTagName,Q,U,$),$.strictReservedNames&&(Q===$.commentPropName||Q===$.cdataPropName||Q===$.textNodeName||Q===$.attributesGroupName))throw Error(`Invalid tag name: ${Q}`);if(M&&L){if(M.tagname!=="!xml")L=this.saveTextToParentTag(L,M,this.readonlyMatcher,!1)}let H=M;if(H&&$.unpairedTagsSet.has(H.tagname))M=this.tagsNodeStack.pop(),this.matcher.pop();let F=!1;if(U.length>0&&U.lastIndexOf("/")===U.length-1){if(F=!0,Q[Q.length-1]==="/")Q=Q.substr(0,Q.length-1),U=Q;else U=U.substr(0,U.length-1);T=Q!==U}let K=null,w={},P=void 0;if(P=ST(R),Q!==O.tagname)this.matcher.push(Q,{},P);if(Q!==U&&T){if(K=this.buildAttributesMap(U,this.matcher,Q),K)w=RT(K,$)}if(Q!==O.tagname)this.isCurrentNodeStopNode=this.isItStopNode();let B=A;if(this.isCurrentNodeStopNode){let q="";if(F)A=X.closeIndex;else if($.unpairedTagsSet.has(Q))A=X.closeIndex;else{let _=this.readStopNodeData(W,R,S+1);if(!_)throw Error(`Unexpected end of ${R}`);A=_.i,q=_.tagContent}let N=new sW(Q);if(K)N[":@"]=K;N.add($.textNodeName,q),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(M,N,this.readonlyMatcher,B)}else{if(F){({tagName:Q,tagExp:U}=l8($.transformTagName,Q,U,$));let q=new sW(Q);if(K)q[":@"]=K;this.addChild(M,q,this.readonlyMatcher,B),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else if($.unpairedTagsSet.has(Q)){let q=new sW(Q);if(K)q[":@"]=K;this.addChild(M,q,this.readonlyMatcher,B),this.matcher.pop(),this.isCurrentNodeStopNode=!1,A=X.closeIndex;continue}else{let q=new sW(Q);if(this.tagsNodeStack.length>$.maxNestedTags)throw Error("Maximum nested tags exceeded");if(this.tagsNodeStack.push(M),K)q[":@"]=K;this.addChild(M,q,this.readonlyMatcher,B),M=q}L="",A=S}}}else L+=W[A];return O.child};function TT(W,O,M,L){if(!this.options.captureMetaData)L=void 0;let $=this.options.jPath?M.toString():M,Y=this.options.updateTag(O.tagname,$,O[":@"]);if(Y===!1);else if(typeof Y==="string")O.tagname=Y,W.addChild(O,L);else W.addChild(O,L)}function FT(W,O,M){let L=this.options.processEntities;if(!L||!L.enabled)return W;if(L.allowedTags){let $=this.options.jPath?M.toString():M;if(!(Array.isArray(L.allowedTags)?L.allowedTags.includes(O):L.allowedTags(O,$)))return W}if(L.tagFilter){let $=this.options.jPath?M.toString():M;if(!L.tagFilter(O,$))return W}return this.entityDecoder.decode(W)}function ET(W,O,M,L){if(W){if(L===void 0)L=O.child.length===0;if(W=this.parseTextData(W,O.tagname,M,!1,O[":@"]?Object.keys(O[":@"]).length!==0:!1,L),W!==void 0&&W!=="")O.add(this.options.textNodeName,W);W=""}return W}function qT(){if(this.stopNodeExpressionsSet.size===0)return!1;return this.matcher.matchesAny(this.stopNodeExpressionsSet)}function BT(W,O,M=">"){let L=0,$=W.length,Y=M.charCodeAt(0),J=M.length>1?M.charCodeAt(1):-1,A="",Z=O;for(let G=O;G<$;G++){let X=W.charCodeAt(G);if(L){if(X===L)L=0}else if(X===34||X===39)L=X;else if(X===Y)if(J!==-1){if(W.charCodeAt(G+1)===J)return A+=W.substring(Z,G),{data:A,index:G}}else return A+=W.substring(Z,G),{data:A,index:G};else if(X===9&&!L)A+=W.substring(Z,G)+" ",Z=G+1}}function r0(W,O,M,L){let $=W.indexOf(O,M);if($===-1)throw Error(L);else return $+O.length-1}function CT(W,O,M,L){let $=W.indexOf(O,M);if($===-1)throw Error(L);return $}function p8(W,O,M,L=">"){let $=BT(W,O+1,L);if(!$)return;let{data:Y,index:J}=$,A=Y.search(/\s/),Z=Y,G=!0;if(A!==-1)Z=Y.substring(0,A),Y=Y.substring(A+1).trimStart();let X=Z;if(M){let Q=Z.indexOf(":");if(Q!==-1)Z=Z.substr(Q+1),G=Z!==$.data.substr(Q+1)}return{tagName:Z,tagExp:Y,closeIndex:J,attrExpPresent:G,rawTagName:X}}function wT(W,O,M){let L=M,$=1,Y=W.length;for(;M<Y;M++)if(W[M]==="<"){let J=W.charCodeAt(M+1);if(J===47){let A=CT(W,">",M,`${O} is not closed`);if(W.substring(M+2,A).trim()===O){if($--,$===0)return{tagContent:W.substring(L,M),i:A}}M=A}else if(J===63)M=r0(W,"?>",M+1,"StopNode is not closed.");else if(J===33&&W.charCodeAt(M+2)===45&&W.charCodeAt(M+3)===45)M=r0(W,"-->",M+3,"StopNode is not closed.");else if(J===33&&W.charCodeAt(M+2)===91)M=r0(W,"]]>",M,"StopNode is not closed.")-2;else{let A=p8(W,M,!1);if(A){if((A&&A.tagName)===O&&A.tagExp[A.tagExp.length-1]!=="/")$++;M=A.closeIndex}}}}function m8(W,O,M){if(O&&typeof W==="string"){let L=W.trim();if(L==="true")return!0;else if(L==="false")return!1;else return k8(W,M)}else if(_A(W))return W;else return""}function l8(W,O,M,L){if(W){let $=W(O);if(M===O)M=$;O=$}return O=cA(O,L),{tagName:O,tagExp:M}}function cA(W,O){if(TL.includes(W))throw Error(`[SECURITY] Invalid name: "${W}" is a reserved JavaScript keyword that could cause prototype pollution`);else if(n1.includes(W))return O.onDangerousProperty(W);return W}var d8=sW.getMetaDataSymbol();function PT(W,O){if(!W||typeof W!=="object")return{};if(!O)return W;let M={};for(let L in W)if(L.startsWith(O)){let $=L.substring(O.length);M[$]=W[L]}else M[L]=W[L];return M}function c8(W,O,M,L){return iA(W,O,M,L)}function iA(W,O,M,L){let $,Y={};for(let J=0;J<W.length;J++){let A=W[J],Z=NT(A);if(Z!==void 0&&Z!==O.textNodeName){let G=PT(A[":@"]||{},O.attributeNamePrefix);M.push(Z,G)}if(Z===O.textNodeName)if($===void 0)$=A[Z];else $+=""+A[Z];else if(Z===void 0)continue;else if(A[Z]){let G=iA(A[Z],O,M,L),X=jT(G,O);if(Object.keys(G).length===0&&O.alwaysCreateTextNode)G[O.textNodeName]="";if(A[":@"])_T(G,A[":@"],L,O);else if(Object.keys(G).length===1&&G[O.textNodeName]!==void 0&&!O.alwaysCreateTextNode)G=G[O.textNodeName];else if(Object.keys(G).length===0)if(O.alwaysCreateTextNode)G[O.textNodeName]="";else G="";if(A[d8]!==void 0&&typeof G==="object"&&G!==null)G[d8]=A[d8];if(Y[Z]!==void 0&&Object.prototype.hasOwnProperty.call(Y,Z)){if(!Array.isArray(Y[Z]))Y[Z]=[Y[Z]];Y[Z].push(G)}else{let Q=O.jPath?L.toString():L;if(O.isArray(Z,Q,X))Y[Z]=[G];else Y[Z]=G}if(Z!==void 0&&Z!==O.textNodeName)M.pop()}}if(typeof $==="string"){if($.length>0)Y[O.textNodeName]=$}else if($!==void 0)Y[O.textNodeName]=$;return Y}function NT(W){let O=Object.keys(W);for(let M=0;M<O.length;M++){let L=O[M];if(L!==":@")return L}}function _T(W,O,M,L){if(O){let $=Object.keys(O),Y=$.length;for(let J=0;J<Y;J++){let A=$[J],Z=A.startsWith(L.attributeNamePrefix)?A.substring(L.attributeNamePrefix.length):A,G=L.jPath?M.toString()+"."+Z:M;if(L.isArray(A,G,!0,!0))W[A]=[O[A]];else W[A]=O[A]}}}function jT(W,O){let{textNodeName:M}=O,L=Object.keys(W).length;if(L===0)return!0;if(L===1&&(W[M]||typeof W[M]==="boolean"||W[M]===0))return!0;return!1}class $M{constructor(W){this.externalEntities={},this.options=vA(W)}parse(W,O){if(typeof W!=="string"&&W.toString)W=W.toString();else if(typeof W!=="string")throw Error("XML data is accepted in String or Bytes[] form.");if(O){if(O===!0)O={};let $=FL(W,O);if($!==!0)throw Error(`${$.err.msg}:${$.err.line}:${$.err.col}`)}let M=new NL(this.options,this.externalEntities),L=M.parseXml(W);if(this.options.preserveOrder||L===void 0)return L;else return c8(L,this.options,M.matcher,M.readonlyMatcher)}addEntity(W,O){if(O.indexOf("&")!==-1)throw Error("Entity value can't have '&'");else if(W.indexOf("&")!==-1||W.indexOf(";")!==-1)throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");else if(O==="&")throw Error("An entity with value '&' is not permitted");else this.externalEntities[W]=O}static getMetaDataSymbol(){return sW.getMetaDataSymbol()}}var sA={validate:FL};function IT(W,O){let M;for(let L=O+1;L<W.length;L+=1){let $=W[L];if(M!==void 0){if($===M)M=void 0;continue}if($==='"'||$==="'"){M=$;continue}if($===">")return L+1}return W.length}function yT(W,O){if(W.startsWith("<!--",O)){let G=W.indexOf("-->",O+4);return{start:O,end:G===-1?W.length:G+3,closing:!1,selfClosing:!1,declaration:!1}}let M=IT(W,O),L=O+1,$=W[L]==="?"||W[L]==="!",Y=W[L]==="/";if(Y)L+=1;while(/\s/.test(W[L]??""))L+=1;let J=L;while(/[A-Za-z0-9:_.-]/.test(W[L]??""))L+=1;let A=L===J?void 0:W.slice(J,L),Z=W.slice(O,M);return{start:O,end:M,name:A,closing:Y,selfClosing:/\/\s*>$/.test(Z),declaration:$}}function DT(W){return W.replace(/[^\r\n\t]/g," ")}function nA(W){let O=W.text,M=[],L=[],$=[],Y=0,J=0;while(Y<O.length){let Z=O.indexOf("<",Y);if(Z===-1)break;let G=yT(O,Z);if(G.declaration)$.push(G.start);if(G.name==="script"&&!G.closing&&!G.selfClosing&&!G.declaration){let X=G.end,Q=O.indexOf("</script>",X);if(Q===-1)throw W.parseError("WOML_UNCLOSED_RAW_BODY","The <script> body is not closed by the required literal </script> terminator.",G.start,G.end,"Add </script>. The terminator is case-sensitive in WOML v0.1.");let R=O.slice(X,Q);M.push(O.slice(J,X),DT(R)),L.push({index:L.length,openingTagOffset:G.start,value:R,span:W.span(X,Q)}),J=Q,Y=Q+9;continue}Y=Math.max(G.end,Z+1)}M.push(O.slice(J));let A=M.join("");if(A.length!==O.length)throw Error("Internal WOML raw-content masking changed source length.");return{source:A,scripts:L,declarationOffsets:$}}var kT={preserveOrder:!0,ignoreAttributes:!1,attributeNamePrefix:"",parseTagValue:!1,parseAttributeValue:!1,trimValues:!1,allowBooleanAttributes:!1,commentPropName:!1},bT=new $M(kT);function s8(W){return Object.keys(W).find((O)=>O!==":@")}function oA(W){let O=s8(W);return O!==void 0&&!O.startsWith("#")&&!O.startsWith("?")}function fT(W,O){if(W==="InvalidAttr")return O.includes("is repeated")?"WOML_DUPLICATE_ATTRIBUTE":"WOML_INVALID_ATTRIBUTE";return"WOML_MALFORMED_MARKUP"}function vT(W,O){if(O>0&&W.includes("closing tag 'script'"))return"The first literal </script> ends a script body in WOML v0.1. Do not place that exact sequence inside JavaScript text or comments.";return}function i8(W,O){let M;for(let L=O+1;L<W.length;L+=1){let $=W[L];if(M!==void 0){if($===M)M=void 0}else if($==='"'||$==="'")M=$;else if($===">")return L+1}return W.length}function gT(W,O,M,L){let $=W.text,Y=[],J=L;while(J<M-1){while(/\s/.test($[J]??""))J+=1;if($[J]===">"||$[J]==="/")break;let A=J;while(/[^\s=/>]/.test($[J]??""))J+=1;let Z=J,G=$.slice(A,Z);while(/\s/.test($[J]??""))J+=1;if($[J]!=="=")break;J+=1;while(/\s/.test($[J]??""))J+=1;let X=$[J];if(X!=='"'&&X!=="'")break;J+=1;let Q=J;while(J<M&&$[J]!==X)J+=1;let R=J;if($[J]===X)J+=1;Y.push({name:G,span:W.span(A,J),nameSpan:W.span(A,Z),valueSpan:W.span(Q,R)})}return Y}function xT(W,O){let M=[],L=[],$=0;while($<O.length){let Y=O.indexOf("<",$);if(Y===-1)break;if(O.startsWith("<!--",Y)){let T=O.indexOf("-->",Y+4);$=T===-1?O.length:T+3;continue}if(O[Y+1]==="?"||O[Y+1]==="!"){$=i8(O,Y);continue}let J=i8(O,Y),A=Y+1,Z=O[A]==="/";if(Z)A+=1;while(/\s/.test(O[A]??""))A+=1;let G=A;while(/[A-Za-z0-9:_.-]/.test(O[G]??""))G+=1;let X=O.slice(A,G);if(Z){let T=L.pop();if(T!==void 0)T.closeStart=Y,T.end=J;$=J;continue}let Q=/\/\s*>$/.test(O.slice(Y,J)),R={name:X,start:Y,openEnd:J,closeStart:J,end:J,selfClosing:Q,attributes:gT(W,Y,J,G),children:[]},U=L[L.length-1];if(U===void 0)M.push(R);else U.children.push(R);if(!Q)L.push(R);$=J}return M}function hT(W){let O=s8(W);if(O===void 0)return[];let M=W[O];if(!Array.isArray(M))return[];return M.filter((L)=>typeof L==="object"&&L!==null&&oA(L))}function rA(W,O,M){let L=[],$=O;while($<M){let Y=W.text.indexOf("<!--",$),J=Y===-1||Y>=M?M:Y,A=W.text.slice($,J);if(A.trim().length>0)L.push({kind:"text",value:A,span:W.span($,J)});if(J===M)break;let Z=W.text.indexOf("-->",Y+4);$=Z===-1?M:Math.min(Z+3,M)}return L}function tA(W,O,M,L){let $=s8(O);if($!==M.name)throw Error(`Internal WOML parser location mismatch: expected ${$}, found ${M.name}.`);let Y=O[":@"]??{},J={};for(let G of M.attributes){let X=Y[G.name];J[G.name]={name:G.name,value:typeof X==="string"?X:String(X??""),span:G.span,nameSpan:G.nameSpan,valueSpan:G.valueSpan}}let A=L.get(M.start),Z=[];if(A!==void 0)Z.push({kind:"raw",value:A.value,span:A.span});else if(!M.selfClosing){let G=hT(O),X=M.openEnd;for(let Q=0;Q<M.children.length;Q+=1){let R=M.children[Q];Z.push(...rA(W,X,R.start));let U=G[Q];if(U===void 0)throw Error(`Internal WOML parser lost child <${R.name}>.`);Z.push(tA(W,U,R,L)),X=R.end}Z.push(...rA(W,X,M.closeStart))}return{kind:"element",name:M.name,attributes:J,children:Z,span:W.span(M.start,M.end),openTagSpan:W.span(M.start,M.openEnd)}}function aA(W,O,M){let L=O;while(L<M){if(/\s/.test(W[L])){L+=1;continue}if(W.startsWith("<!--",L)){let $=W.indexOf("-->",L+4);if($===-1||$>=M)return;L=$+3;continue}return L}return}function YM(W,O={}){let M=new n(O.file??"<memory>",W),L=nA(M);if(L.declarationOffsets.length>0){let U=L.declarationOffsets[0];throw M.parseError("WOML_DECLARATION_NOT_ALLOWED","WOML does not allow XML declarations, doctypes, CDATA, or processing instructions.",U,i8(W,U))}let $=sA.validate(L.source,{allowBooleanAttributes:!1});if($!==!0){let U=$.err.line??1,T=$.err.col??1,S=M.offsetAt(U,T);throw M.parseError(fT($.err.code,$.err.msg),$.err.msg,S,S+1,vT($.err.msg,L.scripts.length))}let Y;try{Y=bT.parse(L.source)}catch(U){throw M.parseError("WOML_MALFORMED_MARKUP",U instanceof Error?U.message:"Unable to parse WOML markup.",0)}let J=Y.filter(oA),A=xT(M,L.source);if(J.length!==1||A.length!==1){let U=A[1],T=U?.start??0;throw M.parseError("WOML_MULTIPLE_ROOTS","A WOML file must contain exactly one root element.",T,U?.openEnd??T+1)}let Z=A[0],G=aA(W,0,Z.start);if(G!==void 0)throw M.parseError("WOML_TEXT_OUTSIDE_ROOT","Text is not allowed before the WOML root element.",G);let X=aA(W,Z.end,W.length);if(X!==void 0)throw M.parseError("WOML_TEXT_OUTSIDE_ROOT","Text is not allowed after the WOML root element.",X);let Q=new Map(L.scripts.map((U)=>[U.openingTagOffset,U])),R=tA(M,J[0],Z,Q);return{kind:"document",file:M.path,source:W,root:R,span:M.span(0,W.length)}}var uT=[{name:"minute",minimum:0,maximum:59},{name:"hour",minimum:0,maximum:23},{name:"day-of-month",minimum:1,maximum:31},{name:"month",minimum:1,maximum:12},{name:"day-of-week",minimum:0,maximum:7,normalize:(W)=>W===7?0:W}];var lT=new Set(Intl.supportedValuesOf("timeZone"));class nW extends Error{reason;constructor(W){super(W);this.reason=W;this.name="ScheduleCronSyntaxError"}}function _L(W){if(!/^[0-9]+$/.test(W))return;let O=Number(W);return Number.isSafeInteger(O)?O:void 0}function n8(W,O){return W>=O.minimum&&W<=O.maximum}function pT(W,O){if(W.length===0)throw new nW(`${O.name} must not be empty`);let M=new Set;for(let $ of W.split(",")){if($.length===0)throw new nW(`${O.name} contains an empty list item`);let Y=$.split("/");if(Y.length>2||Y.some((X)=>X.length===0))throw new nW(`${O.name} contains an invalid step`);let J=Y[0],A=Y[1]===void 0?1:_L(Y[1]);if(A===void 0||A<1)throw new nW(`${O.name} step must be a positive integer`);let Z,G;if(J==="*")Z=O.minimum,G=O.maximum;else if(J.includes("-")){let X=J.split("-");if(X.length!==2)throw new nW(`${O.name} contains an invalid range`);let Q=_L(X[0]),R=_L(X[1]);if(Q===void 0||R===void 0||!n8(Q,O)||!n8(R,O)||Q>R)throw new nW(`${O.name} range is outside ${O.minimum}-${O.maximum}`);Z=Q,G=R}else{let X=_L(J);if(X===void 0||!n8(X,O))throw new nW(`${O.name} value is outside ${O.minimum}-${O.maximum}`);Z=X,G=Y[1]===void 0?X:O.maximum}for(let X=Z;X<=G;X+=A)M.add(O.normalize?.(X)??X)}let L=new Set;for(let $=O.minimum;$<=O.maximum;$+=1)L.add(O.normalize?.($)??$);return{values:M,unrestricted:M.size===L.size&&[...L].every(($)=>M.has($))}}function eA(W){if(W.length>256)throw new nW("cron must not exceed 256 characters");if(W!==W.trim()||/\s/.test(W.replace(/ /g,"")))throw new nW("cron must use single ASCII spaces between fields");let O=W.split(" ");if(O.length!==5||O.some((L)=>L.length===0))throw new nW("cron must contain exactly five fields separated by single spaces");let M=O.map((L,$)=>pT(L,uT[$]));return{dialect:"woml-cron-v1",source:W,minute:M[0],hour:M[1],dayOfMonth:M[2],month:M[3],dayOfWeek:M[4]}}function WZ(W){return lT.has(W)}import{createHash as mT}from"crypto";import{readFileSync as $Z,realpathSync as IL,statSync as YZ}from"fs";import{dirname as a8,isAbsolute as JZ,relative as o8,resolve as yL,sep as t8}from"path";var AZ=/^[a-z][A-Za-z0-9]*$/,ZZ=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,dT=/^(?:\.\/|\.\.\/)(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\.(?:js|ts)$/,cT=/^(?:\.\/|\.\.\/)(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\.woml$/,OZ=/^\{\{secrets\.([A-Z][A-Z0-9_]*)\}\}$/,iT=/^\{\{context\.(?:payload(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|steps\.[a-z][A-Za-z0-9]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|item(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|iteration\.(?:index|total))\}\}$/,sT=new Set(["__proto__","prototype","constructor"]),nT=new Set(["woml","imports","module","props","prop","workflow","config","lifecycle","on-start","on-step-start","on-step-success","on-step-failure","on-step-complete","on-success","on-error","on-failure","on-cancel","on-complete","triggers","manual","webhook","slack","schedule","interval","event","schema","steps","step","script","choose","switch","case","default","when","otherwise","result","parallel","for-each","fork","branch","approval","notify","provider","when-approved","when-rejected"]);function GZ(W,O,M,L,$,Y){return{phase:O,code:M,message:L,file:W.file,location:$,...Y===void 0?{}:{hint:Y}}}function m(W,O,M,L,$){throw new O0(GZ(W,"validation",O,M,L,$))}function a0(W,O,M,L,$){throw new RO(GZ(W,"compile",O,M,L,$))}function o0(W,O){let M=[];for(let L of O.children){if(L.kind!=="element")m(W,"WOML_UNEXPECTED_CONTENT",`<${O.name}> may contain WOML elements only.`,L.span);M.push(L)}return M}function t0(W,O){let M=Object.values(O.attributes)[0];if(M!==void 0)m(W,"WOML_UNKNOWN_ATTRIBUTE",`<${O.name}> does not accept attribute "${M.name}".`,M.nameSpan)}function DL(W,O,M){let L=Object.values(O.attributes).find(($)=>!M.has($.name));if(L!==void 0)m(W,"WOML_UNKNOWN_ATTRIBUTE",`Unknown attribute "${L.name}" on <${O.name}>.`,L.nameSpan)}function rT(W,O){if(O.children.length>0)m(W,"WOML_REUSABLE_TAG_CHILDREN_UNSUPPORTED",`<${O.name}> must be empty; reusable structural children are not supported in this release.`,O.children[0].span,"Pass declared props as attributes. General custom structural tags are postponed.")}function JM(W,O,M){let L=O.attributes[M];if(L===void 0)m(W,"WOML_MISSING_ATTRIBUTE",`<${O.name}> requires the "${M}" attribute.`,O.openTagSpan);return L}function MZ(W,O,M){let L=O.attributes[M];if(L===void 0)return!1;if(L.value!=="true"&&L.value!=="false")m(W,"WOML_PROP_BOOLEAN_INVALID",`Prop attribute "${M}" must be exactly "true" or "false".`,L.valueSpan);return L.value==="true"}function aT(W){return W.replace(/-([a-z0-9])/g,(O,M)=>M.toUpperCase())}function oT(W,O){if(O===void 0)return[];t0(W,O);let M=o0(W,O);if(M.length===0)m(W,"WOML_PROPS_EMPTY","<props> requires at least one <prop> declaration.",O.openTagSpan,"Remove the empty <props> block when the reusable definition has no props.");let L=new Set,$=new Set;return M.map((Y)=>{if(Y.name!=="prop")m(W,"WOML_PROPS_INVALID_CHILD",`<props> accepts <prop> declarations only; found <${Y.name}>.`,Y.openTagSpan);if(DL(W,Y,new Set(["name","required","secret"])),Y.children.length>0)m(W,"WOML_PROP_NOT_EMPTY","<prop> is an empty declaration and cannot contain child content.",Y.children[0].span);let J=JM(W,Y,"name"),A=J.value,Z=aT(A);if(A.length>128||!ZZ.test(A))m(W,"WOML_PROP_NAME_INVALID",`Prop name "${A}" must use lowercase kebab-case.`,J.valueSpan,"Example: customer-id");if(sT.has(Z))m(W,"WOML_PROP_NAME_RESERVED",`Prop name "${A}" maps to reserved JavaScript key "${Z}".`,J.valueSpan);if(L.has(A)||$.has(Z))m(W,"WOML_PROP_DUPLICATE",`Prop "${A}" duplicates an existing source or JavaScript binding name.`,J.valueSpan);return L.add(A),$.add(Z),{name:A,bindingName:Z,required:MZ(W,Y,"required"),secret:MZ(W,Y,"secret"),element:Y}})}function LZ(W,O){if(O===void 0)return[];t0(W,O);let M=o0(W,O);if(M.length===0)m(W,"WOML_IMPORTS_EMPTY","<imports> requires at least one <module> declaration.",O.openTagSpan);let L=new Set,$=new Set;return M.map((Y)=>{if(Y.name!=="module")m(W,"WOML_IMPORTS_INVALID_CHILD",`<imports> accepts <module> declarations only; found <${Y.name}>.`,Y.openTagSpan);if(DL(W,Y,new Set(["name","from"])),Y.children.length>0)m(W,"WOML_INVALID_STRUCTURE","<module> cannot contain child content.",Y.children[0].span);let J=JM(W,Y,"name"),A=JM(W,Y,"from"),Z=J.value,G=A.value,X=G.endsWith(".woml"),Q=X?ZZ.test(Z):AZ.test(Z);if(Z.length>128||!Q)m(W,"WOML_MODULE_ALIAS_INVALID",X?`Reusable definition name "${Z}" must use lowercase kebab-case.`:`Module name "${Z}" must be a JavaScript-safe lower-camel alias.`,J.valueSpan,X?"Example: calculate-discount":"Example: spreadsheet or customerTools");if(X&&nT.has(Z))m(W,"WOML_REUSABLE_ALIAS_RESERVED",`Reusable definition name "${Z}" is reserved by WOML.`,J.valueSpan);if(L.has(Z))m(W,"WOML_MODULE_ALIAS_DUPLICATE",`Import name "${Z}" is declared more than once.`,J.valueSpan);if($.has(G))m(W,"WOML_MODULE_SOURCE_DUPLICATE",`Import source "${G}" is already declared under another name.`,A.valueSpan);if(!(X?cT.test(G):dT.test(G))||G.includes("\\")||G.includes("\x00")||G.includes("?")||G.includes("#"))m(W,"WOML_MODULE_PATH_INVALID",`Import source "${G}" must be an explicit relative POSIX path ending in .js, .ts, or .woml.`,A.valueSpan);return L.add(Z),$.add(G),{name:Z,from:G,kind:X?"reusable-definition":"script-module",element:Y}})}function XZ(W,O){if(W.name===O)return W;for(let M of W.children){if(M.kind!=="element")continue;let L=XZ(M,O);if(L!==void 0)return L}return}function tT(W,O,M){if(M==="reusable-step")DL(W,O,new Set(["name","description"]));else{DL(W,O,new Set(["kind"]));let $=JM(W,O,"kind");if($.value!=="notification")m(W,"WOML_PROVIDER_KIND_UNSUPPORTED",`Provider kind "${$.value}" is not executable in this release.`,$.valueSpan,$.value==="trigger"?"Custom trigger providers are reserved for a future reviewed inbound-provider contract.":'Use kind="notification".')}let L=o0(W,O);if(L.length!==1||L[0].name!=="script")m(W,M==="reusable-step"?"WOML_REUSABLE_STEP_OPERATION_REQUIRED":"WOML_PROVIDER_OPERATION_REQUIRED",`<${O.name}> must contain exactly one <script>.`,L[1]?.openTagSpan??L[0]?.openTagSpan??O.openTagSpan);if(t0(W,L[0]),L[0].children.length!==1||L[0].children[0].kind!=="raw")m(W,"WOML_SCRIPT_BODY_REQUIRED","<script> requires one raw JavaScript body.",L[0].openTagSpan)}function eT(W,O){if(O===void 0)return;t0(W,O);let M=o0(W,O);if(M.length===0)m(W,"WOML_LIFECYCLE_ACTION_REQUIRED","<lifecycle> requires at least one reusable lifecycle hook.",O.openTagSpan);let L=["on-success","on-error","on-complete"],$=new Set;for(let Y of M){if(L.indexOf(Y.name)===-1)m(W,Y.name.startsWith("on-step-")?"WOML_REUSABLE_STEP_HOOK_UNSUPPORTED":"WOML_REUSABLE_LIFECYCLE_HOOK_INVALID",`<${Y.name}> is not available in a reusable definition lifecycle.`,Y.openTagSpan,"Use <on-success>, <on-error>, and <on-complete> only.");if($.has(Y.name))m(W,"WOML_LIFECYCLE_DUPLICATE",`<${Y.name}> may appear only once.`,Y.openTagSpan);t0(W,Y);let A=o0(W,Y);if(A.length===0)m(W,"WOML_LIFECYCLE_ACTION_REQUIRED",`<${Y.name}> requires at least one <script> action.`,Y.openTagSpan);for(let Z of A){if(Z.name==="notify")m(W,"WOML_REUSABLE_LIFECYCLE_NOTIFY_UNSUPPORTED","Reusable definition lifecycle hooks support script actions only in v1.",Z.openTagSpan,"Use the custom provider from a workflow lifecycle <notify> action, where notification delivery is durable and recoverable.");if(Z.name!=="script")m(W,"WOML_LIFECYCLE_ACTION_INVALID",`<${Y.name}> supports <script> actions only.`,Z.openTagSpan)}$.add(Y.name)}}function F0(W){let O=W.root;if(O.name!=="woml")m(W,"WOML_EXPECTED_DOCUMENT_ROOT",`Expected <woml> as the document root, found <${O.name}>.`,O.openTagSpan);t0(W,O);let M=o0(W,O),L=M.find((U)=>U.name==="workflow"),$=M.find((U)=>U.name==="step"),Y=M.find((U)=>U.name==="provider"),J=[L,$,Y].filter(Boolean).length;if(J!==1){if(J===0&&M.every((U)=>U.name==="imports"||U.name==="props"))m(W,"WOML_DOCUMENT_STRUCTURE_INVALID","<woml> requires exactly one <workflow>, reusable <step>, or <provider> definition.",M[0]?.openTagSpan??O.openTagSpan);m(W,"WOML_DOCUMENT_PROFILE_INVALID","<woml> must contain exactly one <workflow>, reusable <step>, or <provider> definition.",(L??$??Y??M[0]??O).openTagSpan)}let A=M[0]?.name==="imports"?M[0]:void 0,Z=M.find((U)=>U.name==="props"),G=M.find((U)=>U.name==="lifecycle");if(L!==void 0){let U=XZ(O,"props");if(U!==void 0)m(W,"WOML_PROPS_WORKFLOW_FORBIDDEN","<props> is available only in reusable step or provider definition files, never in a workflow document.",U.openTagSpan);let T=[A,L].filter((S)=>S!==void 0);if(M.length!==T.length||M.some((S,H)=>S!==T[H]))m(W,"WOML_DOCUMENT_STRUCTURE_INVALID","<woml> workflow documents require optional <imports> followed by exactly one <workflow>.",M.find((S,H)=>S!==T[H])?.openTagSpan??O.openTagSpan);return{kind:"workflow",sourcePath:W.file,imports:LZ(W,A),props:[],definition:L}}let X=$??Y,Q=[A,Z,X,G].filter((U)=>U!==void 0);if(M.length!==Q.length||M.some((U,T)=>U!==Q[T]))m(W,"WOML_DOCUMENT_STRUCTURE_INVALID","Reusable documents require optional <imports>, optional <props>, one <step> or <provider>, then optional <lifecycle>.",M.find((U,T)=>U!==Q[T])?.openTagSpan??O.openTagSpan);let R=$===void 0?"notification-provider":"reusable-step";return tT(W,X,R),eT(W,G),{kind:R,sourcePath:W.file,imports:LZ(W,A),props:oT(W,Z),definition:X,...G===void 0?{}:{lifecycle:G}}}function WF(W,O,M){if(O.secret){if(!OZ.test(M.value))m(W,"WOML_REUSABLE_SECRET_PROP_INVALID",`Secret prop "${O.name}" requires exactly {{secrets.SECRET_NAME}}.`,M.valueSpan);return}if(OZ.test(M.value))m(W,"WOML_REUSABLE_SECRET_PROP_UNDECLARED",`Prop "${O.name}" is not declared secret="true".`,M.valueSpan);if((M.value.includes("{{")||M.value.includes("}}"))&&!iT.test(M.value))m(W,"WOML_REUSABLE_PROP_VALUE_INVALID",`Prop "${O.name}" must be a literal string or one exact context reference.`,M.valueSpan,"Mixed interpolation is not supported in reusable props v1.")}function OF(W,O,M,L,$){let Y=L.get(O.name);if(Y===void 0)return;if(M?.name==="triggers"&&["slack","telegram","discord","whatsapp"].includes(O.name))return;let J=new Set(["steps","when","otherwise","branch","parallel","for-each","when-approved","when-rejected","case","default"]);if(Y.kind==="reusable-step"&&!J.has(M?.name??""))m(W,"WOML_REUSABLE_STEP_PLACEMENT_INVALID",`Reusable step <${O.name}> is valid only where an ordinary <step> is allowed.`,O.openTagSpan);if(Y.kind==="notification-provider"&&M?.name!=="notify")m(W,"WOML_REUSABLE_PROVIDER_PLACEMENT_INVALID",`Notification provider <${O.name}> is valid only as a direct child of <notify>.`,O.openTagSpan);if(Y.kind==="notification-provider"&&$.some((G)=>G.name.startsWith("on-"))&&O.attributes.message===void 0)m(W,"WOML_REUSABLE_PROVIDER_MESSAGE_REQUIRED",`Informational provider <${O.name}> requires the "message" attribute.`,O.openTagSpan);rT(W,O);let A=Y.kind==="reusable-step"?new Set(["id","name","description","retry","retry-delay","retry-backoff","retry-max-delay"]):new Set(["message"]);if(Y.kind==="reusable-step"){let G=JM(W,O,"id");if(!AZ.test(G.value))m(W,"WOML_INVALID_ID",`Custom step ID "${G.value}" must be a JavaScript-safe lower-camel identifier.`,G.valueSpan)}let Z=new Map(Y.props.map((G)=>[G.name,G]));for(let G of Object.values(O.attributes)){if(A.has(G.name))continue;let X=Z.get(G.name);if(X===void 0)m(W,"WOML_REUSABLE_PROP_UNKNOWN",`<${O.name}> does not declare prop "${G.name}".`,G.nameSpan);WF(W,X,G)}for(let G of Y.props)if(G.required&&O.attributes[G.name]===void 0)m(W,"WOML_REUSABLE_PROP_REQUIRED",`<${O.name}> requires prop "${G.name}".`,O.openTagSpan)}function r8(W,O,M,L,$=[]){OF(W,O,L,M,$);for(let Y of O.children)if(Y.kind==="element")r8(W,Y,M,O,[...$,O])}function L0(W,O){return o8(W,O).split(t8).join("/")}function jL(W){return`sha256:${mT("sha256").update(W).digest("hex")}`}function M0(W,O,M,L,$,Y){let J=new n(L0(W,O),M),A=Y===void 0?0:Math.max(0,M.indexOf(Y));throw new RO({phase:"compile",code:L,message:$,file:J.path,location:J.span(A,A+Math.max(Y?.length??1,1))})}function QZ(W,O,M,L=[]){if(M.has(W))return;let $;try{$=$Z(W,"utf8")}catch{M0(O,W,"","WOML_MODULE_FILE_NOT_READABLE",`Module source "${L0(O,W)}" could not be read.`)}let Y;try{let J=W.endsWith(".ts")?"ts":"js";Y=new Bun.Transpiler({loader:J}).scan($).imports}catch(J){M0(O,W,$,"WOML_MODULE_SYNTAX_INVALID",`Cannot parse module source: ${J instanceof Error?J.message:String(J)}`)}for(let J of Y){if(J.kind!=="import-statement")M0(O,W,$,J.kind==="dynamic-import"?"WOML_MODULE_DYNAMIC_IMPORT_UNSUPPORTED":"WOML_MODULE_IMPORT_UNSUPPORTED",`Import form "${J.kind}" is unsupported in Module profile v1.`,J.path);if(!J.path.startsWith("./")&&!J.path.startsWith("../"))M0(O,W,$,"WOML_MODULE_PACKAGE_IMPORT_UNAVAILABLE",`Package import "${J.path}" is unavailable until the postponed package milestone.`,J.path);if(!/\.(?:js|ts)$/.test(J.path))M0(O,W,$,"WOML_MODULE_IMPORT_EXTENSION_REQUIRED",`Static import "${J.path}" requires an explicit .js or .ts extension.`,J.path);let A=yL(a8(W),J.path),Z;try{if(Z=IL(A),!YZ(Z).isFile())throw Error("not a file")}catch{M0(O,W,$,"WOML_MODULE_FILE_NOT_FOUND",`Module dependency "${J.path}" does not resolve to a readable file.`,J.path)}let G=o8(O,Z);if(G===".."||G.startsWith(`..${t8}`)||JZ(G))M0(O,W,$,"WOML_MODULE_SYMLINK_ESCAPE",`Module dependency "${J.path}" resolves outside the project boundary.`,J.path);if(L.includes(Z))M0(O,W,$,"WOML_MODULE_GRAPH_CYCLE",`Module dependency graph contains a cycle through "${J.path}".`,J.path);QZ(Z,O,M,[...L,W])}M.set(W,{path:L0(O,W),digest:jL($),kind:"script-module"})}function MF(W,O,M){let{from:L}=O,$=yL(a8(W.file),L),Y;try{if(!YZ($).isFile())throw Error("not a file");Y=IL($)}catch{a0(W,O.kind==="reusable-definition"?"WOML_REUSABLE_SOURCE_NOT_FOUND":"WOML_MODULE_FILE_NOT_FOUND",`Import source "${L}" does not exist or is not a file.`,O.element.attributes.from?.valueSpan??O.element.openTagSpan)}let J=o8(M,Y);if(J===".."||J.startsWith(`..${t8}`)||JZ(J))a0(W,"WOML_MODULE_PROJECT_BOUNDARY",`Import source "${L}" resolves outside the project boundary.`,O.element.attributes.from?.valueSpan??O.element.openTagSpan);return Y}function LF(W,O={}){let M=IL(yL(O.sourcePath??W.file)),L=IL(yL(O.projectRoot??a8(M))),$={...W,file:M},Y=F0($),J=[],A=new Map;A.set(M,{path:L0(L,M),digest:jL($.source),kind:Y.kind});let Z=(U,T,S)=>{let H=new Map,F=new Set;for(let K of T.imports){let w=MF(U,K,L);if(F.has(w))a0(U,"WOML_MODULE_SOURCE_DUPLICATE",`Import source "${K.from}" resolves to a file already imported by this document.`,K.element.attributes.from?.valueSpan??K.element.openTagSpan);F.add(w);let P=$Z(w,"utf8");if(K.kind==="script-module"){QZ(w,L,A);continue}if(S.includes(w))a0(U,"WOML_REUSABLE_IMPORT_CYCLE",`Reusable definition import cycle detected: ${[...S,w].map((V)=>L0(L,V)).join(" -> ")}.`,K.element.openTagSpan);let B=YM(P,{file:w}),q=F0(B);if(q.kind==="workflow")a0(U,"WOML_REUSABLE_WORKFLOW_IMPORT_FORBIDDEN",`Import "${K.name}" points to a runnable workflow, not a reusable step or provider.`,K.element.openTagSpan,"Use services.workflows.call() or services.workflows.start() for workflow-to-workflow communication.");H.set(K.name,q);let N=jL(P);A.set(w,{path:L0(L,w),digest:N,kind:q.kind}),J.push({alias:K.name,sourcePath:L0(L,w),digest:N,kind:q.kind,props:q.props.map(({element:V,...C})=>C)});let _=Z(B,q,[...S,w]);r8(B,B.root,_)}return H},G=Z($,Y,[M]);r8($,$.root,G);let X=[...A.values()].sort((U,T)=>U.path.localeCompare(T.path)),Q=[...J].sort((U,T)=>`${U.alias}\x00${U.sourcePath}`.localeCompare(`${T.alias}\x00${T.sourcePath}`)),R=jL(JSON.stringify({root:L0(L,M),sources:X,definitions:Q}));return{root:Y,definitions:Q,sources:X,rootHash:R}}function e8(W){let O=F0(W);if(O.kind!=="workflow")a0(W,"WOML_DEFINITION_NOT_RUNNABLE",`This file defines a ${O.kind==="reusable-step"?"reusable step":"notification provider"} and cannot be run independently.`,O.definition.openTagSpan,'Import it from a workflow with <module name="custom-tag" from="./definition.woml" />.')}function $F(W){let O=W.definitions.map((M)=>({name:M.alias,description:M.kind==="reusable-step"?`Reusable WOML step from ${M.sourcePath}`:`Reusable WOML notification provider from ${M.sourcePath}`,attributes:[...M.kind==="reusable-step"?[{name:"id",description:"Required workflow-wide step identity."},{name:"name",description:"Optional invocation display name."},{name:"description",description:"Optional invocation description."},{name:"retry",description:"Optional total attempt count."}]:[{name:"message",description:"Required for informational lifecycle notifications."}],...M.props.map((L)=>({name:L.name,description:`${L.required?"Required":"Optional"}${L.secret?" secret":""} prop; available as props.${L.bindingName}.`}))]}));return`${JSON.stringify({version:1.1,tags:O},null,2)}
28
+ `}var JF={insideForkBranch:!1,insideForEach:!1,shadowedServices:[]},AF=new Set(["woml","imports","module","workflow","config","lifecycle","on-start","on-step-start","on-step-success","on-step-failure","on-step-complete","on-success","on-error","on-cancel","on-complete","triggers","manual","webhook","schema","steps","step","script","branch","choose","switch","case","default","fork","parallel","for-each","when","otherwise","result","approval","notify","slack","telegram","discord","whatsapp","schedule","interval","event","when-approved","when-rejected"]),ZF=new Set,GF={woml:{attributes:new Set},imports:{attributes:new Set},module:{attributes:new Set(["name","from"])},workflow:{attributes:new Set(["id","name","description","version"]),stagedAttributes:new Set(["tags"])},config:{attributes:new Set(["concurrency","timeout","rate-limit","queue"])},lifecycle:{attributes:new Set},"on-start":{attributes:new Set},"on-step-start":{attributes:new Set(["steps"])},"on-step-success":{attributes:new Set(["steps"])},"on-step-failure":{attributes:new Set(["steps"])},"on-step-complete":{attributes:new Set(["steps"])},"on-success":{attributes:new Set},"on-error":{attributes:new Set},"on-cancel":{attributes:new Set},"on-complete":{attributes:new Set},triggers:{attributes:new Set},manual:{attributes:new Set(["id"])},webhook:{attributes:new Set(["id","path","method","auth","secret"])},schema:{attributes:new Set},steps:{attributes:new Set},step:{attributes:new Set(["id","name","description","retry","retry-backoff","retry-delay","retry-max-delay"]),stagedAttributes:new Set(["timeout"])},script:{attributes:new Set},branch:{attributes:new Set(["id","name","description"])},choose:{attributes:new Set(["id","name","description"])},switch:{attributes:new Set(["id","name","description","value"])},case:{attributes:new Set(["value"])},default:{attributes:new Set},fork:{attributes:new Set(["id","join"])},parallel:{attributes:new Set(["id","name","description","concurrency","on-error"])},"for-each":{attributes:new Set(["id","name","description","items","concurrency"])},when:{attributes:new Set(["test"])},otherwise:{attributes:new Set},result:{attributes:new Set(["value"])},approval:{attributes:new Set(["id","name","description","timeout","on-timeout"])},notify:{attributes:new Set},slack:{attributes:new Set(["id","events","channels","message","bot-token","app-token"])},telegram:{attributes:new Set(["id","events","chats","message","bot-token"])},discord:{attributes:new Set(["id","events","channels","message","bot-token"])},whatsapp:{attributes:new Set(["id","events","recipients","message","access-token","phone-number-id","verify-token","app-secret","template","language"])},schedule:{attributes:new Set(["id","cron","timezone","on-missed"])},interval:{attributes:new Set(["id","every","on-missed"])},event:{attributes:new Set(["id","name","secret"])},"when-approved":{attributes:new Set},"when-rejected":{attributes:new Set}},XF=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,$9=/^[a-z][A-Za-z0-9]*$/,QF=/^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?$/,RF=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)+$/,SF=/^[a-z][A-Za-z0-9]*$/,UF=/^(?:\.\/|\.\.\/)(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+\.(?:js|ts)$/,zF=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/,RZ=/^sha256:[0-9a-f]{64}$/,VF=/^[A-Za-z_$][A-Za-z0-9_$]*$/,SZ=1e6,UZ=1e6,HF=31536000000,KF=new Set(["http","db","storage","cache","events","queue","workflows","state","context","attempt","services","secrets"]);function BZ(W,O,M,L,$,Y){return{code:M,phase:O,message:L,file:W.file,location:$,...Y===void 0?{}:{hint:Y}}}function E(W,O,M,L,$){throw new O0(BZ(W,"validation",O,M,L,$))}function HW(W,O,M,L,$){throw new RO(BZ(W,"compile",O,M,L,$))}function CZ(W,O,M){if(!AF.has(O.name)){if(M?.name==="lifecycle"&&O.name==="on-failure")E(W,"WOML_LIFECYCLE_HOOK_INVALID","WOML lifecycle uses <on-error>, not <on-failure>.",O.openTagSpan,"Replace <on-failure> with <on-error>; the same hook name is used in workflows and reusable definitions.");if(M?.name==="notify")E(W,"WOML_NOTIFY_UNSUPPORTED_PROVIDER",`<notify> supports built-in <slack>, <telegram>, <discord>, and imported custom providers; found <${O.name}>.`,O.openTagSpan);if(ZF.has(O.name))E(W,"WOML_FEATURE_NOT_EXECUTABLE",`<${O.name}> is designed but is not executable in the first WOML CLI profile.`,O.openTagSpan);E(W,"WOML_UNKNOWN_ELEMENT",`Unknown WOML element <${O.name}>.`,O.openTagSpan)}let L=GF[O.name];for(let $ of Object.values(O.attributes)){if(L.stagedAttributes?.has($.name)===!0)E(W,"WOML_FEATURE_NOT_EXECUTABLE",`Attribute "${$.name}" on <${O.name}> is designed but is not executable in the first WOML CLI profile.`,$.nameSpan);if(!L.attributes.has($.name)){let Y=$.name==="steps"&&O.name.startsWith("on-")&&!O.name.startsWith("on-step-");E(W,Y?"WOML_LIFECYCLE_STEP_FILTER_INVALID":$.name==="retry"||$.name.startsWith("retry-")?"WOML_RETRY_HANDLER_UNSUPPORTED":O.name==="slack"?"WOML_SLACK_UNKNOWN_ATTRIBUTE":O.name==="telegram"?"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE":O.name==="discord"?"WOML_DISCORD_UNKNOWN_ATTRIBUTE":O.name==="whatsapp"?"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE":O.name==="for-each"?"WOML_FOR_EACH_ATTRIBUTE_UNKNOWN":O.name==="config"?"WOML_CONFIG_ATTRIBUTE_UNKNOWN":"WOML_UNKNOWN_ATTRIBUTE",Y?'Attribute "steps" is valid only on step lifecycle hooks.':$.name==="retry"||$.name.startsWith("retry-")?`Retry attributes are valid only on <step>; found "${$.name}" on <${O.name}>.`:`Unknown attribute "${$.name}" on <${O.name}>.`,$.nameSpan,$.name==="retry"||$.name.startsWith("retry-")?"Move the retry policy to a script-bearing <step>.":void 0)}}for(let $ of O.children)if($.kind==="element")CZ(W,$,O)}function wZ(W,O){for(let M of Object.values(O.attributes)){let L=O.name==="slack"&&(M.name==="bot-token"||M.name==="app-token"),$=O.name==="telegram"&&M.name==="bot-token",Y=O.name==="discord"&&M.name==="bot-token",J=O.name==="whatsapp"&&(M.name==="access-token"||M.name==="verify-token"||M.name==="app-secret"),A=O.name==="webhook"&&M.name==="secret",Z=O.name==="event"&&M.name==="secret";if(L||$||Y||J||A||Z){RW(W,M);continue}if(UL(M.value)!==void 0||M.value.includes("{{secrets."))E(W,"WOML_SECRET_SINK_UNSUPPORTED","Secret references are allowed only in reviewed secret-bearing attributes. Direct script access and arbitrary attribute interpolation are unavailable.",M.valueSpan)}for(let M of O.children)if(M.kind==="element")wZ(W,M)}function e(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_MISSING_ATTRIBUTE",`<${O.name}> requires the "${M}" attribute.`,O.openTagSpan);return L}function GW(W,O){let M=[];for(let L of O.children){if(L.kind!=="element")E(W,"WOML_UNEXPECTED_CONTENT",`<${O.name}> may contain WOML elements only.`,L.span);M.push(L)}return M}function rW(W,O){if(O.children.length>0)E(W,"WOML_INVALID_STRUCTURE",`<${O.name}> cannot contain child content in the first WOML CLI profile.`,O.children[0].span)}function TF(W,O){if(O.value.length>256||!XF.test(O.value))E(W,"WOML_INVALID_ID",`Workflow ID "${O.value}" must use lowercase kebab-case.`,O.valueSpan,"Example: content-moderator");return O.value}function SO(W,O,M){if(O.value.length>256||!$9.test(O.value))E(W,"WOML_INVALID_ID",`${M==="trigger"?"Trigger":M==="branch"?"Branch":M==="choose"?"Choice":M==="switch"?"Switch":M==="fork"?"Fork":M==="parallel"?"Parallel":M==="for-each"?"For-each":M==="approval"?"Approval":"Step"} ID "${O.value}" must be a JavaScript-safe lower-camel identifier.`,O.valueSpan,"Use letters and numbers, start with a lowercase letter, and do not use hyphens.");return O.value}function GM(W,O,M){let L=O.attributes[M];if(L===void 0)return;if(L.value.trim().length===0)E(W,"WOML_EMPTY_METADATA",`Attribute "${M}" on <${O.name}> must not be empty.`,L.valueSpan);return L.value}function FF(W,O){let M=GM(W,O,"name"),L=GM(W,O,"description"),$=GM(W,O,"version");if(M===void 0&&L===void 0&&$===void 0)return;return{...M===void 0?{}:{name:M},...L===void 0?{}:{description:L},...$===void 0?{}:{version:$}}}function $1(W,O){let M=GM(W,O,"name"),L=GM(W,O,"description");if(M===void 0&&L===void 0)return;return{...M===void 0?{}:{name:M},...L===void 0?{}:{description:L}}}function EF(W,O){let M=GW(W,O),L=M.filter((U)=>U.name==="config"),$=M.filter((U)=>U.name==="lifecycle"),Y=M.filter((U)=>U.name==="triggers"),J=M.filter((U)=>U.name==="steps");if(L.length>1)E(W,"WOML_CONFIG_DUPLICATE",`<workflow> accepts at most one <config> element; found ${L.length}.`,L[1]?.openTagSpan??O.openTagSpan);if($.length>1)E(W,"WOML_LIFECYCLE_DUPLICATE",`<workflow> accepts at most one <lifecycle> container; found ${$.length}.`,$[1]?.openTagSpan??O.openTagSpan);if(Y.length>1)E(W,"WOML_TRIGGER_CONTAINER_COUNT",`<workflow> accepts at most one <triggers> container; found ${Y.length}.`,Y[1]?.openTagSpan??O.openTagSpan);if(J.length!==1)E(W,"WOML_STEPS_CONTAINER_COUNT",`<workflow> requires exactly one <steps> container; found ${J.length}.`,J[1]?.openTagSpan??O.openTagSpan);let A=Y[0],Z=L[0],G=$[0],X=J[0],Q=new Set(["config","lifecycle","triggers","steps"]),R=M.find((U)=>!Q.has(U.name));if(R!==void 0)E(W,"WOML_INVALID_STRUCTURE",`<workflow> cannot contain <${R.name}> directly.`,R.openTagSpan,"Use optional <config>, <lifecycle>, and <triggers> containers plus exactly one <steps> container, in any order.");return[Z,G,A,X]}function zZ(W,O,M){let L=/^(?:(?:[1-9][0-9]*)(?:\.[0-9]+)?|0\.[0-9]*[1-9][0-9]*)(ms|s|m|h|d)$/.exec(O.value);if(L===null)E(W,M,`Policy duration "${O.value}" must be positive and include ms, s, m, h, or d.`,O.valueSpan,"Examples: 500ms, 10s, 5m, 2h, 1d");let J=Number(O.value.slice(0,-L[1].length))*{ms:1,s:1000,m:60000,h:3600000,d:86400000}[L[1]];if(!Number.isSafeInteger(J)||J<1||J>HF)E(W,M,`Policy duration "${O.value}" must resolve to a whole number of milliseconds from 1ms through 365d.`,O.valueSpan);return J}function qF(W,O){if(O.children.length>0)E(W,"WOML_CONFIG_CHILD_NOT_ALLOWED","<config> is data-only and cannot contain text or child elements.",O.children[0].span,"Declare workflow runtime policy through <config> attributes only.");if(Object.keys(O.attributes).length===0)E(W,"WOML_CONFIG_EMPTY","<config> requires at least one runtime-policy attribute.",O.openTagSpan,"Add concurrency, timeout, rate-limit, or queue; otherwise remove <config>.");let M=O.attributes.concurrency,L;if(M!==void 0){if(!/^[1-9][0-9]*$/.test(M.value))E(W,"WOML_CONFIG_CONCURRENCY_INVALID",`Workflow concurrency "${M.value}" must be a positive integer.`,M.valueSpan);if(L=Number(M.value),!Number.isSafeInteger(L)||L>SZ)E(W,"WOML_CONFIG_CONCURRENCY_INVALID",`Workflow concurrency must be between 1 and ${SZ}.`,M.valueSpan)}let $=O.attributes.timeout,Y=$===void 0?void 0:zZ(W,$,"WOML_CONFIG_TIMEOUT_INVALID"),J=O.attributes["rate-limit"],A;if(J!==void 0){let X=J.value.indexOf("/"),Q=J.value.slice(0,X),R=J.value.slice(X+1);if(X<=0||J.value.indexOf("/",X+1)!==-1||!/^[1-9][0-9]*$/.test(Q)||R.length===0)E(W,"WOML_CONFIG_RATE_LIMIT_INVALID",`Rate limit "${J.value}" must use positive-integer/duration syntax.`,J.valueSpan,"Example: 100/1m");let U=Number(Q);if(!Number.isSafeInteger(U)||U>UZ)E(W,"WOML_CONFIG_RATE_LIMIT_INVALID",`Rate-limit count must be between 1 and ${UZ}.`,J.valueSpan);let T=new n(W.file,W.source),S=J.valueSpan.start.offset+X+1,H={name:J.name,value:R,nameSpan:J.nameSpan,valueSpan:T.span(S,J.valueSpan.end.offset),span:J.span};A={count:U,windowMs:zZ(W,H,"WOML_CONFIG_RATE_LIMIT_INVALID"),algorithm:"rolling_window"}}let Z=O.attributes.queue,G;if(Z!==void 0){if(Z.value.length>128||!zF.test(Z.value))E(W,"WOML_CONFIG_QUEUE_INVALID",`Queue name "${Z.value}" must be a lowercase dot, underscore, or kebab identifier.`,Z.valueSpan,"Examples: orders, moderation-high, agents.inbound");G={name:Z.value,discipline:"work_conserving_fifo"}}return{element:O,value:{profileVersion:1,...L===void 0?{}:{concurrency:L},...Y===void 0?{}:{timeoutMs:Y},...A===void 0?{}:{rateLimit:A},...G===void 0?{}:{queue:G}}}}function PZ(W,O,M){let L=M==="webhook"?"webhook":"event",$=M==="webhook"?"WOML_WEBHOOK":"WOML_EVENT";if(Object.keys(O.attributes).length>0){let U=Object.values(O.attributes)[0];E(W,"WOML_UNKNOWN_ATTRIBUTE",`Unknown attribute "${U.name}" on <schema>.`,U.nameSpan)}let Y=O.children.find((U)=>U.kind!=="text");if(Y!==void 0)E(W,`${$}_SCHEMA_STRUCTURE_INVALID`,"<schema> must contain inline JSON only.",Y.span);let A=O.children.filter((U)=>U.kind==="text").map((U)=>U.value).join(""),Z=O.children[0]?.span??O.openTagSpan,G;try{G=JSON.parse(A)}catch(U){let T=U instanceof SyntaxError?/position\s+(\d+)/i.exec(U.message)?.[1]:void 0,S=T===void 0?0:Number(T),H=new n(W.file,W.source),F=Math.min(Z.start.offset+S,Z.end.offset);E(W,`${$}_SCHEMA_JSON_INVALID`,"<schema> must contain valid JSON.",H.span(F,Math.min(F+1,Z.end.offset)))}if(G===null||typeof G!=="object"||Array.isArray(G))E(W,`${$}_SCHEMA_INVALID`,"<schema> must contain a JSON Schema object.",Z);let X=new qZ.default({allErrors:!0,strict:!1}),Q=!1,R;try{if(Q=X.validateSchema(G)===!0,Q)X.compile(G)}catch(U){Q=!1,R=U instanceof Error?U.message:void 0}if(!Q){let T=X.errors?.[0]?.message??R;E(W,`${$}_SCHEMA_INVALID`,`Inline ${L} JSON Schema is invalid${T===void 0?".":`: ${T}.`}`,Z)}return G}function BF(W,O){let M=SO(W,e(W,O,"id"),"trigger"),L=e(W,O,"path");if(L.value.length>2048||!QF.test(L.value)||L.value==="/_woml"||L.value.startsWith("/_woml/"))E(W,"WOML_WEBHOOK_PATH_INVALID",`Webhook path "${L.value}" must be an exact absolute route without parameters, wildcards, repeated slashes, or the reserved /_woml prefix.`,L.valueSpan);let $=O.attributes.method;if($!==void 0&&$.value!=="POST")E(W,"WOML_WEBHOOK_METHOD_UNSUPPORTED",`Webhook method "${$.value}" is not executable in Webhook HTTP v1; use POST.`,$.valueSpan);let Y=e(W,O,"auth"),J;if(Y.value==="none"){let G=O.attributes.secret;if(G!==void 0)E(W,"WOML_WEBHOOK_AUTH_INVALID",'A webhook with auth="none" must not declare a secret.',G.nameSpan);J={kind:"none"}}else if(Y.value==="bearer")J={kind:"bearer",secret:RW(W,e(W,O,"secret"))};else E(W,"WOML_WEBHOOK_AUTH_INVALID",`Webhook auth "${Y.value}" must be "bearer" or "none".`,Y.valueSpan);let A=GW(W,O);if(A.length>1||A.length===1&&A[0].name!=="schema"){let G=A.find((X)=>X.name!=="schema")??A[1];E(W,"WOML_WEBHOOK_STRUCTURE_INVALID","<webhook> may contain at most one inline <schema>.",G?.openTagSpan??O.openTagSpan)}let Z=A[0]===void 0?void 0:PZ(W,A[0],"webhook");return{kind:"webhook",id:M,path:L.value,method:"POST",authentication:J,...Z===void 0?{}:{schema:Z}}}function CF(W,O){rW(W,O);let M=SO(W,e(W,O,"id"),"trigger"),L=e(W,O,"cron");try{eA(L.value)}catch(J){let A=J instanceof nW?J.reason:"cron does not match WOML Cron v1";E(W,"WOML_SCHEDULE_CRON_INVALID",`Schedule cron is invalid: ${A}.`,L.valueSpan,"Use five numeric fields: minute hour day-of-month month day-of-week. Lists, ranges, and /steps are supported.")}let $=O.attributes.timezone?.value??"UTC";if(!WZ($))E(W,"WOML_SCHEDULE_TIMEZONE_INVALID",`Schedule timezone "${$}" is not a canonical IANA timezone identifier.`,O.attributes.timezone?.valueSpan??O.openTagSpan,"Examples: UTC, Europe/Berlin, America/New_York");let Y=O.attributes["on-missed"]?.value??"skip";if(Y!=="skip"&&Y!=="run-once")E(W,"WOML_TRIGGER_MISFIRE_INVALID",`Schedule on-missed must be "skip" or "run-once", found "${Y}".`,O.attributes["on-missed"].valueSpan);return{kind:"schedule",id:M,cron:L.value,timezone:$,onMissed:Y}}function wF(W,O){rW(W,O);let M=SO(W,e(W,O,"id"),"trigger"),L=e(W,O,"every"),$=/^([1-9][0-9]*)(ms|s|m|h|d)$/.exec(L.value);if($===null)E(W,"WOML_INTERVAL_INVALID",`Interval every="${L.value}" must be one positive whole duration using ms, s, m, h, or d.`,L.valueSpan,"Examples: 1s, 5m, 24h, 30d");let Y=Number($[1])*O1[$[2]];if(!Number.isSafeInteger(Y)||Y<O1.s||Y>O1.d*30)E(W,"WOML_INTERVAL_INVALID",`Interval every="${L.value}" must resolve to a whole duration from 1s through 30d.`,L.valueSpan);let J=O.attributes["on-missed"]?.value??"skip";if(J!=="skip"&&J!=="run-once")E(W,"WOML_TRIGGER_MISFIRE_INVALID",`Interval on-missed must be "skip" or "run-once", found "${J}".`,O.attributes["on-missed"].valueSpan);return{kind:"interval",id:M,everyMs:Y,onMissed:J}}function PF(W,O){let M=SO(W,e(W,O,"id"),"trigger"),L=e(W,O,"name"),$=O.attributes.secret,Y=$===void 0?void 0:RW(W,$);if(L.value.length>256||!RF.test(L.value))E(W,"WOML_EVENT_NAME_INVALID",`Event name "${L.value}" must start with a lowercase letter and contain at least two lowercase alphanumeric segments separated by one dot, underscore, or hyphen.`,L.valueSpan,"Examples: order.created, payment_failed, agent-response");let J=GW(W,O);if(J.length>1||J.length===1&&J[0].name!=="schema"){let Z=J.find((G)=>G.name!=="schema")??J[1];E(W,"WOML_EVENT_STRUCTURE_INVALID","<event> may contain at most one inline <schema>.",Z?.openTagSpan??O.openTagSpan)}let A=J[0]===void 0?void 0:PZ(W,J[0],"event");return{kind:"event",id:M,name:L.value,...Y===void 0?{}:{secret:Y},...A===void 0?{}:{schema:A}}}function NF(W,O){let M=GW(W,O);if(M.length===0)E(W,"WOML_TRIGGER_REQUIRED","<triggers> requires at least one executable trigger.",O.openTagSpan);if(M.length>64)E(W,"WOML_MODULE_ALIAS_LIMIT_EXCEEDED",`<imports> declares ${M.length} modules; Module profile v1 allows at most 64.`,M[64].openTagSpan);let L=M.map((Y)=>{if(Y.name==="manual")return rW(W,Y),{kind:"manual",id:SO(W,e(W,Y,"id"),"trigger")};if(Y.name==="webhook")return BF(W,Y);if(Y.name==="slack")return gF(W,Y);if(Y.name==="telegram")return hF(W,Y);if(Y.name==="discord")return lF(W,Y);if(Y.name==="whatsapp")return iF(W,Y);if(Y.name==="schedule")return CF(W,Y);if(Y.name==="interval")return wF(W,Y);if(Y.name==="event")return PF(W,Y);E(W,"WOML_TRIGGER_UNSUPPORTED",`<${Y.name}> is not an executable trigger in this release.`,Y.openTagSpan)}),$=new Set;for(let Y=0;Y<L.length;Y+=1){let J=L[Y];if($.has(J.id))E(W,"WOML_TRIGGER_ID_DUPLICATE",`Trigger ID "${J.id}" is already used in this workflow.`,e(W,M[Y],"id").valueSpan);$.add(J.id)}return L}function NZ(W,O){let M=O.children.filter((L)=>L.kind==="raw");if(O.children.some((L)=>L.kind!=="raw")||M.length>1)E(W,"WOML_INVALID_STRUCTURE","<script> must contain one raw JavaScript body and no WOML child elements.",O.children[0]?.span??O.openTagSpan);return{source:M[0]?.value??"",span:M[0]?.span??O.openTagSpan}}function _F(W,O,M=[]){let L=q8(O.source,{shadowedServices:M});if(L.issue===void 0)return L;let $=new n(W.file,W.source),Y=O.span.start.offset+L.issue.start,J=O.span.start.offset+L.issue.end;E(W,L.issue.code,L.issue.message,$.span(Y,Math.max(Y+1,J)),L.issue.hint)}function jF(W,O,M){let L=O.value.indexOf(M,16),$=O.valueSpan.start.offset+L;return new n(W.file,W.source).span($,$+M.length)}function q0(W,O,M={}){let L=/^\{\{(context\.(?:(?:payload|trigger)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|steps\.([a-z][A-Za-z0-9]*)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|item(?:\.[A-Za-z_$][A-Za-z0-9_$]*)*|iteration\.(?:index|total)))\}\}$/.exec(O.value);if(L===null)E(W,M.invalidCode??"WOML_INVALID_REFERENCE",M.invalidMessage??`Attribute "${O.name}" must contain exactly one WOML context reference.`,O.valueSpan,M.invalidHint??"Example: {{context.steps.checkContent.needsReview}}");let $=L[1].split(".").slice(1);if(M.allowIteration!==!0&&($[0]==="item"||$[0]==="iteration"))E(W,M.invalidCode??"WOML_ITERATION_REFERENCE_OUTSIDE_FOR_EACH",M.invalidMessage??`Reference "${O.value}" is available only inside a <for-each> body.`,O.valueSpan,M.invalidHint??"Use context.payload or an earlier context.steps output outside the loop.");let Y=L[2],J=Y===void 0?O.valueSpan:jF(W,O,Y);return{path:$.map((A,Z)=>Z===0&&A==="payload"?"trigger":A),...Y===void 0?{}:{structuralId:Y},span:J}}function B0(W,O,M,L){let $=SO(W,M,L);if(O.has($))E(W,"WOML_DUPLICATE_ID",`Structural ID "${$}" is duplicated across workflow steps, choices, loops, forks, parallel groups, and approvals.`,M.valueSpan);return O.add($),$}var O1={ms:1,s:1000,m:60000,h:3600000,d:86400000},IF=O1.h*24;function VZ(W,O,M){let L=/^(?:(?:[1-9][0-9]*)(?:\.[0-9]+)?|0\.[0-9]*[1-9][0-9]*)(ms|s|m|h|d)$/.exec(O.value);if(L===null)E(W,M,`Retry duration "${O.value}" must be a positive duration using ms, s, m, h, or d.`,O.valueSpan,"Examples: 500ms, 1s, 30m, 24h");let Y=Number(O.value.slice(0,-L[1].length))*O1[L[1]];if(!Number.isSafeInteger(Y)||Y<1||Y>IF)E(W,M,`Retry duration "${O.value}" must resolve to a whole number of milliseconds from 1ms through 24h.`,O.valueSpan);return Y}function yF(W,O){let M=O.attributes.retry,L=O.attributes["retry-backoff"],$=O.attributes["retry-delay"],Y=O.attributes["retry-max-delay"],J=L??$??Y;if(M===void 0){if(J!==void 0)E(W,"WOML_RETRY_BACKOFF_REQUIRES_RETRY",`Attribute "${J.name}" requires retry greater than 1 on the same <step>.`,J.nameSpan);return}if(!/^[1-9][0-9]*$/.test(M.value))E(W,"WOML_RETRY_INVALID",`Retry "${M.value}" must be an integer from 1 through 10.`,M.valueSpan);let A=Number(M.value);if(!Number.isSafeInteger(A)||A>10)E(W,"WOML_RETRY_INVALID",`Retry "${M.value}" must be an integer from 1 through 10.`,M.valueSpan);if(A===1){if(J!==void 0)E(W,"WOML_RETRY_BACKOFF_REQUIRES_RETRY",`Attribute "${J.name}" requires retry greater than 1 on the same <step>.`,J.nameSpan);return}let Z=L?.value??"exponential";if(Z!=="fixed"&&Z!=="exponential")E(W,"WOML_RETRY_BACKOFF_INVALID",`Retry backoff must be "fixed" or "exponential", found "${Z}".`,L.valueSpan);let G=$===void 0?1000:VZ(W,$,"WOML_RETRY_DELAY_INVALID");if(Z==="fixed"){if(Y!==void 0)E(W,"WOML_RETRY_MAX_DELAY_NOT_ALLOWED",'Attribute "retry-max-delay" is available only with exponential retry backoff.',Y.nameSpan);return{maxAttempts:A,backoff:{kind:"fixed",delayMs:G}}}let X=Y===void 0?Math.max(30000,G):VZ(W,Y,"WOML_RETRY_MAX_DELAY_INVALID");if(X<G)E(W,"WOML_RETRY_MAX_DELAY_INVALID",'Attribute "retry-max-delay" must be greater than or equal to "retry-delay".',Y.valueSpan);return{maxAttempts:A,backoff:{kind:"exponential",initialDelayMs:G,multiplier:2,maximumDelayMs:X}}}function DF(W,O){let M=O.attributes.timeout,L=O.attributes["on-timeout"];if(M===void 0){if(L!==void 0)E(W,"WOML_APPROVAL_TIMEOUT_INVALID","<approval> cannot declare on-timeout without a timeout.",L.nameSpan);return}let $=/^(?:(?:[1-9][0-9]*)(?:\.[0-9]+)?|0\.[0-9]*[1-9][0-9]*)(ms|s|m|h|d)$/.exec(M.value);if($===null)E(W,"WOML_APPROVAL_TIMEOUT_INVALID",`Approval timeout "${M.value}" must be a positive duration using ms, s, m, h, or d.`,M.valueSpan,"Examples: 500ms, 30m, 24h");let J=Number(M.value.slice(0,-$[1].length))*O1[$[1]];if(!Number.isSafeInteger(J)||J<1)E(W,"WOML_APPROVAL_TIMEOUT_INVALID",`Approval timeout "${M.value}" must resolve to a positive safe integer number of milliseconds.`,M.valueSpan);return J}function HZ(W,O,M,L){return GW(W,O).map(($)=>C0(W,$,M,`<${O.name}>`,L))}var kF=/^#[a-z0-9][a-z0-9_-]{0,79}$/,bF=/^[CG][A-Z0-9]{8,31}$/,fF=/^[a-z0-9][a-z0-9_-]{0,79}$/,vF=/^[CGD][A-Z0-9]{8,31}$/;function xO(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_SLACK_ATTRIBUTE_REQUIRED",`<slack> requires the "${M}" attribute.`,O.openTagSpan);return L}function _Z(W,O){let M=new n(W.file,W.source),L=[...O.value.matchAll(/\S+/g)].map(($)=>{let Y=O.valueSpan.start.offset+($.index??0);return{value:$[0],span:M.span(Y,Y+$[0].length)}});if(L.length===0)E(W,"WOML_SLACK_CHANNELS_EMPTY","<slack> channels must contain at least one channel alias or conversation ID.",O.valueSpan);for(let $ of L)if(!kF.test($.value)&&!bF.test($.value))E(W,"WOML_SLACK_CHANNEL_INVALID",`Slack destination "${$.value}" must be a lowercase #channel alias or a Slack conversation ID.`,$.span,"Examples: #approvals or C0123456789");return L}function KZ(W,O,M){let L=new n(W.file,W.source),$=[],Y=0;for(let J of O.value.split(",")){let A=J.length-J.trimStart().length,Z=J.trim(),G=O.valueSpan.start.offset+Y+A;if(Z.length===0)E(W,"WOML_SLACK_TRIGGER_LIST_INVALID",`<slack> ${M} must be a comma-separated list without empty items.`,L.span(G,G));$.push({value:Z,span:L.span(G,G+Z.length)}),Y+=J.length+1}return $}function gF(W,O){if(rW(W,O),O.attributes.message!==void 0)E(W,"WOML_SLACK_UNKNOWN_ATTRIBUTE",'Attribute "message" is valid on lifecycle notifications, not a Slack trigger.',O.attributes.message.nameSpan);let M=SO(W,e(W,O,"id"),"trigger"),L=KZ(W,e(W,O,"events"),"events"),$=[],Y=new Set;for(let X of L){if(X.value!=="app-mention"&&X.value!=="direct-message")E(W,"WOML_SLACK_TRIGGER_EVENT_INVALID",`Unsupported Slack trigger event "${X.value}".`,X.span,"Use app-mention, direct-message, or both.");if(Y.has(X.value))E(W,"WOML_SLACK_TRIGGER_EVENT_DUPLICATE",`Slack trigger event "${X.value}" is listed more than once.`,X.span);Y.add(X.value),$.push(X.value)}let J=O.attributes.channels,A=J===void 0?[]:KZ(W,J,"channels"),Z=[],G=new Set;for(let X of A){if(!fF.test(X.value)&&!vF.test(X.value))E(W,"WOML_SLACK_TRIGGER_CHANNEL_INVALID",`Slack trigger channel "${X.value}" must be a lowercase channel name or Slack conversation ID.`,X.span,"Examples: woml-testing or C0123456789");if(G.has(X.value))E(W,"WOML_SLACK_TRIGGER_CHANNEL_DUPLICATE",`Slack trigger channel "${X.value}" is listed more than once.`,X.span);G.add(X.value),Z.push(X.value)}return{kind:"slack",id:M,events:$,channels:Z,botToken:RW(W,xO(W,O,"bot-token")),appToken:RW(W,xO(W,O,"app-token"))}}var xF=/^-?[1-9][0-9]{0,19}$/;function M1(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_TELEGRAM_ATTRIBUTE_REQUIRED",`<telegram> requires the "${M}" attribute.`,O.openTagSpan);return L}function jZ(W,O,M){let L=new n(W.file,W.source),$=[],Y=0;for(let J of O.value.split(",")){let A=J.length-J.trimStart().length,Z=J.trim(),G=O.valueSpan.start.offset+Y+A;if(Z.length===0)E(W,"WOML_TELEGRAM_LIST_INVALID",`<telegram> ${M} must be a comma-separated list without empty items.`,L.span(G,G));$.push({value:Z,span:L.span(G,G+Z.length)}),Y+=J.length+1}return $}function hF(W,O){rW(W,O);for(let $ of["chats","message"]){let Y=O.attributes[$];if(Y!==void 0)E(W,"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE",`Attribute "${$}" is valid on a Telegram notification, not a trigger.`,Y.nameSpan)}let M=SO(W,e(W,O,"id"),"trigger"),L=jZ(W,M1(W,O,"events"),"events");if(L.length!==1||L[0].value!=="message"){let $=L.find((J)=>J.value!=="message"),Y=$??L[1];E(W,$===void 0?"WOML_TELEGRAM_TRIGGER_EVENT_DUPLICATE":"WOML_TELEGRAM_TRIGGER_EVENT_INVALID",$===void 0?'Telegram trigger event "message" is listed more than once.':`Unsupported Telegram trigger event "${$.value}".`,Y?.span??O.openTagSpan,'Telegram v1 supports events="message".')}return{kind:"telegram",id:M,events:["message"],botToken:RW(W,M1(W,O,"bot-token"))}}function IZ(W,O){let M=jZ(W,M1(W,O,"chats"),"chats"),L=new Set;for(let $ of M){if(!xF.test($.value))E(W,"WOML_TELEGRAM_CHAT_INVALID",`Telegram chat "${$.value}" must be a numeric Telegram chat ID.`,$.span,"Use the positive user/chat ID or negative group/channel ID returned by Telegram.");if(L.has($.value))E(W,"WOML_TELEGRAM_CHAT_DUPLICATE",`Telegram chat "${$.value}" is listed more than once.`,$.span);L.add($.value)}return M}var uF=/^[0-9]{17,20}$/;function L1(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_DISCORD_ATTRIBUTE_REQUIRED",`<discord> requires the "${M}" attribute.`,O.openTagSpan);return L}function yZ(W,O,M){let L=new n(W.file,W.source),$=[],Y=0;for(let J of O.value.split(",")){let A=J.length-J.trimStart().length,Z=J.trim(),G=O.valueSpan.start.offset+Y+A;if(Z.length===0)E(W,"WOML_DISCORD_LIST_INVALID",`<discord> ${M} must be a comma-separated list without empty items.`,L.span(G,G));$.push({value:Z,span:L.span(G,G+Z.length)}),Y+=J.length+1}return $}function Y9(W,O,M){let L=O.attributes.channels;if(L===void 0){if(M)L1(W,O,"channels");return[]}let $=yZ(W,L,"channels"),Y=new Set;for(let J of $){if(!uF.test(J.value))E(W,"WOML_DISCORD_CHANNEL_INVALID",`Discord channel "${J.value}" must be a numeric Discord channel ID containing 17 to 20 digits.`,J.span,"Enable Discord Developer Mode and copy the channel ID; channel names are not durable routing identities.");if(Y.has(J.value))E(W,"WOML_DISCORD_CHANNEL_DUPLICATE",`Discord channel "${J.value}" is listed more than once.`,J.span);Y.add(J.value)}return $}function lF(W,O){rW(W,O);let M=O.attributes.message;if(M!==void 0)E(W,"WOML_DISCORD_UNKNOWN_ATTRIBUTE",'Attribute "message" is valid on a Discord lifecycle notification, not a trigger.',M.nameSpan);let L=SO(W,e(W,O,"id"),"trigger"),$=yZ(W,L1(W,O,"events"),"events"),Y=[],J=new Set;for(let A of $){if(A.value!=="app-mention"&&A.value!=="direct-message")E(W,"WOML_DISCORD_TRIGGER_EVENT_INVALID",`Unsupported Discord trigger event "${A.value}".`,A.span,"Discord v1 supports app-mention and direct-message. Slash commands are deferred.");if(J.has(A.value))E(W,"WOML_DISCORD_TRIGGER_EVENT_DUPLICATE",`Discord trigger event "${A.value}" is listed more than once.`,A.span);J.add(A.value),Y.push(A.value)}return{kind:"discord",id:L,events:Y,channels:Y9(W,O,!1).map((A)=>A.value),botToken:RW(W,L1(W,O,"bot-token"))}}var pF=/^[1-9][0-9]{5,19}$/,mF=/^[1-9][0-9]{7,15}$/,dF=/^[a-z0-9_]+$/,cF=/^[a-z]{2,3}(?:_[A-Z]{2})?$/;function BO(W,O,M){let L=O.attributes[M];if(L===void 0)E(W,"WOML_WHATSAPP_ATTRIBUTE_REQUIRED",`<whatsapp> requires the "${M}" attribute.`,O.openTagSpan);return L}function DZ(W,O){let M=BO(W,O,"template");if(!dF.test(M.value))E(W,"WOML_WHATSAPP_TEMPLATE_INVALID",`WhatsApp template "${M.value}" must contain lowercase letters, digits, and underscores only.`,M.valueSpan,"Use the exact approved Meta template name, for example woml_approval_v1.");let L=BO(W,O,"language");if(!cF.test(L.value))E(W,"WOML_WHATSAPP_LANGUAGE_INVALID",`WhatsApp template language "${L.value}" is invalid.`,L.valueSpan,"Use a language code such as en, en_US, or pt_BR.");return{templateName:M.value,language:L.value}}function kZ(W,O){let M=BO(W,O,"recipients"),L=new n(W.file,W.source),$=[],Y=new Set,J=0;for(let A of M.value.split(",")){let Z=A.length-A.trimStart().length,G=A.trim(),X=M.valueSpan.start.offset+J+Z,Q=L.span(X,X+G.length);if(!mF.test(G))E(W,"WOML_WHATSAPP_RECIPIENT_INVALID",`WhatsApp recipient "${G}" must be an international phone number containing 8 to 16 digits without a plus sign or spaces.`,Q,'Example: recipients="15551234567".');if(Y.has(G))E(W,"WOML_WHATSAPP_RECIPIENT_DUPLICATE",`WhatsApp recipient "${G}" is listed more than once.`,Q);Y.add(G),$.push({value:G,span:Q}),J+=A.length+1}return $}function J9(W,O){let M=BO(W,O,"phone-number-id");if(!pF.test(M.value))E(W,"WOML_WHATSAPP_PHONE_NUMBER_ID_INVALID","WhatsApp phone-number-id must be the numeric Meta Phone Number ID, not the display phone number.",M.valueSpan);return M.value}function iF(W,O){rW(W,O);for(let L of["recipients","message","access-token","template","language"]){let $=O.attributes[L];if($!==void 0)E(W,"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE",`Attribute "${L}" is valid on a WhatsApp notification, not a trigger.`,$.nameSpan)}let M=BO(W,O,"events");if(M.value!=="message")E(W,"WOML_WHATSAPP_TRIGGER_EVENT_INVALID",`Unsupported WhatsApp trigger event "${M.value}".`,M.valueSpan,'WhatsApp v1 supports events="message"; delivery-status callbacks never create workflow runs.');return{kind:"whatsapp",id:SO(W,e(W,O,"id"),"trigger"),events:["message"],phoneNumberId:J9(W,O),verifyToken:RW(W,BO(W,O,"verify-token")),appSecret:RW(W,BO(W,O,"app-secret"))}}function sF(W,O,M){let L=GW(W,O);if(L.length===0)E(W,"WOML_NOTIFY_EMPTY","<notify> must contain at least one notification provider.",O.openTagSpan);let $=new Set,Y=[];return L.forEach((J,A)=>{if(J.name!=="slack"&&J.name!=="telegram"&&J.name!=="discord"&&J.name!=="whatsapp")E(W,"WOML_NOTIFY_UNSUPPORTED_PROVIDER",`<notify> supports built-in <slack>, <telegram>, <discord>, and <whatsapp> providers; found <${J.name}>.`,J.openTagSpan);rW(W,J);for(let Q of["id","events","message","verify-token","app-secret"]){let R=J.attributes[Q];if(R!==void 0)E(W,J.name==="telegram"?"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE":J.name==="discord"?"WOML_DISCORD_UNKNOWN_ATTRIBUTE":J.name==="whatsapp"?"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE":"WOML_SLACK_UNKNOWN_ATTRIBUTE",Q==="message"?'Attribute "message" is valid on a lifecycle notification, not an approval notification.':`Attribute "${Q}" is valid on a ${J.name==="telegram"?"Telegram":J.name==="discord"?"Discord":J.name==="whatsapp"?"WhatsApp":"Slack"} trigger, not a notification provider.`,R.nameSpan)}if(J.name==="telegram"){let Q=IZ(W,J),R=RW(W,M1(W,J,"bot-token"));Q.forEach((U,T)=>{let S=`telegram\x00${R.name}\x00${U.value}`;if($.has(S))E(W,"WOML_TELEGRAM_CHAT_DUPLICATE",`Telegram destination "${U.value}" is duplicated for the same credential.`,U.span);$.add(S),Y.push({deliveryId:`${M}:notify:${A}:chat:${T}`,provider:"telegram",destination:U.value,botToken:R})});return}if(J.name==="discord"){let Q=Y9(W,J,!0),R=RW(W,L1(W,J,"bot-token"));Q.forEach((U,T)=>{let S=`discord\x00${R.name}\x00${U.value}`;if($.has(S))E(W,"WOML_DISCORD_CHANNEL_DUPLICATE",`Discord destination "${U.value}" is duplicated for the same credential.`,U.span);$.add(S),Y.push({deliveryId:`${M}:notify:${A}:channel:${T}`,provider:"discord",destination:U.value,botToken:R})});return}if(J.name==="whatsapp"){let Q=kZ(W,J),R=RW(W,BO(W,J,"access-token")),U=J9(W,J),{templateName:T,language:S}=DZ(W,J);Q.forEach((H,F)=>{let K=`whatsapp\x00${R.name}\x00${U}\x00${H.value}`;if($.has(K))E(W,"WOML_WHATSAPP_RECIPIENT_DUPLICATE",`WhatsApp recipient "${H.value}" is duplicated for the same credential and phone identity.`,H.span);$.add(K),Y.push({deliveryId:`${M}:notify:${A}:recipient:${F}`,provider:"whatsapp",destination:H.value,accessToken:R,phoneNumberId:U,templateName:T,language:S})});return}let Z=_Z(W,xO(W,J,"channels")),G=RW(W,xO(W,J,"bot-token")),X=RW(W,xO(W,J,"app-token"));Z.forEach((Q,R)=>{let U=`${G.name}\x00${X.name}\x00${Q.value}`;if($.has(U))E(W,"WOML_SLACK_CHANNEL_DUPLICATE",`Slack destination "${Q.value}" is duplicated for the same credential set.`,Q.span);$.add(U),Y.push({deliveryId:`${M}:notify:${A}:channel:${R}`,provider:"slack",destination:Q.value,botToken:G,appToken:X})})}),Y}function nF(W,O,M,L){let $=B0(W,M,e(W,O,"id"),"approval"),Y=GW(W,O),J=Y.filter((R)=>R.name==="notify"),A=Y.filter((R)=>R.name==="when-approved"),Z=Y.filter((R)=>R.name==="when-rejected"),G=Y.find((R)=>R.name!=="notify"&&R.name!=="when-approved"&&R.name!=="when-rejected");if(G!==void 0)E(W,"WOML_APPROVAL_STRUCTURE_INVALID",`<approval id="${$}"> may contain optional <notify>, then <when-approved> and <when-rejected> only.`,G.openTagSpan);if(J.length>1||J.length===1&&Y[0]!==J[0])E(W,"WOML_NOTIFY_INVALID_ORDER","<notify> may appear once and must be the first child of <approval>.",J[1]?.openTagSpan??J[0]?.openTagSpan??O.openTagSpan);if(A.length!==1||Z.length!==1){let R=A[1]??Z[1];E(W,"WOML_APPROVAL_STRUCTURE_INVALID",`<approval id="${$}"> requires exactly one <when-approved> and one <when-rejected>.`,R?.openTagSpan??O.openTagSpan)}if(Y.length!==2+J.length||Y[J.length]!==A[0]||Y[J.length+1]!==Z[0])E(W,"WOML_APPROVAL_STRUCTURE_INVALID","<when-approved> must appear before <when-rejected> inside <approval>.",Y[0]?.openTagSpan??O.openTagSpan);let X=O.attributes["on-timeout"],Q=X?.value??"fail";if(Q!=="reject"&&Q!=="fail")E(W,"WOML_APPROVAL_TIMEOUT_INVALID",`Approval on-timeout must be "reject" or "fail", found "${Q}".`,X.valueSpan);return{kind:"approval",id:$,element:O,metadata:$1(W,O),timeoutMs:DF(W,O),onTimeout:Q,notifications:J.length===0?[]:sF(W,J[0],$),approvedItems:HZ(W,A[0],M,L),rejectedItems:HZ(W,Z[0],M,L)}}function bZ(W,O,M,L=[]){let $=B0(W,M,e(W,O,"id"),"step"),Y=GW(W,O);if(Y.length!==1||Y[0].name!=="script")E(W,"WOML_STEP_OPERATION_COUNT",`<step id="${$}"> must contain exactly one <script> operation.`,Y[1]?.openTagSpan??Y[0]?.openTagSpan??O.openTagSpan);let J=NZ(W,Y[0]);return{kind:"step",id:$,source:J.source,scriptSpan:J.span,scriptAnalysis:_F(W,J,L),retryPolicy:yF(W,O),metadata:$1(W,O)}}var fZ={"on-start":"run_start","on-step-start":"step_start","on-step-success":"step_success","on-step-failure":"step_failure","on-step-complete":"step_complete","on-success":"run_success","on-error":"run_failure","on-cancel":"run_cancel","on-complete":"run_complete"},O9=Object.keys(fZ);function rF(W,O,M,L,$,Y){let A=new n(W.file,W.source).span(O.valueSpan.start.offset+L,O.valueSpan.start.offset+L+M.length),Z=/^context\.(payload(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+|steps\.([a-z][A-Za-z0-9]*)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+)$/.exec(M);if(Z!==null){if(Z[2]!==void 0&&!Y.has(Z[2]))E(W,"WOML_LIFECYCLE_STEP_UNKNOWN",`Lifecycle template references unknown executable step "${Z[2]}".`,A);return{kind:"contextReference",path:Z[1].split(".").map((U,T)=>T===0&&U==="payload"?"trigger":U)}}let G=/^lifecycle\.(event|workflow\.(?:id|outcome)|step\.(?:id|outcome|attempts)|failure\.(?:code|message))$/.exec(M);if(G===null)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Unsupported lifecycle template reference "${M}".`,A,"Use a scalar context.payload, context.steps, or reviewed lifecycle field.");let X=G[1].split("."),Q=$.startsWith("step_"),R=$==="step_success"||$==="step_failure"||$==="step_complete"||$==="run_success"||$==="run_failure"||$==="run_cancel"||$==="run_complete";if(X[0]==="step"&&!Q)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Reference "${M}" is unavailable for ${$}.`,A);if(X.at(-1)==="outcome"&&!R)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Reference "${M}" is unavailable before an outcome is decided.`,A);if(X[0]==="failure"&&$!=="step_failure"&&$!=="run_failure")E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID",`Reference "${M}" is available only in failure hooks.`,A);return{kind:"lifecycleReference",path:X}}function aF(W,O,M,L){if(O.value.length===0||O.value.length>4096)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle notification messages must contain 1 through 4096 characters.",O.valueSpan);let $=[],Y=0,J=0;for(let Z of O.value.matchAll(/\{\{([^{}]+)\}\}/g)){let G=Z.index??0,X=O.value.slice(Y,G);if(X.includes("{{")||X.includes("}}"))E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle message contains an unmatched WOML template delimiter.",O.valueSpan);if(X.length>0)$.push({kind:"text",text:X});let Q=Z[1].trim(),R=G+Z[0].indexOf(Q);$.push(rF(W,O,Q,R,M,L)),J+=1,Y=G+Z[0].length}let A=O.value.slice(Y);if(A.includes("{{")||A.includes("}}"))E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle message contains an unmatched WOML template delimiter.",O.valueSpan);if(A.length>0)$.push({kind:"text",text:A});if(J>32)E(W,"WOML_LIFECYCLE_TEMPLATE_INVALID","Lifecycle messages may contain at most 32 placeholders.",O.valueSpan);return{kind:"template",parts:$}}function oF(W,O,M,L,$,Y){let J=GW(W,O);if(J.length===0)E(W,"WOML_LIFECYCLE_ACTION_REQUIRED","<notify> must contain at least one notification provider.",O.openTagSpan);let A=new Set,Z=[];return J.forEach((G,X)=>{if(G.name!=="slack"&&G.name!=="telegram"&&G.name!=="discord"&&G.name!=="whatsapp")E(W,"WOML_NOTIFY_UNSUPPORTED_PROVIDER",`<notify> supports built-in <slack>, <telegram>, <discord>, and <whatsapp> providers; found <${G.name}>.`,G.openTagSpan);rW(W,G);for(let S of["id","events","verify-token","app-secret"]){let H=G.attributes[S];if(H!==void 0)E(W,G.name==="telegram"?"WOML_TELEGRAM_UNKNOWN_ATTRIBUTE":G.name==="discord"?"WOML_DISCORD_UNKNOWN_ATTRIBUTE":G.name==="whatsapp"?"WOML_WHATSAPP_UNKNOWN_ATTRIBUTE":"WOML_SLACK_UNKNOWN_ATTRIBUTE",`Attribute "${S}" is valid on a ${G.name==="telegram"?"Telegram":G.name==="discord"?"Discord":G.name==="whatsapp"?"WhatsApp":"Slack"} trigger, not a lifecycle notification.`,H.nameSpan)}let Q=aF(W,G.name==="telegram"?M1(W,G,"message"):G.name==="discord"?L1(W,G,"message"):G.name==="whatsapp"?BO(W,G,"message"):xO(W,G,"message"),M,Y);if(G.name==="telegram"){let S=IZ(W,G),H=RW(W,M1(W,G,"bot-token"));S.forEach((F,K)=>{let w=`telegram\x00${H.name}\x00${F.value}`;if(A.has(w))E(W,"WOML_TELEGRAM_CHAT_DUPLICATE",`Telegram destination "${F.value}" is duplicated for the same credential.`,F.span);A.add(w),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${X}:chat:${K}`,provider:"telegram",destination:F.value,botToken:H,message:Q})});return}if(G.name==="discord"){let S=Y9(W,G,!0),H=RW(W,L1(W,G,"bot-token"));S.forEach((F,K)=>{let w=`discord\x00${H.name}\x00${F.value}`;if(A.has(w))E(W,"WOML_DISCORD_CHANNEL_DUPLICATE",`Discord destination "${F.value}" is duplicated for the same credential.`,F.span);A.add(w),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${X}:channel:${K}`,provider:"discord",destination:F.value,botToken:H,message:Q})});return}if(G.name==="whatsapp"){let S=kZ(W,G),H=RW(W,BO(W,G,"access-token")),F=J9(W,G),{templateName:K,language:w}=DZ(W,G);S.forEach((P,B)=>{let q=`whatsapp\x00${H.name}\x00${F}\x00${P.value}`;if(A.has(q))E(W,"WOML_WHATSAPP_RECIPIENT_DUPLICATE",`WhatsApp recipient "${P.value}" is duplicated for the same credential and phone identity.`,P.span);A.add(q),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${X}:recipient:${B}`,provider:"whatsapp",destination:P.value,accessToken:H,phoneNumberId:F,templateName:K,language:w,message:Q})});return}let R=_Z(W,xO(W,G,"channels")),U=RW(W,xO(W,G,"bot-token")),T=RW(W,xO(W,G,"app-token"));R.forEach((S,H)=>{let F=`${U.name}\x00${T.name}\x00${S.value}`;if(A.has(F))E(W,"WOML_SLACK_CHANNEL_DUPLICATE",`Slack destination "${S.value}" is duplicated for the same credential set.`,S.span);A.add(F),Z.push({deliveryId:`lifecycle:${L}:action:${$}:provider:${X}:channel:${H}`,provider:"slack",destination:S.value,botToken:U,appToken:T,message:Q})})}),{kind:"notify",deliveries:Z}}function tF(W,O,M,L=[]){let $=GW(W,O);if($.length===0)E(W,"WOML_LIFECYCLE_ACTION_REQUIRED","<lifecycle> must contain at least one lifecycle hook.",O.openTagSpan);let Y=gO(M.items),J=new Set(Y.map((X)=>X.id)),A=new Set;for(let X of $){if(O9.indexOf(X.name)===-1)E(W,"WOML_LIFECYCLE_ACTION_INVALID",`<lifecycle> cannot contain <${X.name}>.`,X.openTagSpan);if(A.has(X.name))E(W,"WOML_LIFECYCLE_DUPLICATE",`<${X.name}> may appear only once in <lifecycle>.`,X.openTagSpan);A.add(X.name)}return{hooks:[...$].sort((X,Q)=>O9.indexOf(X.name)-O9.indexOf(Q.name)).map((X,Q)=>{let R=fZ[X.name],U=X.attributes.steps,T=R.startsWith("step_"),S;if(U!==void 0){if(!T)E(W,"WOML_LIFECYCLE_STEP_FILTER_INVALID",'Attribute "steps" is valid only on step lifecycle hooks.',U.nameSpan);let K=U.value.trim().split(/\s+/).filter(Boolean);if(K.length===0||new Set(K).size!==K.length)E(W,"WOML_LIFECYCLE_STEP_FILTER_INVALID","Lifecycle step filters must be a non-empty list of unique step IDs.",U.valueSpan);for(let w of K){if(!$9.test(w))E(W,"WOML_LIFECYCLE_STEP_FILTER_INVALID",`Lifecycle step filter "${w}" is not a valid step ID.`,U.valueSpan);if(!J.has(w))E(W,"WOML_LIFECYCLE_STEP_UNKNOWN",`Lifecycle step filter names unknown executable step "${w}".`,U.valueSpan)}S=K}let H=GW(W,X);if(H.length===0)E(W,"WOML_LIFECYCLE_ACTION_REQUIRED",`<${X.name}> requires at least one <script> or <notify> action.`,X.openTagSpan);let F=H.map((K,w)=>{if(K.name==="script"){let P=NZ(W,K),B=HL(P.source,{shadowedServices:L});if(B.issue!==void 0){let q=new n(W.file,W.source),N=P.span.start.offset+B.issue.start;E(W,B.issue.code,B.issue.message,q.span(N,Math.max(N+1,P.span.start.offset+B.issue.end)),B.issue.hint)}return{kind:"script",source:P.source,scriptSpan:P.span,scriptAnalysis:B}}if(K.name==="notify")return oF(W,K,R,Q,w,J);E(W,"WOML_LIFECYCLE_ACTION_INVALID",`<${X.name}> supports <script> and <notify> actions only.`,K.openTagSpan)});return{event:R,...S===void 0?{}:{stepIds:S},actions:F}})}}function E0(W,O=new Map){for(let M of W){if(M.kind==="step"){O.set(M.id,M.scriptAnalysis);continue}if(M.kind==="parallel"){for(let L of M.children)O.set(L.id,L.scriptAnalysis);continue}if(M.kind==="forEach"){E0(M.items,O);continue}if(M.kind==="branch"){for(let L of M.arms)E0(L.items,O);continue}if(M.kind==="controlChoice"||M.kind==="switch"){for(let L of M.arms)E0(L.items,O);continue}if(M.kind==="fork"){for(let L of M.branches)E0(L.items,O);continue}E0(M.approvedItems,O),E0(M.rejectedItems,O)}return O}var eF=new Set(["http","db","storage","cache","events","workflows","state","telegram","discord","whatsapp"]);function gO(W,O=[]){for(let M of W)if(M.kind==="step")O.push(M);else if(M.kind==="parallel")O.push(...M.children);else if(M.kind==="forEach")gO(M.items,O);else if(M.kind==="branch")for(let L of M.arms)gO(L.items,O);else if(M.kind==="controlChoice"||M.kind==="switch")for(let L of M.arms)gO(L.items,O);else if(M.kind==="fork")for(let L of M.branches)gO(L.items,O);else gO(M.approvedItems,O),gO(M.rejectedItems,O);return O}function W1(W,O=[]){for(let M of W)if(M.kind==="approval")O.push(...M.notifications),W1(M.approvedItems,O),W1(M.rejectedItems,O);else if(M.kind==="forEach")W1(M.items,O);else if(M.kind==="branch"||M.kind==="controlChoice"||M.kind==="switch")for(let L of M.arms)W1(L.items,O);else if(M.kind==="fork")for(let L of M.branches)W1(L.items,O);return O}function WE(W){let O=XM(W),M=O.lifecycle?.hooks.flatMap((Y)=>Y.actions.flatMap((J)=>J.kind==="script"?[J.scriptAnalysis]:[]))??[],L=[...new Set([...gO(O.flow.items).map((Y)=>Y.scriptAnalysis),...M].flatMap((Y)=>Y.requiredServices))].sort(),$=O.modules.map((Y)=>Y.name);return{referencedServices:L,referencedModules:L.filter((Y)=>$.includes(Y)),unusedModules:$.filter((Y)=>!L.includes(Y))}}var OE=["context","attempt","services","secrets"],ME=["context","lifecycle","attempt","services","secrets"];function kL(W,O){return W.map((M)=>{if(M.handler!=="runtime.script")return M;let L={bindingVersion:1,bindings:OE,requiredSecrets:O.get(M.id)?.requiredSecrets??[]};return{...M,scriptRuntime:L}})}function LE(W){return{profileVersion:1,hooks:W.hooks.map((O)=>{let M=`lifecycle:${O.event}`,L=O.actions.map((Y,J)=>{let A=`${M}:action:${J}`;if(Y.kind==="script"){let Z={bindingVersion:2,bindings:ME,requiredSecrets:Y.scriptAnalysis.requiredSecrets};return{actionId:A,handler:"runtime.lifecycle-script",inputs:{kind:"object",fields:{source:{kind:"literal",value:Y.source}}},scriptRuntime:Z}}return{actionId:A,handler:"notification.informational",inputs:{kind:"object",fields:{deliveries:{kind:"array",items:Y.deliveries.map((Z)=>({kind:"object",fields:{deliveryId:{kind:"literal",value:Z.deliveryId},provider:{kind:"literal",value:Z.provider},destination:{kind:"literal",value:Z.destination},credentials:vZ(Z),...Z.provider==="whatsapp"?{templateName:{kind:"literal",value:Z.templateName},language:{kind:"literal",value:Z.language}}:{},message:Z.message}}))}}}}});return{hookId:M,event:O.event,...O.stepIds===void 0?{}:{stepIds:O.stepIds},actions:L}})}}function vZ(W){return W.provider==="slack"?{kind:"object",fields:{botToken:W.botToken,appToken:W.appToken}}:W.provider==="whatsapp"?{kind:"object",fields:{accessToken:W.accessToken,phoneNumberId:{kind:"literal",value:W.phoneNumberId}}}:{kind:"object",fields:{botToken:W.botToken}}}function $E(W,O,M,L,$){let Y=L==="choose"?"WOML_CHOOSE":"WOML_BRANCH",J=O.name==="when"?q0(W,e(W,O,"test"),{allowIteration:$.insideForEach}):void 0,A=GW(W,O),Z=A.filter((U)=>U.name==="result");if(Z.length!==1)E(W,`${Y}_RESULT_REQUIRED`,`<${O.name}> must contain exactly one <result>.`,Z[1]?.openTagSpan??O.openTagSpan);let G=Z[0];if(A.at(-1)!==G)E(W,`${Y}_RESULT_ORDER`,`<result> must be the final child of its <${L}> arm.`,G.openTagSpan);rW(W,G);let X=A.slice(0,-1);if(X.length===0)E(W,"WOML_INVALID_STRUCTURE",`<${O.name}> must contain at least one step item before <result>.`,O.openTagSpan);let Q=X.map((U)=>C0(W,U,M,`<${O.name}>`,$)),R=q0(W,e(W,G,"value"),{allowIteration:$.insideForEach});if(O.name==="when")return{kind:"when",element:O,test:J,items:Q,result:R};return{kind:"otherwise",element:O,items:Q,result:R}}function TZ(W,O,M,L){let $=O.name,Y=$==="choose"?"WOML_CHOOSE":"WOML_BRANCH",J=B0(W,M,e(W,O,"id"),$),A=$1(W,O),Z=GW(W,O);if(Z.filter((R)=>R.name==="when").length===0)E(W,`${Y}_WHEN_REQUIRED`,`<${$} id="${J}"> requires at least one <when>.`,O.openTagSpan);let X=Z.flatMap((R,U)=>R.name==="otherwise"?[U]:[]);if(X.length===0)E(W,`${Y}_OTHERWISE_REQUIRED`,`<${$} id="${J}"> requires exactly one final <otherwise>.`,O.openTagSpan);if(X.length>1)E(W,`${Y}_OTHERWISE_ORDER`,`<otherwise> may appear exactly once and must be the final <${$}> case.`,Z[X[1]].openTagSpan);let Q=X[0];if(Q!==Z.length-1)E(W,`${Y}_OTHERWISE_ORDER`,`<otherwise> must be the final child of <${$}>.`,Z[Q].openTagSpan);for(let R=0;R<Q;R+=1)if(Z[R].name!=="when")E(W,"WOML_INVALID_STRUCTURE",`<${$}> cannot contain <${Z[R].name}> outside a <when> or <otherwise> arm.`,Z[R].openTagSpan);return{kind:"branch",sourceElementName:$,id:J,element:O,metadata:A,arms:Z.map((R)=>$E(W,R,M,$,L))}}function YE(W,O,M,L){let $=O.name==="when"?q0(W,e(W,O,"test"),{allowIteration:L.insideForEach}):void 0,Y=GW(W,O),J=Y.find((Z)=>Z.name==="result");if(J!==void 0)E(W,"WOML_CHOOSE_RESULT_REQUIRES_ID","A control-only <choose> must not contain <result>; add an id to the choice to publish a merged result.",J.openTagSpan,'Either remove every <result>, or add id="..." and end every arm with exactly one <result>.');if(Y.length===0)E(W,"WOML_CHOOSE_ARM_EMPTY",`<${O.name}> in a control-only <choose> must contain at least one flow item.`,O.openTagSpan);let A=Y.map((Z)=>C0(W,Z,M,`<${O.name}>`,L));return O.name==="when"?{kind:"when",element:O,test:$,items:A}:{kind:"otherwise",element:O,items:A}}function JE(W,O,M,L){let $=O.attributes.name??O.attributes.description;if($!==void 0)E(W,"WOML_CHOOSE_METADATA_REQUIRES_ID",`Attribute "${$.name}" is available only on a result-producing <choose id="...">.`,$.nameSpan,"Remove the display metadata or add an id and one final <result> to every arm.");let Y=GW(W,O);if(Y.filter((G)=>G.name==="when").length===0)E(W,"WOML_CHOOSE_WHEN_REQUIRED","<choose> requires at least one <when>.",O.openTagSpan);let A=Y.flatMap((G,X)=>G.name==="otherwise"?[X]:[]);if(A.length===0)E(W,"WOML_CHOOSE_OTHERWISE_REQUIRED","<choose> requires exactly one final <otherwise>.",O.openTagSpan);if(A.length>1)E(W,"WOML_CHOOSE_OTHERWISE_ORDER","<otherwise> may appear exactly once and must be the final <choose> case.",Y[A[1]].openTagSpan);let Z=A[0];if(Z!==Y.length-1)E(W,"WOML_CHOOSE_OTHERWISE_ORDER","<otherwise> must be the final child of <choose>.",Y[Z].openTagSpan);for(let G=0;G<Z;G+=1)if(Y[G].name!=="when")E(W,"WOML_INVALID_STRUCTURE",`<choose> cannot contain <${Y[G].name}> outside a <when> or <otherwise> arm.`,Y[G].openTagSpan);return{kind:"controlChoice",element:O,arms:Y.map((G)=>YE(W,G,M,L))}}function AE(W,O,M,L,$){let Y=GW(W,O),J=Y.filter((X)=>X.name==="result"),A,Z=Y;if($){if(J.length!==1)E(W,"WOML_SWITCH_RESULT_REQUIRED",`<${O.name}> must contain exactly one final <result> because its <switch> has an id.`,J[1]?.openTagSpan??O.openTagSpan);if(Y.at(-1)!==J[0])E(W,"WOML_SWITCH_RESULT_ORDER",`<result> must be the final child of <${O.name}>.`,J[0].openTagSpan);rW(W,J[0]),A=q0(W,e(W,J[0],"value"),{allowIteration:L.insideForEach}),Z=Y.slice(0,-1)}else if(J.length>0)E(W,"WOML_SWITCH_RESULT_REQUIRES_ID","A control-only <switch> cannot contain <result>; add an id to publish one merged result.",J[0].openTagSpan);if(Z.length===0)E(W,"WOML_SWITCH_ARM_EMPTY",`<${O.name}> must contain at least one flow item${$?" before <result>":""}.`,O.openTagSpan);let G=Z.map((X)=>C0(W,X,M,`<${O.name}>`,L));if(O.name==="case"){let X=e(W,O,"value");if(X.value.length===0)E(W,"WOML_SWITCH_CASE_VALUE_EMPTY",'<case value="..."> requires a non-empty string.',X.valueSpan);return{kind:"case",element:O,value:X.value,items:G,...A===void 0?{}:{result:A}}}return{kind:"default",element:O,items:G,...A===void 0?{}:{result:A}}}function ZE(W,O,M,L){let $=O.attributes.id,Y=$===void 0?void 0:B0(W,M,$,"switch"),J=O.attributes.name??O.attributes.description;if(Y===void 0&&J!==void 0)E(W,"WOML_SWITCH_METADATA_REQUIRES_ID",`Attribute "${J.name}" is available only on a result-producing <switch id="...">.`,J.nameSpan);let A=q0(W,e(W,O,"value"),{allowIteration:L.insideForEach}),Z=GW(W,O);if(Z.filter((R)=>R.name==="case").length===0)E(W,"WOML_SWITCH_CASE_REQUIRED","<switch> requires at least one <case>.",O.openTagSpan);let X=Z.flatMap((R,U)=>R.name==="default"?[U]:[]);if(X.length!==1||X[0]!==Z.length-1)E(W,"WOML_SWITCH_DEFAULT_ORDER","<switch> requires exactly one final <default>.",Z[X[1]??X[0]??0]?.openTagSpan??O.openTagSpan);let Q=new Set;for(let R=0;R<Z.length-1;R+=1){let U=Z[R];if(U.name!=="case")E(W,"WOML_SWITCH_STRUCTURE_INVALID",`<switch> accepts <case> children followed by one <default>; found <${U.name}>.`,U.openTagSpan);let T=e(W,U,"value");if(Q.has(T.value))E(W,"WOML_SWITCH_CASE_DUPLICATE",`Switch case value "${T.value}" is declared more than once.`,T.valueSpan);Q.add(T.value)}return{kind:"switch",...Y===void 0?{}:{id:Y},element:O,...Y===void 0?{}:{metadata:$1(W,O)},selector:A,arms:Z.map((R)=>AE(W,R,M,L,Y!==void 0))}}function GE(W,O){let M=new n(W.file,W.source),L=[...O.value.matchAll(/[^\t\n\r ]+/g)].map(($)=>{let Y=O.valueSpan.start.offset+($.index??0);return{value:$[0],span:M.span(Y,Y+$[0].length)}});if(L.length===0)E(W,"WOML_FORK_JOIN_INVALID",'Fork join must be "all", "none", or one or more direct branch IDs.',O.valueSpan);return L}function XE(W,O,M,L){let $=B0(W,M,e(W,O,"id"),"fork"),Y=GW(W,O);if(Y.length===0)E(W,"WOML_FORK_EMPTY",`<fork id="${$}"> must contain at least one direct <branch>.`,O.openTagSpan);let J=Y.find((U)=>U.name!=="branch");if(J!==void 0)E(W,"WOML_FORK_CHILD_INVALID",`<fork id="${$}"> accepts direct <branch> children only; found <${J.name}>.`,J.openTagSpan);let A=new Set,Z={...L,insideForkBranch:!0},G=Y.map((U)=>{for(let F of Object.values(U.attributes))if(F.name!=="id")E(W,"WOML_FORK_BRANCH_ATTRIBUTE_UNSUPPORTED",`Fork branch <branch> accepts only "id"; found "${F.name}".`,F.nameSpan);let T=e(W,U,"id"),S=SO(W,T,"branch");if(S==="all"||S==="none")E(W,"WOML_FORK_BRANCH_ID_RESERVED",`Fork branch ID "${S}" is reserved by the join grammar.`,T.valueSpan,"Choose a descriptive branch ID such as instagram or analytics.");if(A.has(S))E(W,"WOML_FORK_BRANCH_ID_DUPLICATE",`Fork branch ID "${S}" is duplicated inside <fork id="${$}">.`,T.valueSpan);A.add(S);let H=GW(W,U);if(H.length===0)E(W,"WOML_FORK_BRANCH_EMPTY",`<branch id="${S}"> must contain at least one flow item.`,U.openTagSpan);return{id:S,element:U,items:H.map((F)=>C0(W,F,M,`<branch id="${S}">`,Z))}}),X=O.attributes.join;if(X===void 0)return{kind:"fork",id:$,element:O,branches:G,joinedBranchIds:G.map((U)=>U.id)};let Q=GE(W,X);if(Q.length===1&&Q[0].value==="all")return{kind:"fork",id:$,element:O,branches:G,joinedBranchIds:G.map((U)=>U.id)};if(Q.length===1&&Q[0].value==="none")return{kind:"fork",id:$,element:O,branches:G,joinedBranchIds:[]};let R=new Set;for(let U of Q){if(U.value==="all"||U.value==="none")E(W,"WOML_FORK_JOIN_INVALID",`Reserved join value "${U.value}" cannot be mixed with branch IDs.`,U.span);if(!$9.test(U.value))E(W,"WOML_FORK_JOIN_INVALID",`Fork join item "${U.value}" must be a JavaScript-safe branch ID.`,U.span);if(!A.has(U.value))E(W,"WOML_FORK_JOIN_UNKNOWN_BRANCH",`Fork join names unknown direct branch "${U.value}".`,U.span);if(R.has(U.value))E(W,"WOML_FORK_JOIN_DUPLICATE",`Fork join lists branch "${U.value}" more than once.`,U.span);R.add(U.value)}return{kind:"fork",id:$,element:O,branches:G,joinedBranchIds:G.filter((U)=>R.has(U.id)).map((U)=>U.id)}}function QE(W,O,M,L){let $=B0(W,M,e(W,O,"id"),"parallel"),Y=$1(W,O),J=GW(W,O);if(J.length===0)E(W,"WOML_PARALLEL_EMPTY",`<parallel id="${$}"> must contain at least one direct <step> child.`,O.openTagSpan);let A=J.find((U)=>U.name!=="step");if(A!==void 0){if(A.name==="approval")E(W,"WOML_APPROVAL_PLACEMENT_INVALID",`<approval> cannot be a direct child of <parallel id="${$}"> in this profile.`,A.openTagSpan,"Place the approval before or after the parallel group, or inside a selected branch arm.");E(W,"WOML_PARALLEL_CHILD_UNSUPPORTED",`<parallel id="${$}"> accepts direct <step> children only in this profile; found <${A.name}>.`,A.openTagSpan,"Move branching around the parallel group, or wait for a future explicit lane/sequence construct.")}let Z=J.map((U)=>bZ(W,U,M,L.shadowedServices)),G=O.attributes.concurrency,X=Z.length;if(G!==void 0){if(!/^[1-9][0-9]*$/.test(G.value))E(W,"WOML_PARALLEL_INVALID_CONCURRENCY",`Parallel concurrency "${G.value}" must be a positive integer.`,G.valueSpan);if(X=Number(G.value),!Number.isSafeInteger(X)||X>Z.length)E(W,"WOML_PARALLEL_INVALID_CONCURRENCY",`Parallel concurrency must not exceed its ${Z.length} direct child${Z.length===1?"":"ren"}.`,G.valueSpan)}let Q=O.attributes["on-error"],R=Q?.value??"fail-fast";if(R!=="fail-fast"&&R!=="wait-all")E(W,"WOML_PARALLEL_INVALID_POLICY",`Parallel on-error must be "fail-fast" or "wait-all", found "${R}".`,Q.valueSpan);return{kind:"parallel",id:$,element:O,metadata:Y,concurrency:X,onError:R,children:Z}}function RE(W,O,M,L){let $=O.attributes.id;if($===void 0)E(W,"WOML_FOR_EACH_ID_REQUIRED",'<for-each> requires the "id" attribute.',O.openTagSpan,'Example: <for-each id="processItems" items="{{context.payload.items}}">');let Y=O.attributes.items;if(Y===void 0)E(W,"WOML_FOR_EACH_ITEMS_REQUIRED",'<for-each> requires the "items" attribute.',O.openTagSpan,'Reference an array, for example items="{{context.steps.load.items}}".');let J=B0(W,M,$,"for-each"),A=q0(W,Y,{invalidCode:"WOML_FOR_EACH_ITEMS_INVALID",invalidMessage:'Attribute "items" on <for-each> must contain exactly one context.payload or context.steps reference.',invalidHint:'Example: items="{{context.steps.load.items}}"'});if(/^\{\{context\.trigger(?:\.|\}\})/.test(Y.value))E(W,"WOML_FOR_EACH_ITEMS_INVALID",'Attribute "items" on <for-each> uses the retired context.trigger spelling.',Y.valueSpan,'Use context.payload for trigger data, for example items="{{context.payload.items}}".');let Z=O.attributes.concurrency,G=1;if(Z!==void 0){if(!/^[1-9][0-9]*$/.test(Z.value))E(W,"WOML_FOR_EACH_CONCURRENCY_INVALID",`For-each concurrency "${Z.value}" must be an integer from 1 through 64.`,Z.valueSpan);if(G=Number(Z.value),!Number.isSafeInteger(G)||G>64)E(W,"WOML_FOR_EACH_CONCURRENCY_INVALID","For-each concurrency must be an integer from 1 through 64.",Z.valueSpan)}let X=GW(W,O),Q=X.filter((F)=>F.name==="result");if(Q.length>1)E(W,"WOML_FOR_EACH_RESULT_INVALID","<for-each> accepts at most one <result>.",Q[1].openTagSpan);let R=Q[0];if(R!==void 0&&X.at(-1)!==R)E(W,"WOML_FOR_EACH_RESULT_ORDER","<result> must be the final child of <for-each>.",R.openTagSpan);if(R!==void 0){if(rW(W,R),R.attributes.value===void 0)E(W,"WOML_FOR_EACH_RESULT_INVALID",'<result> inside <for-each> requires the "value" attribute.',R.openTagSpan,'Example: <result value="{{context.steps.buildItemResult}}" />')}let U=R===void 0?X:X.slice(0,-1);if(U.length===0)E(W,"WOML_FOR_EACH_EMPTY",`<for-each id="${J}"> must contain at least one flow item.`,O.openTagSpan);let T={...L,insideForEach:!0},S=U.map((F)=>C0(W,F,M,`<for-each id="${J}">`,T)),H=R===void 0?void 0:q0(W,e(W,R,"value"),{allowIteration:!0,invalidCode:"WOML_FOR_EACH_RESULT_INVALID",invalidMessage:"<for-each> result must contain exactly one iteration-visible context reference.",invalidHint:'Example: <result value="{{context.steps.buildItemResult}}" />'});return{kind:"forEach",id:J,element:O,metadata:$1(W,O),itemsReference:A,concurrency:G,items:S,...H===void 0?{}:{result:H}}}function C0(W,O,M,L,$){if(O.name==="step")return bZ(W,O,M,$.shadowedServices);if(O.name==="branch"){if($.insideForkBranch)E(W,"WOML_FORK_BRANCH_CHILD_INVALID","A fork-owned <branch> supports <step>, <choose>, <switch>, <parallel>, and <approval> flow items; nested conditional flow uses <choose> or <switch>.",O.openTagSpan);if(!O.children.some((J)=>J.kind==="element"&&(J.name==="when"||J.name==="otherwise")))E(W,"WOML_FORK_BRANCH_PLACEMENT_INVALID","A route <branch> is valid only as a direct child of <fork>. Conditional flow uses <choose>.",O.openTagSpan,"Wrap route branches in <fork>, or rename an intended conditional container to <choose>.");return TZ(W,O,M,$)}if(O.name==="choose")return O.attributes.id===void 0?JE(W,O,M,$):TZ(W,O,M,$);if(O.name==="switch")return ZE(W,O,M,$);if(O.name==="case"||O.name==="default")E(W,"WOML_SWITCH_ARM_PLACEMENT_INVALID",`<${O.name}> is valid only as a direct child of <switch>.`,O.openTagSpan);if(O.name==="fork"){if($.insideForEach)E(W,"WOML_FOR_EACH_NESTING_UNSUPPORTED","<fork> is not supported inside <for-each> in the first iteration profile.",O.openTagSpan,"Move the fork outside the loop; loop-owned fork settlement is reserved for a later reviewed profile.");if($.insideForkBranch)E(W,"WOML_FORK_NESTED_UNSUPPORTED","A <fork> cannot appear anywhere inside a fork-owned branch in Fork v1.",O.openTagSpan,"Move the nested fan-out outside the branch or use <parallel> for direct concurrent steps.");return XE(W,O,M,$)}if(O.name==="parallel")return QE(W,O,M,$);if(O.name==="for-each"){if($.insideForEach)E(W,"WOML_FOR_EACH_NESTING_UNSUPPORTED","Nested <for-each> is not supported in the first iteration profile.",O.openTagSpan,"Flatten the input before this loop or move the nested iteration into a later workflow.");return RE(W,O,M,$)}if(O.name==="approval"){if($.insideForEach)E(W,"WOML_FOR_EACH_NESTING_UNSUPPORTED","<approval> is not supported inside <for-each> in the first iteration profile.",O.openTagSpan,"Collect the iteration results and request approval after the loop.");return nF(W,O,M,$)}if(O.name==="when-approved"||O.name==="when-rejected")E(W,"WOML_APPROVAL_PLACEMENT_INVALID",`<${O.name}> is valid only as a direct child of <approval>.`,O.openTagSpan);if(O.name==="notify"||O.name==="slack"||O.name==="telegram"||O.name==="discord")E(W,"WOML_NOTIFY_INVALID_ORDER",O.name==="notify"?"<notify> is valid only as the first direct child of <approval>.":`<${O.name}> is valid only as a direct child of <notify>.`,O.openTagSpan);E(W,"WOML_INVALID_STRUCTURE",`${L} cannot contain <${O.name}> as a flow item.`,O.openTagSpan)}function e0(W,O,M,L,$){let Y=O.structuralId;if(Y===void 0)return;if(!M.has(Y))HW(W,"WOML_UNKNOWN_REFERENCE",`Reference names unknown structural ID "${Y}".`,O.span);if(!L.has(Y)){if($.has(Y))HW(W,"WOML_FORK_REFERENCE_NOT_VISIBLE",`Output "${Y}" belongs to an unjoined or sibling fork branch and is not visible on this route.`,O.span,"Reference an output from the current branch, or include the producing branch in the fork join before reading it on the continuation route.");HW(W,"WOML_REFERENCE_NOT_DOMINATING",`Output "${Y}" is not guaranteed to be available at this reference.`,O.span)}}function Y0(W,O=new Set){for(let M of W)if(M.kind==="step")O.add(M.id);else if(M.kind==="parallel")for(let L of M.children)O.add(L.id);else if(M.kind==="forEach")O.add(M.id),Y0(M.items,O);else if(M.kind==="branch"){O.add(M.id);for(let L of M.arms)Y0(L.items,O)}else if(M.kind==="controlChoice"||M.kind==="switch"){if(M.kind==="switch"&&M.id!==void 0)O.add(M.id);for(let L of M.arms)Y0(L.items,O)}else if(M.kind==="approval")O.add(M.id),Y0(M.approvedItems,O),Y0(M.rejectedItems,O);else for(let L of M.branches)Y0(L.items,O);return O}function $0(W,O,M,L=new Set,$=new Set){let Y=new Set(L),J=new Set($);for(let A of O){if(A.kind==="step"){Y.add(A.id);continue}if(A.kind==="parallel"){for(let Z of A.children)Y.add(Z.id);continue}if(A.kind==="forEach"){let Z=A.itemsReference.structuralId;if(Z!==void 0){if(!M.has(Z))HW(W,"WOML_UNKNOWN_REFERENCE",`For-each items reference names unknown structural ID "${Z}".`,A.itemsReference.span);if(!Y.has(Z))HW(W,"WOML_FOR_EACH_ITEMS_NOT_VISIBLE",`For-each items reference "${Z}" is not guaranteed before this loop.`,A.itemsReference.span,"Reference context.payload or a step output that succeeds before <for-each>.")}let G=$0(W,A.items,M,new Set(Y),new Set(J));if(A.result!==void 0)e0(W,A.result,M,G,J);Y.add(A.id);continue}if(A.kind==="approval"){let Z=new Set(Y);Z.add(A.id),$0(W,A.approvedItems,M,Z,new Set(J)),$0(W,A.rejectedItems,M,Z,new Set(J)),Y.add(A.id);continue}if(A.kind==="fork"){let Z=new Map(A.branches.map((R)=>[R.id,Y0(R.items)])),G=new Set([...Z.values()].flatMap((R)=>[...R])),X=new Map;for(let R of A.branches){let U=Z.get(R.id),T=new Set(J);for(let S of G)if(!U.has(S))T.add(S);X.set(R.id,$0(W,R.items,M,new Set(Y),T))}let Q=new Set(A.joinedBranchIds);for(let R of A.branches){let U=Z.get(R.id);if(Q.has(R.id)){let T=X.get(R.id);for(let S of U)if(T.has(S))Y.add(S)}else for(let T of U)J.add(T)}continue}if(A.kind==="controlChoice"){for(let Z of A.arms){if(Z.test!==void 0)e0(W,Z.test,M,Y,J);$0(W,Z.items,M,new Set(Y),new Set(J))}continue}if(A.kind==="switch"){e0(W,A.selector,M,Y,J);for(let Z of A.arms){let G=$0(W,Z.items,M,new Set(Y),new Set(J));if(Z.result!==void 0)e0(W,Z.result,M,G,J)}if(A.id!==void 0)Y.add(A.id);continue}for(let Z of A.arms){if(Z.test!==void 0)e0(W,Z.test,M,Y,J);let G=$0(W,Z.items,M,Y,new Set(J));e0(W,Z.result,M,G,J)}Y.add(A.id)}return Y}function SE(W,O,M=[]){let L=GW(W,O);if(L.length===0)E(W,"WOML_EMPTY_STEPS","<steps> must contain at least one step item.",O.openTagSpan);let $=new Set,Y=L.map((P)=>C0(W,P,$,"<steps>",{...JF,shadowedServices:M}));$0(W,Y,$);let J=Y.at(-1);if(J?.kind==="parallel")E(W,"WOML_PARALLEL_TERMINAL_UNSUPPORTED",`Root <parallel id="${J.id}"> cannot be the final workflow item because a parallel group has no aggregate result.`,J.element.openTagSpan,"Add a downstream <step> that builds the workflow result.");if(J?.kind==="fork"&&!Y.slice(0,-1).some((P)=>P.kind==="step"||P.kind==="branch"||P.kind==="approval"))E(W,"WOML_FORK_TERMINAL_RESULT_REQUIRED",`Terminal <fork id="${J.id}"> has no earlier value-producing main-route item to preserve as the workflow result.`,J.element.openTagSpan,"Add a value-producing <step> before the terminal fork or add a result-building step after it.");let A=(P)=>{for(let B of P){if(B.kind==="branch")return B.element;if(B.kind==="controlChoice"||B.kind==="switch")for(let q of B.arms){let N=A(q.items);if(N!==void 0)return N}if(B.kind==="forEach"){let q=A(B.items);if(q!==void 0)return q}if(B.kind==="fork")for(let q of B.branches){let N=A(q.items);if(N!==void 0)return N}if(B.kind==="approval"){let q=A(B.approvedItems);if(q!==void 0)return q;let N=A(B.rejectedItems);if(N!==void 0)return N}}return},Z=(P)=>{for(let B of P){if(B.kind==="parallel")return B.element;if(B.kind==="branch")for(let q of B.arms){let N=Z(q.items);if(N!==void 0)return N}if(B.kind==="controlChoice"||B.kind==="switch")for(let q of B.arms){let N=Z(q.items);if(N!==void 0)return N}if(B.kind==="forEach"){let q=Z(B.items);if(q!==void 0)return q}if(B.kind==="fork")for(let q of B.branches){let N=Z(q.items);if(N!==void 0)return N}if(B.kind==="approval"){let q=Z(B.approvedItems);if(q!==void 0)return q;let N=Z(B.rejectedItems);if(N!==void 0)return N}}return},G=(P)=>{for(let B of P){if(B.kind==="approval")return B.element;if(B.kind==="branch")for(let q of B.arms){let N=G(q.items);if(N!==void 0)return N}if(B.kind==="controlChoice"||B.kind==="switch")for(let q of B.arms){let N=G(q.items);if(N!==void 0)return N}if(B.kind==="forEach"){let q=G(B.items);if(q!==void 0)return q}if(B.kind==="fork")for(let q of B.branches){let N=G(q.items);if(N!==void 0)return N}}return},X=(P)=>{for(let B of P){if(B.kind==="branch")for(let q of B.arms){let N=X(q.items);if(N!==void 0)return N}if(B.kind==="controlChoice"||B.kind==="switch")for(let q of B.arms){let N=X(q.items);if(N!==void 0)return N}if(B.kind==="forEach"){let q=X(B.items);if(q!==void 0)return q}if(B.kind==="fork")for(let q of B.branches){let N=X(q.items);if(N!==void 0)return N}if(B.kind==="approval"){if(B.notifications.length>0)return B.element;let q=X(B.approvedItems);if(q!==void 0)return q;let N=X(B.rejectedItems);if(N!==void 0)return N}}return},Q=A(Y),R=Z(Y),U=G(Y),T=X(Y),S=(P,B)=>{for(let q of P){if(q.kind===B)return q.element;if(q.kind==="branch"||q.kind==="controlChoice"||q.kind==="switch")for(let N of q.arms){let _=S(N.items,B);if(_!==void 0)return _}else if(q.kind==="forEach"){let N=S(q.items,B);if(N!==void 0)return N}else if(q.kind==="approval"){let N=S(q.approvedItems,B);if(N!==void 0)return N;let _=S(q.rejectedItems,B);if(_!==void 0)return _}else if(q.kind==="fork")for(let N of q.branches){let _=S(N.items,B);if(_!==void 0)return _}}return},H=S(Y,"fork"),F=S(Y,"controlChoice"),K=S(Y,"switch"),w=S(Y,"forEach");return{items:Y,...Q===void 0?{}:{firstBranch:Q},...R===void 0?{}:{firstParallel:R},...U===void 0?{}:{firstApproval:U},...T===void 0?{}:{firstNotification:T},...H===void 0?{}:{firstFork:H},...F===void 0?{}:{firstControlChoice:F},...K===void 0?{}:{firstSwitch:K},...w===void 0?{}:{firstForEach:w}}}function A9(W){let O={id:W.id,handler:"runtime.script",...W.metadata===void 0?{}:{metadata:W.metadata},...W.retryPolicy===void 0?{}:{retryPolicy:W.retryPolicy},inputs:{kind:"object",fields:{source:{kind:"literal",value:W.source}}}};return{entryId:W.id,exitId:W.id,nodes:[O],edges:[]}}function uO(W){return{kind:"contextReference",path:W.path}}function Y1(W,O){return{id:`${W}-to-${O}`,from:W,to:O,condition:{kind:"always"}}}function UE(W){let O=`__woml_branch__${W.id}__select`,M=W.arms.map((A)=>vL(A.items)),L=W.arms.map((A,Z)=>A.kind==="when"?`${W.id}:when:${Z}`:`${W.id}:otherwise`),$={id:O,handler:"engine.branch-select",inputs:{kind:"object",fields:{}},...W.metadata===void 0?{}:{metadata:W.metadata}},Y={id:W.id,handler:"engine.branch-result",inputs:{kind:"object",fields:Object.fromEntries(W.arms.map((A,Z)=>[L[Z],uO(A.result)]))}},J=W.arms.map((A,Z)=>({id:L[Z],from:O,to:M[Z].entryId,condition:A.kind==="when"?{kind:"boolean",value:uO(A.test)}:{kind:"always"},branchId:W.id}));return{entryId:O,exitId:W.id,nodes:[$,...M.flatMap((A)=>A.nodes),Y],edges:[...J,...M.flatMap((A)=>A.edges),...M.map((A)=>Y1(A.exitId,W.id))]}}function gZ(W){let O=`__woml_parallel__${W.id}__start`,M={id:O,handler:"engine.parallel-start",inputs:{kind:"object",fields:{concurrency:{kind:"literal",value:W.concurrency},onError:{kind:"literal",value:W.onError}}},...W.metadata===void 0?{}:{metadata:W.metadata}},L=W.children.map(A9),$={id:W.id,handler:"engine.parallel-join",inputs:{kind:"object",fields:{}}},Y=L.map((A,Z)=>({id:`${W.id}:child:${Z}`,from:O,to:A.entryId,condition:{kind:"always"},parallelId:W.id})),J=L.map((A,Z)=>({id:`${W.id}:join:${Z}`,from:A.exitId,to:W.id,condition:{kind:"always"},parallelId:W.id}));return{entryId:O,exitId:W.id,nodes:[M,...L.flatMap((A)=>A.nodes),$],edges:[...Y,...L.flatMap((A)=>A.edges),...J]}}function fL(W,O,M){return{id:`${W}:${O}`,from:W,to:M,condition:{kind:"equals",left:{kind:"contextReference",path:["steps",W,"decision"]},right:{kind:"literal",value:O}},approvalId:W}}function xZ(W){let O=`__woml_approval__${W.id}__join`,M=W.approvedItems.length===0?void 0:vL(W.approvedItems),L=W.rejectedItems.length===0?void 0:vL(W.rejectedItems),$={...W.timeoutMs===void 0?{}:{timeoutMs:{kind:"literal",value:W.timeoutMs}},onTimeout:{kind:"literal",value:W.onTimeout},...W.notifications.length===0?{}:{notifications:{kind:"array",items:W.notifications.map((G)=>({kind:"object",fields:{deliveryId:{kind:"literal",value:G.deliveryId},provider:{kind:"literal",value:G.provider},destination:{kind:"literal",value:G.destination},credentials:vZ(G),...G.provider==="whatsapp"?{templateName:{kind:"literal",value:G.templateName},language:{kind:"literal",value:G.language}}:{}}}))}}},Y={id:W.id,handler:"engine.approval-wait",inputs:{kind:"object",fields:$},...W.metadata===void 0?{}:{metadata:W.metadata}},J={id:O,handler:"engine.approval-join",inputs:{kind:"object",fields:{}}},A=[fL(W.id,"approved",M?.entryId??O),fL(W.id,"rejected",L?.entryId??O)],Z=[...M===void 0?[]:[{id:`${W.id}:approved:join`,from:M.exitId,to:O,condition:{kind:"always"},approvalId:W.id}],...L===void 0?[]:[{id:`${W.id}:rejected:join`,from:L.exitId,to:O,condition:{kind:"always"},approvalId:W.id}]];return{entryId:W.id,exitId:O,nodes:[Y,...M?.nodes??[],...L?.nodes??[],J],edges:[...A,...M?.edges??[],...L?.edges??[],...Z]}}function zE(W){if(W.kind==="step")return A9(W);if(W.kind==="branch")return UE(W);if(W.kind==="parallel")return gZ(W);if(W.kind==="approval")return xZ(W);throw Error("Model v13 flow reached legacy lowering before the FJ3 feature gate.")}function vL(W){let O=W.map(zE),M=[],L=[];for(let $=0;$<O.length;$+=1){let Y=O[$];if(M.push(...Y.nodes),$>0)L.push(Y1(O[$-1].exitId,Y.entryId));L.push(...Y.edges)}return{entryId:O[0].entryId,exitId:O.at(-1).exitId,nodes:M,edges:L}}function hO(W,O){return{id:W,handler:O,inputs:{kind:"object",fields:{}}}}function VE(W,O,M){return M.contextVisibility.push({nodeId:W.id,stepIds:[...O]}),{...A9(W),visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function HE(W,O,M){for(let $ of W.children)M.contextVisibility.push({nodeId:$.id,stepIds:[...O]});return{...gZ(W),visibleAfter:new Set([...O,...W.children.map(($)=>$.id)])}}function KE(W,O,M,L){let $=`__woml_branch__${W.id}__select`,Y=W.arms.map((X,Q)=>J0(X.items,new Set(O),`${M}_arm_${Q}`,L)),J=W.arms.map((X,Q)=>X.kind==="when"?`${W.id}:when:${Q}`:`${W.id}:otherwise`),A={id:$,handler:"engine.branch-select",inputs:{kind:"object",fields:{}},...W.metadata===void 0?{}:{metadata:W.metadata}},Z={id:W.id,handler:"engine.branch-result",inputs:{kind:"object",fields:Object.fromEntries(W.arms.map((X,Q)=>[J[Q],uO(X.result)]))}},G=W.arms.map((X,Q)=>({id:J[Q],from:$,to:Y[Q].entryId,condition:X.kind==="when"?{kind:"boolean",value:uO(X.test)}:{kind:"always"},branchId:W.id}));return{entryId:$,exitId:W.id,nodes:[A,...Y.flatMap((X)=>X.nodes),Z],edges:[...G,...Y.flatMap((X)=>X.edges),...Y.map((X)=>Y1(X.exitId,W.id))],visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function TE(W,O,M,L){let $=`__woml_choice__${M}`,Y=`${$}__select`,J=`${$}__join`,A=W.arms.map((G,X)=>J0(G.items,new Set(O),`${M}_arm_${X}`,L)),Z=W.arms.map((G,X)=>G.kind==="when"?`${$}:when:${X}`:`${$}:otherwise`);return L.choices.push({choiceId:$,selectorNodeId:Y,joinNodeId:J,armIds:Z}),{entryId:Y,exitId:J,nodes:[hO(Y,"engine.choice-select"),...A.flatMap((G)=>G.nodes),hO(J,"engine.choice-join")],edges:[...W.arms.map((G,X)=>({id:Z[X],from:Y,to:A[X].entryId,condition:G.kind==="when"?{kind:"boolean",value:uO(G.test)}:{kind:"always"}})),...A.flatMap((G)=>G.edges),...A.map((G,X)=>({id:`${Z[X]}:join`,from:G.exitId,to:J,condition:{kind:"always"}}))],visibleAfter:new Set(O)}}function FE(W,O,M,L){let $=`__woml_choice__${M}_switch`,Y=`${$}__select`,J=`${$}__join`,A=W.arms.map((R,U)=>J0(R.items,new Set(O),`${M}_arm_${U}`,L)),Z=W.arms.map((R,U)=>R.kind==="case"?`${$}:case:${U}`:`${$}:default`),G=W.arms.findIndex((R)=>R.kind==="default"),X={choiceId:$,selectorNodeId:Y,joinNodeId:J,armIds:Z,stringSelector:uO(W.selector),stringCases:W.arms.flatMap((R,U)=>R.kind==="case"?[{armId:Z[U],value:R.value}]:[]),defaultArmId:Z[G],...W.id===void 0?{}:{resultNodeId:W.id}};L.choices.push(X);let Q=W.id===void 0?void 0:{id:W.id,handler:"engine.choice-result",inputs:{kind:"object",fields:Object.fromEntries(W.arms.map((R,U)=>[Z[U],uO(R.result)]))},...W.metadata===void 0?{}:{metadata:W.metadata}};return{entryId:Y,exitId:Q?.id??J,nodes:[hO(Y,"engine.choice-select"),...A.flatMap((R)=>R.nodes),hO(J,"engine.choice-join"),...Q===void 0?[]:[Q]],edges:[...W.arms.map((R,U)=>({id:Z[U],from:Y,to:A[U].entryId,condition:{kind:"always"}})),...A.flatMap((R)=>R.edges),...A.map((R,U)=>({id:`${Z[U]}:join`,from:R.exitId,to:J,condition:{kind:"always"}})),...Q===void 0?[]:[Y1(J,Q.id)]],visibleAfter:W.id===void 0?new Set(O):new Set([...O,W.id]),...W.id===void 0?{}:{lastResultNodeId:W.id}}}function EE(W,O,M,L){let $=`__woml_approval__${W.id}__join`,Y=new Set([...O,W.id]),J=W.approvedItems.length===0?void 0:J0(W.approvedItems,new Set(Y),`${M}_approved`,L),A=W.rejectedItems.length===0?void 0:J0(W.rejectedItems,new Set(Y),`${M}_rejected`,L),Z=xZ({...W,approvedItems:[],rejectedItems:[]}),G=Z.nodes[0],X=Z.nodes.at(-1),Q=[fL(W.id,"approved",J?.entryId??$),fL(W.id,"rejected",A?.entryId??$)],R=[...J===void 0?[]:[{id:`${W.id}:approved:join`,from:J.exitId,to:$,condition:{kind:"always"},approvalId:W.id}],...A===void 0?[]:[{id:`${W.id}:rejected:join`,from:A.exitId,to:$,condition:{kind:"always"},approvalId:W.id}]];return{entryId:W.id,exitId:$,nodes:[G,...J?.nodes??[],...A?.nodes??[],X],edges:[...Q,...J?.edges??[],...A?.edges??[],...R],visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function qE(W,O,M,L){let $=`__woml_fork__${W.id}__open`,Y=`__woml_fork__${W.id}__join`,J=W.branches.map((X,Q)=>({branch:X,fragment:J0(X.items,new Set(O),`${M}_branch_${Q}`,L),terminalNodeId:`__woml_fork__${W.id}__${X.id}__terminal`})),A=new Set(W.joinedBranchIds),Z={forkId:W.id,openNodeId:$,joinNodeId:Y,branches:J.map(({branch:X,fragment:Q,terminalNodeId:R})=>({branchId:X.id,entryNodeId:Q.entryId,terminalNodeId:R})),joinedBranchIds:W.joinedBranchIds};L.forks.push(Z),L.ownedBranchTerminalNodeIds.push(...Z.branches.map((X)=>X.terminalNodeId));let G=new Set(O);for(let{branch:X,fragment:Q}of J){if(!A.has(X.id))continue;let R=Y0(X.items);for(let U of R)if(Q.visibleAfter.has(U))G.add(U)}return{entryId:$,exitId:Y,nodes:[hO($,"engine.fork-open"),...J.flatMap(({fragment:X,terminalNodeId:Q})=>[...X.nodes,hO(Q,"engine.fork-branch-terminal")]),hO(Y,"engine.fork-join")],edges:[...J.map(({branch:X,fragment:Q})=>({id:`${W.id}:branch:${X.id}`,from:$,to:Q.entryId,condition:{kind:"always"}})),...J.flatMap(({branch:X,fragment:Q,terminalNodeId:R})=>[...Q.edges,{id:`${W.id}:terminal:${X.id}`,from:Q.exitId,to:R,condition:{kind:"always"}}]),...W.joinedBranchIds.length===0?[{id:`${W.id}:join:none`,from:$,to:Y,condition:{kind:"always"}}]:W.joinedBranchIds.map((X)=>({id:`${W.id}:join:${X}`,from:Z.branches.find((Q)=>Q.branchId===X).terminalNodeId,to:Y,condition:{kind:"always"}}))],visibleAfter:G}}function BE(W,O,M,L){let $=`__woml_for_each__${W.id}__open`,Y={forks:[],choices:[],forEach:[],contextVisibility:[],ownedBranchTerminalNodeIds:[]},J=J0(W.items,new Set,`${M}_for_each_${W.id}`,Y);if(Y.forks.length>0||Y.forEach.length>0||Y.ownedBranchTerminalNodeIds.length>0)throw Error("Model v16 for-each body contains a forbidden nested owner.");L.forEach.push({forEachId:W.id,openNodeId:$,resultNodeId:W.id,...W.metadata===void 0?{}:{metadata:W.metadata},items:uO(W.itemsReference),concurrency:W.concurrency,outerStepIds:[...O],body:{entryNodeIds:[J.entryId],nodes:J.nodes,edges:J.edges,choices:Y.choices,contextVisibility:Y.contextVisibility,terminalNodeId:J.exitId},...W.result===void 0?{}:{result:uO(W.result)}});let A={id:W.id,handler:"engine.for-each-result",inputs:{kind:"object",fields:{}},...W.metadata===void 0?{}:{metadata:W.metadata}};return{entryId:$,exitId:W.id,nodes:[hO($,"engine.for-each-open"),A],edges:[Y1($,W.id)],visibleAfter:new Set([...O,W.id]),lastResultNodeId:W.id}}function CE(W,O,M,L){if(W.kind==="step")return VE(W,O,L);if(W.kind==="parallel")return HE(W,O,L);if(W.kind==="branch")return KE(W,O,M,L);if(W.kind==="controlChoice")return TE(W,O,M,L);if(W.kind==="switch")return FE(W,O,M,L);if(W.kind==="approval")return EE(W,O,M,L);if(W.kind==="forEach")return BE(W,O,M,L);return qE(W,O,M,L)}function J0(W,O,M,L){let $=[],Y=[],J=new Set(O),A,Z,G;for(let X=0;X<W.length;X+=1){let Q=CE(W[X],J,`${M}_${X}`,L);if(Z??=Q.entryId,G!==void 0)Y.push(Y1(G,Q.entryId));$.push(...Q.nodes),Y.push(...Q.edges),G=Q.exitId,J=new Set(Q.visibleAfter),A=Q.lastResultNodeId??A}if(Z===void 0||G===void 0)throw Error("Model v13 lowering requires a non-empty flow.");return{entryId:Z,exitId:G,nodes:$,edges:Y,visibleAfter:J,...A===void 0?{}:{lastResultNodeId:A}}}function wE(W){let O={forks:[],choices:[],forEach:[],contextVisibility:[],ownedBranchTerminalNodeIds:[]},M=J0(W,new Set,"root",O);if(M.lastResultNodeId===void 0)throw Error("Model v13 workflow has no deterministic value-producing main-route result.");let L="__woml_workflow__settlement",$=[{id:"__woml_workflow__:main:settlement",from:M.exitId,to:L,condition:{kind:"always"}},...O.ownedBranchTerminalNodeIds.map((Y)=>({id:`${Y}:settlement`,from:Y,to:L,condition:{kind:"always"}}))];return{fragment:M,forEach:O.forEach,graph:{entryNodeIds:[M.entryId],nodes:[...M.nodes,hO(L,"engine.workflow-settlement")],edges:[...M.edges,...$],forks:O.forks,choices:O.choices,contextVisibility:O.contextVisibility,settlement:{nodeId:L,mainResultNodeId:M.lastResultNodeId,ownedBranchTerminalNodeIds:O.ownedBranchTerminalNodeIds}}}}function PE(W){if(W.kind==="manual")return{id:W.id,handler:"trigger.manual",config:{kind:"object",fields:{}}};if(W.kind==="slack")return{id:W.id,handler:"trigger.slack",config:{kind:"object",fields:{events:{kind:"array",items:W.events.map((M)=>({kind:"literal",value:M}))},channels:{kind:"array",items:W.channels.map((M)=>({kind:"literal",value:M}))},botToken:W.botToken,appToken:W.appToken}}};if(W.kind==="telegram")return{id:W.id,handler:"trigger.telegram",config:{kind:"object",fields:{events:{kind:"array",items:[{kind:"literal",value:"message"}]},botToken:W.botToken}}};if(W.kind==="discord")return{id:W.id,handler:"trigger.discord",config:{kind:"object",fields:{events:{kind:"array",items:W.events.map((M)=>({kind:"literal",value:M}))},...W.channels.length===0?{}:{channels:{kind:"array",items:W.channels.map((M)=>({kind:"literal",value:M}))}},botToken:W.botToken}}};if(W.kind==="whatsapp")return{id:W.id,handler:"trigger.whatsapp",config:{kind:"object",fields:{events:{kind:"array",items:[{kind:"literal",value:"message"}]},phoneNumberId:{kind:"literal",value:W.phoneNumberId},verifyToken:W.verifyToken,appSecret:W.appSecret}}};if(W.kind==="schedule")return{id:W.id,handler:"trigger.schedule",config:{kind:"object",fields:{cron:{kind:"literal",value:W.cron},timezone:{kind:"literal",value:W.timezone},onMissed:{kind:"literal",value:W.onMissed}}}};if(W.kind==="interval")return{id:W.id,handler:"trigger.interval",config:{kind:"object",fields:{everyMs:{kind:"literal",value:W.everyMs},onMissed:{kind:"literal",value:W.onMissed}}}};if(W.kind==="event")return{id:W.id,handler:"trigger.event",config:{kind:"object",fields:{name:{kind:"literal",value:W.name},...W.secret===void 0?{}:{secret:W.secret},...W.schema===void 0?{}:{schema:{kind:"literal",value:W.schema}}}}};let O=W.authentication.kind==="none"?{kind:"object",fields:{kind:{kind:"literal",value:"none"}}}:{kind:"object",fields:{kind:{kind:"literal",value:"bearer"},secret:W.authentication.secret}};return{id:W.id,handler:"trigger.webhook",config:{kind:"object",fields:{path:{kind:"literal",value:W.path},method:{kind:"literal",value:W.method},authentication:O,...W.schema===void 0?{}:{schema:{kind:"literal",value:W.schema}}}}}}function NE(W,O){let M=GW(W,O);if(M.length===0)E(W,"WOML_IMPORTS_EMPTY","<imports> requires at least one <module> declaration.",O.openTagSpan,"Remove the empty <imports> container when the workflow has no modules.");let L=[],$=new Set,Y=new Set;for(let J of M){if(J.name!=="module")E(W,"WOML_IMPORTS_INVALID_CHILD",`<imports> accepts <module> declarations only; found <${J.name}>.`,J.openTagSpan);rW(W,J);let A=e(W,J,"name"),Z=e(W,J,"from"),G=A.value,X=Z.value;if(G.length>128||!SF.test(G))E(W,"WOML_MODULE_ALIAS_INVALID",`Module name "${G}" must be a JavaScript-safe lower-camel alias.`,A.valueSpan,"Example: spreadsheet or customerTools");if(KF.has(G))E(W,"WOML_MODULE_ALIAS_RESERVED",`Module name "${G}" is reserved by WOML.`,A.valueSpan,"Choose a workflow-specific module name.");if($.has(G))E(W,"WOML_MODULE_ALIAS_DUPLICATE",`Module name "${G}" is declared more than once.`,A.valueSpan);if($.add(G),X.endsWith(".woml"))E(W,"WOML_MODULE_WORKFLOW_UNSUPPORTED","<module> imports JavaScript or TypeScript code, not .woml workflows.",Z.valueSpan,"Use services.events.emit() for one-to-many workflow triggers. Durable services.workflows.call() is the next roadmap milestone.");if(X.includes("\\")||X.includes("\x00")||X.includes("?")||X.includes("#")||!UF.test(X))E(W,"WOML_MODULE_PATH_INVALID",`Module source "${X}" must be an explicit relative POSIX path ending in .js or .ts.`,Z.valueSpan,"Example: ./modules/spreadsheet.ts");if(Y.has(X))E(W,"WOML_MODULE_SOURCE_DUPLICATE",`Module source "${X}" is already declared under another name.`,Z.valueSpan,"Declare one stable services alias for each module entry point.");Y.add(X),L.push({name:G,from:X,element:J,nameAttribute:A,fromAttribute:Z})}return L}function XM(W){let O=W.root;if(O.name!=="woml")E(W,"WOML_EXPECTED_DOCUMENT_ROOT",`Expected <woml> as the document root, found <${O.name}>.`,O.openTagSpan,O.name==="workflow"?"Wrap the existing <workflow> with <woml>...</woml>.":"A WOML document contains optional <imports> followed by exactly one <workflow>.");wZ(W,O),CZ(W,O);let M=GW(W,O),L,$;if(M.length===1&&M[0].name==="workflow")$=M[0];else if(M.length===2&&M[0].name==="imports"&&M[1].name==="workflow")L=M[0],$=M[1];else{let F=M.find((K)=>K.name!=="imports"&&K.name!=="workflow")??M[0]??O;E(W,"WOML_DOCUMENT_STRUCTURE_INVALID","<woml> requires optional <imports> followed by exactly one <workflow>.",F.openTagSpan,"Use <woml><imports>...</imports><workflow ...>...</workflow></woml>.")}let Y=L===void 0?[]:NE(W,L);if($===void 0)throw Error("validated WOML document did not contain a workflow");let J=TF(W,e(W,$,"id")),A=FF(W,$),[Z,G,X,Q]=EF(W,$),R=Z===void 0?void 0:qF(W,Z),U=X===void 0?[]:NF(W,X),T=Y.filter((F)=>F.name==="telegram"||F.name==="discord"||F.name==="whatsapp").map((F)=>F.name),S=SE(W,Q,T),H=G===void 0?void 0:tF(W,G,S,T);return{element:$,modules:Y,workflowId:J,...A===void 0?{}:{metadata:A},triggers:U,flow:S,...H===void 0?{}:{lifecycle:H},...R===void 0?{}:{runtimePolicy:R}}}function hZ(W){return XM(W)}function _E(W){XM(W);let O=[],M=F0(W);if(M.kind==="workflow"){for(let $ of M.imports)if($.name==="telegram"||$.name==="discord"||$.name==="whatsapp"){let Y=$.name==="telegram"?"Telegram":$.name==="discord"?"Discord":"WhatsApp";O.push({severity:"warning",code:"WOML_BUILTIN_SERVICE_SHADOWED",phase:"validation",message:`The local module alias "${$.name}" shadows the built-in services.${$.name} capability in this workflow.`,file:W.file,location:$.element.openTagSpan,hint:`Keep this name to preserve the local module, or rename it when you want services.${$.name}.send() from the built-in ${Y} provider.`})}}let L=($,Y)=>{if($.name==="branch"&&Y!=="fork")O.push({severity:"warning",code:"WOML_DEPRECATED_CONDITIONAL_BRANCH",phase:"validation",message:"Conditional <branch> is deprecated; use <choose> for mutually exclusive conditions.",file:W.file,location:$.openTagSpan,hint:"Rename the opening <branch> tag to <choose> and the matching closing </branch> tag to </choose>. The id, cases, result, and runtime behavior stay unchanged."});for(let J of $.children)if(J.kind==="element")L(J,$.name)};return L(W.root,void 0),O}function bL(W,O,M){return{name:O,value:M,span:W.openTagSpan,nameSpan:W.openTagSpan,valueSpan:W.openTagSpan}}function uZ(W,O){if(O.root.kind!=="workflow")return;let M=new Map(O.definitions.map((Y)=>[Y.alias,Y.kind])),L=(Y,J=[])=>{let A=M.get(Y.name);if(A==="reusable-step"){let G=Object.fromEntries(Object.entries(Y.attributes).filter(([R])=>new Set(["id","name","description","retry","retry-delay","retry-backoff","retry-max-delay"]).has(R))),X={kind:"raw",value:"return null;",span:Y.openTagSpan},Q={kind:"element",name:"script",attributes:{},children:[X],span:Y.span,openTagSpan:Y.openTagSpan};return{...Y,name:"step",attributes:G,children:[Q]}}if(A==="notification-provider"){if(J.at(-1)==="triggers")return Y;let G=J.some((Q)=>Q.startsWith("on-")),X={channels:bL(Y,"channels","#custom-provider"),"bot-token":bL(Y,"bot-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}"),"app-token":bL(Y,"app-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}")};if(G)X.message=Y.attributes.message??bL(Y,"message","Custom notification");return{...Y,name:"slack",attributes:X,children:[]}}let Z=Y.children.map((G)=>G.kind==="element"?L(G,[...J,Y.name]):G);if(Y.name==="imports")Z=Z.filter((G)=>G.kind!=="element"||G.attributes.from?.value.endsWith(".woml")!==!0);return{...Y,children:Z}},$=L(W.root);$={...$,children:$.children.filter((Y)=>Y.kind!=="element"||Y.name!=="imports"||Y.children.length>0)},XM({...W,root:$})}function jE(W,O){let M=(L)=>L.split("-").filter(Boolean).map(($)=>`${$[0]?.toUpperCase()??""}${$.slice(1)}`).join("");return`reusable${M(W)}${M(O)}`}function IE(W,O){let M=M9(W,O).split(L9).join("/");return M.startsWith(".")?M:`./${M}`}function ZM(W,O,M){return{name:W,value:O,span:M,nameSpan:M,valueSpan:M}}function FZ(W,O){if(O===void 0)return;let M={};for(let L of O.children){if(L.kind!=="element")continue;let $=L.children.filter((Y)=>Y.kind==="element").map((Y,J)=>`${W}:${L.name}:${J}`);if(L.name==="on-success")M.onSuccess=$;if(L.name==="on-error")M.onError=$;if(L.name==="on-complete")M.onComplete=$}return Object.keys(M).length===0?void 0:M}function yE(W,O){if(O.value.length===0||O.value.length>16384)E(W,"WOML_PROVIDER_MESSAGE_INVALID","Custom provider messages must contain 1 through 16384 characters.",O.valueSpan);let M=[],L=0,$=0;for(let J of O.value.matchAll(/\{\{([^{}]+)\}\}/g)){let A=J.index??0,Z=O.value.slice(L,A);if(Z.includes("{{")||Z.includes("}}"))E(W,"WOML_PROVIDER_MESSAGE_INVALID","Custom provider message contains an unmatched WOML template delimiter.",O.valueSpan);if(Z.length>0)M.push({kind:"text",text:Z});let G=J[1].trim(),X=/^context\.(payload(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+|steps\.[a-z][A-Za-z0-9]*(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+)$/.exec(G);if(X===null)E(W,"WOML_PROVIDER_MESSAGE_INVALID",`Unsupported custom provider message reference "${G}".`,O.valueSpan,"Use scalar context.payload or context.steps references only.");M.push({kind:"contextReference",path:X[1].split(".").map((Q,R)=>R===0&&Q==="payload"?"trigger":Q)}),$+=1,L=A+J[0].length}let Y=O.value.slice(L);if(Y.includes("{{")||Y.includes("}}")||$>32)E(W,"WOML_PROVIDER_MESSAGE_INVALID",$>32?"Custom provider messages may contain at most 32 placeholders.":"Custom provider message contains an unmatched WOML template delimiter.",O.valueSpan);if(Y.length>0)M.push({kind:"text",text:Y});return{kind:"template",parts:M}}function EZ(W,O){return W.flatMap((M)=>{let L=O.attributes[M.name];if(L===void 0)return[];let $=/^\{\{secrets\.([A-Z][A-Z0-9_]*)\}\}$/.exec(L.value),Y=/^\{\{context\.(.+)\}\}$/.exec(L.value);return[{name:M.name,bindingName:M.bindingName,secret:M.secret,expression:$!==null?{kind:"secret",name:$[1]}:Y!==null?{kind:"context",path:Y[1]}:{kind:"literal",value:L.value}}]})}function Z9(W,O,M){if(O.root.kind!=="workflow")HW(W,"WOML_DEFINITION_NOT_RUNNABLE","Only a workflow document can be lowered into a reusable-step workflow.",O.root.definition.openTagSpan);uZ(W,O);let L=W9(AM(W.file)),$=new Map(O.root.imports.filter((S)=>S.kind==="reusable-definition").map((S)=>[S.name,M9(M.projectRoot,AM(W9(W.file),S.from)).split(L9).join("/")])),Y=new Map;for(let S of O.definitions){if($.get(S.alias)!==S.sourcePath||Y.has(S.alias))continue;let H=AM(M.projectRoot,S.sourcePath),F=YM(YF(H,"utf8"),{file:H}),K=F0(F);if(K.kind==="workflow")continue;let w=K.definition.children.find((k)=>k.kind==="element"&&k.name==="script"),P=w.children[0],B=P?.kind==="raw"?P.value:"",q=K.kind==="reusable-step"?B8(B):C8(B);if(q.issue!==void 0){let k=new n(F.file,F.source),p=w.children[0].span.start.offset+q.issue.start;throw new RO({phase:"compile",code:q.issue.code,message:q.issue.message,file:F.file,location:k.span(p,p+Math.max(1,q.issue.end-q.issue.start)),...q.issue.hint===void 0?{}:{hint:q.issue.hint}})}let N=K.imports.filter((k)=>k.kind==="script-module").map((k)=>({name:k.name,runtimeName:jE(S.alias,k.name),from:IE(L,AM(W9(H),k.from))})),_=(k)=>{let p=k;for(let XW of N)p=p.replace(new RegExp(`\\bservices\\.${XW.name}\\b`,"g"),`services.${XW.runtimeName}`);return p},V=_(B),C=`reusable_${S.alias.replaceAll("-","_")}_${S.digest.slice(7,23)}`,I=K.lifecycle?.children.flatMap((k)=>{if(k.kind!=="element")return[];return k.children.flatMap((p,XW)=>{if(p.kind!=="element"||p.name!=="script")return[];let MW=p.children[0],AW=MW?.kind==="raw"?MW.value:"",v=HL(AW);if(v.issue!==void 0){let kW=new n(F.file,F.source),iW=(MW?.span.start.offset??p.openTagSpan.start.offset)+v.issue.start;throw new RO({phase:"compile",code:v.issue.code,message:v.issue.message,file:F.file,location:kW.span(iW,iW+Math.max(1,v.issue.end-v.issue.start)),...v.issue.hint===void 0?{}:{hint:v.issue.hint}})}return[{hook:k.name,index:XW,source:_(AW)}]})})??[],b={kind:K.kind,alias:S.alias,source:S.sourcePath,digest:S.digest,scriptArtifactId:C,scriptSource:V,lifecycleScripts:I,imports:N,props:K.props};Y.set(S.alias,{prepared:b,inspection:K,script:w})}let J=[],A=[],Z=[],G=new Map,X=(S,H=[])=>{let F=Y.get(S.name);if(F?.inspection.kind==="notification-provider"){if(H.at(-1)?.name==="triggers")return S;let K=H.at(-1),w=K?.children.filter((b)=>b.kind==="element").indexOf(S)??-1,P=[...H].reverse().find((b)=>b.name==="approval"),B=H.find((b)=>b.name==="lifecycle"),q=B===void 0?void 0:H.find((b)=>b.name.startsWith("on-")),N=P===void 0?"informational":"approval",_,V;if(P!==void 0)V=P.attributes.id.value,_=`${V}:notify:${w}:channel:0`;else{let b=B.children.filter((p)=>p.kind==="element").indexOf(q),k=q.children.filter((p)=>p.kind==="element").indexOf(K);_=`lifecycle:${b}:action:${k}:provider:${w}:channel:0`}let C=S.attributes.message;A.push({kind:"notification-provider",providerId:_,alias:F.prepared.alias,definitionDigest:F.prepared.digest,source:F.prepared.source,scriptArtifactId:F.prepared.scriptArtifactId,props:EZ(F.prepared.props,S),...F.inspection.lifecycle===void 0?{}:{lifecycle:FZ(_,F.inspection.lifecycle)}}),Z.push({providerId:_,domain:N,...V===void 0?{}:{ownerNodeId:V},...N==="approval"&&C!==void 0?{message:yE(W,C),messageAttribute:C}:{}});let I={channels:ZM("channels","#custom-provider",S.openTagSpan),"bot-token":ZM("bot-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}",S.openTagSpan),"app-token":ZM("app-token","{{secrets.WOML_CUSTOM_PROVIDER_PLACEHOLDER}}",S.openTagSpan)};if(N==="informational")I.message=C;return{...S,name:"slack",attributes:I,children:[]}}if(F?.inspection.kind==="reusable-step"){let K=S.attributes.id.value,w=F.inspection.definition.attributes,P={};for(let _ of["id","name","description","retry","retry-delay","retry-backoff","retry-max-delay"]){let V=S.attributes[_]??(_==="name"||_==="description"?w[_]:void 0);if(V!==void 0)P[_]=V}let B=EZ(F.prepared.props,S);J.push({kind:"step",invocationId:K,nodeId:K,alias:F.prepared.alias,definitionDigest:F.prepared.digest,source:F.prepared.source,scriptArtifactId:F.prepared.scriptArtifactId,props:B,...F.inspection.lifecycle===void 0?{}:{lifecycle:FZ(K,F.inspection.lifecycle)}}),G.set(K,S.attributes);let q={kind:"raw",value:F.prepared.scriptSource,span:F.script.children[0].span},N={...F.script,children:[q]};return{...S,name:"step",attributes:P,children:[N]}}return{...S,children:S.children.map((K)=>K.kind==="element"?X(K,[...H,S]):K)}},Q=X(W.root),R=Q.children.find((S)=>S.kind==="element"&&S.name==="imports"),U=[...R?.children.filter((S)=>S.kind==="element"&&S.attributes.from?.value.endsWith(".woml")!==!0)??[],...[...Y.values()].flatMap(({prepared:S,inspection:H})=>S.imports.map((F)=>{let K=H.imports.find((w)=>w.name===F.name);return{...K.element,attributes:{name:ZM("name",F.runtimeName,K.element.openTagSpan),from:ZM("from",F.from,K.element.openTagSpan)}}}))],T=Q.children.filter((S)=>S.kind!=="element"||S.name!=="imports");if(U.length>0){let S=R?.openTagSpan??Q.openTagSpan;T.unshift({kind:"element",name:"imports",attributes:{},children:U,span:S,openTagSpan:S})}return Q={...Q,children:T},{document:{...W,root:Q},rootSource:M9(M.projectRoot,AM(W.file)).split(L9).join("/"),definitions:[...Y.values()].map((S)=>S.prepared),invocations:J,providerInvocations:A,providerDeliveries:Z,invocationAttributes:G}}function G9(W,O,M=!1,L=[]){e8(W);let{element:$,modules:Y,workflowId:J,metadata:A,triggers:Z,flow:G,lifecycle:X,runtimePolicy:Q}=XM(W),R=E0(G.items),U=X?.hooks.flatMap((j)=>j.actions.flatMap((KW)=>KW.kind==="script"?[{analysis:KW.scriptAnalysis,span:KW.scriptSpan}]:[]))??[],T=W1(G.items),S=X?.hooks.flatMap((j)=>j.actions.flatMap((KW)=>KW.kind==="notify"?KW.deliveries:[]))??[],H=[...T,...S].filter((j)=>j.provider==="telegram"),F=[...T,...S].filter((j)=>j.provider==="discord"),K=[...T,...S].filter((j)=>j.provider==="whatsapp"),w=Y.some((j)=>j.name==="telegram"),P=Y.some((j)=>j.name==="discord"),B=Y.some((j)=>j.name==="whatsapp"),q=[...R.values(),...U.map((j)=>j.analysis)],N=L.includes("telegram"),_=L.includes("discord"),V=L.includes("whatsapp"),C=!w&&(N||q.some((j)=>j.requiredServices.includes("telegram"))),I=!P&&(_||q.some((j)=>j.requiredServices.includes("discord"))),b=!B&&(V||q.some((j)=>j.requiredServices.includes("whatsapp"))),k=Z.some((j)=>j.kind==="telegram")||Z.some((j)=>j.kind==="discord")||Z.some((j)=>j.kind==="whatsapp")||H.length>0||F.length>0||K.length>0||C||I||b,p=G.firstForEach!==void 0,XW=p||k||M||G.firstSwitch!==void 0,MW=XW||G.firstFork!==void 0||G.firstControlChoice!==void 0;if(Y.length>0&&O===void 0)HW(W,"WOML_MODULE_EXECUTION_UNAVAILABLE","The MS2 frontend can compile imported modules, but runtime module loading begins in MS3.",Y[0].element.openTagSpan,"Use `woml check <file>` to inspect the immutable module graph without running it.");if(Y.length===0&&O!==void 0)HW(W,"WOML_MODULE_RUNTIME_UNEXPECTED","A module runtime profile cannot be attached to a workflow with no <module> declarations.",$.openTagSpan);if(Z.length===0&&G.firstApproval!==void 0)HW(W,"WOML_WORKFLOW_CALL_WAIT_UNSUPPORTED","A call-only workflow cannot contain Human Approval in Workflow Calls v1.",G.firstApproval.openTagSpan,"Use terminal steps, branch, parallel, retry, modules, and managed services. Long approval-waiting child calls require the future engine suspension boundary.");if(O!==void 0){let j=Y.map((wW)=>wW.name).sort(),KW=O.modules.map((wW)=>wW.name);if(O.profileVersion!==1||O.modules.length===0||JSON.stringify(KW)!==JSON.stringify(j))HW(W,"WOML_MODULE_RUNTIME_MISMATCH","Compiled module bindings must match every declared module alias exactly.",$.openTagSpan);for(let wW of O.modules){let k9=Y.find((M$)=>M$.name===wW.name);if(!RZ.test(wW.bundleDigest)||!RZ.test(wW.sourceMapDigest))HW(W,"WOML_MODULE_ARTIFACT_DIGEST_INVALID",`Compiled module "${wW.name}" requires canonical bundle and source-map SHA-256 identities.`,k9.element.openTagSpan);if(wW.exports.length===0||new Set(wW.exports).size!==wW.exports.length||[...wW.exports].sort().join("\x00")!==wW.exports.join("\x00")||wW.exports.some((M$)=>!VF.test(M$)))HW(W,"WOML_MODULE_RUNTIME_EXPORTS_INVALID",`Compiled module "${wW.name}" requires sorted, unique JavaScript-safe function exports.`,k9.element.openTagSpan)}}if(MW&&!G.items.some((j)=>j.kind==="step"||j.kind==="branch"||j.kind==="approval"||j.kind==="forEach")){let j=G.firstFork??G.firstControlChoice??G.firstSwitch??G.firstForEach;HW(W,"WOML_WORKFLOW_RESULT_REQUIRED",`This Model v${p?"16":k?"15":XW?"14":"13"} workflow has no deterministic value-producing item on its main route.`,j.openTagSpan,'Add a main-route <step>, result-producing <choose id="..."> or <switch id="...">, or <approval> before the terminal control structure.')}let AW=MW?wE(G.items):void 0,v=AW?.fragment??vL(G.items),kW=new Set([...eF,...Y.map((j)=>j.name)]),iW=[...gO(G.items).flatMap((j)=>j.scriptAnalysis.serviceReferences.map((KW)=>({span:j.scriptSpan,reference:KW}))),...U.flatMap((j)=>j.analysis.serviceReferences.map((KW)=>({span:j.span,reference:KW})))].find(({reference:j})=>!kW.has(j.name));if(iW!==void 0){let j=new n(W.file,W.source),KW=iW.span.start.offset+iW.reference.start;HW(W,"WOML_MODULE_SERVICE_UNKNOWN",`Unknown service alias "${iW.reference.name}".`,j.span(KW,KW+Math.max(1,iW.reference.end-iW.reference.start)),"Use a built-in service or declare the local module in <imports>.")}let _0=MW||X!==void 0||Q!==void 0||Z.length===0||O!==void 0||[...R.values()].some((j)=>j.requiredSecrets.length>0||j.usesServices||j.usesNativeFetch),U1=_0?kL(v.nodes,R):v.nodes,mO=AW===void 0?{entryNodeIds:[v.entryId],nodes:U1,edges:v.edges}:p?{...AW.graph,nodes:kL(AW.graph.nodes,R),forEach:AW.forEach.map((j)=>({...j,body:{...j.body,nodes:kL(j.body.nodes,R)}}))}:{...AW.graph,nodes:kL(AW.graph.nodes,R)},aW=k?{profileVersion:1,providers:[...Z.some((j)=>j.kind==="whatsapp")||K.length>0||b?[{provider:"whatsapp",triggerIds:Z.filter((j)=>j.kind==="whatsapp").map((j)=>j.id),notificationDeliveryIds:K.map((j)=>j.deliveryId),messaging:b,credentialNames:[...new Set([...Z.flatMap((j)=>j.kind==="whatsapp"?[j.verifyToken.name,j.appSecret.name]:[]),...K.map((j)=>j.accessToken.name),...q.flatMap((j)=>j.requiredServices.includes("whatsapp")||V?j.requiredSecrets:[])])].sort()}]:[],...Z.some((j)=>j.kind==="discord")||F.length>0||I?[{provider:"discord",triggerIds:Z.filter((j)=>j.kind==="discord").map((j)=>j.id),notificationDeliveryIds:F.map((j)=>j.deliveryId),messaging:I,credentialNames:[...new Set([...Z.flatMap((j)=>j.kind==="discord"?[j.botToken.name]:[]),...F.map((j)=>j.botToken.name),...q.flatMap((j)=>j.requiredServices.includes("discord")||_?j.requiredSecrets:[])])].sort()}]:[],...Z.some((j)=>j.kind==="telegram")||H.length>0||C?[{provider:"telegram",triggerIds:Z.filter((j)=>j.kind==="telegram").map((j)=>j.id),notificationDeliveryIds:H.map((j)=>j.deliveryId),messaging:C,credentialNames:[...new Set([...Z.flatMap((j)=>j.kind==="telegram"?[j.botToken.name]:[]),...H.map((j)=>j.botToken.name),...q.flatMap((j)=>j.requiredServices.includes("telegram")||N?j.requiredSecrets:[])])].sort()}]:[]].sort((j,KW)=>j.provider.localeCompare(KW.provider))}:void 0,bW=aW?.providers.find((j)=>j.credentialNames.length===0);if(bW!==void 0){let j=bW.provider==="telegram"?"Telegram":bW.provider==="discord"?"Discord":"WhatsApp";HW(W,`WOML_${bW.provider.toUpperCase()}_CREDENTIAL_UNRESOLVED`,`${j} usage requires at least one explicit symbolic secret reference in the workflow.`,$.openTagSpan,bW.provider==="whatsapp"?"Pass secrets.WHATSAPP_ACCESS_TOKEN from the WOML script into the imported module that calls services.whatsapp.send().":`Pass secrets.${bW.provider==="telegram"?"TELEGRAM":"DISCORD"}_BOT_TOKEN from the WOML script into the imported module that calls services.${bW.provider}.send().`)}let EW={workflowId:J,...A===void 0?{}:{metadata:A},triggers:Z.map(PE),graph:mO,...O===void 0?{}:{moduleRuntime:O},...X===void 0?{}:{lifecycle:LE(X)},...Q===void 0?{}:{runtimePolicy:Q.value}},y9=MW?p?{schemaVersion:16,...EW,graph:mO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1},...aW===void 0?{}:{communication:aW}}:k?{schemaVersion:15,...EW,communication:aW,graph:mO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1}}:XW?{schemaVersion:14,...EW,graph:mO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1}}:{schemaVersion:13,...EW,graph:mO,runtimePolicy:Q?.value??{profileVersion:1,concurrency:1}}:Q!==void 0?{schemaVersion:12,...EW,runtimePolicy:Q.value}:X!==void 0?{schemaVersion:11,...EW}:Z.length===0?{schemaVersion:10,...EW}:O!==void 0?{schemaVersion:9,...EW,moduleRuntime:O}:_0?{schemaVersion:8,...EW}:Z.length>1||Z.some((j)=>j.kind!=="manual")?{schemaVersion:7,...EW}:v.nodes.some((j)=>j.retryPolicy!==void 0)?{schemaVersion:6,...EW}:G.firstNotification!==void 0?{schemaVersion:5,...EW}:G.firstApproval!==void 0?{schemaVersion:4,...EW}:G.firstParallel!==void 0?{schemaVersion:3,...EW}:G.firstBranch===void 0?{schemaVersion:1,...EW}:{schemaVersion:2,...EW},D9=$8(y9.graph,{requireSingleTerminal:!0});if(D9.length>0)HW(W,"WOML_INVALID_DAG",D9[0].message,$.openTagSpan);return y9}function X9(W,O){let M=G9(W.document,O,!0);if(M.schemaVersion!==14&&M.schemaVersion!==15&&M.schemaVersion!==16)throw Error("reusable-step lowering did not produce Model v14, v15, or v16");let L=new Map(W.invocations.map((K)=>[K.nodeId,K])),$=(K)=>{let w=L.get(K.id);if(w===void 0)return K;let P=w.props.flatMap((B)=>B.expression.kind==="secret"?[B.expression.name]:[]).sort();return{...K,scriptRuntime:{bindingVersion:3,bindings:["props","context","attempt","services"],requiredSecrets:P},metadata:{...K.metadata??{},reusableDefinition:{alias:w.alias,invocationSource:W.rootSource,definitionSource:w.source,definitionDigest:w.definitionDigest}}}},Y=M.graph.nodes.map($),J=M.schemaVersion===16?M.graph.forEach:void 0,A=J?.map((K)=>({...K,body:{...K.body,nodes:K.body.nodes.map($)}})),Z=new Map((M.graph.contextVisibility??[]).map((K)=>[K.nodeId,K.stepIds]));for(let K of J??[])for(let w of K.body.contextVisibility)Z.set(w.nodeId,[...K.outerStepIds,...w.stepIds]);let G=new Map(W.providerInvocations.map((K)=>[K.providerId,K])),X=new Map(W.providerDeliveries.map((K)=>[K.providerId,K])),Q=new Map([...M.graph.nodes.map((K)=>[K.id,K]),...(J??[]).flatMap((K)=>K.body.nodes.map((w)=>[w.id,w]))]),R=new Map,U=(K)=>{let w=Z.get(K);if(w!==void 0)return new Set(w);let P=R.get(K);if(P!==void 0)return P;R.set(K,new Set);let B=M.graph.edges.filter((_)=>_.to===K).map((_)=>_.from);if(B.length===0)return new Set;let q=B.map((_)=>{let V=new Set(U(_)),C=Q.get(_);if(C?.handler==="runtime.script"||C?.handler==="engine.branch-result"||C?.handler==="engine.choice-result"||C?.handler==="engine.approval-join")V.add(_);return V}),N=new Set([...q[0]].filter((_)=>q.every((V)=>V.has(_))));return R.set(K,N),N},T=(K)=>{if(K.kind==="array")return{...K,items:K.items.map(T)};if(K.kind!=="object")return K;let w=K.fields.deliveryId;if(w?.kind==="literal"&&typeof w.value==="string"&&X.has(w.value)){let P=X.get(w.value),B=G.get(P.providerId);return{kind:"object",fields:{deliveryId:w,provider:{kind:"literal",value:"custom"},destination:{kind:"literal",value:B.alias},credentials:{kind:"object",fields:{}},providerId:{kind:"literal",value:B.providerId},domain:{kind:"literal",value:P.domain},...P.message===void 0?K.fields.message===void 0?{}:{message:K.fields.message}:{message:P.message}}}}return{...K,fields:Object.fromEntries(Object.entries(K.fields).map(([P,B])=>[P,T(B)]))}};for(let K of W.invocations){let w=new Set(Z.get(K.nodeId)??[]);for(let P of K.props){if(P.expression.kind!=="context"||!P.expression.path.startsWith("steps."))continue;let B=P.expression.path.split(".")[1];if(w.has(B))continue;let q=W.invocationAttributes.get(K.invocationId)?.[P.name];HW(W.document,"WOML_REUSABLE_PROP_CONTEXT_UNAVAILABLE",`Prop "${P.name}" on <${K.alias}> cannot read step "${B}" from this graph position.`,q?.valueSpan??W.document.root.openTagSpan,"Reference context.payload or a step that is guaranteed to be visible before this invocation.")}}for(let K of W.providerInvocations){let w=X.get(K.providerId),P=new Set(w.ownerNodeId===void 0?M.graph.nodes.filter((q)=>q.handler==="runtime.script").map((q)=>q.id):U(w.ownerNodeId)),B=[...K.props.flatMap((q)=>q.expression.kind==="context"?[q.expression.path]:[]),...w.message?.kind==="template"?w.message.parts.flatMap((q)=>q.kind==="contextReference"?[q.path.join(".")]:[]):[]];for(let q of B){if(!q.startsWith("steps."))continue;let N=q.split(".")[1];if(P.has(N))continue;HW(W.document,"WOML_REUSABLE_PROP_CONTEXT_UNAVAILABLE",`Custom provider <${K.alias}> cannot read step "${N}" from this notification position.`,w.messageAttribute?.valueSpan??W.document.root.openTagSpan,"Pass context.payload or a step output available before this notification.")}}let S=Y.map((K)=>({...K,inputs:T(K.inputs)})),H=M.lifecycle===void 0?void 0:{...M.lifecycle,hooks:M.lifecycle.hooks.map((K)=>({...K,actions:K.actions.map((w)=>({...w,inputs:T(w.inputs)}))}))};return{...M,graph:{...M.graph,nodes:S,...A===void 0?{}:{forEach:A}},...H===void 0?{}:{lifecycle:H},reusableDefinitions:[...W.invocations,...W.providerInvocations]}}function DE(W){return G9(W)}function Q9(W,O,M={}){let L=G9(W,O,!1,M.forcedCommunicationServices??(M.forceModelV15===!0?["telegram"]:[]));if(L.schemaVersion!==9&&L.schemaVersion!==10&&L.schemaVersion!==11&&L.schemaVersion!==12&&L.schemaVersion!==13&&L.schemaVersion!==14&&L.schemaVersion!==15&&L.schemaVersion!==16)throw Error("module compilation did not produce Model v9, v10, v11, v12, v13, v14, v15, or v16");return L}import{mkdtempSync as kE,readFileSync as R9,realpathSync as w0,rmSync as bE,statSync as mZ}from"fs";import{tmpdir as fE}from"os";import{dirname as A0,extname as dZ,isAbsolute as vE,join as lZ,relative as gL,resolve as IW,sep as xL}from"path";var cZ="woml.definition-package/v1",hL="woml.module-resolver/v1",iZ="woml.definition-package/v2",sZ="woml.definition-package/v3",nZ="woml.definition-package/v4",rZ="woml.definition-package/v5",aZ="woml.definition-package/v6",oZ="woml.definition-package/v7",tZ="woml.definition-package/v8",S9="woml.definition-package/v9",U9="woml.definition-package/v10",z9="woml.definition-package/v11";function gE(W,O){let M=O==="text/typescript"?new Bun.Transpiler({loader:"ts"}).transformSync(W):W,L=d1(M,{ecmaVersion:"latest",sourceType:"module"}),$=new Set,Y=!1,J=(A)=>{if(Array.isArray(A)){for(let G of A)J(G);return}if(typeof A!=="object"||A===null)return;let Z=A;if(Z.type==="MemberExpression"&&typeof Z.object==="object"&&Z.object!==null&&Z.object.type==="Identifier"&&Z.object.name==="services"&&Z.computed===!0)Y=!0;else if(Z.type==="MemberExpression"&&Z.computed!==!0&&typeof Z.object==="object"&&Z.object!==null&&Z.object.type==="Identifier"&&Z.object.name==="services"&&typeof Z.property==="object"&&Z.property!==null&&Z.property.type==="Identifier"&&typeof Z.property.name==="string")$.add(Z.property.name);for(let[G,X]of Object.entries(Z))if(G!=="start"&&G!=="end")J(X)};return J(L),{references:[...$].sort(),dynamic:Y}}function eZ(W,O={}){let M=SM(W,O),L=IW(O.sourcePath??W.file),$=w0(IW(O.projectRoot??A0(L))),Y=new Set,J=[];for(let A of M.sources){if(A.mediaType==="application/woml+xml")continue;let Z=R9(IW($,A.path),"utf8"),G=gE(Z,A.mediaType);if(G.dynamic){let Q=new n(A.path,Z),R=Math.max(0,Z.indexOf("services"));throw WW(A.path,"WOML_SCRIPT_SERVICE_ACCESS_DYNAMIC","Computed service access is not supported in a WOML local module.",Q.span(R,Math.min(Z.length,R+8)),"Use a static service name such as services.state.")}let X=G.references;for(let Q of X)Y.add(Q);if(X.includes("state"))J.push(A.path)}return{referencedServices:[...Y].sort(),durableStateSources:J.sort()}}var pZ=512,xE=16777216;function wO(W){return typeof W==="object"&&W!==null&&typeof W.type==="string"&&typeof W.start==="number"&&typeof W.end==="number"}function hE(W){let O=[];for(let[M,L]of Object.entries(W)){if(M==="type"||M==="start"||M==="end")continue;if(wO(L))O.push(L);else if(Array.isArray(L)){for(let $ of L)if(wO($))O.push($)}}return O}function uE(W){let O=[W];while(O.length>0){let M=O.pop();if(M.type==="CallExpression"){let L=M.callee;if(wO(L)&&L.type==="Identifier"&&L.name==="require")return M}if(M.type==="MemberExpression"){let{object:L,property:$}=M,Y=wO(L)&&L.type==="Identifier"&&L.name==="exports",J=wO(L)&&L.type==="Identifier"&&L.name==="module"&&wO($)&&($.type==="Identifier"&&$.name==="exports"||$.type==="Literal"&&$.value==="exports");if(Y||J)return M}O.push(...hE(M))}return}function zW(W){if(W===null||typeof W==="boolean"||typeof W==="string")return JSON.stringify(W);if(typeof W==="number"){if(!Number.isFinite(W))throw TypeError("Canonical WOML package values must be finite JSON numbers.");return JSON.stringify(W)}if(Array.isArray(W))return`[${W.map(zW).join(",")}]`;if(typeof W==="object"&&W!==null){let O=W;return`{${Object.keys(O).sort().map((M)=>`${JSON.stringify(M)}:${zW(O[M])}`).join(",")}}`}throw TypeError("Canonical WOML package values must be JSON-compatible.")}function $W(W){return`sha256:${new Bun.CryptoHasher("sha256").update(W).digest("hex")}`}function QM(W,O){let M=gL(W,O).split(xL).join("/");return M.length===0?".":M}function RM(W,O){let M=gL(W,O);return M===""||!M.startsWith(`..${xL}`)&&M!==".."&&!vE(M)}function WW(W,O,M,L,$){let Y={code:O,phase:"compile",message:M,file:W,location:L,...$===void 0?{}:{hint:$}};return new RO(Y)}function CO(W,O,M,L,$){throw WW(W.file,M,L,O.fromAttribute.valueSpan,$)}function $O(W,O,M){let L=M===void 0?0:Math.max(0,O.indexOf(M));return W.span(L,Math.min(O.length,L+Math.max(1,M?.length??1)))}function lE(W,O,M,L){if(!RM(O,W))CO(M,L,"WOML_MODULE_PATH_ESCAPE",`Module source "${L.from}" escapes the project boundary.`,`Project boundary: ${O}`);let $;try{if(!mZ(W).isFile())throw Error("not a file");$=w0(W)}catch{CO(M,L,"WOML_MODULE_FILE_NOT_FOUND",`Module source "${L.from}" does not resolve to a readable file.`)}if(!RM(O,$))CO(M,L,"WOML_MODULE_SYMLINK_ESCAPE",`Module source "${L.from}" resolves outside the project boundary.`,"Move the source into the project instead of following an external symlink.");return $}function pE(W,O,M){let L=QM(O,W),$=new n(L,M),Y=dZ(W)===".ts"?"ts":"js",J=new Bun.Transpiler({loader:Y}),A,Z;try{A=J.scan(M),Z=J.transformSync(M)}catch(R){throw WW(L,"WOML_MODULE_SYNTAX_INVALID",`Cannot parse module source: ${R instanceof Error?R.message:String(R)}`,$O($,M))}let G;try{let R=d1(Z,{ecmaVersion:"latest",sourceType:"module",allowHashBang:!0});if(!wO(R))throw Error("module parser returned no program");G=R}catch(R){throw WW(L,"WOML_MODULE_SYNTAX_INVALID",`Cannot parse transpiled module: ${R instanceof Error?R.message:String(R)}`,$O($,M))}let X=[],Q=G.body??[];for(let R of Q){if(!wO(R))continue;if(R.type==="ExportDefaultDeclaration")throw WW(L,"WOML_MODULE_DEFAULT_EXPORT_UNSUPPORTED","WOML modules expose named function exports only; default exports are unsupported.",$O($,M,"export default"));if(R.type!=="ExportNamedDeclaration")continue;let U=R.declaration;if(wO(U)&&U.type==="FunctionDeclaration"){if(U.generator===!0)throw WW(L,"WOML_MODULE_GENERATOR_EXPORT_UNSUPPORTED","Generator functions are not part of the Module v1 public surface.",$O($,M,"export"));let T=U.id;if(wO(T)&&T.type==="Identifier"&&T.name!==void 0)X.push(T.name);continue}throw WW(L,"WOML_MODULE_EXPORT_UNSUPPORTED","Export runtime functions directly with `export function name(...)` or `export async function name(...)`.",$O($,M,"export"),"Default exports, export lists, re-exports, classes, constants, and CommonJS exports are outside Module profile v1.")}if(uE(G)!==void 0)throw WW(L,"WOML_MODULE_COMMONJS_UNSUPPORTED","CommonJS require/exports are unsupported; use static ESM imports and direct named function exports.",$O($,M,M.includes("module.exports")?"module.exports":M.includes("require")?"require":"exports"));for(let R of A.imports){if(R.kind==="dynamic-import")throw WW(L,"WOML_MODULE_DYNAMIC_IMPORT_UNSUPPORTED",`Dynamic import of "${R.path}" is unsupported.`,$O($,M,R.path),"Use a static relative import statement so the dependency can be hashed before activation.");if(R.kind!=="import-statement")throw WW(L,"WOML_MODULE_IMPORT_UNSUPPORTED",`Import form "${R.kind}" is unsupported in Module profile v1.`,$O($,M,R.path))}return{imports:A.imports,runtimeExports:[...A.exports].sort(),functionExports:X.sort()}}function SM(W,O={}){let M=hZ(W),L=IW(O.sourcePath??W.file),$=IW(O.projectRoot??A0(L)),Y;try{Y=w0($)}catch{throw WW(W.file,"WOML_MODULE_PROJECT_ROOT_INVALID",`Module project root "${$}" is not a readable directory.`,W.root.openTagSpan)}if(!RM(Y,L))throw WW(W.file,"WOML_MODULE_DOCUMENT_ESCAPE","The importing WOML document is outside the configured project boundary.",W.root.openTagSpan);try{let H=w0(L);if(!mZ(H).isFile()||!RM(Y,H))throw Error("outside project boundary")}catch{throw WW(W.file,"WOML_MODULE_DOCUMENT_INVALID","The importing WOML document must be a readable file inside the project boundary.",W.root.openTagSpan)}let J=new Map,A=[],Z=new Map,G=0,X=(H,F)=>{let K=lE(H,Y,W,F),w=J.get(K);if(w!==void 0)return w;let P=A.indexOf(K);if(P!==-1){let k=[...A.slice(P),K].map((p)=>QM(Y,p)).join(" -> ");CO(W,F,"WOML_MODULE_GRAPH_CYCLE",`Module dependency graph contains a cycle: ${k}.`)}let B=QM(Y,K),q=B.toLocaleLowerCase("en-US"),N=Z.get(q);if(N!==void 0&&N!==B)CO(W,F,"WOML_MODULE_PATH_CASE_COLLISION",`Module paths "${N}" and "${B}" differ by case only.`);Z.set(q,B);let _=dZ(K);if(_!==".js"&&_!==".ts")CO(W,F,"WOML_MODULE_EXTENSION_UNSUPPORTED",`Module dependency "${B}" must end in .js or .ts.`);let V;try{V=R9(K,"utf8")}catch{CO(W,F,"WOML_MODULE_FILE_NOT_READABLE",`Module source "${B}" could not be read.`)}if(J.size+A.length>=pZ)CO(W,F,"WOML_MODULE_GRAPH_LIMIT_EXCEEDED",`Module graph exceeds the ${pZ}-source limit.`);if(G+=Buffer.byteLength(V),G>xE)CO(W,F,"WOML_MODULE_SIZE_LIMIT_EXCEEDED","Module graph exceeds the 16 MiB source limit.");let C=pE(K,Y,V);A.push(K);let I=[];for(let k of C.imports){if(!k.path.startsWith("./")&&!k.path.startsWith("../")){let XW=new n(B,V);throw WW(B,"WOML_MODULE_PACKAGE_IMPORT_UNAVAILABLE",`Package import "${k.path}" is unavailable until MS5.`,$O(XW,V,k.path),"Use an explicit relative .js or .ts dependency in the local-module slice.")}if(!/\.(?:js|ts)$/.test(k.path)){let XW=new n(B,V);throw WW(B,"WOML_MODULE_IMPORT_EXTENSION_REQUIRED",`Static import "${k.path}" requires an explicit .js or .ts extension.`,$O(XW,V,k.path))}let p=X(IW(A0(K),k.path),F);I.push(p.portablePath)}A.pop();let b={absolutePath:K,portablePath:B,source:V,mediaType:_===".ts"?"text/typescript":"text/javascript",digest:$W(V),dependencies:[...new Set(I)].sort(),functionExports:C.functionExports,runtimeExports:C.runtimeExports};return J.set(K,b),b},Q=[],R=new Map;for(let H of M.modules){let F=X(IW(A0(L),H.from),H),K=R.get(F.absolutePath);if(K!==void 0)CO(W,H,"WOML_MODULE_SOURCE_DUPLICATE",`Module source "${H.from}" is already exposed as "${K}".`,"Declare one stable services alias for each module entry point.");R.set(F.absolutePath,H.name);let w=F.runtimeExports.filter((P)=>!F.functionExports.includes(P));if(w.length>0){let P=new n(F.portablePath,F.source);throw WW(F.portablePath,"WOML_MODULE_EXPORT_UNSUPPORTED",`Module runtime export "${w[0]}" is not a direct named function export.`,$O(P,F.source,w[0]))}if(F.functionExports.length===0){let P=new n(F.portablePath,F.source);throw WW(F.portablePath,"WOML_MODULE_EXPORTS_EMPTY","A declared WOML module requires at least one named function export.",$O(P,F.source))}Q.push({name:H.name,entrypoint:F.portablePath,exports:F.functionExports})}let U=QM(Y,L),T=[{path:U,mediaType:"application/woml+xml",digest:$W(W.source),dependencies:Q.map((H)=>H.entrypoint).sort()},...[...J.values()].sort((H,F)=>H.portablePath.localeCompare(F.portablePath)).map((H)=>({path:H.portablePath,mediaType:H.mediaType,digest:H.digest,dependencies:H.dependencies}))],S={schemaVersion:1,profile:cZ,executable:!1,workflow:{id:M.workflowId,source:U},modules:Q.sort((H,F)=>H.name.localeCompare(F.name)),sources:T,compiler:{name:"woml",version:"0.1.0",resolverProfile:hL},permissions:{secrets:[],networkOrigins:[]}};return{...S,rootHash:$W(zW(S))}}function mE(W,O,M){let L=new Map;for(let $ of M){if($.mediaType==="application/woml+xml")continue;let Y=IW(O,$.path);for(let J of[Y,gL(process.cwd(),Y),$.path])L.set(J.split(xL).join("/"),$.path)}return W.replace(/^\/\/ (.+)$/gm,($,Y)=>{let J=L.get(Y.replaceAll("\\","/"));return J===void 0?$:`// ${J}`}).replace(/^\/\/# debugId=.*(?:\n|$)/gm,"").replace(/\n+$/,`
29
+ `)}function dE(W,O,M,L){let $;try{$=JSON.parse(W)}catch{throw WW("module-source-map","WOML_MODULE_SOURCE_MAP_INVALID","Bun produced an invalid JSON source map.",new n("module-source-map",W).span(0,1))}let{sources:Y,sourcesContent:J}=$;if(!Array.isArray(Y)||!Array.isArray(J))throw WW("module-source-map","WOML_MODULE_SOURCE_MAP_INVALID","The module source map must retain source names and source content.",new n("module-source-map",W).span(0,1));let A=new Map(L.map((G)=>[G.path,G])),Z=[];for(let G=0;G<Y.length;G+=1){let X=Y[G],Q=J[G];if(typeof X!=="string"||typeof Q!=="string")throw WW("module-source-map","WOML_MODULE_SOURCE_MAP_INVALID","The module source map contains a non-text source entry.",new n("module-source-map",W).span(0,1));let R;try{R=w0(IW(A0(O),X))}catch{throw WW("module-source-map","WOML_MODULE_SOURCE_MAP_SOURCE_UNKNOWN",`The module source map references an unknown source "${X}".`,new n("module-source-map",W).span(0,1))}if(!RM(M,R))throw WW("module-source-map","WOML_MODULE_SOURCE_MAP_ESCAPE","The module source map references a file outside the project boundary.",new n("module-source-map",W).span(0,1));let U=QM(M,R),T=A.get(U);if(T===void 0||T.digest!==$W(Q))throw WW(U,"WOML_MODULE_SOURCE_CHANGED_DURING_BUILD",`Module source "${U}" changed while its immutable bundle was being built.`,new n(U,Q).span(0,1),"Run the build again after the source editor has finished writing.");Z.push(U)}return $.sources=Z,delete $.debugId,delete $.sourceRoot,delete $.file,zW($)}function cE(W,O){let M=O[0],L=M?.message??"Bun could not compile the module.",$=M?.position?.file,Y=$===void 0?W.entrypoint:$,J="";try{J=R9(Y,"utf8")}catch{}let A=new n(Y,J),Z=Math.max(1,M?.position?.line??1),G=Math.max(1,M?.position?.column??1),X=A.offsetAt(Z,G);return WW(Y,"WOML_MODULE_BUILD_FAILED",`Cannot compile module "${W.name}": ${L}`,A.span(X,Math.min(J.length,X+1)))}function iE(W){let O=["// Generated by WOML Module System MS2. Do not edit.","export interface WomlImportedServices {"];for(let M of W){O.push(` readonly ${JSON.stringify(M.name)}: Readonly<{`);for(let L of M.exports)O.push(` readonly ${JSON.stringify(L)}: (...args: readonly unknown[]) => unknown | Promise<unknown>;`);O.push(" }>;")}return O.push("}","","declare const services: WomlImportedServices;",""),O.join(`
30
+ `)}async function V9(W,O={}){let M=SM(W,O);if(M.modules.length===0)throw WW(W.file,"WOML_MODULES_REQUIRED","Definition Package v2 is reserved for workflows that declare at least one module.",W.root.openTagSpan);let L=IW(O.sourcePath??W.file),$=w0(IW(O.projectRoot??A0(L))),Y=kE(lZ(fE(),"woml-ms2-build-")),J=[],A=[];try{for(let K of M.modules){let w=lZ(Y,K.name),P=await Bun.build({entrypoints:[IW($,K.entrypoint)],root:$,outdir:w,naming:"[name].[ext]",target:"bun",format:"esm",splitting:!1,sourcemap:"external",packages:"bundle",allowUnresolved:[],env:"disable",minify:!1});if(!P.success)throw cE(K,P.logs);let B=P.outputs.find((k)=>k.kind==="entry-point"),q=P.outputs.find((k)=>k.kind==="sourcemap");if(B===void 0||q===void 0)throw WW(K.entrypoint,"WOML_MODULE_BUILD_OUTPUT_MISSING",`Bun did not produce both an ESM bundle and source map for module "${K.name}".`,new n(K.entrypoint,"").span(0,0));let N=mE(await B.text(),$,M.sources),_=dE(await q.text(),q.path,$,M.sources);if(N.includes($)||_.includes($))throw WW(K.entrypoint,"WOML_MODULE_ARTIFACT_PATH_LEAK","A compiled module artifact contains an absolute developer-machine path.",new n(K.entrypoint,"").span(0,0));let V=`modules/${K.name}.mjs`,C=`modules/${K.name}.mjs.map`,I=$W(N),b=$W(_);J.push({path:V,kind:"module-bundle",mediaType:"text/javascript",digest:I,content:N},{path:C,kind:"source-map",mediaType:"application/source-map+json",digest:b,content:_}),A.push({...K,bundle:{path:V,digest:I},sourceMap:{path:C,digest:b}})}}finally{bE(Y,{recursive:!0,force:!0})}if(SM(W,O).rootHash!==M.rootHash)throw WW(W.file,"WOML_MODULE_SOURCE_CHANGED_DURING_BUILD","The WOML source or module graph changed while the immutable package was being built.",W.root.openTagSpan,"Run the build again after the source editor has finished writing.");let G=A.map((K)=>({name:K.name,bundleDigest:K.bundle.digest,sourceMapDigest:K.sourceMap.digest,exports:K.exports})),X=eZ(W,O),Q=["telegram","discord","whatsapp"].filter((K)=>X.referencedServices.includes(K)&&!M.modules.some((w)=>w.name===K)),R=Q9(W,{profileVersion:1,modules:G},{forcedCommunicationServices:Q}),U=zW(R),T=$W(U),S=iE(M.modules);J.unshift({path:`workflow.compiled.v${R.schemaVersion}.json`,kind:"workflow-model",mediaType:"application/json",digest:T,content:U}),J.push({path:"types/services.generated.d.ts",kind:"type-declarations",mediaType:"text/typescript",digest:$W(S),content:S});let H={executable:!0,runtimeReady:!1,workflow:{id:M.workflow.id,source:M.workflow.source,modelDigest:T,model:R},modules:A,sources:M.sources,artifacts:J,compiler:{name:"woml",version:"0.1.0",resolverProfile:hL,bundler:{name:"bun",version:Bun.version,target:"bun",format:"esm",sourceMap:"external"}},permissions:M.permissions};if(R.schemaVersion===16){let K={schemaVersion:11,profile:z9,...H,workflow:{...H.workflow,model:R},definitions:[]};return{...K,rootHash:$W(zW(K))}}if(R.schemaVersion===15){let K={schemaVersion:10,profile:U9,...H,workflow:{...H.workflow,model:R},definitions:[]};return{...K,rootHash:$W(zW(K))}}if(R.schemaVersion===14){let K={schemaVersion:9,profile:S9,...H,workflow:{...H.workflow,model:R},definitions:[]};return{...K,rootHash:$W(zW(K))}}if(R.schemaVersion===13){let K={schemaVersion:8,profile:tZ,...H,workflow:{...H.workflow,model:R}};return{...K,rootHash:$W(zW(K))}}if(R.schemaVersion===12){let K={schemaVersion:7,profile:oZ,...H,workflow:{...H.workflow,model:R}};return{...K,rootHash:$W(zW(K))}}if(R.schemaVersion===11){let K={schemaVersion:6,profile:aZ,...H,workflow:{...H.workflow,model:R}};return{...K,rootHash:$W(zW(K))}}if(R.schemaVersion===10){let K={schemaVersion:4,profile:nZ,...H,workflow:{...H.workflow,model:R}};return{...K,rootHash:$W(zW(K))}}let F={schemaVersion:2,profile:iZ,...H,workflow:{...H.workflow,model:R}};return{...F,rootHash:$W(zW(F))}}async function sE(W,O,M={}){if(O.root.kind!=="workflow")throw WW(W.file,"WOML_DEFINITION_NOT_RUNNABLE","A reusable definition package requires a workflow entry document.",O.root.definition.openTagSpan);let L=IW(M.sourcePath??W.file),$=w0(IW(M.projectRoot??A0(L))),Y=Z9(W,O,{projectRoot:$});if(Y.invocations.length===0&&Y.providerInvocations.length===0)throw WW(W.file,"WOML_REUSABLE_STEP_USAGE_REQUIRED","Definition Package v9 requires at least one custom-step or custom-provider invocation.",O.root.definition.openTagSpan);let J=SM(Y.document,{sourcePath:L,projectRoot:$}),A=J.modules.length>0?await V9(Y.document,{sourcePath:L,projectRoot:$}):void 0,Z=A?.workflow.model.moduleRuntime,G=X9(Y,Z),X=zW(G),Q=$W(X),R=new Map((A?.sources??J.sources).map((C)=>[C.path,C])),U=Y.definitions.map((C)=>C.source).sort(),T=new Map(Y.definitions.map((C)=>[C.source,C])),S=O.sources.map((C)=>{let I=R.get(C.path),b=T.get(C.path),k=C.path===Y.rootSource?[...new Set([...I?.dependencies??[],...U])].sort():b===void 0?I?.dependencies??[]:b.imports.map((p)=>gL($,IW(A0(L),p.from)).split(xL).join("/")).sort();return{path:C.path,mediaType:C.kind==="script-module"?C.path.endsWith(".ts")?"text/typescript":"text/javascript":"application/woml+xml",digest:C.digest,dependencies:k}}).sort((C,I)=>C.path.localeCompare(I.path)),H=(A?.artifacts??[]).filter((C)=>C.kind==="module-bundle"||C.kind==="source-map"),F=Y.definitions.map((C)=>({path:`definitions/${C.scriptArtifactId}.js`,kind:"module-bundle",mediaType:"text/javascript",digest:$W(C.scriptSource),content:C.scriptSource})),K=[...Y.invocations,...Y.providerInvocations].flatMap((C)=>{return Y.definitions.find((b)=>b.alias===C.alias).lifecycleScripts.map((b)=>({path:`definitions/${C.kind==="step"?C.invocationId:C.providerId}.${b.hook}.${b.index}.js`,kind:"module-bundle",mediaType:"text/javascript",digest:$W(b.source),content:b.source}))}),w=["// Generated by WOML reusable definitions SCP3. Do not edit.",...Y.definitions.flatMap((C)=>[`export interface ${C.alias.replace(/(^|-)([a-z0-9])/g,(I,b,k)=>k.toUpperCase())}Props {`,...C.props.map((I)=>` readonly ${JSON.stringify(I.bindingName)}${I.required?"":"?"}: string;`),"}"]),""].join(`
31
+ `),P=[{path:`workflow.compiled.v${G.schemaVersion}.json`,kind:"workflow-model",mediaType:"application/json",digest:Q,content:X},...H,...F,...K,{path:"types/props.generated.d.ts",kind:"type-declarations",mediaType:"text/typescript",digest:$W(w),content:w}].sort((C,I)=>C.path.localeCompare(I.path)),B=Y.definitions.map((C)=>({alias:C.alias,kind:C.kind,source:C.source,digest:C.digest,dependencies:S.find((I)=>I.path===C.source)?.dependencies??[],props:C.props.map((I)=>({name:I.name,bindingName:I.bindingName,required:I.required,secret:I.secret}))})).sort((C,I)=>C.alias.localeCompare(I.alias)),q=[...new Set([...[...Y.invocations,...Y.providerInvocations].flatMap((C)=>C.props.flatMap((I)=>I.expression.kind==="secret"?[I.expression.name]:[])),...G.schemaVersion===15?G.communication.providers.flatMap((C)=>C.credentialNames):[],...A?.permissions.secrets??[]])].sort(),N={executable:!0,workflow:{id:G.workflowId,source:Y.rootSource,modelDigest:Q,model:G},definitions:B,modules:A?.modules??[],sources:S,artifacts:P,compiler:A?.compiler??{name:"woml",version:"0.1.0",resolverProfile:hL,bundler:{name:"bun",version:Bun.version,target:"bun",format:"esm",sourceMap:"external"}},permissions:{secrets:q,networkOrigins:A?.permissions.networkOrigins??[]}},_=G.schemaVersion!==15||G.communication.providers.every((C)=>C.provider==="telegram"||C.provider==="discord"||C.provider==="whatsapp"),V=G.schemaVersion===16?{schemaVersion:11,profile:z9,runtimeReady:!0,...N,workflow:{...N.workflow,model:G}}:G.schemaVersion===15?{schemaVersion:10,profile:U9,runtimeReady:_,...N,workflow:{...N.workflow,model:G}}:{schemaVersion:9,profile:S9,runtimeReady:!0,...N,workflow:{...N.workflow,model:G}};return{...V,rootHash:$W(zW(V))}}async function nE(W,O={}){let M=await V9(W,O);if(M.schemaVersion===11){let{rootHash:$,...Y}=M,J={...Y,runtimeReady:!0};return{...J,rootHash:$W(zW(J))}}if(M.schemaVersion===10){let $=M.workflow.model.communication.providers.find((Z)=>Z.provider!=="telegram"&&Z.provider!=="discord");if($!==void 0)throw WW(W.file,"WOML_COMMUNICATION_RUNTIME_UNAVAILABLE",`The built-in ${$.provider} provider is not executable in this runtime.`,W.root.openTagSpan,"Use a currently supported built-in provider or a custom notification provider.");let{rootHash:Y,...J}=M,A={...J,runtimeReady:!0};return{...A,rootHash:$W(zW(A))}}if(M.schemaVersion===9){let{rootHash:$,...Y}=M,J={...Y,runtimeReady:!0};return{...J,rootHash:$W(zW(J))}}if(M.schemaVersion===8)throw WW(W.file,"WOML_FORK_RUNTIME_UNAVAILABLE","Fork and control-choice syntax compiled successfully, but Model v13 execution begins in FJ5.",W.root.openTagSpan,"Use `woml check` to review Definition Package v8 during FJ3.");if(M.schemaVersion===7)throw WW(W.file,"WOML_RUNTIME_POLICY_RUNTIME_UNAVAILABLE","Runtime-policy syntax compiled successfully, but Model v12 local-module runtime packaging is not available yet.",W.root.openTagSpan,"Use `woml check` to review Definition Package v7; runtime-package integration is scheduled for RP6.");if(M.schemaVersion===6)throw WW(W.file,"WOML_LIFECYCLE_RUNTIME_UNAVAILABLE","Lifecycle syntax compiled successfully, but durable lifecycle execution begins in LEC2 and LEC3.",W.root.openTagSpan,"Use `woml check` to review the Model v11 definition during LEC1.");if(M.schemaVersion===4){let $={schemaVersion:5,profile:rZ,executable:M.executable,runtimeReady:!0,compilationRootHash:M.rootHash,workflow:M.workflow,modules:M.modules,sources:M.sources,artifacts:M.artifacts,compiler:M.compiler,permissions:M.permissions};return{...$,rootHash:$W(zW($))}}let L={schemaVersion:3,profile:sZ,executable:M.executable,runtimeReady:!0,compilationRootHash:M.rootHash,workflow:M.workflow,modules:M.modules,sources:M.sources,artifacts:M.artifacts,compiler:M.compiler,permissions:M.permissions};return{...L,rootHash:$W(zW(L))}}var rE="/callbacks/whatsapp";function WG(W){return JSON.stringify(W)}function aE(W){let O=new Map;for(let L of W){let $=O.get(L.name)??new Set;for(let Y of L.exports)$.add(Y);O.set(L.name,$)}return`// Generated by WOML. Run \`woml types\` to refresh this file.
32
32
  // Local modules receive services only. Pass context, attempt, and individual
33
33
  // secret values explicitly from the calling WOML step.
34
34
 
@@ -245,18 +245,18 @@ interface WomlBuiltinServices {
245
245
  }
246
246
 
247
247
  interface WomlImportedServices {
248
- ${[...O.entries()].sort(([L],[$])=>L.localeCompare($)).flatMap(([L,$])=>[` readonly ${tZ(L)}: Readonly<{`,...[...$].sort().map((Y)=>` readonly ${tZ(Y)}: (...args: readonly any[]) => any;`)," }>;"]).join(`
248
+ ${[...O.entries()].sort(([L],[$])=>L.localeCompare($)).flatMap(([L,$])=>[` readonly ${WG(L)}: Readonly<{`,...[...$].sort().map((Y)=>` readonly ${WG(Y)}: (...args: readonly any[]) => any;`)," }>;"]).join(`
249
249
  `)}
250
250
  }
251
251
 
252
252
  declare const services: Readonly<WomlBuiltinServices & WomlImportedServices>;
253
- `}var e0="dev.woml.cli.secrets.v1",RM="WOML_SECRET_",WX="WOML_SECRETS_PROVIDER",U9="WOML_SECRETS_DIRECTORY",eZ=2048;class c extends Error{code;constructor(W,O,M){super(O,M);this.name="SecretStoreError",this.code=W}}function mW(W){if(TO(W))return;throw new c("WOML_SECRET_NAME_INVALID","Secret names must start with A-Z and contain only A-Z, 0-9, or underscore.")}function gL(W){let O=new TextEncoder().encode(W).byteLength;if(O===0)throw new c("WOML_SECRET_VALUE_EMPTY","Secret values must not be empty.");if(O>eZ)throw new c("WOML_SECRET_VALUE_TOO_LARGE",`Secret values must not exceed ${eZ} UTF-8 bytes.`)}async function dP(W,O){let M=[];for(let L of[...new Set(W.map(($)=>$.name))])if(mW(L),!await O.has(L))M.push(L);if(M.length>0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required secret${M.length===1?"":"s"}: ${M.join(", ")}.`)}var OX="__woml_metadata_index_v1__";function sE(){let W=Bun.secrets;if(W!==void 0)return W;throw new c("WOML_SECRET_STORE_UNAVAILABLE","This Bun runtime does not provide OS-native secret storage. Upgrade to a Bun release with Bun.secrets support.")}function hL(W){if(W instanceof c)return W;return new c("WOML_SECRET_STORE_UNAVAILABLE","The operating-system credential store is unavailable or locked.",{cause:W})}class uL{provider="os-keychain";#W;#O;constructor(W=sE(),O=()=>new Date){this.#W=W,this.#O=O}async get(W){mW(W);try{return await this.#W.get({service:e0,name:W})??void 0}catch(O){throw hL(O)}}async has(W){return await this.get(W)!==void 0}async list(){return(await this.#M()).secrets.map((O)=>({name:O.name,provider:this.provider,updatedAt:O.updatedAt}))}async set(W,O){mW(W),gL(O);try{let M=await this.#M();await this.#W.set({service:e0,name:W,value:O,allowUnrestrictedAccess:!1});let L=M.secrets.filter(($)=>$.name!==W);L.push({name:W,updatedAt:this.#O().toISOString()}),L.sort(($,Y)=>$.name.localeCompare(Y.name)),await this.#L({version:1,secrets:L})}catch(M){throw hL(M)}}async delete(W){mW(W);try{let O=await this.#M(),M=await this.#W.delete({service:e0,name:W});if(O.secrets.some((L)=>L.name===W))await this.#L({version:1,secrets:O.secrets.filter((L)=>L.name!==W)});return M}catch(O){throw hL(O)}}async#M(){let W;try{W=await this.#W.get({service:e0,name:OX})}catch(O){throw hL(O)}if(W===null)return{version:1,secrets:[]};try{let O=JSON.parse(W);if(O.version!==1||!Array.isArray(O.secrets))throw null;let M=new Set;return{version:1,secrets:O.secrets.map(($)=>{if(typeof $!=="object"||$===null||!("name"in $)||!("updatedAt"in $)||typeof $.name!=="string"||typeof $.updatedAt!=="string"||!Number.isFinite(Date.parse($.updatedAt))||M.has($.name))throw null;return mW($.name),M.add($.name),{name:$.name,updatedAt:$.updatedAt}})}}catch(O){throw new c("WOML_SECRET_INDEX_INVALID","The protected WOML secret metadata index is invalid.",{cause:O})}}async#L(W){await this.#W.set({service:e0,name:OX,value:JSON.stringify(W),allowUnrestrictedAccess:!1})}}class lL{provider="environment";#W;constructor(W=process.env){this.#W=W}async get(W){mW(W);let O=this.#W[`${RM}${W}`];return O===""?void 0:O}async has(W){return await this.get(W)!==void 0}async list(){return Object.keys(this.#W).filter((W)=>W.startsWith(RM)).map((W)=>W.slice(RM.length)).filter(nE).filter((W)=>this.#W[`${RM}${W}`]!=="").sort().map((W)=>({name:W,provider:this.provider}))}async set(W,O){throw this.#O()}async delete(W){throw this.#O()}#O(){return new c("WOML_SECRET_PROVIDER_READ_ONLY","The environment secret provider is read-only. Configure WOML_SECRET_<NAME> in the CI secret manager.")}}function nE(W){try{return mW(W),!0}catch{return!1}}import{lstat as MX,readdir as rE,readFile as aE,realpath as oE}from"fs/promises";import{isAbsolute as tE,join as eE,resolve as Wq}from"path";function xO(W,O){return new c("WOML_SECRET_FILE_UNSAFE",W,{cause:O})}class pL{provider="mounted-files";#W;constructor(W){if(!tE(W))throw xO("WOML_SECRETS_DIRECTORY must be an absolute path.");this.#W=Wq(W)}async get(W){mW(W),await this.#O();let O=eE(this.#W,W),M;try{M=await MX(O)}catch($){if($ instanceof Error&&"code"in $&&$.code==="ENOENT")return;throw xO(`Mounted secret ${W} could not be inspected.`,$)}if(M.isSymbolicLink()||!M.isFile())throw xO(`Mounted secret ${W} must be a regular file, not a link.`);if(process.platform!=="win32"){let $=typeof process.getuid==="function"?process.getuid():void 0;if($!==void 0&&M.uid!==$&&M.uid!==0)throw xO(`Mounted secret ${W} must be owned by the runtime user or root.`);if((M.mode&63)!==0)throw xO(`Mounted secret ${W} must not be accessible by group or other users.`)}if(M.size>2049)throw new c("WOML_SECRET_VALUE_TOO_LARGE","Mounted secret values must not exceed 2048 UTF-8 bytes.");let L=await aE(O,"utf8");if(L.endsWith(`\r
253
+ `}var J1="dev.woml.cli.secrets.v1",UM="WOML_SECRET_",MG="WOML_SECRETS_PROVIDER",H9="WOML_SECRETS_DIRECTORY",OG=2048;class c extends Error{code;constructor(W,O,M){super(O,M);this.name="SecretStoreError",this.code=W}}function mW(W){if(EO(W))return;throw new c("WOML_SECRET_NAME_INVALID","Secret names must start with A-Z and contain only A-Z, 0-9, or underscore.")}function uL(W){let O=new TextEncoder().encode(W).byteLength;if(O===0)throw new c("WOML_SECRET_VALUE_EMPTY","Secret values must not be empty.");if(O>OG)throw new c("WOML_SECRET_VALUE_TOO_LARGE",`Secret values must not exceed ${OG} UTF-8 bytes.`)}async function nN(W,O){let M=[];for(let L of[...new Set(W.map(($)=>$.name))])if(mW(L),!await O.has(L))M.push(L);if(M.length>0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required secret${M.length===1?"":"s"}: ${M.join(", ")}.`)}var LG="__woml_metadata_index_v1__";function oE(){let W=Bun.secrets;if(W!==void 0)return W;throw new c("WOML_SECRET_STORE_UNAVAILABLE","This Bun runtime does not provide OS-native secret storage. Upgrade to a Bun release with Bun.secrets support.")}function lL(W){if(W instanceof c)return W;return new c("WOML_SECRET_STORE_UNAVAILABLE","The operating-system credential store is unavailable or locked.",{cause:W})}class pL{provider="os-keychain";#W;#O;constructor(W=oE(),O=()=>new Date){this.#W=W,this.#O=O}async get(W){mW(W);try{return await this.#W.get({service:J1,name:W})??void 0}catch(O){throw lL(O)}}async has(W){return await this.get(W)!==void 0}async list(){return(await this.#M()).secrets.map((O)=>({name:O.name,provider:this.provider,updatedAt:O.updatedAt}))}async set(W,O){mW(W),uL(O);try{let M=await this.#M();await this.#W.set({service:J1,name:W,value:O,allowUnrestrictedAccess:!1});let L=M.secrets.filter(($)=>$.name!==W);L.push({name:W,updatedAt:this.#O().toISOString()}),L.sort(($,Y)=>$.name.localeCompare(Y.name)),await this.#L({version:1,secrets:L})}catch(M){throw lL(M)}}async delete(W){mW(W);try{let O=await this.#M(),M=await this.#W.delete({service:J1,name:W});if(O.secrets.some((L)=>L.name===W))await this.#L({version:1,secrets:O.secrets.filter((L)=>L.name!==W)});return M}catch(O){throw lL(O)}}async#M(){let W;try{W=await this.#W.get({service:J1,name:LG})}catch(O){throw lL(O)}if(W===null)return{version:1,secrets:[]};try{let O=JSON.parse(W);if(O.version!==1||!Array.isArray(O.secrets))throw null;let M=new Set;return{version:1,secrets:O.secrets.map(($)=>{if(typeof $!=="object"||$===null||!("name"in $)||!("updatedAt"in $)||typeof $.name!=="string"||typeof $.updatedAt!=="string"||!Number.isFinite(Date.parse($.updatedAt))||M.has($.name))throw null;return mW($.name),M.add($.name),{name:$.name,updatedAt:$.updatedAt}})}}catch(O){throw new c("WOML_SECRET_INDEX_INVALID","The protected WOML secret metadata index is invalid.",{cause:O})}}async#L(W){await this.#W.set({service:J1,name:LG,value:JSON.stringify(W),allowUnrestrictedAccess:!1})}}class mL{provider="environment";#W;constructor(W=process.env){this.#W=W}async get(W){mW(W);let O=this.#W[`${UM}${W}`];return O===""?void 0:O}async has(W){return await this.get(W)!==void 0}async list(){return Object.keys(this.#W).filter((W)=>W.startsWith(UM)).map((W)=>W.slice(UM.length)).filter(tE).filter((W)=>this.#W[`${UM}${W}`]!=="").sort().map((W)=>({name:W,provider:this.provider}))}async set(W,O){throw this.#O()}async delete(W){throw this.#O()}#O(){return new c("WOML_SECRET_PROVIDER_READ_ONLY","The environment secret provider is read-only. Configure WOML_SECRET_<NAME> in the CI secret manager.")}}function tE(W){try{return mW(W),!0}catch{return!1}}import{lstat as $G,readdir as eE,readFile as Wq,realpath as Oq}from"fs/promises";import{isAbsolute as Mq,join as Lq,resolve as $q}from"path";function lO(W,O){return new c("WOML_SECRET_FILE_UNSAFE",W,{cause:O})}class dL{provider="mounted-files";#W;constructor(W){if(!Mq(W))throw lO("WOML_SECRETS_DIRECTORY must be an absolute path.");this.#W=$q(W)}async get(W){mW(W),await this.#O();let O=Lq(this.#W,W),M;try{M=await $G(O)}catch($){if($ instanceof Error&&"code"in $&&$.code==="ENOENT")return;throw lO(`Mounted secret ${W} could not be inspected.`,$)}if(M.isSymbolicLink()||!M.isFile())throw lO(`Mounted secret ${W} must be a regular file, not a link.`);if(process.platform!=="win32"){let $=typeof process.getuid==="function"?process.getuid():void 0;if($!==void 0&&M.uid!==$&&M.uid!==0)throw lO(`Mounted secret ${W} must be owned by the runtime user or root.`);if((M.mode&63)!==0)throw lO(`Mounted secret ${W} must not be accessible by group or other users.`)}if(M.size>2049)throw new c("WOML_SECRET_VALUE_TOO_LARGE","Mounted secret values must not exceed 2048 UTF-8 bytes.");let L=await Wq(O,"utf8");if(L.endsWith(`\r
254
254
  `))L=L.slice(0,-2);else if(L.endsWith(`
255
- `))L=L.slice(0,-1);if(L.includes("\x00"))throw xO(`Mounted secret ${W} contains a NUL byte.`);return gL(L),L}async has(W){return await this.get(W)!==void 0}async list(){await this.#O();let W=(await rE(this.#W)).sort(),O=[];for(let M of W){try{mW(M)}catch{continue}if(await this.get(M)!==void 0)O.push({name:M,provider:this.provider})}return O}async set(W,O){throw this.#M()}async delete(W){throw this.#M()}async#O(){let W;try{if(W=await MX(this.#W),W.isSymbolicLink()||!W.isDirectory())throw null;if(await oE(this.#W)!==this.#W)throw null}catch(O){throw xO("WOML_SECRETS_DIRECTORY must be a real, existing directory.",O)}if(process.platform!=="win32"){let O=typeof process.getuid==="function"?process.getuid():void 0;if(O!==void 0&&W.uid!==O&&W.uid!==0)throw xO("WOML_SECRETS_DIRECTORY must be owned by the runtime user or root.");if((W.mode&18)!==0)throw xO("WOML_SECRETS_DIRECTORY must not be writable by group or other users.")}}#M(){return new c("WOML_SECRET_PROVIDER_READ_ONLY","The mounted-file secret provider is read-only. Update the mounted secret through the deployment platform.")}}class z9{provider="production";#W;constructor(W){if(W.length===0)throw new c("WOML_SECRET_PROVIDER_INVALID","The production secret provider requires at least one source.");this.#W=W}async get(W){mW(W);let O=[];for(let M of this.#W){let L=await M.get(W);if(L!==void 0)O.push({provider:M.provider,value:L})}if(O.length===0)return;if(O.some((M)=>M.value!==O[0].value))throw new c("WOML_SECRET_SOURCE_CONFLICT",`Secret ${W} has conflicting values in configured production sources: ${O.map((M)=>M.provider).join(", ")}.`);return O[0].value}async has(W){return await this.get(W)!==void 0}async list(){let W=new Set;for(let M of this.#W)for(let L of await M.list())W.add(L.name);let O=[];for(let M of[...W].sort())await this.get(M),O.push({name:M,provider:this.provider});return O}async set(W,O){throw this.#O()}async delete(W){throw this.#O()}#O(){return new c("WOML_SECRET_PROVIDER_READ_ONLY","The production secret provider is read-only. Rotate the selected environment, mounted-file, or OS source directly.")}}function LX(W=process.env){let O=W[WX]??"os";if(O==="os")return new uL;if(O==="env")return new lL(W);if(O==="files"){let M=W[U9];if(M===void 0||M.length===0)throw new c("WOML_SECRET_PROVIDER_INVALID",'WOML_SECRETS_DIRECTORY is required when WOML_SECRETS_PROVIDER="files".');return new pL(M)}if(O==="production"){let M=[],L=W[U9];if(L!==void 0&&L.length>0)M.push(new pL(L));return M.push(new lL(W),new uL),new z9(M)}throw new c("WOML_SECRET_PROVIDER_INVALID",'WOML_SECRETS_PROVIDER must be "os", "env", "files", or "production".')}import{createHash as Oq,randomUUID as Mq}from"crypto";var SO="woml.notification-provider-host",wO=1,UM=2,mL=1048576;class kW extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="SlackTransportError"}}async function $X(W,O){let M=await W.get(O.botToken.name),L=await W.get(O.appToken.name),$=[...M===void 0||M.length===0?[O.botToken.name]:[],...L===void 0||L.length===0?[O.appToken.name]:[]];if($.length>0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required Slack credential${$.length===1?"":"s"}: ${$.join(", ")}.`);return{botToken:M,appToken:L}}function YX(W,O){return`${W}${Oq("sha256").update(O).digest("hex").slice(0,8).toUpperCase()}`}class V9{#W;#O;#M;#L;#G;#$;#Y=new Map;#Z=new Map;#A=new Map;#X=new Set;#Q=new Map;#R=0;#J=!1;constructor(W){this.#W=W.emit,this.#O=W.automaticDecision,this.#M=W.automaticActorId??"U12345678",this.#L=W.automaticDelayMs??0,this.#G=W.deliveryFailuresBeforeSuccess??0,this.#$=new Set(W.failedDestinations??[])}get connectionCount(){return this.#Y.size}messages(){return[...this.#Z.values()]}async ensureConnection(W,O){if(this.#J)throw this.#S();let M=this.#Y.get(W);if(M!==void 0&&M!==O)throw new kW({kind:"provider_auth_failed",code:"WOML_SLACK_AUTH_FAILED",message:"The Slack app credential changed while its connection was active.",retryable:!1});this.#Y.set(W,O)}async deliver(W){if(this.#J)throw this.#S();if(this.#$.has(W.invocation.destination))throw new kW({kind:"destination_invalid",code:"WOML_SLACK_DESTINATION_INVALID",message:`The fake Slack destination ${W.invocation.destination} is unavailable.`,retryable:!1});let O=(this.#Q.get(W.invocation.deliveryId)??0)+1;if(this.#Q.set(W.invocation.deliveryId,O),O<=this.#G)throw new kW({kind:"rate_limited",code:"WOML_SLACK_RATE_LIMITED",message:"The fake Slack transport is temporarily rate-limited.",retryable:!0,retryAfterMs:1});let M=this.#A.get(W.invocation.idempotencyKey);if(M!==void 0)return M.providerMessage;this.#R+=1;let L={workspaceId:YX("T",W.credentials.botToken),channelId:W.invocation.destination.startsWith("#")?YX("C",W.invocation.destination):W.invocation.destination,messageId:`${1723024800+this.#R}.${String(this.#R).padStart(6,"0")}`},$={deliveryId:W.invocation.deliveryId,destination:W.invocation.destination,providerMessage:L,...W.invocation.protocolVersion===1?{decisionCapability:W.invocation.decisionCapability}:{},message:W.invocation.protocolVersion===1?W.invocation.message.approvalName:W.invocation.message,idempotencyKey:W.invocation.idempotencyKey};if(this.#Z.set(W.invocation.deliveryId,$),this.#A.set(W.invocation.idempotencyKey,$),W.invocation.protocolVersion===1&&this.#O!==void 0)setTimeout(()=>{this.click(W.invocation.deliveryId,this.#O,this.#M)},this.#L);return L}async update(W){if(this.#J)throw this.#S();if(this.#X.has(W.invocation.idempotencyKey))return;if(!("workspaceId"in W.invocation.providerMessage))throw new kW({kind:"update_failed",code:"WOML_SLACK_UPDATE_FAILED",message:"Slack received a non-Slack message identity.",retryable:!1});let O=this.#Z.get(W.invocation.deliveryId);if(O!==void 0&&(O.providerMessage.workspaceId!==W.invocation.providerMessage.workspaceId||O.providerMessage.channelId!==W.invocation.providerMessage.channelId||O.providerMessage.messageId!==W.invocation.providerMessage.messageId))throw new kW({kind:"update_failed",code:"WOML_SLACK_UPDATE_FAILED",message:"The Slack message identity does not match the delivered message.",retryable:!1});if(O!==void 0)O.resolution=W.invocation.resolution;this.#X.add(W.invocation.idempotencyKey)}async click(W,O,M="U12345678"){if(this.#J)return;let L=this.#Z.get(W);if(L===void 0||L.resolution!==void 0||L.decisionCapability===void 0)return;await this.#W({protocol:SO,protocolVersion:wO,messageType:"interaction",interactionId:`interaction_${Mq()}`,deliveryId:W,provider:"slack",decisionCapability:L.decisionCapability,decision:O,providerActorId:M,occurredAt:new Date().toISOString()})}async close(){this.#J=!0,this.#Y.clear()}#S(){return new kW({kind:"provider_unavailable",code:"WOML_SLACK_UNAVAILABLE",message:"The fake Slack transport is closed.",retryable:!0})}}class Lq{#W=new Map;#O=new Map;#M=new Map;register(W){let O=W.adapter.provider;if(W.role==="trigger"){this.#L(this.#W,O,W.role),this.#W.set(O,W.adapter);return}if(W.role==="notification"){this.#L(this.#O,O,W.role),this.#O.set(O,W.adapter);return}this.#L(this.#M,O,W.role),this.#M.set(O,W.adapter)}triggerAdapters(){return[...this.#W.values()]}notificationAdapter(W){return this.#O.get(W)}messagingAdapter(W){return this.#M.get(W)}providers(W){return[...(W==="trigger"?this.#W:W==="notification"?this.#O:this.#M).keys()]}#L(W,O,M){if(W.has(O))throw Error(`Communication ${M} adapter "${O}" is registered more than once.`)}}class $q{#W;#O=[];#M="created";constructor(W){let O=new Set;for(let M of W){if(O.has(M.provider))throw Error(`Communication trigger adapter "${M.provider}" is registered more than once.`);O.add(M.provider)}this.#W=[...W]}providers(){return this.#W.map((W)=>W.provider)}async start(){if(this.#M!=="created")throw Error("Communication trigger host cannot be started twice.");this.#M="starting";try{for(let W of this.#W)this.#O.push(W),await W.start();this.#M="started"}catch(W){throw await this.#L(),this.#M="closed",W}}async close(){if(this.#M==="closed")return;this.#M="closed",await this.#L()}async#L(){let W=[];for(let O of this.#O.splice(0).reverse())try{await O.close()}catch(M){W.push(M)}if(W.length>0)throw AggregateError(W,"One or more communication trigger adapters failed to close.")}}class dW extends Error{failure;constructor(W){super(typeof W==="object"&&W!==null&&"message"in W&&typeof W.message==="string"?W.message:"The communication provider adapter failed.");this.failure=W;this.name="CommunicationProviderAdapterError"}}var W1=64,O1=1000;var dL=40000,JX=100;class gO extends Error{constructor(){super("WOML_PROVIDER_RESPONSE_TOO_LARGE");this.name="ProviderResponseLimitError"}}function M1(W){return W.length>0&&Buffer.byteLength(W,"utf8")<=16384&&!/[\u0000-\u001f\u007f]/u.test(W)}async function L1(W,O=1048576){let M=Number(W.headers.get("content-length"));if(Number.isFinite(M)&&M>O)throw new gO;if(W.body===null)return"";let L=W.body.getReader(),$=[],Y=0;try{for(;;){let Z=await L.read();if(Z.done)break;if(Y+=Z.value.byteLength,Y>O)throw await L.cancel(),new gO;$.push(Z.value)}}finally{L.releaseLock()}let J=new Uint8Array(Y),A=0;for(let Z of $)J.set(Z,A),A+=Z.byteLength;return new TextDecoder().decode(J)}function $1(W){let O=JSON.stringify(W);if(Buffer.byteLength(O,"utf8")>65536)throw Error("WOML_PROVIDER_REQUEST_TOO_LARGE");return O}class Y1 extends Error{constructor(W){super(W);this.name="NotificationProtocolError"}}function q0(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function RO(W,O,M=[]){let L=new Set([...O,...M]);return O.every(($)=>Object.hasOwn(W,$))&&Object.keys(W).every(($)=>L.has($))}var E0=/^.{1,320}$/s,Yq=/^[a-z][A-Za-z0-9]*$/,Jq=/^aprreq_[A-Za-z0-9_-]+$/,Aq=/^[a-z][A-Za-z0-9]*:notify:(0|[1-9][0-9]*):(channel|chat|recipient):(0|[1-9][0-9]*)$/,Zq=/^nupdate_[A-Za-z0-9_-]+$/,sL=/^sha256:[a-f0-9]{64}$/,Xq=/^(#[a-z0-9][a-z0-9_-]{0,79}|[CG][A-Z0-9]{8,31})$/,XX=/^-?[1-9][0-9]{0,19}$/,iL=/^[1-9][0-9]{16,19}$/,GX=/^[0-9]{8,16}$/,QX=/^[0-9]{6,32}$/,AX=/^[a-z][a-z0-9_]{0,511}$/,ZX=/^[a-z]{2,3}(?:_[A-Z]{2})?$/;function SX(W){return W==="slack"||W==="telegram"||W==="discord"||W==="whatsapp"}function RX(W,O){return typeof W==="string"&&(O==="slack"?Xq.test(W):O==="telegram"?XX.test(W):O==="discord"?iL.test(W):O==="whatsapp"&&GX.test(W))}function cL(W){return q0(W)&&RO(W,["kind","name"])&&W.kind==="secretReference"&&typeof W.name==="string"&&W.name.length<=255&&TO(W.name)}function UX(W,O){if(!q0(W))return!1;if(O==="telegram"||O==="discord")return RO(W,["botToken"])&&cL(W.botToken);if(O==="whatsapp")return RO(W,["accessToken","phoneNumberId"])&&cL(W.accessToken)&&typeof W.phoneNumberId==="string"&&QX.test(W.phoneNumberId);return O==="slack"&&RO(W,["botToken","appToken"])&&cL(W.botToken)&&cL(W.appToken)}function zM(W){if(q0(W)&&RO(W,["provider","accountId","conversationId","messageId"])&&(W.provider==="telegram"||W.provider==="discord"||W.provider==="whatsapp")&&typeof W.accountId==="string"&&(W.provider==="telegram"?/^[1-9][0-9]{0,19}$/.test(W.accountId):W.provider==="discord"?iL.test(W.accountId):QX.test(W.accountId))&&typeof W.conversationId==="string"&&(W.provider==="telegram"?XX.test(W.conversationId):W.provider==="discord"?iL.test(W.conversationId):GX.test(W.conversationId))&&typeof W.messageId==="string"&&(W.provider==="telegram"?/^[1-9][0-9]{0,19}$/.test(W.messageId):W.provider==="discord"?iL.test(W.messageId):W.messageId.length>=1&&W.messageId.length<=512))return!0;return q0(W)&&RO(W,["workspaceId","channelId","messageId"])&&typeof W.workspaceId==="string"&&/^T[A-Z0-9]{8,31}$/.test(W.workspaceId)&&typeof W.channelId==="string"&&/^[CGD][A-Z0-9]{8,31}$/.test(W.channelId)&&typeof W.messageId==="string"&&/^[0-9]{10,}\.[0-9]{6}$/.test(W.messageId)}function Gq(W){return W.protocol===SO&&W.protocolVersion===wO&&typeof W.invocationId==="string"&&E0.test(W.invocationId)&&typeof W.runId==="string"&&E0.test(W.runId)&&typeof W.approvalId==="string"&&Yq.test(W.approvalId)&&typeof W.requestId==="string"&&Jq.test(W.requestId)&&typeof W.deliveryId==="string"&&Aq.test(W.deliveryId)&&SX(W.provider)&&UX(W.credentials,W.provider)}function Qq(W){return W.protocol===SO&&W.protocolVersion===UM&&typeof W.invocationId==="string"&&E0.test(W.invocationId)&&typeof W.runId==="string"&&E0.test(W.runId)&&typeof W.hookInvocationId==="string"&&sL.test(W.hookInvocationId)&&typeof W.actionId==="string"&&E0.test(W.actionId)&&typeof W.deliveryId==="string"&&E0.test(W.deliveryId)&&SX(W.provider)&&RX(W.destination,W.provider)&&typeof W.idempotencyKey==="string"&&sL.test(W.idempotencyKey)&&UX(W.credentials,W.provider)}function Sq(W){return q0(W)&&RO(W,["workflowId","approvalName"],["approvalDescription","expiresAt"])&&typeof W.workflowId==="string"&&E0.test(W.workflowId)&&typeof W.approvalName==="string"&&W.approvalName.length>=1&&W.approvalName.length<=256&&(W.approvalDescription===void 0||typeof W.approvalDescription==="string"&&W.approvalDescription.length>=1&&W.approvalDescription.length<=2000)&&(W.expiresAt===void 0||typeof W.expiresAt==="string"&&Number.isFinite(Date.parse(W.expiresAt)))}function zX(W){if(!q0(W))throw new Y1("The provider host received an invalid invocation envelope.");if(W.protocolVersion===UM){let O=W.provider==="whatsapp"?["templateName","language"]:[];if(!Qq(W)||!RO(W,["protocol","protocolVersion","messageType","mode","invocationId","runId","hookInvocationId","actionId","deliveryId","provider","destination","idempotencyKey","credentials","message",...O])||W.messageType!=="deliver"||W.mode!=="informational"||typeof W.message!=="string"||W.message.length<1||[...W.message].length>4096||W.provider==="whatsapp"&&(typeof W.templateName!=="string"||!AX.test(W.templateName)||typeof W.language!=="string"||!ZX.test(W.language)))throw new Y1("The provider host received an invalid informational delivery invocation.");return}if(!Gq(W))throw new Y1("The provider host received an invalid invocation envelope.");if(W.messageType==="deliver"){let O=W.provider==="whatsapp"?["templateName","language"]:[];if(!RO(W,["protocol","protocolVersion","messageType","invocationId","runId","approvalId","requestId","deliveryId","provider","destination","idempotencyKey","credentials","decisionCapability","message",...O])||!RX(W.destination,W.provider)||typeof W.idempotencyKey!=="string"||!sL.test(W.idempotencyKey)||typeof W.decisionCapability!=="string"||W.decisionCapability.length<43||W.decisionCapability.length>512||!Sq(W.message)||W.provider==="whatsapp"&&(typeof W.templateName!=="string"||!AX.test(W.templateName)||typeof W.language!=="string"||!ZX.test(W.language)))throw new Y1("The provider host received an invalid delivery invocation.");return}if(W.messageType!=="update"||!RO(W,["protocol","protocolVersion","messageType","invocationId","runId","approvalId","requestId","deliveryId","updateId","idempotencyKey","provider","credentials","providerMessage","resolution"])||typeof W.updateId!=="string"||W.updateId.length>256||!Zq.test(W.updateId)||typeof W.idempotencyKey!=="string"||!sL.test(W.idempotencyKey)||!zM(W.providerMessage)||W.resolution!=="approved"&&W.resolution!=="rejected"&&W.resolution!=="timeout_failed")throw new Y1("The provider host received an invalid update invocation.")}var Rq=new Set(["secret_not_found","provider_auth_failed","destination_invalid","rate_limited","provider_unavailable","delivery_ambiguous","request_invalid","host_crashed","size_limit_exceeded","update_failed"]);function H9(W){return q0(W)&&RO(W,["kind","code","message","retryable"],["retryAfterMs"])&&typeof W.kind==="string"&&Rq.has(W.kind)&&typeof W.code==="string"&&/^WOML_[A-Z0-9_]+$/.test(W.code)&&typeof W.message==="string"&&W.message.length>=1&&W.message.length<=1024&&typeof W.retryable==="boolean"&&(W.retryAfterMs===void 0||Number.isSafeInteger(W.retryAfterMs)&&Number(W.retryAfterMs)>=0&&Number(W.retryAfterMs)<=86400000)}function VX(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The provider invocation failed safely."}class VM{provider="slack";#W;constructor(W){this.#W=W}async resolveCredentials(W,O){if(!("appToken"in O.credentials))throw Error("Slack requires botToken and appToken credentials.");let M=await $X(W,O.credentials);return{credentials:M,secretValues:[M.botToken,M.appToken]}}async prepare(W,O){if(!("appToken"in W.credentials))throw Error("Slack requires an appToken credential.");await this.#W.ensureConnection(W.credentials.appToken.name,O.appToken)}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A Slack update cannot be delivered as a new message.");return await this.#W.deliver({invocation:W,credentials:O})}async update(W,O){if(W.messageType!=="update")throw Error("A Slack delivery cannot be executed as an update.");if(!("workspaceId"in W.providerMessage)||!("appToken"in W.credentials))throw Error("Slack received an invalid message update identity.");await this.#W.update({invocation:W,credentials:O})}validMessageIdentity(W){return zM(W)}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_SLACK_RESPONSE_INVALID",message:"Slack returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW&&H9(W.failure))return{...W.failure,message:VX(W.failure.message,O)};if(W instanceof kW&&H9(W.failure))return{...W.failure,message:VX(W.failure.message,O)};if(W instanceof c&&W.code==="WOML_SECRET_NOT_FOUND")return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required Slack credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_SLACK_UNAVAILABLE",message:"The Slack adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function Uq(W){return Math.max(0,performance.now()-W)}function nL(W,O,M,L){return{protocol:SO,protocolVersion:W,messageType:"completed",invocationId:O,outcome:L,durationMs:Uq(M)}}function zq(W){return Buffer.byteLength(JSON.stringify(W),"utf8")}class K9{#W;#O;#M;#L;#G;#$=new Map;#Y=!1;constructor(W){if([W.adapter,W.adapters,W.transport].filter((L)=>L!==void 0).length>1)throw Error("NotificationProviderHost accepts adapters or a legacy Slack transport, not both.");if(W.adapter===void 0&&W.adapters===void 0&&W.transport===void 0)throw Error("NotificationProviderHost requires a provider adapter.");this.#W=W.secretStore;let O=W.adapters??[W.adapter??new VM(W.transport)],M=new Map;for(let L of O){if(M.has(L.provider))throw Error(`Notification adapter "${L.provider}" is registered more than once.`);M.set(L.provider,L)}this.#O=M,this.#M=W.send,this.#L=W.maxFrameBytes??mL,this.#G=W.protocolVersion??wO}accept(W){if(this.#Y)throw Error("The notification provider host is closed.");zX(W);let O=this.#O.get(W.provider);if(O===void 0)throw Error(`Notification invocation provider "${W.provider}" has no active adapter.`);if(W.protocolVersion!==this.#G)throw Error(`Notification Provider Host v${this.#G} cannot execute a v${W.protocolVersion} invocation.`);if(this.#$.has(W.invocationId))throw Error(`Invocation ID "${W.invocationId}" is already active.`);let M=this.#Z(W,O).finally(()=>{this.#$.delete(W.invocationId)});this.#$.set(W.invocationId,M)}async drain(){while(this.#$.size>0)await Promise.all([...this.#$.values()])}async close(){this.#Y=!0,await this.drain(),await Promise.all([...this.#O.values()].map((W)=>W.close()))}async#Z(W,O){let M=performance.now(),L=[],$;try{let Y=await O.resolveCredentials(this.#W,W),J=Y.credentials;if(L=[...Y.secretValues],await O.prepare(W,J),W.messageType==="deliver"){let A=await O.deliver(W,J);if(!O.validMessageIdentity(A))throw new dW(O.invalidMessageIdentityFailure());$=nL(W.protocolVersion,W.invocationId,M,{kind:"delivery_success",providerMessage:A})}else await O.update(W,J),$=nL(W.protocolVersion,W.invocationId,M,{kind:"update_success"})}catch(Y){$=nL(W.protocolVersion,W.invocationId,M,{kind:"failure",error:O.safeFailure(Y,L)})}if(zq($)>this.#L)$=nL(W.protocolVersion,W.invocationId,M,{kind:"failure",error:{kind:"size_limit_exceeded",code:"WOML_NOTIFICATION_SIZE_LIMIT_EXCEEDED",message:"The provider response exceeds the protocol byte limit.",retryable:!1}});await this.#M($)}}import{randomUUID as KX}from"crypto";var Vq="https://slack.com/api/",Hq=1e4,Kq=new Set(["connections:write","chat:write","chat:write.public","app_mentions:read","channels:read","channels:history","groups:read","groups:history","im:read","im:history","mpim:read","mpim:history"]);function rL(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function HX(W){if(typeof W!=="string"||W.length>1024)return[];let O=W.split(",").map((M)=>M.trim()).filter((M)=>Kq.has(M));return[...new Set(O)].slice(0,32)}function zW(W,O,M,L,$){return new kW({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}function aL(W,O,M,L={}){if(W==="ratelimited"||W==="rate_limited")return zW("rate_limited","WOML_SLACK_RATE_LIMITED","Slack rate-limited the request.",!0,M);if(["invalid_auth","not_authed","account_inactive","token_expired","token_revoked","not_allowed_token_type","missing_scope","no_permission"].includes(W)){let $=HX(L.needed),Y=HX(L.provided),J=L.method!==void 0&&/^[a-z][a-zA-Z0-9.]{0,79}$/.test(L.method)?L.method:void 0,A=[J===void 0?"The Slack app does not have a required permission.":`Slack operation ${J} needs additional app permissions.`,...$.length===0?[]:[`Missing scopes: ${$.join(", ")}.`],...Y.length===0?[]:[`Granted scopes: ${Y.join(", ")}.`],"Add the missing Bot Token Scopes and reinstall the Slack app to the workspace."].join(" ");return zW("provider_auth_failed",W==="missing_scope"||W==="no_permission"?"WOML_SLACK_PERMISSION_DENIED":"WOML_SLACK_AUTH_FAILED",W==="missing_scope"||W==="no_permission"?A:"Slack rejected a configured credential.",!1)}if(["channel_not_found","not_in_channel","is_archived","restricted_action"].includes(W))return zW("destination_invalid","WOML_SLACK_DESTINATION_INVALID","Slack could not access the configured channel.",!1);if(O==="delivery"&&["fatal_error","internal_error"].includes(W))return zW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack did not confirm whether the message was created; WOML will not replay it automatically.",!1);return zW(O==="update"?"update_failed":"provider_unavailable",O==="update"?"WOML_SLACK_UPDATE_FAILED":"WOML_SLACK_UNAVAILABLE",O==="update"?"Slack could not update the approval message.":"Slack could not complete the request.",!0)}class T9{#W;#O;#M;#L;#G;#$;#Y=new Map;#Z=new Map;#A=new Map;#X=new Map;#Q=new Map;#R=new Map;#J=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.createWebSocket??((O)=>new WebSocket(O)),this.#M=W.socketOpenTimeoutMs??Hq,this.#L=W.reconnectBaseDelayMs??500,this.#G=W.log??(()=>{}),this.#$=W.onConnectionState??(()=>{})}subscribe(W,O,M){if(this.#J)throw this.#z();let L=this.#Y.get(W);if(L===void 0){let $=this.#A.get(W)??new Map;if($.has(O))throw Error(`Slack listener "${O}" is already registered.`);$.set(O,M),this.#A.set(W,$)}else{let $=L.listeners.get(O);if($===void 0)L.listeners.set(O,{listener:M,references:new Set([W])});else $.references.add(W)}return()=>{let $=this.#Y.get(W),Y=$?.listeners.get(O);if(Y?.references.delete(W),Y?.references.size===0)$?.listeners.delete(O);let J=this.#A.get(W);if(J?.delete(O),J?.size===0)this.#A.delete(W)}}async ensureConnection(W,O){if(this.#J)throw this.#z();if(!O.startsWith("xapp-"))throw zW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The configured Slack app token is invalid.",!1);let M=this.#Y.get(W);if(M!==void 0&&M.token!==O)throw zW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The Slack app token changed while its Socket Mode connection was active.",!1);if(M===void 0){if(M=this.#Z.get(O),M===void 0)M={token:O,references:new Set,listeners:new Map,reconnectAttempt:0},this.#Z.set(O,M);M.references.add(W);let L=this.#A.get(W);if(L!==void 0){for(let[$,Y]of L){let J=M.listeners.get($);if(J===void 0)M.listeners.set($,{listener:Y,references:new Set([W])});else J.references.add(W)}this.#A.delete(W)}this.#Y.set(W,M)}if(M.socket?.readyState===1)return;if(M.opening===void 0)this.#U(M,"connecting"),M.opening=this.#V(M).finally(()=>{M.opening=void 0});await M.opening}async botIdentity(W,O){if(!O.startsWith("xoxb-"))throw zW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The configured Slack bot token is invalid.",!1);let M=this.#Q.get(W);if(M!==void 0&&M!==O)throw zW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The Slack bot token changed while the Slack host was active.",!1);this.#Q.set(W,O);let L=this.#X.get(O);if(L!==void 0)return await L;let $=this.api("auth.test",O,{},"none").then((Y)=>{if(typeof Y.team_id!=="string"||!/^T[A-Z0-9]{8,31}$/.test(Y.team_id)||typeof Y.user_id!=="string"||!/^U[A-Z0-9]{8,31}$/.test(Y.user_id))throw zW("request_invalid","WOML_SLACK_RESPONSE_INVALID","Slack returned an invalid workspace identity.",!1);return{token:O,teamId:Y.team_id,userId:Y.user_id}});return this.#X.set(O,$),await $}async resolveDestination(W,O,M){if(!W.startsWith("#"))return W;let L=W.slice(1),$=`${M}\x00${L}`,Y=this.#R.get($);if(Y!==void 0)return await Y;let J=this.#S(L,M);return this.#R.set($,J),await J}async api(W,O,M,L){if(this.#J)throw this.#z();let $;try{$=await this.#W(`${Vq}${W}`,{method:"POST",headers:{Authorization:`Bearer ${O}`,"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(M)})}catch{if(L==="delivery")throw zW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","The Slack delivery connection ended without a definitive response; WOML will not replay it automatically.",!1);throw zW(L==="update"?"update_failed":"provider_unavailable",L==="update"?"WOML_SLACK_UPDATE_FAILED":"WOML_SLACK_UNAVAILABLE",L==="update"?"The Slack message update could not be confirmed.":"Slack is currently unavailable.",!0)}let Y=Number($.headers.get("retry-after")),J=Number.isFinite(Y)?Math.max(0,Y*1000):void 0;if($.status===429)throw aL("ratelimited",L,J);if(!$.ok){if(L==="delivery"&&$.status>=500)throw zW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack did not confirm whether the message was created; WOML will not replay it automatically.",!1);throw aL("service_unavailable",L,J)}let A;try{A=await $.json()}catch{throw L==="delivery"?zW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack returned an unreadable delivery response; WOML will not replay it automatically.",!1):zW(L==="update"?"update_failed":"request_invalid",L==="update"?"WOML_SLACK_UPDATE_FAILED":"WOML_SLACK_RESPONSE_INVALID","Slack returned an unreadable response.",L==="update")}if(!rL(A))throw aL("invalid_response",L);if(A.ok!==!0)throw aL(typeof A.error==="string"?A.error:"invalid_response",L,J,{method:W,needed:A.needed,provided:A.provided});return A}async close(){if(this.#J)return;this.#J=!0;for(let W of this.#Z.values()){if(W.reconnectTimer!==void 0)clearTimeout(W.reconnectTimer);W.socket?.close(1000,"WOML Slack host shutting down"),this.#U(W,"stopped")}this.#Y.clear(),this.#Z.clear(),this.#A.clear(),this.#X.clear(),this.#Q.clear(),this.#R.clear()}async#S(W,O){let M;do{let L=await this.api("conversations.list",O,{types:"public_channel,private_channel",exclude_archived:!0,limit:200,...M===void 0?{}:{cursor:M}},"none");if(!Array.isArray(L.channels))throw zW("request_invalid","WOML_SLACK_RESPONSE_INVALID","Slack returned an invalid channel list.",!1);for(let $ of L.channels)if(rL($)&&$.name===W&&typeof $.id==="string"&&/^[CG][A-Z0-9]{8,31}$/.test($.id))return $.id;M=rL(L.response_metadata)&&typeof L.response_metadata.next_cursor==="string"&&L.response_metadata.next_cursor.length>0?L.response_metadata.next_cursor:void 0}while(M!==void 0);throw zW("destination_invalid","WOML_SLACK_DESTINATION_INVALID",`Slack channel #${W} was not found or is not visible to the app.`,!1)}async#V(W){let O=await this.api("apps.connections.open",W.token,{},"none");if(typeof O.url!=="string"||!O.url.startsWith("wss://"))throw zW("request_invalid","WOML_SLACK_RESPONSE_INVALID","Slack returned an invalid Socket Mode endpoint.",!1);let M=this.#O(O.url);W.socket=M,M.addEventListener("message",(L)=>{this.#F(W,M,L.data)}),M.addEventListener("close",()=>{if(W.socket===M)W.socket=void 0,this.#H(W)}),await new Promise((L,$)=>{let Y=setTimeout(()=>{M.close(1011,"Socket Mode open timeout"),$(zW("provider_unavailable","WOML_SLACK_UNAVAILABLE","Slack Socket Mode did not connect before its deadline.",!0))},this.#M);M.addEventListener("open",()=>{clearTimeout(Y),W.reconnectAttempt=0,this.#U(W,"ready"),L()},{once:!0}),M.addEventListener("error",()=>{clearTimeout(Y),$(zW("provider_unavailable","WOML_SLACK_UNAVAILABLE","Slack Socket Mode could not establish a connection.",!0))},{once:!0})})}#H(W){if(this.#J||W.reconnectTimer!==void 0)return;let O=Math.min(this.#L*2**W.reconnectAttempt,30000);W.reconnectAttempt+=1,this.#U(W,"reconnecting",O),W.reconnectTimer=setTimeout(()=>{if(W.reconnectTimer=void 0,this.#J||W.opening!==void 0)return;W.opening=this.#V(W).catch(()=>this.#H(W)).finally(()=>{W.opening=void 0})},O)}#F(W,O,M){if(typeof M!=="string")return;let L;try{L=JSON.parse(M)}catch{return}if(!rL(L))return;if(L.type==="disconnect"){if(W.socket===O)W.socket=void 0,O.close(1000,"Slack requested Socket Mode refresh"),this.#H(W);return}let $=typeof L.envelope_id==="string"?L.envelope_id:void 0,Y=!1,J={body:L,...$===void 0?{}:{envelopeId:$},appTokenReferences:[...W.references].sort(),acknowledge:()=>{if(Y||$===void 0)return;Y=!0,O.send(JSON.stringify({envelope_id:$}))}};for(let A of W.listeners.values())Promise.resolve(A.listener(J)).catch((Z)=>{let X=Z instanceof Error?Z.message:String(Z);this.#G(`Slack envelope listener failed safely: ${X}`)})}#z(){return zW("provider_unavailable","WOML_SLACK_UNAVAILABLE","The shared Slack transport is closed.",!0)}#U(W,O,M){this.#$({state:O,appTokenReferences:[...W.references].sort(),...M===void 0?{}:{retryAt:new Date(Date.now()+M).toISOString()}})}}var FX="woml_approval_approved",EX="woml_approval_rejected",qX="woml_approval_actions";function oL(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function HM(W,O){return[...W].slice(0,O).join("")}function J1(W,O,M,L){return new kW({kind:W,code:O,message:M,retryable:L})}function TX(W,O){return JSON.stringify({version:1,deliveryId:W.invocation.deliveryId,decisionCapability:W.invocation.decisionCapability,decision:O})}function Tq(W){let{message:O}=W.invocation,M=[`Workflow: ${O.workflowId}`,...O.approvalDescription===void 0?[]:[O.approvalDescription],...O.expiresAt===void 0?[]:[`Decision deadline: ${O.expiresAt}`]].join(`
256
- `);return[{type:"header",text:{type:"plain_text",text:HM(O.approvalName,150),emoji:!0}},{type:"section",text:{type:"plain_text",text:HM(M,3000),emoji:!0}},{type:"actions",block_id:qX,elements:[{type:"button",text:{type:"plain_text",text:"Approve",emoji:!0},action_id:FX,style:"primary",value:TX(W,"approved")},{type:"button",text:{type:"plain_text",text:"Reject",emoji:!0},action_id:EX,style:"danger",value:TX(W,"rejected")}]}]}function Fq(W){let O={approved:["Approved","This workflow approval was accepted."],rejected:["Rejected","This workflow approval was rejected."],timeout_failed:["Approval expired","The approval deadline passed and the workflow failed."]},[M,L]=O[W.invocation.resolution];return[{type:"header",text:{type:"plain_text",text:M,emoji:!0}},{type:"section",text:{type:"plain_text",text:L,emoji:!0}}]}function Eq(W){if(typeof W!=="string"||W.length>1500)return;try{let O=JSON.parse(W);if(!oL(O)||Object.keys(O).length!==4||O.version!==1||typeof O.deliveryId!=="string"||typeof O.decisionCapability!=="string"||O.decision!=="approved"&&O.decision!=="rejected")return;return O}catch{return}}class F9{#W;#O;#M;#L;#G=`approval_${KX()}`;#$=new Map;#Y=new Map;#Z=new Set;#A=new Map;#X=!1;constructor(W){this.#W=W.emit,this.#L=W.log??(()=>{}),this.#M=W.sharedTransport===void 0,this.#O=W.sharedTransport??new T9({fetch:W.fetch,createWebSocket:W.createWebSocket,socketOpenTimeoutMs:W.socketOpenTimeoutMs,reconnectBaseDelayMs:W.reconnectBaseDelayMs,log:W.log})}async ensureConnection(W,O){if(this.#X)throw this.#S();if(!this.#$.has(W))this.#$.set(W,this.#O.subscribe(W,this.#G,(M)=>this.#J(M)));await this.#O.ensureConnection(W,O)}async deliver(W){if(this.#X)throw this.#S();let O=W.invocation.idempotencyKey,M=this.#Y.get(O);if(M!==void 0)return await M;let L=this.#Q(W).catch(($)=>{throw this.#Y.delete(O),$});if(this.#Y.set(O,L),W.invocation.protocolVersion===1)this.#Z.add(W.invocation.deliveryId);return await L}async update(W){if(this.#X)throw this.#S();let O=W.invocation.idempotencyKey,M=this.#A.get(O);if(M!==void 0)return await M;let L=this.#R(W).catch(($)=>{throw this.#A.delete(O),$});this.#A.set(O,L),await L}async close(){if(this.#X)return;this.#X=!0;for(let W of this.#$.values())W();if(this.#$.clear(),this.#M)await this.#O.close()}async#Q(W){if(!("botToken"in W.invocation.credentials))throw J1("request_invalid","WOML_NOTIFICATION_REQUEST_INVALID","Slack received non-Slack credentials.",!1);let O=W.invocation.credentials.botToken.name,M=await this.#O.botIdentity(O,W.credentials.botToken),L=await this.#O.resolveDestination(W.invocation.destination,O,W.credentials.botToken),$=W.invocation,Y=$.protocolVersion===2,J=$.protocolVersion===2?{text:HM($.message,4096)}:{text:`Approval required: ${HM($.message.approvalName,300)}`,blocks:Tq({...W,invocation:$})},A=await this.#O.api("chat.postMessage",W.credentials.botToken,{channel:L,...J,unfurl_links:!1,unfurl_media:!1},"delivery"),Z={workspaceId:M.teamId,channelId:A.channel,messageId:A.ts};if(!zM(Z))throw J1("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack created an unrecognized response; WOML will not replay the message automatically.",!1);return this.#L(Y?`Slack lifecycle notification sent to ${W.invocation.destination}.`:`Slack approval sent to ${W.invocation.destination}; waiting for Approve or Reject.`),Z}async#R(W){if(!("workspaceId"in W.invocation.providerMessage))throw J1("update_failed","WOML_SLACK_UPDATE_FAILED","Slack received a non-Slack message identity.",!1);if(!("botToken"in W.invocation.credentials))throw J1("update_failed","WOML_SLACK_UPDATE_FAILED","Slack received non-Slack credentials.",!1);let O=W.invocation.credentials.botToken.name;if((await this.#O.botIdentity(O,W.credentials.botToken)).teamId!==W.invocation.providerMessage.workspaceId)throw J1("update_failed","WOML_SLACK_UPDATE_FAILED","The Slack message belongs to a different workspace.",!1);let L=W.invocation.resolution==="approved"?"Approved":W.invocation.resolution==="rejected"?"Rejected":"Approval expired";await this.#O.api("chat.update",W.credentials.botToken,{channel:W.invocation.providerMessage.channelId,ts:W.invocation.providerMessage.messageId,text:L,blocks:Fq(W)},"update")}async#J(W){let O=W.body;if(O.type!=="interactive"||!oL(O.payload))return;W.acknowledge();let M=O.payload;if(M.type!=="block_actions"||!Array.isArray(M.actions))return;let L=M.actions[0];if(!oL(L)||L.block_id!==qX)return;let $=L.action_id===FX?"approved":L.action_id===EX?"rejected":void 0,Y=Eq(L.value);if(Y===void 0||Y.decision!==$)return;if(!this.#Z.has(Y.deliveryId))return;if(!oL(M.user)||typeof M.user.id!=="string"||!/^U[A-Z0-9]{8,31}$/.test(M.user.id))return;await this.#W({protocol:SO,protocolVersion:wO,messageType:"interaction",interactionId:W.envelopeId===void 0?`slack_${KX()}`:HM(`slack_${W.envelopeId}`,320),deliveryId:Y.deliveryId,provider:"slack",decisionCapability:Y.decisionCapability,decision:Y.decision,providerActorId:M.user.id,occurredAt:new Date().toISOString()})}#S(){return J1("provider_unavailable","WOML_SLACK_UNAVAILABLE","The Slack approval adapter is closed.",!0)}}var qq="https://api.telegram.org",Bq=25,wq=30000;function cW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}class CO extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="TelegramTransportError"}}function CW(W,O,M,L,$){return new CO({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}function E9(W,O,M){let L=typeof O.error_code==="number"?O.error_code:W,$=cW(O.parameters)?O.parameters.retry_after:void 0;if(L===429)return CW("rate_limited","WOML_TELEGRAM_RATE_LIMITED","Telegram rate-limited the bot request.",!0,typeof $==="number"&&Number.isFinite($)?Math.max(0,Math.floor($*1000)):void 0);if(L===401)return CW("provider_auth_failed","WOML_TELEGRAM_AUTH_FAILED","Telegram rejected the configured bot token.",!1);if(L===400||L===403)return CW("destination_invalid","WOML_TELEGRAM_DESTINATION_INVALID","Telegram could not access the configured chat. Confirm the numeric chat ID and add the bot to that chat.",!1);if(L===409&&M==="read")return CW("provider_unavailable","WOML_TELEGRAM_POLLING_CONFLICT","Telegram long polling is unavailable because another poller or webhook is active for this bot.",!1);if(M==="delivery")return CW("delivery_ambiguous","WOML_TELEGRAM_DELIVERY_AMBIGUOUS","Telegram did not confirm whether the message was created; WOML will not replay the uncertain delivery automatically.",!1);return CW(M==="update"?"update_failed":"provider_unavailable",M==="update"?"WOML_TELEGRAM_UPDATE_FAILED":"WOML_TELEGRAM_UNAVAILABLE",M==="update"?"Telegram could not update the message.":"Telegram could not complete the request.",!0)}class q9{#W;#O;#M;#L;#G;#$=new Map;#Y=new Map;#Z=new Map;#A=new Set;#X=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.pollTimeoutSeconds??Bq,this.#M=W.retryDelayMs??1000,this.#L=W.log??(()=>{}),this.#G=W.onFatal??(()=>{})}subscribe(W,O,M){if(this.#X)throw this.#S();if(this.#V()>=O1)throw CW("size_limit_exceeded","WOML_TELEGRAM_SUBSCRIBER_LIMIT",`Telegram supports at most ${O1} active trigger subscriptions per runtime.`,!1);let L=this.#Y.get(W),$=L?.listeners??this.#Z.get(W)??new Map;if($.has(O))throw Error(`Telegram listener "${O}" is already registered.`);if($.set(O,M),L===void 0)this.#Z.set(W,$);return()=>$.delete(O)}async ensurePolling(W,O){if(this.#X)throw this.#S();let M=this.#Y.get(W);if(M!==void 0){if(M.token!==O)throw this.#S();return M.identity}let L=this.#$.get(O);if(L===void 0){if(this.#$.size>=W1)throw CW("size_limit_exceeded","WOML_TELEGRAM_CONNECTION_LIMIT",`Telegram supports at most ${W1} bot connections per runtime.`,!1);let Y=await this.botIdentity(O);L={token:O,references:new Set,listeners:new Map,identity:Y,offset:0},this.#$.set(O,L),L.task=this.#Q(L)}L.references.add(W),this.#Y.set(W,L);let $=this.#Z.get(W);if($!==void 0){for(let[Y,J]of $)L.listeners.set(Y,J);this.#Z.delete(W)}return L.identity}async botIdentity(W){let O=await this.#J(W,"getMe",{},"read");if(!cW(O)||!Number.isSafeInteger(O.id)&&typeof O.id!=="string"||O.is_bot!==!0||O.username!==void 0&&typeof O.username!=="string")throw CW("request_invalid","WOML_TELEGRAM_RESPONSE_INVALID","Telegram returned an invalid bot identity.",!1);return{botId:String(O.id),...typeof O.username==="string"?{username:O.username}:{}}}async sendMessage(W){let O=W.decisionCapability===void 0?void 0:{inline_keyboard:[[{text:"Approve",callback_data:`a:${W.decisionCapability}`},{text:"Reject",callback_data:`r:${W.decisionCapability}`}]]},M=await this.#J(W.botToken,"sendMessage",{chat_id:W.conversationId,text:W.text,...W.replyToMessageId===void 0?{}:{reply_parameters:{message_id:Number(W.replyToMessageId)}},...O===void 0?{}:{reply_markup:O}},"delivery");if(!cW(M)||!Number.isSafeInteger(M.message_id)||!cW(M.chat)||!Number.isSafeInteger(M.chat.id)&&typeof M.chat.id!=="string")throw CW("request_invalid","WOML_TELEGRAM_RESPONSE_INVALID","Telegram returned an invalid message identity.",!1);return{provider:"telegram",accountId:W.accountId,conversationId:String(M.chat.id),messageId:String(M.message_id)}}async updateMessage(W){await this.#J(W.botToken,"editMessageReplyMarkup",{chat_id:W.conversationId,message_id:Number(W.messageId),reply_markup:{inline_keyboard:[]}},"update")}async answerCallback(W,O,M){let L=this.#Y.get(W);if(L===void 0)return;await this.#J(L.token,"answerCallbackQuery",{callback_query_id:O,text:M},"read")}async close(){if(this.#X)return;this.#X=!0;for(let W of this.#A)W.abort();await Promise.allSettled([...this.#$.values()].flatMap((W)=>W.task===void 0?[]:[W.task])),this.#Y.clear(),this.#$.clear(),this.#Z.clear()}async#Q(W){while(!this.#X)try{let O=await this.#J(W.token,"getUpdates",{offset:W.offset,timeout:this.#O,allowed_updates:["message","callback_query"]},"read",(this.#O+5)*1000);if(!Array.isArray(O)||O.length>JX)throw CW("request_invalid","WOML_TELEGRAM_RESPONSE_INVALID","Telegram returned an invalid update batch.",!1);for(let M of O){let L=this.#R(M,W.identity);if(L===void 0){if(cW(M)&&Number.isSafeInteger(M.update_id))W.offset=Number(M.update_id)+1;continue}for(let $ of W.listeners.values())await $(L);W.offset=L.updateId+1}}catch(O){if(this.#X)return;if(O instanceof CO&&!O.failure.retryable){this.#G(O.failure);return}let M=O instanceof CO?O.failure.message:"Telegram polling failed safely.";this.#L(`${M} Retrying Telegram polling.`),await Bun.sleep(this.#M)}}#R(W,O){if(!cW(W)||!Number.isSafeInteger(W.update_id))return;let M=Number(W.update_id);if(cW(W.callback_query)){let Z=W.callback_query;if(typeof Z.id!=="string"||!cW(Z.from)||!Number.isSafeInteger(Z.from.id)&&typeof Z.from.id!=="string"||typeof Z.data!=="string")return;let X=/^(a|r):(ncap_[a-f0-9]+\.[a-f0-9]+)$/.exec(Z.data);if(X===null)return;return{kind:"callback",updateId:M,callbackQueryId:Z.id,actorId:String(Z.from.id),decisionCapability:X[2],decision:X[1]==="a"?"approved":"rejected"}}if(!cW(W.message))return;let L=W.message;if(!Number.isSafeInteger(L.message_id)||!Number.isSafeInteger(L.date)||typeof L.text!=="string"||Buffer.byteLength(L.text,"utf8")>dL||!cW(L.from)||!Number.isSafeInteger(L.from.id)&&typeof L.from.id!=="string"||L.from.is_bot===!0||!cW(L.chat)||!Number.isSafeInteger(L.chat.id)&&typeof L.chat.id!=="string")return;let $=L.chat.type,Y=$==="private"?"direct":$==="channel"?"channel":"group",J=[L.from.first_name,L.from.last_name].filter((Z)=>typeof Z==="string"&&Z.length>0).join(" "),A=cW(L.reply_to_message)&&Number.isSafeInteger(L.reply_to_message.message_id)?String(L.reply_to_message.message_id):void 0;return{kind:"message",updateId:M,payload:{provider:"telegram",event:"message",text:L.text,senderId:String(L.from.id),...J.length===0?{}:{senderName:J},conversationId:String(L.chat.id),conversationType:Y,messageId:String(L.message_id),...A===void 0?{}:{replyToMessageId:A},occurredAt:new Date(Number(L.date)*1000).toISOString(),providerData:{botId:O.botId}}}}async#J(W,O,M,L,$=wq){if(!M1(W))throw CW("provider_auth_failed","WOML_TELEGRAM_CREDENTIAL_INVALID","The configured Telegram bot token has an invalid shape or exceeds the credential limit.",!1);let Y;try{Y=$1(M)}catch{throw CW("size_limit_exceeded","WOML_TELEGRAM_REQUEST_TOO_LARGE","The Telegram request exceeds the 64 KiB provider limit.",!1)}let J=new AbortController;this.#A.add(J);let A=setTimeout(()=>J.abort(),$),Z;try{Z=await this.#W(`${qq}/bot${W}/${O}`,{method:"POST",headers:{"content-type":"application/json"},body:Y,signal:J.signal})}catch(Q){if(Q instanceof dW)throw Q;throw CW(L==="delivery"?"delivery_ambiguous":"provider_unavailable",L==="delivery"?"WOML_TELEGRAM_DELIVERY_AMBIGUOUS":"WOML_TELEGRAM_UNAVAILABLE",L==="delivery"?"The Telegram delivery connection ended without a confirmed result.":"Telegram is temporarily unavailable.",L!=="delivery")}finally{clearTimeout(A),this.#A.delete(J)}let X;try{X=await L1(Z)}catch(Q){if(Q instanceof gO)throw CW("size_limit_exceeded","WOML_TELEGRAM_RESPONSE_TOO_LARGE","Telegram returned a response larger than the 1 MiB provider limit.",!1);throw E9(Z.status,{},L)}let G;try{G=JSON.parse(X)}catch{throw E9(Z.status,{},L)}if(!cW(G)||G.ok!==!0)throw E9(Z.status,cW(G)?G:{},L);return G.result}#S(){return CW("provider_unavailable","WOML_TELEGRAM_UNAVAILABLE","The Telegram transport is closed or has conflicting credentials.",!0)}#V(){let W=0;for(let O of this.#$.values())W+=O.listeners.size;for(let O of this.#Z.values())W+=O.size;return W}}function Cq(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The Telegram provider failed safely."}function Nq(W){if("mode"in W)return W.message;return[W.message.approvalName,W.message.approvalDescription,`Workflow: ${W.message.workflowId}`,W.message.expiresAt===void 0?void 0:`Deadline: ${W.message.expiresAt}`].filter((O)=>O!==void 0&&O.length>0).join(`
257
- `)}class B9{provider="telegram";#W;#O=new Map;#M=new Map;constructor(W){this.#W=W}async resolveCredentials(W,O){let M=O.credentials,L=await W.get(M.botToken.name);if(L===void 0||L.length===0)throw new c("WOML_SECRET_NOT_FOUND","A required Telegram bot token is not available.");return{credentials:{botToken:L},secretValues:[L]}}async prepare(W,O){if(this.#O.has(O.botToken))return;let M=await this.#W.botIdentity(O.botToken);this.#O.set(O.botToken,M.botId)}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A Telegram update cannot be delivered as a new message.");let M=this.#M.get(W.idempotencyKey);if(M!==void 0)return M;let L=this.#O.get(O.botToken);if(L===void 0)throw Error("Telegram bot identity is unavailable.");let $=await this.#W.sendMessage({botToken:O.botToken,accountId:L,conversationId:W.destination,text:Nq(W),..."mode"in W?{}:{decisionCapability:W.decisionCapability}});return this.#M.set(W.idempotencyKey,$),$}async update(W,O){if(W.messageType!=="update"||!("provider"in W.providerMessage)||W.providerMessage.provider!=="telegram")throw Error("Telegram received an invalid message update identity.");await this.#W.updateMessage({botToken:O.botToken,conversationId:W.providerMessage.conversationId,messageId:W.providerMessage.messageId,resolution:W.resolution})}validMessageIdentity(W){return typeof W==="object"&&W!==null&&"provider"in W&&W.provider==="telegram"&&"accountId"in W&&typeof W.accountId==="string"&&"conversationId"in W&&typeof W.conversationId==="string"&&"messageId"in W&&typeof W.messageId==="string"}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_TELEGRAM_RESPONSE_INVALID",message:"Telegram returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW)return W.failure;if(W instanceof CO)return{...W.failure,message:Cq(W.failure.message,O)};if(W instanceof c)return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required Telegram credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_TELEGRAM_UNAVAILABLE",message:"The Telegram adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function Pq(W){return W.kind==="object"?W.fields:void 0}function _q(W){if(W?.kind!=="array")return[];return W.items.flatMap((O)=>O.kind==="literal"&&typeof O.value==="string"?[O.value]:[])}function Jj(W,O){return W.triggers.filter((M)=>M.handler==="trigger.telegram").map((M)=>{let L=Pq(M.config),$=_q(L?.events),Y=L?.botToken?.kind==="secretReference"?L.botToken.name:void 0;if(L===void 0||$.length!==1||$[0]!=="message"||Y===void 0)throw Error(`Compiled Telegram trigger "${M.id}" does not match Model v15.`);return{workflowId:W.workflowId,definitionHash:O,triggerId:M.id,events:["message"],credentialNames:{botToken:Y}}})}import{randomUUID as BX}from"crypto";class jq{provider="telegram";#W;#O=`telegram_${BX()}`;#M=[];#L=[];#G=!1;#$=!1;constructor(W){if(W.registrations.length===0&&(W.credentialNames?.length??0)===0)throw Error("TelegramTriggerHost requires a trigger or notification credential.");this.#W=W}async start(){if(this.#G||this.#$)throw Error("Telegram trigger host cannot be started twice.");this.#G=!0;let W=new Set([...this.#W.registrations.map((O)=>O.credentialNames.botToken),...this.#W.credentialNames??[]]);try{for(let O of W){let M=await this.#W.secretStore.get(O);if(M===void 0||M.length===0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required secret: ${O}. Configure it with: woml secrets set ${O}`);this.#L.push(this.#W.transport.subscribe(O,`${this.#O}:${O}`,($)=>this.#Y(O,$)));let L=await this.#W.transport.ensurePolling(O,M);for(let $ of this.#W.registrations)if($.credentialNames.botToken===O)this.#M.push({...$,botId:L.botId});this.#W.diagnostic?.("WOML_TELEGRAM_READY",`Telegram bot${L.username===void 0?"":` @${L.username}`} is ready.`)}}catch(O){throw await this.close(),O}}async close(){if(this.#$)return;this.#$=!0;for(let W of this.#L.splice(0))W();this.#M.splice(0)}async#Y(W,O){if(O.kind==="callback"){if(this.#W.resolveApproval===void 0)return;let L=await this.#W.resolveApproval(O);try{await this.#W.transport.answerCallback(W,O.callbackQueryId,L==="already-resolved"?"This approval was already resolved.":L==="expired"?"This approval has expired.":O.decision==="approved"?"Approved":"Rejected")}catch($){let Y=$ instanceof CO?$.failure.code:"WOML_TELEGRAM_CALLBACK_ACK_FAILED";this.#W.diagnostic?.(Y,"The approval decision was saved, but Telegram could not acknowledge the button press.")}return}let M=this.#M.filter((L)=>L.credentialNames.botToken===W&&L.botId===O.payload.providerData.botId&&L.events.includes("message"));for(let L of M){let $={contract:"woml.trigger-ingress",contractVersion:1,messageType:"admit",requestId:`request_telegram_${BX()}`,workflowId:L.workflowId,definitionHash:L.definitionHash,triggerId:L.triggerId,triggerHandler:"trigger.telegram",sourceIdentity:`telegram:${L.botId}:${O.updateId}:${L.workflowId}:${L.triggerId}`,payload:{...O.payload},receivedAt:new Date().toISOString()},Y=await this.#W.submit($);if(Y.messageType==="rejected")throw new CO({kind:"provider_unavailable",code:Y.failure.code,message:Y.failure.message,retryable:Y.failure.retryable});this.#W.diagnostic?.(Y.duplicate?"WOML_TELEGRAM_TRIGGER_DUPLICATE":"WOML_TELEGRAM_TRIGGER_ACCEPTED",`${Y.duplicate?"Recognized duplicate":"Accepted"} Telegram message ${O.updateId} for trigger "${L.triggerId}": ${Y.runId}.`)}}}function Sj(W){if(W instanceof c)return{code:W.code,message:W.message};if(W instanceof CO)return{code:W.failure.code,message:W.failure.message};return{code:"WOML_TELEGRAM_TRIGGER_UNAVAILABLE",message:"The Telegram long-polling host could not start safely."}}var Iq="https://discord.com/api/v10",yq="wss://gateway.discord.gg/?v=10&encoding=json",Dq=30000,kq=30000,bq=37377;function bW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function NO(W){return typeof W==="string"&&/^[0-9]{17,20}$/.test(W)}class PO extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="DiscordTransportError"}}function $W(W,O,M,L,$){return new PO({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}class w9{#W;#O;#M;#L;#G;#$;#Y;#Z;#A=new Map;#X=new Map;#Q=new Map;#R=new Set;#J=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.createWebSocket??((O)=>new WebSocket(O)),this.#M=W.apiBase??Iq,this.#L=W.gatewayUrl??yq,this.#G=W.reconnectDelayMs??1000,this.#$=W.readyTimeoutMs??kq,this.#Y=W.log??(()=>{}),this.#Z=W.onFatal??(()=>{})}subscribe(W,O,M){if(this.#J)throw this.#K();if(this.#N()>=O1)throw $W("size_limit_exceeded","WOML_DISCORD_SUBSCRIBER_LIMIT",`Discord supports at most ${O1} active trigger subscriptions per runtime.`,!1);let L=this.#X.get(W),$=L?.listeners??this.#Q.get(W)??new Map;if($.has(O))throw Error(`Discord listener "${O}" is already registered.`);if($.set(O,M),L===void 0)this.#Q.set(W,$);return()=>$.delete(O)}async ensureConnected(W,O){if(this.#J)throw this.#K();let M=this.#X.get(W);if(M!==void 0){if(M.token!==O)throw this.#K();return M.identity}let L=this.#A.get(O);if(L===void 0){if(this.#A.size>=W1)throw $W("size_limit_exceeded","WOML_DISCORD_CONNECTION_LIMIT",`Discord supports at most ${W1} bot connections per runtime.`,!1);let Y=await this.botIdentity(O);L={token:O,references:new Set([W]),listeners:this.#Q.get(W)??new Map,identity:Y,awaitingHeartbeatAck:!1,dispatchChain:Promise.resolve(),fatal:!1},this.#A.set(O,L),this.#X.set(W,L),this.#Q.delete(W);try{await this.#S(L)}catch(J){throw this.#A.delete(O),this.#X.delete(W),J}return L.identity}L.references.add(W),this.#X.set(W,L);let $=this.#Q.get(W);if($!==void 0){for(let[Y,J]of $)L.listeners.set(Y,J);this.#Q.delete(W)}return L.identity}async botIdentity(W){let O=await this.#T(W,"/users/@me","GET",void 0,"read");if(!bW(O)||!NO(O.id)||typeof O.username!=="string"||O.username.length===0||O.bot!==!0)throw $W("request_invalid","WOML_DISCORD_RESPONSE_INVALID","Discord returned an invalid bot identity.",!1);return{botId:O.id,username:O.username}}async sendMessage(W){let O=W.decisionCapability===void 0?void 0:[{type:1,components:[{type:2,style:3,label:"Approve",custom_id:`a:${W.decisionCapability}`},{type:2,style:4,label:"Reject",custom_id:`r:${W.decisionCapability}`}]}],M=await this.#T(W.botToken,`/channels/${W.conversationId}/messages`,"POST",{content:W.text,...W.replyToMessageId===void 0?{}:{message_reference:{message_id:W.replyToMessageId,fail_if_not_exists:!1}},...O===void 0?{}:{components:O}},"delivery");if(!bW(M)||!NO(M.id)||!NO(M.channel_id))throw $W("delivery_ambiguous","WOML_DISCORD_RESPONSE_INVALID","Discord returned an invalid message identity.",!1);return{provider:"discord",accountId:W.accountId,conversationId:M.channel_id,messageId:M.id}}async updateMessage(W){await this.#T(W.botToken,`/channels/${W.conversationId}/messages/${W.messageId}`,"PATCH",{components:[]},"update")}async acknowledgeInteraction(W,O){await this.#T(void 0,`/interactions/${W.interactionId}/${W.interactionToken}/callback`,"POST",{type:4,data:{content:O,flags:64}},"read")}async close(){if(this.#J)return;this.#J=!0;for(let W of this.#R)W.abort();for(let W of this.#A.values())this.#U(W),W.socket?.close(1000,"WOML runtime stopped");await Promise.allSettled([...this.#A.values()].flatMap((W)=>W.reconnectTask===void 0?[]:[W.reconnectTask])),this.#X.clear(),this.#A.clear(),this.#Q.clear()}async#S(W){if(this.#J||W.fatal)throw this.#K();let O=W.sessionId===void 0?this.#L:`${W.resumeGatewayUrl??this.#L.replace(/\?.*$/,"")}?v=10&encoding=json`,M=this.#O(O);W.socket=M,M.binaryType="arraybuffer";let L=!1,$=!1,Y,J,A=new Promise((Q,S)=>{Y=Q,J=S}),Z=setTimeout(()=>{if(L)return;L=!0,J($W("provider_unavailable","WOML_DISCORD_GATEWAY_TIMEOUT","Discord Gateway did not become ready before the startup deadline.",!0)),M.close(4000,"Gateway startup timeout")},this.#$),X=()=>{if(L)return;L=!0,$=!0,clearTimeout(Z),Y()},G=(Q)=>{if(L)return;L=!0,clearTimeout(Z),J(Q)};M.onopen=()=>{},M.onerror=()=>{if(!L)G($W("provider_unavailable","WOML_DISCORD_GATEWAY_UNAVAILABLE","Discord Gateway could not be reached.",!0)),M.close(4000,"Gateway connection error")},M.onmessage=(Q)=>{W.dispatchChain=W.dispatchChain.then(()=>this.#V(W,Q.data,X)).catch((S)=>this.#B(W,S))},M.onclose=(Q)=>{if(this.#U(W),W.socket===M)W.socket=void 0;let S=this.#w(Q.code);if(!L)G(S);if(this.#J||W.fatal||Q.code===1000)return;if(!S.failure.retryable){W.fatal=!0,this.#Z(S.failure);return}if(!$)return;this.#q(W,S.failure.retryAfterMs)},await A}async#V(W,O,M){let L=typeof O==="string"?O:O instanceof ArrayBuffer?new TextDecoder().decode(O):ArrayBuffer.isView(O)?new TextDecoder().decode(O):void 0;if(L===void 0||Buffer.byteLength(L,"utf8")>1048576)throw $W("size_limit_exceeded","WOML_DISCORD_GATEWAY_FRAME_TOO_LARGE","Discord sent an invalid or oversized Gateway frame.",!1);let $;try{$=JSON.parse(L)}catch{throw $W("request_invalid","WOML_DISCORD_GATEWAY_FRAME_INVALID","Discord sent invalid Gateway JSON.",!1)}if(!bW($)||typeof $.op!=="number")return;if(typeof $.s==="number"&&Number.isSafeInteger($.s))W.sequence=$.s;if($.op===10){if(!bW($.d)||typeof $.d.heartbeat_interval!=="number")throw $W("request_invalid","WOML_DISCORD_GATEWAY_HELLO_INVALID","Discord sent an invalid Gateway hello.",!1);if(this.#F(W,$.d.heartbeat_interval),W.sessionId!==void 0&&W.sequence!==void 0)this.#E(W,{op:6,d:{token:W.token,session_id:W.sessionId,seq:W.sequence}});else this.#E(W,{op:2,d:{token:W.token,intents:bq,properties:{os:process.platform,browser:"woml",device:"woml"}}});return}if($.op===11){W.awaitingHeartbeatAck=!1;return}if($.op===1){this.#z(W);return}if($.op===7){W.socket?.close(4000,"Discord requested reconnect");return}if($.op===9){if($.d!==!0)W.sessionId=void 0,W.sequence=void 0,W.resumeGatewayUrl=void 0;W.socket?.close(4000,"Discord invalidated the session");return}if($.op!==0||typeof $.t!=="string")return;if($.t==="READY"){if(!bW($.d)||typeof $.d.session_id!=="string"||typeof $.d.resume_gateway_url!=="string"||!bW($.d.user)||$.d.user.id!==W.identity.botId)throw $W("request_invalid","WOML_DISCORD_GATEWAY_READY_INVALID","Discord returned an invalid Gateway ready identity.",!1);W.sessionId=$.d.session_id,W.resumeGatewayUrl=$.d.resume_gateway_url,M();return}if($.t==="RESUMED"){M();return}let Y=this.#H($.t,$.d,W.identity);if(Y===void 0)return;for(let J of W.listeners.values())await J(Y)}#H(W,O,M){if(!bW(O))return;if(W==="INTERACTION_CREATE"){if(O.type!==3||!NO(O.id)||typeof O.token!=="string"||!bW(O.data)||typeof O.data.custom_id!=="string")return;let Z=/^(a|r):(ncap_[a-f0-9]+\.[a-f0-9]+)$/.exec(O.data.custom_id),X=bW(O.member)&&bW(O.member.user)?O.member.user.id:bW(O.user)?O.user.id:void 0;if(Z===null||!NO(X))return;return{kind:"interaction",eventId:O.id,interactionId:O.id,interactionToken:O.token,actorId:X,decisionCapability:Z[2],decision:Z[1]==="a"?"approved":"rejected"}}if(W!=="MESSAGE_CREATE")return;if(!NO(O.id)||!NO(O.channel_id)||typeof O.content!=="string"||Buffer.byteLength(O.content,"utf8")>dL||typeof O.timestamp!=="string"||!bW(O.author)||!NO(O.author.id)||O.author.bot===!0||O.author.id===M.botId)return;let L=O.guild_id===void 0||O.guild_id===null,$=Array.isArray(O.mentions)&&O.mentions.some((Z)=>bW(Z)&&Z.id===M.botId);if(!L&&!$)return;let Y=new Date(O.timestamp);if(Number.isNaN(Y.getTime()))return;let J=bW(O.message_reference)&&NO(O.message_reference.message_id)?O.message_reference.message_id:void 0,A=typeof O.author.global_name==="string"&&O.author.global_name.length>0?O.author.global_name:typeof O.author.username==="string"&&O.author.username.length>0?O.author.username:void 0;return{kind:"message",eventId:O.id,payload:{provider:"discord",event:L?"direct-message":"app-mention",text:O.content,senderId:O.author.id,...A===void 0?{}:{senderName:A},conversationId:O.channel_id,conversationType:L?"direct":"group",messageId:O.id,...J===void 0?{}:{replyToMessageId:J},occurredAt:Y.toISOString(),providerData:{botId:M.botId,...NO(O.guild_id)?{guildId:O.guild_id}:{}}}}}#F(W,O){if(!Number.isFinite(O)||O<1000)throw $W("request_invalid","WOML_DISCORD_GATEWAY_HELLO_INVALID","Discord returned an invalid heartbeat interval.",!1);this.#U(W),W.awaitingHeartbeatAck=!1,this.#z(W),W.heartbeatTimer=setInterval(()=>this.#z(W),Math.floor(O))}#z(W){if(W.awaitingHeartbeatAck){W.socket?.close(4000,"Heartbeat acknowledgement missed");return}W.awaitingHeartbeatAck=!0,this.#E(W,{op:1,d:W.sequence??null})}#U(W){if(W.heartbeatTimer!==void 0)clearInterval(W.heartbeatTimer),W.heartbeatTimer=void 0;W.awaitingHeartbeatAck=!1}#E(W,O){if(W.socket?.readyState!==1)return;W.socket.send(JSON.stringify(O))}#q(W,O){if(W.reconnectTask!==void 0||this.#J)return;let M=async()=>{if(await Bun.sleep(O??this.#G),this.#J||W.fatal)return;try{await this.#S(W),this.#Y(`Discord bot ${W.identity.username} resumed Gateway events.`)}catch(L){if(this.#J||W.fatal)return;let $=L instanceof PO?L.failure:this.#K().failure;if(!$.retryable){W.fatal=!0,this.#Z($);return}this.#Y(`${$.message} Retrying Discord Gateway.`),setTimeout(()=>this.#q(W,$.retryAfterMs),0)}};W.reconnectTask=M(),W.reconnectTask.finally(()=>{W.reconnectTask=void 0})}#B(W,O){let M=O instanceof PO?O.failure:{kind:"provider_unavailable",code:"WOML_DISCORD_TRIGGER_UNAVAILABLE",message:"The durable WOML trigger authority rejected the Discord event.",retryable:!1};if(!M.retryable){W.fatal=!0,this.#Z(M),W.socket?.close(1000,"Fatal trigger admission failure");return}W.socket?.close(4000,"Retryable trigger admission failure")}#w(W){if(W===4004)return $W("provider_auth_failed","WOML_DISCORD_AUTH_FAILED","Discord rejected the configured bot token.",!1);if(W===4013||W===4014)return $W("permission_denied","WOML_DISCORD_INTENTS_MISSING","Discord rejected the required Gateway intents. Enable Message Content Intent for the bot and verify its server permissions.",!1);if(W===4008)return $W("rate_limited","WOML_DISCORD_GATEWAY_RATE_LIMITED","Discord rate-limited the Gateway connection.",!0,5000);return $W("provider_unavailable","WOML_DISCORD_GATEWAY_UNAVAILABLE","The Discord Gateway connection closed and will be resumed safely.",!0)}async#T(W,O,M,L,$){if(W!==void 0&&!M1(W))throw $W("provider_auth_failed","WOML_DISCORD_CREDENTIAL_INVALID","The configured Discord bot token has an invalid shape or exceeds the credential limit.",!1);let Y;try{Y=L===void 0?void 0:$1(L)}catch{throw $W("size_limit_exceeded","WOML_DISCORD_REQUEST_TOO_LARGE","The Discord request exceeds the 64 KiB provider limit.",!1)}let J=new AbortController;this.#R.add(J);let A=setTimeout(()=>J.abort(),Dq),Z;try{Z=await this.#W(`${this.#M}${O}`,{method:M,headers:{...W===void 0?{}:{authorization:`Bot ${W}`},...L===void 0?{}:{"content-type":"application/json"}},...Y===void 0?{}:{body:Y},signal:J.signal})}catch{throw $W($==="delivery"?"delivery_ambiguous":"provider_unavailable",$==="delivery"?"WOML_DISCORD_DELIVERY_AMBIGUOUS":"WOML_DISCORD_UNAVAILABLE",$==="delivery"?"The Discord delivery connection ended without a confirmed result.":"Discord is temporarily unavailable.",$!=="delivery")}finally{clearTimeout(A),this.#R.delete(J)}let X;if(Z.status===204)X=void 0;else{let G;try{G=await L1(Z)}catch(Q){if(Q instanceof gO)throw $W("size_limit_exceeded","WOML_DISCORD_RESPONSE_TOO_LARGE","Discord returned a response larger than the 1 MiB provider limit.",!1);X=void 0,G=""}if(G.length>0)try{X=JSON.parse(G)}catch{X=void 0}}if(!Z.ok)throw this.#C(Z.status,X,$);return X}#C(W,O,M){if(W===429){let L=bW(O)?O.retry_after:void 0;return $W("rate_limited","WOML_DISCORD_RATE_LIMITED","Discord rate-limited the bot request.",!0,typeof L==="number"&&Number.isFinite(L)?Math.max(0,Math.ceil(L*1000)):void 0)}if(W===401)return $W("provider_auth_failed","WOML_DISCORD_AUTH_FAILED","Discord rejected the configured bot token.",!1);if(W===403)return $W("permission_denied","WOML_DISCORD_PERMISSION_DENIED","Discord denied the bot permission to access the configured channel.",!1);if(W===404)return $W("destination_invalid","WOML_DISCORD_DESTINATION_INVALID","Discord could not find the configured channel or message.",!1);if(M==="delivery")return $W("delivery_ambiguous","WOML_DISCORD_DELIVERY_AMBIGUOUS","Discord did not confirm whether the message was created.",!1);return $W(M==="update"?"update_failed":"provider_unavailable",M==="update"?"WOML_DISCORD_UPDATE_FAILED":"WOML_DISCORD_UNAVAILABLE",M==="update"?"Discord could not update the message.":"Discord could not complete the request.",!0)}#K(){return $W("provider_unavailable","WOML_DISCORD_UNAVAILABLE","The Discord transport is closed or has conflicting credentials.",!0)}#N(){let W=0;for(let O of this.#A.values())W+=O.listeners.size;for(let O of this.#Q.values())W+=O.size;return W}}function fq(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The Discord provider failed safely."}function vq(W){if("mode"in W)return W.message;return[W.message.approvalName,W.message.approvalDescription,`Workflow: ${W.message.workflowId}`,W.message.expiresAt===void 0?void 0:`Deadline: ${W.message.expiresAt}`].filter((O)=>O!==void 0&&O.length>0).join(`
258
- `)}class C9{provider="discord";#W;#O=new Map;#M=new Map;constructor(W){this.#W=W}async resolveCredentials(W,O){let M=O.credentials,L=await W.get(M.botToken.name);if(L===void 0||L.length===0)throw new c("WOML_SECRET_NOT_FOUND","A required Discord bot token is not available.");return{credentials:{botToken:L},secretValues:[L]}}async prepare(W,O){if(this.#O.has(O.botToken))return;let M=await this.#W.botIdentity(O.botToken);this.#O.set(O.botToken,M.botId)}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A Discord update cannot be delivered as a new message.");let M=this.#M.get(W.idempotencyKey);if(M!==void 0)return M;let L=this.#O.get(O.botToken);if(L===void 0)throw Error("Discord bot identity is unavailable.");let $=await this.#W.sendMessage({botToken:O.botToken,accountId:L,conversationId:W.destination,text:vq(W),..."mode"in W?{}:{decisionCapability:W.decisionCapability}});return this.#M.set(W.idempotencyKey,$),$}async update(W,O){if(W.messageType!=="update"||!("provider"in W.providerMessage)||W.providerMessage.provider!=="discord")throw Error("Discord received an invalid message update identity.");await this.#W.updateMessage({botToken:O.botToken,conversationId:W.providerMessage.conversationId,messageId:W.providerMessage.messageId,resolution:W.resolution})}validMessageIdentity(W){return typeof W==="object"&&W!==null&&"provider"in W&&W.provider==="discord"&&"accountId"in W&&typeof W.accountId==="string"&&"conversationId"in W&&typeof W.conversationId==="string"&&"messageId"in W&&typeof W.messageId==="string"}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_DISCORD_RESPONSE_INVALID",message:"Discord returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW)return W.failure;if(W instanceof PO){let M=W.failure.kind==="permission_denied"?"destination_invalid":W.failure.kind;return{...W.failure,kind:M,message:fq(W.failure.message,O)}}if(W instanceof c)return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required Discord credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_DISCORD_UNAVAILABLE",message:"The Discord adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function xq(W){return W.kind==="object"?W.fields:void 0}function wX(W){if(W?.kind!=="array")return[];return W.items.flatMap((O)=>O.kind==="literal"&&typeof O.value==="string"?[O.value]:[])}function Pj(W,O){return W.triggers.filter((M)=>M.handler==="trigger.discord").map((M)=>{let L=xq(M.config),$=wX(L?.events),Y=wX(L?.channels),J=L?.botToken?.kind==="secretReference"?L.botToken.name:void 0;if(L===void 0||$.length===0||$.some((A)=>A!=="app-mention"&&A!=="direct-message")||Y.some((A)=>!/^[0-9]{17,20}$/.test(A))||J===void 0)throw Error(`Compiled Discord trigger "${M.id}" does not match Model v15.`);return{workflowId:W.workflowId,definitionHash:O,triggerId:M.id,events:$,channels:Y,credentialNames:{botToken:J}}})}import{randomUUID as CX}from"crypto";class gq{provider="discord";#W;#O=`discord_${CX()}`;#M=[];#L=[];#G=!1;#$=!1;constructor(W){if(W.registrations.length===0&&(W.credentialNames?.length??0)===0)throw Error("DiscordTriggerHost requires a trigger or notification credential.");this.#W=W}async start(){if(this.#G||this.#$)throw Error("Discord trigger host cannot be started twice.");this.#G=!0;let W=new Set([...this.#W.registrations.map((O)=>O.credentialNames.botToken),...this.#W.credentialNames??[]]);try{for(let O of W){let M=await this.#W.secretStore.get(O);if(M===void 0||M.length===0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required secret: ${O}. Configure it with: woml secrets set ${O}`);this.#L.push(this.#W.transport.subscribe(O,`${this.#O}:${O}`,($)=>this.#Y(O,$)));let L=await this.#W.transport.ensureConnected(O,M);for(let $ of this.#W.registrations)if($.credentialNames.botToken===O)this.#M.push({...$,botId:L.botId});this.#W.diagnostic?.("WOML_DISCORD_READY",`Discord bot @${L.username} is ready.`)}}catch(O){throw await this.close(),O}}async close(){if(this.#$)return;this.#$=!0;for(let W of this.#L.splice(0))W();this.#M.splice(0)}async#Y(W,O){if(O.kind==="interaction"){if(this.#W.resolveApproval===void 0)return;let L=await this.#W.resolveApproval(O);try{await this.#W.transport.acknowledgeInteraction(O,L==="already-resolved"?"This approval was already resolved.":L==="expired"?"This approval has expired.":O.decision==="approved"?"Approved":"Rejected")}catch($){let Y=$ instanceof PO?$.failure.code:"WOML_DISCORD_INTERACTION_ACK_FAILED";this.#W.diagnostic?.(Y,"The approval decision was saved, but Discord could not acknowledge the button interaction.")}return}let M=this.#M.filter((L)=>{if(L.credentialNames.botToken!==W||L.botId!==O.payload.providerData.botId||!L.events.includes(O.payload.event))return!1;return O.payload.event!=="app-mention"||L.channels.length===0||L.channels.includes(O.payload.conversationId)});for(let L of M){let $={contract:"woml.trigger-ingress",contractVersion:1,messageType:"admit",requestId:`request_discord_${CX()}`,workflowId:L.workflowId,definitionHash:L.definitionHash,triggerId:L.triggerId,triggerHandler:"trigger.discord",sourceIdentity:`discord:${L.botId}:${O.eventId}:${L.workflowId}:${L.triggerId}`,payload:{...O.payload},receivedAt:new Date().toISOString()},Y=await this.#W.submit($);if(Y.messageType==="rejected")throw new PO({kind:"provider_unavailable",code:Y.failure.code,message:Y.failure.message,retryable:!1});this.#W.diagnostic?.(Y.duplicate?"WOML_DISCORD_TRIGGER_DUPLICATE":"WOML_DISCORD_TRIGGER_ACCEPTED",`${Y.duplicate?"Recognized duplicate":"Accepted"} Discord ${O.payload.event} ${O.eventId} for trigger "${L.triggerId}": ${Y.runId}.`)}}}function kj(W){if(W instanceof c)return{code:W.code,message:W.message};if(W instanceof PO)return{code:W.failure.code,message:W.failure.message};return{code:"WOML_DISCORD_TRIGGER_UNAVAILABLE",message:"The Discord Gateway host could not start safely."}}var hq="https://graph.facebook.com/v23.0",uq=30000;function tL(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}class eL extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="WhatsAppTransportError"}}function LO(W,O,M,L,$){return new eL({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}function lq(W,O){let M=tL(O.error)?O.error:{},L=typeof M.code==="number"?M.code:void 0;if(W===429||L===4)return LO("rate_limited","WOML_WHATSAPP_RATE_LIMITED","WhatsApp rate-limited the message request.",!0);if(W===401||W===403||L===190)return LO("provider_auth_failed","WOML_WHATSAPP_AUTH_FAILED","Meta rejected the configured WhatsApp access token or permission.",!1);if(W===400)return LO("destination_invalid","WOML_WHATSAPP_REQUEST_REJECTED","WhatsApp rejected the recipient or approved-template request.",!1);return LO("delivery_ambiguous","WOML_WHATSAPP_DELIVERY_AMBIGUOUS","Meta did not confirm whether the WhatsApp message was accepted; WOML will not replay the uncertain delivery automatically.",!1)}class N9{#W;#O;#M=new Set;#L=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.apiBase??hq}async sendTemplate(W){if(this.#L)throw LO("provider_unavailable","WOML_WHATSAPP_UNAVAILABLE","The WhatsApp transport is closed.",!0);if(!M1(W.accessToken))throw LO("provider_auth_failed","WOML_WHATSAPP_CREDENTIAL_INVALID","The configured WhatsApp access token has an invalid shape or exceeds the credential limit.",!1);let O=W.parameters.length===0?[]:[{type:"body",parameters:W.parameters.map((G)=>({type:"text",text:G}))}];if(W.decisionCapability!==void 0)O.push({type:"button",sub_type:"quick_reply",index:"0",parameters:[{type:"payload",payload:`woml_approve:${W.decisionCapability}`}]},{type:"button",sub_type:"quick_reply",index:"1",parameters:[{type:"payload",payload:`woml_reject:${W.decisionCapability}`}]});let M;try{M=$1({messaging_product:"whatsapp",recipient_type:"individual",to:W.conversationId,type:"template",template:{name:W.templateName,language:{code:W.language},...O.length===0?{}:{components:O}}})}catch{throw LO("size_limit_exceeded","WOML_WHATSAPP_REQUEST_TOO_LARGE","The WhatsApp request exceeds the 64 KiB provider limit.",!1)}let L=new AbortController;this.#M.add(L);let $=setTimeout(()=>L.abort(),uq),Y;try{Y=await this.#W(`${this.#O}/${W.phoneNumberId}/messages`,{method:"POST",headers:{authorization:`Bearer ${W.accessToken}`,"content-type":"application/json"},body:M,signal:L.signal})}catch{throw LO("delivery_ambiguous","WOML_WHATSAPP_DELIVERY_AMBIGUOUS","The WhatsApp request ended before Meta confirmed delivery.",!1)}finally{clearTimeout($),this.#M.delete(L)}let J;try{J=await L1(Y)}catch(G){if(G instanceof gO)throw LO("size_limit_exceeded","WOML_WHATSAPP_RESPONSE_TOO_LARGE","Meta returned a response larger than the 1 MiB provider limit.",!1);throw LO("delivery_ambiguous","WOML_WHATSAPP_RESPONSE_INVALID","Meta returned an unreadable WhatsApp response.",!1)}let A;try{A=J.length===0?{}:JSON.parse(J)}catch{throw LO("delivery_ambiguous","WOML_WHATSAPP_RESPONSE_INVALID","Meta returned an invalid WhatsApp response.",!1)}if(!Y.ok)throw lq(Y.status,tL(A)?A:{});let Z=tL(A)&&Array.isArray(A.messages)?A.messages:[],X=tL(Z[0])?Z[0]:void 0;if(typeof X?.id!=="string"||X.id.length===0)throw LO("delivery_ambiguous","WOML_WHATSAPP_RESPONSE_INVALID","Meta accepted the request but returned no valid message identity.",!1);return{provider:"whatsapp",accountId:W.phoneNumberId,conversationId:W.conversationId,messageId:X.id}}async close(){this.#L=!0;for(let W of this.#M)W.abort();this.#M.clear()}}function pq(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The WhatsApp provider failed safely."}class P9{provider="whatsapp";#W;#O=new Map;constructor(W){this.#W=W}async resolveCredentials(W,O){let M=O.credentials,L=await W.get(M.accessToken.name);if(L===void 0||L.length===0)throw new c("WOML_SECRET_NOT_FOUND","A required WhatsApp access token is not available.");return{credentials:{accessToken:L,phoneNumberId:M.phoneNumberId},secretValues:[L]}}async prepare(){}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A WhatsApp update cannot be delivered as a new message.");let M=this.#O.get(W.idempotencyKey);if(M!==void 0)return M;if(W.templateName===void 0||W.language===void 0)throw Error("WhatsApp delivery is missing approved-template metadata.");let L=!("mode"in W),$=L?[W.message.approvalName,W.message.approvalDescription??"",W.message.workflowId,W.message.expiresAt??"No deadline"]:[W.message],Y=await this.#W.sendTemplate({accessToken:O.accessToken,phoneNumberId:O.phoneNumberId,conversationId:W.destination,templateName:W.templateName,language:W.language,parameters:$,...L?{decisionCapability:W.decisionCapability}:{}});return this.#O.set(W.idempotencyKey,Y),Y}async update(){throw new dW({kind:"update_failed",code:"WOML_WHATSAPP_UPDATE_UNAVAILABLE",message:"WhatsApp template messages cannot be edited after delivery; the approval decision was still recorded.",retryable:!1})}validMessageIdentity(W){return typeof W==="object"&&W!==null&&"provider"in W&&W.provider==="whatsapp"&&"accountId"in W&&typeof W.accountId==="string"&&"conversationId"in W&&typeof W.conversationId==="string"&&"messageId"in W&&typeof W.messageId==="string"}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_WHATSAPP_RESPONSE_INVALID",message:"WhatsApp returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW)return W.failure;if(W instanceof eL)return{...W.failure,message:pq(W.failure.message,O)};if(W instanceof c)return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required WhatsApp credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_WHATSAPP_UNAVAILABLE",message:"The WhatsApp adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function dq(){let W=process.env.WOML_FAKE_SLACK_DECISION;if(W===void 0||W==="")return;if(W==="approved"||W==="rejected")return W;throw Error("WOML_FAKE_SLACK_DECISION must be approved or rejected.")}function cq(){let W=process.env.WOML_FAKE_SLACK_ACTION_DELAY_MS??"0",O=Number(W);if(!Number.isSafeInteger(O)||O<0||O>60000)throw Error("WOML_FAKE_SLACK_ACTION_DELAY_MS must be an integer from 0 through 60000.");return O}function iq(){let W=process.env.WOML_FAKE_SLACK_DELIVERY_FAILURES??"0",O=Number(W);if(!Number.isSafeInteger(O)||O<0||O>2)throw Error("WOML_FAKE_SLACK_DELIVERY_FAILURES must be an integer from 0 through 2.");return O}function sq(){return(process.env.WOML_FAKE_SLACK_FAILED_DESTINATIONS??"").split(",").map((W)=>W.trim()).filter((W)=>W.length>0)}async function nq(W){await new Promise((O,M)=>{process.stdout.write(W,(L)=>{if(L===null||L===void 0)O();else M(L)})})}async function rq(W={}){let O=W.protocolVersion??(process.env.WOML_NOTIFICATION_PROTOCOL_VERSION==="2"?UM:wO),M=new M$(nq),L=new O$({maxFrameBytes:mL}),$=(G)=>M.send(G),Y=W.createTransport?.($)??(W.adapter==="fake"?new V9({emit:$,automaticDecision:dq(),automaticActorId:process.env.WOML_FAKE_SLACK_ACTOR_ID??"U12345678",automaticDelayMs:cq(),deliveryFailuresBeforeSuccess:iq(),failedDestinations:sq()}):new F9({emit:$,log:(G)=>process.stderr.write(`[woml] ${G}
259
- `)})),J=[new VM(Y)];if(W.adapter!=="fake")J.push(new B9(W.createTelegramTransport?.()??new q9)),J.push(new C9(W.createDiscordTransport?.()??new w9)),J.push(new P9(W.createWhatsAppTransport?.()??new N9));let A=new K9({secretStore:LX(),adapters:J,send:(G)=>M.send(G),protocolVersion:O}),Z=J.map((G)=>G.provider);if(!Z.every((G)=>G==="slack"||G==="telegram"||G==="discord"||G==="whatsapp"))throw Error("The notification host contains an unavailable provider adapter.");let X={protocol:SO,protocolVersion:O,messageType:"ready",hostInstanceId:`notification_host_${mq()}`,providers:Z};try{await M.send(X);let G=Bun.stdin.stream().getReader();while(!0){let{done:Q,value:S}=await G.read();if(Q)break;for(let U of L.push(S))A.accept(U)}L.finish(),await A.close(),await M.drain()}catch(G){await A.close().catch(()=>{});let Q=G instanceof Error?G.message:String(G);process.stderr.write(`WOML notification provider host failed: ${Q}
260
- `),process.exitCode=1}}if(import.meta.main)await rq({adapter:"real"});export{rq as runNotificationProviderHost};
255
+ `))L=L.slice(0,-1);if(L.includes("\x00"))throw lO(`Mounted secret ${W} contains a NUL byte.`);return uL(L),L}async has(W){return await this.get(W)!==void 0}async list(){await this.#O();let W=(await eE(this.#W)).sort(),O=[];for(let M of W){try{mW(M)}catch{continue}if(await this.get(M)!==void 0)O.push({name:M,provider:this.provider})}return O}async set(W,O){throw this.#M()}async delete(W){throw this.#M()}async#O(){let W;try{if(W=await $G(this.#W),W.isSymbolicLink()||!W.isDirectory())throw null;if(await Oq(this.#W)!==this.#W)throw null}catch(O){throw lO("WOML_SECRETS_DIRECTORY must be a real, existing directory.",O)}if(process.platform!=="win32"){let O=typeof process.getuid==="function"?process.getuid():void 0;if(O!==void 0&&W.uid!==O&&W.uid!==0)throw lO("WOML_SECRETS_DIRECTORY must be owned by the runtime user or root.");if((W.mode&18)!==0)throw lO("WOML_SECRETS_DIRECTORY must not be writable by group or other users.")}}#M(){return new c("WOML_SECRET_PROVIDER_READ_ONLY","The mounted-file secret provider is read-only. Update the mounted secret through the deployment platform.")}}class K9{provider="production";#W;constructor(W){if(W.length===0)throw new c("WOML_SECRET_PROVIDER_INVALID","The production secret provider requires at least one source.");this.#W=W}async get(W){mW(W);let O=[];for(let M of this.#W){let L=await M.get(W);if(L!==void 0)O.push({provider:M.provider,value:L})}if(O.length===0)return;if(O.some((M)=>M.value!==O[0].value))throw new c("WOML_SECRET_SOURCE_CONFLICT",`Secret ${W} has conflicting values in configured production sources: ${O.map((M)=>M.provider).join(", ")}.`);return O[0].value}async has(W){return await this.get(W)!==void 0}async list(){let W=new Set;for(let M of this.#W)for(let L of await M.list())W.add(L.name);let O=[];for(let M of[...W].sort())await this.get(M),O.push({name:M,provider:this.provider});return O}async set(W,O){throw this.#O()}async delete(W){throw this.#O()}#O(){return new c("WOML_SECRET_PROVIDER_READ_ONLY","The production secret provider is read-only. Rotate the selected environment, mounted-file, or OS source directly.")}}function YG(W=process.env){let O=W[MG]??"os";if(O==="os")return new pL;if(O==="env")return new mL(W);if(O==="files"){let M=W[H9];if(M===void 0||M.length===0)throw new c("WOML_SECRET_PROVIDER_INVALID",'WOML_SECRETS_DIRECTORY is required when WOML_SECRETS_PROVIDER="files".');return new dL(M)}if(O==="production"){let M=[],L=W[H9];if(L!==void 0&&L.length>0)M.push(new dL(L));return M.push(new mL(W),new pL),new K9(M)}throw new c("WOML_SECRET_PROVIDER_INVALID",'WOML_SECRETS_PROVIDER must be "os", "env", "files", or "production".')}import{createHash as Yq,randomUUID as Jq}from"crypto";var UO="woml.notification-provider-host",PO=1,zM=2,cL=1048576;class yW extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="SlackTransportError"}}async function JG(W,O){let M=await W.get(O.botToken.name),L=await W.get(O.appToken.name),$=[...M===void 0||M.length===0?[O.botToken.name]:[],...L===void 0||L.length===0?[O.appToken.name]:[]];if($.length>0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required Slack credential${$.length===1?"":"s"}: ${$.join(", ")}.`);return{botToken:M,appToken:L}}function AG(W,O){return`${W}${Yq("sha256").update(O).digest("hex").slice(0,8).toUpperCase()}`}class T9{#W;#O;#M;#L;#X;#$;#Y=new Map;#Z=new Map;#A=new Map;#G=new Set;#Q=new Map;#S=0;#J=!1;constructor(W){this.#W=W.emit,this.#O=W.automaticDecision,this.#M=W.automaticActorId??"U12345678",this.#L=W.automaticDelayMs??0,this.#X=W.deliveryFailuresBeforeSuccess??0,this.#$=new Set(W.failedDestinations??[])}get connectionCount(){return this.#Y.size}messages(){return[...this.#Z.values()]}async ensureConnection(W,O){if(this.#J)throw this.#R();let M=this.#Y.get(W);if(M!==void 0&&M!==O)throw new yW({kind:"provider_auth_failed",code:"WOML_SLACK_AUTH_FAILED",message:"The Slack app credential changed while its connection was active.",retryable:!1});this.#Y.set(W,O)}async deliver(W){if(this.#J)throw this.#R();if(this.#$.has(W.invocation.destination))throw new yW({kind:"destination_invalid",code:"WOML_SLACK_DESTINATION_INVALID",message:`The fake Slack destination ${W.invocation.destination} is unavailable.`,retryable:!1});let O=(this.#Q.get(W.invocation.deliveryId)??0)+1;if(this.#Q.set(W.invocation.deliveryId,O),O<=this.#X)throw new yW({kind:"rate_limited",code:"WOML_SLACK_RATE_LIMITED",message:"The fake Slack transport is temporarily rate-limited.",retryable:!0,retryAfterMs:1});let M=this.#A.get(W.invocation.idempotencyKey);if(M!==void 0)return M.providerMessage;this.#S+=1;let L={workspaceId:AG("T",W.credentials.botToken),channelId:W.invocation.destination.startsWith("#")?AG("C",W.invocation.destination):W.invocation.destination,messageId:`${1723024800+this.#S}.${String(this.#S).padStart(6,"0")}`},$={deliveryId:W.invocation.deliveryId,destination:W.invocation.destination,providerMessage:L,...W.invocation.protocolVersion===1?{decisionCapability:W.invocation.decisionCapability}:{},message:W.invocation.protocolVersion===1?W.invocation.message.approvalName:W.invocation.message,idempotencyKey:W.invocation.idempotencyKey};if(this.#Z.set(W.invocation.deliveryId,$),this.#A.set(W.invocation.idempotencyKey,$),W.invocation.protocolVersion===1&&this.#O!==void 0)setTimeout(()=>{this.click(W.invocation.deliveryId,this.#O,this.#M)},this.#L);return L}async update(W){if(this.#J)throw this.#R();if(this.#G.has(W.invocation.idempotencyKey))return;if(!("workspaceId"in W.invocation.providerMessage))throw new yW({kind:"update_failed",code:"WOML_SLACK_UPDATE_FAILED",message:"Slack received a non-Slack message identity.",retryable:!1});let O=this.#Z.get(W.invocation.deliveryId);if(O!==void 0&&(O.providerMessage.workspaceId!==W.invocation.providerMessage.workspaceId||O.providerMessage.channelId!==W.invocation.providerMessage.channelId||O.providerMessage.messageId!==W.invocation.providerMessage.messageId))throw new yW({kind:"update_failed",code:"WOML_SLACK_UPDATE_FAILED",message:"The Slack message identity does not match the delivered message.",retryable:!1});if(O!==void 0)O.resolution=W.invocation.resolution;this.#G.add(W.invocation.idempotencyKey)}async click(W,O,M="U12345678"){if(this.#J)return;let L=this.#Z.get(W);if(L===void 0||L.resolution!==void 0||L.decisionCapability===void 0)return;await this.#W({protocol:UO,protocolVersion:PO,messageType:"interaction",interactionId:`interaction_${Jq()}`,deliveryId:W,provider:"slack",decisionCapability:L.decisionCapability,decision:O,providerActorId:M,occurredAt:new Date().toISOString()})}async close(){this.#J=!0,this.#Y.clear()}#R(){return new yW({kind:"provider_unavailable",code:"WOML_SLACK_UNAVAILABLE",message:"The fake Slack transport is closed.",retryable:!0})}}class Aq{#W=new Map;#O=new Map;#M=new Map;register(W){let O=W.adapter.provider;if(W.role==="trigger"){this.#L(this.#W,O,W.role),this.#W.set(O,W.adapter);return}if(W.role==="notification"){this.#L(this.#O,O,W.role),this.#O.set(O,W.adapter);return}this.#L(this.#M,O,W.role),this.#M.set(O,W.adapter)}triggerAdapters(){return[...this.#W.values()]}notificationAdapter(W){return this.#O.get(W)}messagingAdapter(W){return this.#M.get(W)}providers(W){return[...(W==="trigger"?this.#W:W==="notification"?this.#O:this.#M).keys()]}#L(W,O,M){if(W.has(O))throw Error(`Communication ${M} adapter "${O}" is registered more than once.`)}}class Zq{#W;#O=[];#M="created";constructor(W){let O=new Set;for(let M of W){if(O.has(M.provider))throw Error(`Communication trigger adapter "${M.provider}" is registered more than once.`);O.add(M.provider)}this.#W=[...W]}providers(){return this.#W.map((W)=>W.provider)}async start(){if(this.#M!=="created")throw Error("Communication trigger host cannot be started twice.");this.#M="starting";try{for(let W of this.#W)this.#O.push(W),await W.start();this.#M="started"}catch(W){throw await this.#L(),this.#M="closed",W}}async close(){if(this.#M==="closed")return;this.#M="closed",await this.#L()}async#L(){let W=[];for(let O of this.#O.splice(0).reverse())try{await O.close()}catch(M){W.push(M)}if(W.length>0)throw AggregateError(W,"One or more communication trigger adapters failed to close.")}}class dW extends Error{failure;constructor(W){super(typeof W==="object"&&W!==null&&"message"in W&&typeof W.message==="string"?W.message:"The communication provider adapter failed.");this.failure=W;this.name="CommunicationProviderAdapterError"}}var A1=64,Z1=1000;var iL=40000,ZG=100;class pO extends Error{constructor(){super("WOML_PROVIDER_RESPONSE_TOO_LARGE");this.name="ProviderResponseLimitError"}}function G1(W){return W.length>0&&Buffer.byteLength(W,"utf8")<=16384&&!/[\u0000-\u001f\u007f]/u.test(W)}async function X1(W,O=1048576){let M=Number(W.headers.get("content-length"));if(Number.isFinite(M)&&M>O)throw new pO;if(W.body===null)return"";let L=W.body.getReader(),$=[],Y=0;try{for(;;){let Z=await L.read();if(Z.done)break;if(Y+=Z.value.byteLength,Y>O)throw await L.cancel(),new pO;$.push(Z.value)}}finally{L.releaseLock()}let J=new Uint8Array(Y),A=0;for(let Z of $)J.set(Z,A),A+=Z.byteLength;return new TextDecoder().decode(J)}function Q1(W){let O=JSON.stringify(W);if(Buffer.byteLength(O,"utf8")>65536)throw Error("WOML_PROVIDER_REQUEST_TOO_LARGE");return O}class R1 extends Error{constructor(W){super(W);this.name="NotificationProtocolError"}}function N0(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function zO(W,O,M=[]){let L=new Set([...O,...M]);return O.every(($)=>Object.hasOwn(W,$))&&Object.keys(W).every(($)=>L.has($))}var P0=/^.{1,320}$/s,Gq=/^[a-z][A-Za-z0-9]*$/,Xq=/^aprreq_[A-Za-z0-9_-]+$/,Qq=/^[a-z][A-Za-z0-9]*:notify:(0|[1-9][0-9]*):(channel|chat|recipient):(0|[1-9][0-9]*)$/,Rq=/^nupdate_[A-Za-z0-9_-]+$/,rL=/^sha256:[a-f0-9]{64}$/,Sq=/^(#[a-z0-9][a-z0-9_-]{0,79}|[CG][A-Z0-9]{8,31})$/,QG=/^-?[1-9][0-9]{0,19}$/,nL=/^[1-9][0-9]{16,19}$/,RG=/^[0-9]{8,16}$/,SG=/^[0-9]{6,32}$/,GG=/^[a-z][a-z0-9_]{0,511}$/,XG=/^[a-z]{2,3}(?:_[A-Z]{2})?$/;function UG(W){return W==="slack"||W==="telegram"||W==="discord"||W==="whatsapp"}function zG(W,O){return typeof W==="string"&&(O==="slack"?Sq.test(W):O==="telegram"?QG.test(W):O==="discord"?nL.test(W):O==="whatsapp"&&RG.test(W))}function sL(W){return N0(W)&&zO(W,["kind","name"])&&W.kind==="secretReference"&&typeof W.name==="string"&&W.name.length<=255&&EO(W.name)}function VG(W,O){if(!N0(W))return!1;if(O==="telegram"||O==="discord")return zO(W,["botToken"])&&sL(W.botToken);if(O==="whatsapp")return zO(W,["accessToken","phoneNumberId"])&&sL(W.accessToken)&&typeof W.phoneNumberId==="string"&&SG.test(W.phoneNumberId);return O==="slack"&&zO(W,["botToken","appToken"])&&sL(W.botToken)&&sL(W.appToken)}function VM(W){if(N0(W)&&zO(W,["provider","accountId","conversationId","messageId"])&&(W.provider==="telegram"||W.provider==="discord"||W.provider==="whatsapp")&&typeof W.accountId==="string"&&(W.provider==="telegram"?/^[1-9][0-9]{0,19}$/.test(W.accountId):W.provider==="discord"?nL.test(W.accountId):SG.test(W.accountId))&&typeof W.conversationId==="string"&&(W.provider==="telegram"?QG.test(W.conversationId):W.provider==="discord"?nL.test(W.conversationId):RG.test(W.conversationId))&&typeof W.messageId==="string"&&(W.provider==="telegram"?/^[1-9][0-9]{0,19}$/.test(W.messageId):W.provider==="discord"?nL.test(W.messageId):W.messageId.length>=1&&W.messageId.length<=512))return!0;return N0(W)&&zO(W,["workspaceId","channelId","messageId"])&&typeof W.workspaceId==="string"&&/^T[A-Z0-9]{8,31}$/.test(W.workspaceId)&&typeof W.channelId==="string"&&/^[CGD][A-Z0-9]{8,31}$/.test(W.channelId)&&typeof W.messageId==="string"&&/^[0-9]{10,}\.[0-9]{6}$/.test(W.messageId)}function Uq(W){return W.protocol===UO&&W.protocolVersion===PO&&typeof W.invocationId==="string"&&P0.test(W.invocationId)&&typeof W.runId==="string"&&P0.test(W.runId)&&typeof W.approvalId==="string"&&Gq.test(W.approvalId)&&typeof W.requestId==="string"&&Xq.test(W.requestId)&&typeof W.deliveryId==="string"&&Qq.test(W.deliveryId)&&UG(W.provider)&&VG(W.credentials,W.provider)}function zq(W){return W.protocol===UO&&W.protocolVersion===zM&&typeof W.invocationId==="string"&&P0.test(W.invocationId)&&typeof W.runId==="string"&&P0.test(W.runId)&&typeof W.hookInvocationId==="string"&&rL.test(W.hookInvocationId)&&typeof W.actionId==="string"&&P0.test(W.actionId)&&typeof W.deliveryId==="string"&&P0.test(W.deliveryId)&&UG(W.provider)&&zG(W.destination,W.provider)&&typeof W.idempotencyKey==="string"&&rL.test(W.idempotencyKey)&&VG(W.credentials,W.provider)}function Vq(W){return N0(W)&&zO(W,["workflowId","approvalName"],["approvalDescription","expiresAt"])&&typeof W.workflowId==="string"&&P0.test(W.workflowId)&&typeof W.approvalName==="string"&&W.approvalName.length>=1&&W.approvalName.length<=256&&(W.approvalDescription===void 0||typeof W.approvalDescription==="string"&&W.approvalDescription.length>=1&&W.approvalDescription.length<=2000)&&(W.expiresAt===void 0||typeof W.expiresAt==="string"&&Number.isFinite(Date.parse(W.expiresAt)))}function HG(W){if(!N0(W))throw new R1("The provider host received an invalid invocation envelope.");if(W.protocolVersion===zM){let O=W.provider==="whatsapp"?["templateName","language"]:[];if(!zq(W)||!zO(W,["protocol","protocolVersion","messageType","mode","invocationId","runId","hookInvocationId","actionId","deliveryId","provider","destination","idempotencyKey","credentials","message",...O])||W.messageType!=="deliver"||W.mode!=="informational"||typeof W.message!=="string"||W.message.length<1||[...W.message].length>4096||W.provider==="whatsapp"&&(typeof W.templateName!=="string"||!GG.test(W.templateName)||typeof W.language!=="string"||!XG.test(W.language)))throw new R1("The provider host received an invalid informational delivery invocation.");return}if(!Uq(W))throw new R1("The provider host received an invalid invocation envelope.");if(W.messageType==="deliver"){let O=W.provider==="whatsapp"?["templateName","language"]:[];if(!zO(W,["protocol","protocolVersion","messageType","invocationId","runId","approvalId","requestId","deliveryId","provider","destination","idempotencyKey","credentials","decisionCapability","message",...O])||!zG(W.destination,W.provider)||typeof W.idempotencyKey!=="string"||!rL.test(W.idempotencyKey)||typeof W.decisionCapability!=="string"||W.decisionCapability.length<43||W.decisionCapability.length>512||!Vq(W.message)||W.provider==="whatsapp"&&(typeof W.templateName!=="string"||!GG.test(W.templateName)||typeof W.language!=="string"||!XG.test(W.language)))throw new R1("The provider host received an invalid delivery invocation.");return}if(W.messageType!=="update"||!zO(W,["protocol","protocolVersion","messageType","invocationId","runId","approvalId","requestId","deliveryId","updateId","idempotencyKey","provider","credentials","providerMessage","resolution"])||typeof W.updateId!=="string"||W.updateId.length>256||!Rq.test(W.updateId)||typeof W.idempotencyKey!=="string"||!rL.test(W.idempotencyKey)||!VM(W.providerMessage)||W.resolution!=="approved"&&W.resolution!=="rejected"&&W.resolution!=="timeout_failed")throw new R1("The provider host received an invalid update invocation.")}var Hq=new Set(["secret_not_found","provider_auth_failed","destination_invalid","rate_limited","provider_unavailable","delivery_ambiguous","request_invalid","host_crashed","size_limit_exceeded","update_failed"]);function F9(W){return N0(W)&&zO(W,["kind","code","message","retryable"],["retryAfterMs"])&&typeof W.kind==="string"&&Hq.has(W.kind)&&typeof W.code==="string"&&/^WOML_[A-Z0-9_]+$/.test(W.code)&&typeof W.message==="string"&&W.message.length>=1&&W.message.length<=1024&&typeof W.retryable==="boolean"&&(W.retryAfterMs===void 0||Number.isSafeInteger(W.retryAfterMs)&&Number(W.retryAfterMs)>=0&&Number(W.retryAfterMs)<=86400000)}function KG(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The provider invocation failed safely."}class HM{provider="slack";#W;constructor(W){this.#W=W}async resolveCredentials(W,O){if(!("appToken"in O.credentials))throw Error("Slack requires botToken and appToken credentials.");let M=await JG(W,O.credentials);return{credentials:M,secretValues:[M.botToken,M.appToken]}}async prepare(W,O){if(!("appToken"in W.credentials))throw Error("Slack requires an appToken credential.");await this.#W.ensureConnection(W.credentials.appToken.name,O.appToken)}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A Slack update cannot be delivered as a new message.");return await this.#W.deliver({invocation:W,credentials:O})}async update(W,O){if(W.messageType!=="update")throw Error("A Slack delivery cannot be executed as an update.");if(!("workspaceId"in W.providerMessage)||!("appToken"in W.credentials))throw Error("Slack received an invalid message update identity.");await this.#W.update({invocation:W,credentials:O})}validMessageIdentity(W){return VM(W)}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_SLACK_RESPONSE_INVALID",message:"Slack returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW&&F9(W.failure))return{...W.failure,message:KG(W.failure.message,O)};if(W instanceof yW&&F9(W.failure))return{...W.failure,message:KG(W.failure.message,O)};if(W instanceof c&&W.code==="WOML_SECRET_NOT_FOUND")return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required Slack credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_SLACK_UNAVAILABLE",message:"The Slack adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function Kq(W){return Math.max(0,performance.now()-W)}function aL(W,O,M,L){return{protocol:UO,protocolVersion:W,messageType:"completed",invocationId:O,outcome:L,durationMs:Kq(M)}}function Tq(W){return Buffer.byteLength(JSON.stringify(W),"utf8")}class E9{#W;#O;#M;#L;#X;#$=new Map;#Y=!1;constructor(W){if([W.adapter,W.adapters,W.transport].filter((L)=>L!==void 0).length>1)throw Error("NotificationProviderHost accepts adapters or a legacy Slack transport, not both.");if(W.adapter===void 0&&W.adapters===void 0&&W.transport===void 0)throw Error("NotificationProviderHost requires a provider adapter.");this.#W=W.secretStore;let O=W.adapters??[W.adapter??new HM(W.transport)],M=new Map;for(let L of O){if(M.has(L.provider))throw Error(`Notification adapter "${L.provider}" is registered more than once.`);M.set(L.provider,L)}this.#O=M,this.#M=W.send,this.#L=W.maxFrameBytes??cL,this.#X=W.protocolVersion??PO}accept(W){if(this.#Y)throw Error("The notification provider host is closed.");HG(W);let O=this.#O.get(W.provider);if(O===void 0)throw Error(`Notification invocation provider "${W.provider}" has no active adapter.`);if(W.protocolVersion!==this.#X)throw Error(`Notification Provider Host v${this.#X} cannot execute a v${W.protocolVersion} invocation.`);if(this.#$.has(W.invocationId))throw Error(`Invocation ID "${W.invocationId}" is already active.`);let M=this.#Z(W,O).finally(()=>{this.#$.delete(W.invocationId)});this.#$.set(W.invocationId,M)}async drain(){while(this.#$.size>0)await Promise.all([...this.#$.values()])}async close(){this.#Y=!0,await this.drain(),await Promise.all([...this.#O.values()].map((W)=>W.close()))}async#Z(W,O){let M=performance.now(),L=[],$;try{let Y=await O.resolveCredentials(this.#W,W),J=Y.credentials;if(L=[...Y.secretValues],await O.prepare(W,J),W.messageType==="deliver"){let A=await O.deliver(W,J);if(!O.validMessageIdentity(A))throw new dW(O.invalidMessageIdentityFailure());$=aL(W.protocolVersion,W.invocationId,M,{kind:"delivery_success",providerMessage:A})}else await O.update(W,J),$=aL(W.protocolVersion,W.invocationId,M,{kind:"update_success"})}catch(Y){$=aL(W.protocolVersion,W.invocationId,M,{kind:"failure",error:O.safeFailure(Y,L)})}if(Tq($)>this.#L)$=aL(W.protocolVersion,W.invocationId,M,{kind:"failure",error:{kind:"size_limit_exceeded",code:"WOML_NOTIFICATION_SIZE_LIMIT_EXCEEDED",message:"The provider response exceeds the protocol byte limit.",retryable:!1}});await this.#M($)}}import{randomUUID as FG}from"crypto";var Fq="https://slack.com/api/",Eq=1e4,qq=new Set(["connections:write","chat:write","chat:write.public","app_mentions:read","channels:read","channels:history","groups:read","groups:history","im:read","im:history","mpim:read","mpim:history"]);function oL(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function TG(W){if(typeof W!=="string"||W.length>1024)return[];let O=W.split(",").map((M)=>M.trim()).filter((M)=>qq.has(M));return[...new Set(O)].slice(0,32)}function UW(W,O,M,L,$){return new yW({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}function tL(W,O,M,L={}){if(W==="ratelimited"||W==="rate_limited")return UW("rate_limited","WOML_SLACK_RATE_LIMITED","Slack rate-limited the request.",!0,M);if(["invalid_auth","not_authed","account_inactive","token_expired","token_revoked","not_allowed_token_type","missing_scope","no_permission"].includes(W)){let $=TG(L.needed),Y=TG(L.provided),J=L.method!==void 0&&/^[a-z][a-zA-Z0-9.]{0,79}$/.test(L.method)?L.method:void 0,A=[J===void 0?"The Slack app does not have a required permission.":`Slack operation ${J} needs additional app permissions.`,...$.length===0?[]:[`Missing scopes: ${$.join(", ")}.`],...Y.length===0?[]:[`Granted scopes: ${Y.join(", ")}.`],"Add the missing Bot Token Scopes and reinstall the Slack app to the workspace."].join(" ");return UW("provider_auth_failed",W==="missing_scope"||W==="no_permission"?"WOML_SLACK_PERMISSION_DENIED":"WOML_SLACK_AUTH_FAILED",W==="missing_scope"||W==="no_permission"?A:"Slack rejected a configured credential.",!1)}if(["channel_not_found","not_in_channel","is_archived","restricted_action"].includes(W))return UW("destination_invalid","WOML_SLACK_DESTINATION_INVALID","Slack could not access the configured channel.",!1);if(O==="delivery"&&["fatal_error","internal_error"].includes(W))return UW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack did not confirm whether the message was created; WOML will not replay it automatically.",!1);return UW(O==="update"?"update_failed":"provider_unavailable",O==="update"?"WOML_SLACK_UPDATE_FAILED":"WOML_SLACK_UNAVAILABLE",O==="update"?"Slack could not update the approval message.":"Slack could not complete the request.",!0)}class q9{#W;#O;#M;#L;#X;#$;#Y=new Map;#Z=new Map;#A=new Map;#G=new Map;#Q=new Map;#S=new Map;#J=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.createWebSocket??((O)=>new WebSocket(O)),this.#M=W.socketOpenTimeoutMs??Eq,this.#L=W.reconnectBaseDelayMs??500,this.#X=W.log??(()=>{}),this.#$=W.onConnectionState??(()=>{})}subscribe(W,O,M){if(this.#J)throw this.#z();let L=this.#Y.get(W);if(L===void 0){let $=this.#A.get(W)??new Map;if($.has(O))throw Error(`Slack listener "${O}" is already registered.`);$.set(O,M),this.#A.set(W,$)}else{let $=L.listeners.get(O);if($===void 0)L.listeners.set(O,{listener:M,references:new Set([W])});else $.references.add(W)}return()=>{let $=this.#Y.get(W),Y=$?.listeners.get(O);if(Y?.references.delete(W),Y?.references.size===0)$?.listeners.delete(O);let J=this.#A.get(W);if(J?.delete(O),J?.size===0)this.#A.delete(W)}}async ensureConnection(W,O){if(this.#J)throw this.#z();if(!O.startsWith("xapp-"))throw UW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The configured Slack app token is invalid.",!1);let M=this.#Y.get(W);if(M!==void 0&&M.token!==O)throw UW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The Slack app token changed while its Socket Mode connection was active.",!1);if(M===void 0){if(M=this.#Z.get(O),M===void 0)M={token:O,references:new Set,listeners:new Map,reconnectAttempt:0},this.#Z.set(O,M);M.references.add(W);let L=this.#A.get(W);if(L!==void 0){for(let[$,Y]of L){let J=M.listeners.get($);if(J===void 0)M.listeners.set($,{listener:Y,references:new Set([W])});else J.references.add(W)}this.#A.delete(W)}this.#Y.set(W,M)}if(M.socket?.readyState===1)return;if(M.opening===void 0)this.#U(M,"connecting"),M.opening=this.#V(M).finally(()=>{M.opening=void 0});await M.opening}async botIdentity(W,O){if(!O.startsWith("xoxb-"))throw UW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The configured Slack bot token is invalid.",!1);let M=this.#Q.get(W);if(M!==void 0&&M!==O)throw UW("provider_auth_failed","WOML_SLACK_AUTH_FAILED","The Slack bot token changed while the Slack host was active.",!1);this.#Q.set(W,O);let L=this.#G.get(O);if(L!==void 0)return await L;let $=this.api("auth.test",O,{},"none").then((Y)=>{if(typeof Y.team_id!=="string"||!/^T[A-Z0-9]{8,31}$/.test(Y.team_id)||typeof Y.user_id!=="string"||!/^U[A-Z0-9]{8,31}$/.test(Y.user_id))throw UW("request_invalid","WOML_SLACK_RESPONSE_INVALID","Slack returned an invalid workspace identity.",!1);return{token:O,teamId:Y.team_id,userId:Y.user_id}});return this.#G.set(O,$),await $}async resolveDestination(W,O,M){if(!W.startsWith("#"))return W;let L=W.slice(1),$=`${M}\x00${L}`,Y=this.#S.get($);if(Y!==void 0)return await Y;let J=this.#R(L,M);return this.#S.set($,J),await J}async api(W,O,M,L){if(this.#J)throw this.#z();let $;try{$=await this.#W(`${Fq}${W}`,{method:"POST",headers:{Authorization:`Bearer ${O}`,"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(M)})}catch{if(L==="delivery")throw UW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","The Slack delivery connection ended without a definitive response; WOML will not replay it automatically.",!1);throw UW(L==="update"?"update_failed":"provider_unavailable",L==="update"?"WOML_SLACK_UPDATE_FAILED":"WOML_SLACK_UNAVAILABLE",L==="update"?"The Slack message update could not be confirmed.":"Slack is currently unavailable.",!0)}let Y=Number($.headers.get("retry-after")),J=Number.isFinite(Y)?Math.max(0,Y*1000):void 0;if($.status===429)throw tL("ratelimited",L,J);if(!$.ok){if(L==="delivery"&&$.status>=500)throw UW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack did not confirm whether the message was created; WOML will not replay it automatically.",!1);throw tL("service_unavailable",L,J)}let A;try{A=await $.json()}catch{throw L==="delivery"?UW("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack returned an unreadable delivery response; WOML will not replay it automatically.",!1):UW(L==="update"?"update_failed":"request_invalid",L==="update"?"WOML_SLACK_UPDATE_FAILED":"WOML_SLACK_RESPONSE_INVALID","Slack returned an unreadable response.",L==="update")}if(!oL(A))throw tL("invalid_response",L);if(A.ok!==!0)throw tL(typeof A.error==="string"?A.error:"invalid_response",L,J,{method:W,needed:A.needed,provided:A.provided});return A}async close(){if(this.#J)return;this.#J=!0;for(let W of this.#Z.values()){if(W.reconnectTimer!==void 0)clearTimeout(W.reconnectTimer);W.socket?.close(1000,"WOML Slack host shutting down"),this.#U(W,"stopped")}this.#Y.clear(),this.#Z.clear(),this.#A.clear(),this.#G.clear(),this.#Q.clear(),this.#S.clear()}async#R(W,O){let M;do{let L=await this.api("conversations.list",O,{types:"public_channel,private_channel",exclude_archived:!0,limit:200,...M===void 0?{}:{cursor:M}},"none");if(!Array.isArray(L.channels))throw UW("request_invalid","WOML_SLACK_RESPONSE_INVALID","Slack returned an invalid channel list.",!1);for(let $ of L.channels)if(oL($)&&$.name===W&&typeof $.id==="string"&&/^[CG][A-Z0-9]{8,31}$/.test($.id))return $.id;M=oL(L.response_metadata)&&typeof L.response_metadata.next_cursor==="string"&&L.response_metadata.next_cursor.length>0?L.response_metadata.next_cursor:void 0}while(M!==void 0);throw UW("destination_invalid","WOML_SLACK_DESTINATION_INVALID",`Slack channel #${W} was not found or is not visible to the app.`,!1)}async#V(W){let O=await this.api("apps.connections.open",W.token,{},"none");if(typeof O.url!=="string"||!O.url.startsWith("wss://"))throw UW("request_invalid","WOML_SLACK_RESPONSE_INVALID","Slack returned an invalid Socket Mode endpoint.",!1);let M=this.#O(O.url);W.socket=M,M.addEventListener("message",(L)=>{this.#F(W,M,L.data)}),M.addEventListener("close",()=>{if(W.socket===M)W.socket=void 0,this.#H(W)}),await new Promise((L,$)=>{let Y=setTimeout(()=>{M.close(1011,"Socket Mode open timeout"),$(UW("provider_unavailable","WOML_SLACK_UNAVAILABLE","Slack Socket Mode did not connect before its deadline.",!0))},this.#M);M.addEventListener("open",()=>{clearTimeout(Y),W.reconnectAttempt=0,this.#U(W,"ready"),L()},{once:!0}),M.addEventListener("error",()=>{clearTimeout(Y),$(UW("provider_unavailable","WOML_SLACK_UNAVAILABLE","Slack Socket Mode could not establish a connection.",!0))},{once:!0})})}#H(W){if(this.#J||W.reconnectTimer!==void 0)return;let O=Math.min(this.#L*2**W.reconnectAttempt,30000);W.reconnectAttempt+=1,this.#U(W,"reconnecting",O),W.reconnectTimer=setTimeout(()=>{if(W.reconnectTimer=void 0,this.#J||W.opening!==void 0)return;W.opening=this.#V(W).catch(()=>this.#H(W)).finally(()=>{W.opening=void 0})},O)}#F(W,O,M){if(typeof M!=="string")return;let L;try{L=JSON.parse(M)}catch{return}if(!oL(L))return;if(L.type==="disconnect"){if(W.socket===O)W.socket=void 0,O.close(1000,"Slack requested Socket Mode refresh"),this.#H(W);return}let $=typeof L.envelope_id==="string"?L.envelope_id:void 0,Y=!1,J={body:L,...$===void 0?{}:{envelopeId:$},appTokenReferences:[...W.references].sort(),acknowledge:()=>{if(Y||$===void 0)return;Y=!0,O.send(JSON.stringify({envelope_id:$}))}};for(let A of W.listeners.values())Promise.resolve(A.listener(J)).catch((Z)=>{let G=Z instanceof Error?Z.message:String(Z);this.#X(`Slack envelope listener failed safely: ${G}`)})}#z(){return UW("provider_unavailable","WOML_SLACK_UNAVAILABLE","The shared Slack transport is closed.",!0)}#U(W,O,M){this.#$({state:O,appTokenReferences:[...W.references].sort(),...M===void 0?{}:{retryAt:new Date(Date.now()+M).toISOString()}})}}var qG="woml_approval_approved",BG="woml_approval_rejected",CG="woml_approval_actions";function eL(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function KM(W,O){return[...W].slice(0,O).join("")}function S1(W,O,M,L){return new yW({kind:W,code:O,message:M,retryable:L})}function EG(W,O){return JSON.stringify({version:1,deliveryId:W.invocation.deliveryId,decisionCapability:W.invocation.decisionCapability,decision:O})}function Bq(W){let{message:O}=W.invocation,M=[`Workflow: ${O.workflowId}`,...O.approvalDescription===void 0?[]:[O.approvalDescription],...O.expiresAt===void 0?[]:[`Decision deadline: ${O.expiresAt}`]].join(`
256
+ `);return[{type:"header",text:{type:"plain_text",text:KM(O.approvalName,150),emoji:!0}},{type:"section",text:{type:"plain_text",text:KM(M,3000),emoji:!0}},{type:"actions",block_id:CG,elements:[{type:"button",text:{type:"plain_text",text:"Approve",emoji:!0},action_id:qG,style:"primary",value:EG(W,"approved")},{type:"button",text:{type:"plain_text",text:"Reject",emoji:!0},action_id:BG,style:"danger",value:EG(W,"rejected")}]}]}function Cq(W){let O={approved:["Approved","This workflow approval was accepted."],rejected:["Rejected","This workflow approval was rejected."],timeout_failed:["Approval expired","The approval deadline passed and the workflow failed."]},[M,L]=O[W.invocation.resolution];return[{type:"header",text:{type:"plain_text",text:M,emoji:!0}},{type:"section",text:{type:"plain_text",text:L,emoji:!0}}]}function wq(W){if(typeof W!=="string"||W.length>1500)return;try{let O=JSON.parse(W);if(!eL(O)||Object.keys(O).length!==4||O.version!==1||typeof O.deliveryId!=="string"||typeof O.decisionCapability!=="string"||O.decision!=="approved"&&O.decision!=="rejected")return;return O}catch{return}}class B9{#W;#O;#M;#L;#X=`approval_${FG()}`;#$=new Map;#Y=new Map;#Z=new Set;#A=new Map;#G=!1;constructor(W){this.#W=W.emit,this.#L=W.log??(()=>{}),this.#M=W.sharedTransport===void 0,this.#O=W.sharedTransport??new q9({fetch:W.fetch,createWebSocket:W.createWebSocket,socketOpenTimeoutMs:W.socketOpenTimeoutMs,reconnectBaseDelayMs:W.reconnectBaseDelayMs,log:W.log})}async ensureConnection(W,O){if(this.#G)throw this.#R();if(!this.#$.has(W))this.#$.set(W,this.#O.subscribe(W,this.#X,(M)=>this.#J(M)));await this.#O.ensureConnection(W,O)}async deliver(W){if(this.#G)throw this.#R();let O=W.invocation.idempotencyKey,M=this.#Y.get(O);if(M!==void 0)return await M;let L=this.#Q(W).catch(($)=>{throw this.#Y.delete(O),$});if(this.#Y.set(O,L),W.invocation.protocolVersion===1)this.#Z.add(W.invocation.deliveryId);return await L}async update(W){if(this.#G)throw this.#R();let O=W.invocation.idempotencyKey,M=this.#A.get(O);if(M!==void 0)return await M;let L=this.#S(W).catch(($)=>{throw this.#A.delete(O),$});this.#A.set(O,L),await L}async close(){if(this.#G)return;this.#G=!0;for(let W of this.#$.values())W();if(this.#$.clear(),this.#M)await this.#O.close()}async#Q(W){if(!("botToken"in W.invocation.credentials))throw S1("request_invalid","WOML_NOTIFICATION_REQUEST_INVALID","Slack received non-Slack credentials.",!1);let O=W.invocation.credentials.botToken.name,M=await this.#O.botIdentity(O,W.credentials.botToken),L=await this.#O.resolveDestination(W.invocation.destination,O,W.credentials.botToken),$=W.invocation,Y=$.protocolVersion===2,J=$.protocolVersion===2?{text:KM($.message,4096)}:{text:`Approval required: ${KM($.message.approvalName,300)}`,blocks:Bq({...W,invocation:$})},A=await this.#O.api("chat.postMessage",W.credentials.botToken,{channel:L,...J,unfurl_links:!1,unfurl_media:!1},"delivery"),Z={workspaceId:M.teamId,channelId:A.channel,messageId:A.ts};if(!VM(Z))throw S1("delivery_ambiguous","WOML_NOTIFICATION_DELIVERY_AMBIGUOUS","Slack created an unrecognized response; WOML will not replay the message automatically.",!1);return this.#L(Y?`Slack lifecycle notification sent to ${W.invocation.destination}.`:`Slack approval sent to ${W.invocation.destination}; waiting for Approve or Reject.`),Z}async#S(W){if(!("workspaceId"in W.invocation.providerMessage))throw S1("update_failed","WOML_SLACK_UPDATE_FAILED","Slack received a non-Slack message identity.",!1);if(!("botToken"in W.invocation.credentials))throw S1("update_failed","WOML_SLACK_UPDATE_FAILED","Slack received non-Slack credentials.",!1);let O=W.invocation.credentials.botToken.name;if((await this.#O.botIdentity(O,W.credentials.botToken)).teamId!==W.invocation.providerMessage.workspaceId)throw S1("update_failed","WOML_SLACK_UPDATE_FAILED","The Slack message belongs to a different workspace.",!1);let L=W.invocation.resolution==="approved"?"Approved":W.invocation.resolution==="rejected"?"Rejected":"Approval expired";await this.#O.api("chat.update",W.credentials.botToken,{channel:W.invocation.providerMessage.channelId,ts:W.invocation.providerMessage.messageId,text:L,blocks:Cq(W)},"update")}async#J(W){let O=W.body;if(O.type!=="interactive"||!eL(O.payload))return;W.acknowledge();let M=O.payload;if(M.type!=="block_actions"||!Array.isArray(M.actions))return;let L=M.actions[0];if(!eL(L)||L.block_id!==CG)return;let $=L.action_id===qG?"approved":L.action_id===BG?"rejected":void 0,Y=wq(L.value);if(Y===void 0||Y.decision!==$)return;if(!this.#Z.has(Y.deliveryId))return;if(!eL(M.user)||typeof M.user.id!=="string"||!/^U[A-Z0-9]{8,31}$/.test(M.user.id))return;await this.#W({protocol:UO,protocolVersion:PO,messageType:"interaction",interactionId:W.envelopeId===void 0?`slack_${FG()}`:KM(`slack_${W.envelopeId}`,320),deliveryId:Y.deliveryId,provider:"slack",decisionCapability:Y.decisionCapability,decision:Y.decision,providerActorId:M.user.id,occurredAt:new Date().toISOString()})}#R(){return S1("provider_unavailable","WOML_SLACK_UNAVAILABLE","The Slack approval adapter is closed.",!0)}}var Pq="https://api.telegram.org",Nq=25,_q=30000;function cW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}class NO extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="TelegramTransportError"}}function CW(W,O,M,L,$){return new NO({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}function C9(W,O,M){let L=typeof O.error_code==="number"?O.error_code:W,$=cW(O.parameters)?O.parameters.retry_after:void 0;if(L===429)return CW("rate_limited","WOML_TELEGRAM_RATE_LIMITED","Telegram rate-limited the bot request.",!0,typeof $==="number"&&Number.isFinite($)?Math.max(0,Math.floor($*1000)):void 0);if(L===401)return CW("provider_auth_failed","WOML_TELEGRAM_AUTH_FAILED","Telegram rejected the configured bot token.",!1);if(L===400||L===403)return CW("destination_invalid","WOML_TELEGRAM_DESTINATION_INVALID","Telegram could not access the configured chat. Confirm the numeric chat ID and add the bot to that chat.",!1);if(L===409&&M==="read")return CW("provider_unavailable","WOML_TELEGRAM_POLLING_CONFLICT","Telegram long polling is unavailable because another poller or webhook is active for this bot.",!1);if(M==="delivery")return CW("delivery_ambiguous","WOML_TELEGRAM_DELIVERY_AMBIGUOUS","Telegram did not confirm whether the message was created; WOML will not replay the uncertain delivery automatically.",!1);return CW(M==="update"?"update_failed":"provider_unavailable",M==="update"?"WOML_TELEGRAM_UPDATE_FAILED":"WOML_TELEGRAM_UNAVAILABLE",M==="update"?"Telegram could not update the message.":"Telegram could not complete the request.",!0)}class w9{#W;#O;#M;#L;#X;#$=new Map;#Y=new Map;#Z=new Map;#A=new Set;#G=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.pollTimeoutSeconds??Nq,this.#M=W.retryDelayMs??1000,this.#L=W.log??(()=>{}),this.#X=W.onFatal??(()=>{})}subscribe(W,O,M){if(this.#G)throw this.#R();if(this.#V()>=Z1)throw CW("size_limit_exceeded","WOML_TELEGRAM_SUBSCRIBER_LIMIT",`Telegram supports at most ${Z1} active trigger subscriptions per runtime.`,!1);let L=this.#Y.get(W),$=L?.listeners??this.#Z.get(W)??new Map;if($.has(O))throw Error(`Telegram listener "${O}" is already registered.`);if($.set(O,M),L===void 0)this.#Z.set(W,$);return()=>$.delete(O)}async ensurePolling(W,O){if(this.#G)throw this.#R();let M=this.#Y.get(W);if(M!==void 0){if(M.token!==O)throw this.#R();return M.identity}let L=this.#$.get(O);if(L===void 0){if(this.#$.size>=A1)throw CW("size_limit_exceeded","WOML_TELEGRAM_CONNECTION_LIMIT",`Telegram supports at most ${A1} bot connections per runtime.`,!1);let Y=await this.botIdentity(O);L={token:O,references:new Set,listeners:new Map,identity:Y,offset:0},this.#$.set(O,L),L.task=this.#Q(L)}L.references.add(W),this.#Y.set(W,L);let $=this.#Z.get(W);if($!==void 0){for(let[Y,J]of $)L.listeners.set(Y,J);this.#Z.delete(W)}return L.identity}async botIdentity(W){let O=await this.#J(W,"getMe",{},"read");if(!cW(O)||!Number.isSafeInteger(O.id)&&typeof O.id!=="string"||O.is_bot!==!0||O.username!==void 0&&typeof O.username!=="string")throw CW("request_invalid","WOML_TELEGRAM_RESPONSE_INVALID","Telegram returned an invalid bot identity.",!1);return{botId:String(O.id),...typeof O.username==="string"?{username:O.username}:{}}}async sendMessage(W){let O=W.decisionCapability===void 0?void 0:{inline_keyboard:[[{text:"Approve",callback_data:`a:${W.decisionCapability}`},{text:"Reject",callback_data:`r:${W.decisionCapability}`}]]},M=await this.#J(W.botToken,"sendMessage",{chat_id:W.conversationId,text:W.text,...W.replyToMessageId===void 0?{}:{reply_parameters:{message_id:Number(W.replyToMessageId)}},...O===void 0?{}:{reply_markup:O}},"delivery");if(!cW(M)||!Number.isSafeInteger(M.message_id)||!cW(M.chat)||!Number.isSafeInteger(M.chat.id)&&typeof M.chat.id!=="string")throw CW("request_invalid","WOML_TELEGRAM_RESPONSE_INVALID","Telegram returned an invalid message identity.",!1);return{provider:"telegram",accountId:W.accountId,conversationId:String(M.chat.id),messageId:String(M.message_id)}}async updateMessage(W){await this.#J(W.botToken,"editMessageReplyMarkup",{chat_id:W.conversationId,message_id:Number(W.messageId),reply_markup:{inline_keyboard:[]}},"update")}async answerCallback(W,O,M){let L=this.#Y.get(W);if(L===void 0)return;await this.#J(L.token,"answerCallbackQuery",{callback_query_id:O,text:M},"read")}async close(){if(this.#G)return;this.#G=!0;for(let W of this.#A)W.abort();await Promise.allSettled([...this.#$.values()].flatMap((W)=>W.task===void 0?[]:[W.task])),this.#Y.clear(),this.#$.clear(),this.#Z.clear()}async#Q(W){while(!this.#G)try{let O=await this.#J(W.token,"getUpdates",{offset:W.offset,timeout:this.#O,allowed_updates:["message","callback_query"]},"read",(this.#O+5)*1000);if(!Array.isArray(O)||O.length>ZG)throw CW("request_invalid","WOML_TELEGRAM_RESPONSE_INVALID","Telegram returned an invalid update batch.",!1);for(let M of O){let L=this.#S(M,W.identity);if(L===void 0){if(cW(M)&&Number.isSafeInteger(M.update_id))W.offset=Number(M.update_id)+1;continue}for(let $ of W.listeners.values())await $(L);W.offset=L.updateId+1}}catch(O){if(this.#G)return;if(O instanceof NO&&!O.failure.retryable){this.#X(O.failure);return}let M=O instanceof NO?O.failure.message:"Telegram polling failed safely.";this.#L(`${M} Retrying Telegram polling.`),await Bun.sleep(this.#M)}}#S(W,O){if(!cW(W)||!Number.isSafeInteger(W.update_id))return;let M=Number(W.update_id);if(cW(W.callback_query)){let Z=W.callback_query;if(typeof Z.id!=="string"||!cW(Z.from)||!Number.isSafeInteger(Z.from.id)&&typeof Z.from.id!=="string"||typeof Z.data!=="string")return;let G=/^(a|r):(ncap_[a-f0-9]+\.[a-f0-9]+)$/.exec(Z.data);if(G===null)return;return{kind:"callback",updateId:M,callbackQueryId:Z.id,actorId:String(Z.from.id),decisionCapability:G[2],decision:G[1]==="a"?"approved":"rejected"}}if(!cW(W.message))return;let L=W.message;if(!Number.isSafeInteger(L.message_id)||!Number.isSafeInteger(L.date)||typeof L.text!=="string"||Buffer.byteLength(L.text,"utf8")>iL||!cW(L.from)||!Number.isSafeInteger(L.from.id)&&typeof L.from.id!=="string"||L.from.is_bot===!0||!cW(L.chat)||!Number.isSafeInteger(L.chat.id)&&typeof L.chat.id!=="string")return;let $=L.chat.type,Y=$==="private"?"direct":$==="channel"?"channel":"group",J=[L.from.first_name,L.from.last_name].filter((Z)=>typeof Z==="string"&&Z.length>0).join(" "),A=cW(L.reply_to_message)&&Number.isSafeInteger(L.reply_to_message.message_id)?String(L.reply_to_message.message_id):void 0;return{kind:"message",updateId:M,payload:{provider:"telegram",event:"message",text:L.text,senderId:String(L.from.id),...J.length===0?{}:{senderName:J},conversationId:String(L.chat.id),conversationType:Y,messageId:String(L.message_id),...A===void 0?{}:{replyToMessageId:A},occurredAt:new Date(Number(L.date)*1000).toISOString(),providerData:{botId:O.botId}}}}async#J(W,O,M,L,$=_q){if(!G1(W))throw CW("provider_auth_failed","WOML_TELEGRAM_CREDENTIAL_INVALID","The configured Telegram bot token has an invalid shape or exceeds the credential limit.",!1);let Y;try{Y=Q1(M)}catch{throw CW("size_limit_exceeded","WOML_TELEGRAM_REQUEST_TOO_LARGE","The Telegram request exceeds the 64 KiB provider limit.",!1)}let J=new AbortController;this.#A.add(J);let A=setTimeout(()=>J.abort(),$),Z;try{Z=await this.#W(`${Pq}/bot${W}/${O}`,{method:"POST",headers:{"content-type":"application/json"},body:Y,signal:J.signal})}catch(Q){if(Q instanceof dW)throw Q;throw CW(L==="delivery"?"delivery_ambiguous":"provider_unavailable",L==="delivery"?"WOML_TELEGRAM_DELIVERY_AMBIGUOUS":"WOML_TELEGRAM_UNAVAILABLE",L==="delivery"?"The Telegram delivery connection ended without a confirmed result.":"Telegram is temporarily unavailable.",L!=="delivery")}finally{clearTimeout(A),this.#A.delete(J)}let G;try{G=await X1(Z)}catch(Q){if(Q instanceof pO)throw CW("size_limit_exceeded","WOML_TELEGRAM_RESPONSE_TOO_LARGE","Telegram returned a response larger than the 1 MiB provider limit.",!1);throw C9(Z.status,{},L)}let X;try{X=JSON.parse(G)}catch{throw C9(Z.status,{},L)}if(!cW(X)||X.ok!==!0)throw C9(Z.status,cW(X)?X:{},L);return X.result}#R(){return CW("provider_unavailable","WOML_TELEGRAM_UNAVAILABLE","The Telegram transport is closed or has conflicting credentials.",!0)}#V(){let W=0;for(let O of this.#$.values())W+=O.listeners.size;for(let O of this.#Z.values())W+=O.size;return W}}function jq(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The Telegram provider failed safely."}function Iq(W){if("mode"in W)return W.message;return[W.message.approvalName,W.message.approvalDescription,`Workflow: ${W.message.workflowId}`,W.message.expiresAt===void 0?void 0:`Deadline: ${W.message.expiresAt}`].filter((O)=>O!==void 0&&O.length>0).join(`
257
+ `)}class P9{provider="telegram";#W;#O=new Map;#M=new Map;constructor(W){this.#W=W}async resolveCredentials(W,O){let M=O.credentials,L=await W.get(M.botToken.name);if(L===void 0||L.length===0)throw new c("WOML_SECRET_NOT_FOUND","A required Telegram bot token is not available.");return{credentials:{botToken:L},secretValues:[L]}}async prepare(W,O){if(this.#O.has(O.botToken))return;let M=await this.#W.botIdentity(O.botToken);this.#O.set(O.botToken,M.botId)}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A Telegram update cannot be delivered as a new message.");let M=this.#M.get(W.idempotencyKey);if(M!==void 0)return M;let L=this.#O.get(O.botToken);if(L===void 0)throw Error("Telegram bot identity is unavailable.");let $=await this.#W.sendMessage({botToken:O.botToken,accountId:L,conversationId:W.destination,text:Iq(W),..."mode"in W?{}:{decisionCapability:W.decisionCapability}});return this.#M.set(W.idempotencyKey,$),$}async update(W,O){if(W.messageType!=="update"||!("provider"in W.providerMessage)||W.providerMessage.provider!=="telegram")throw Error("Telegram received an invalid message update identity.");await this.#W.updateMessage({botToken:O.botToken,conversationId:W.providerMessage.conversationId,messageId:W.providerMessage.messageId,resolution:W.resolution})}validMessageIdentity(W){return typeof W==="object"&&W!==null&&"provider"in W&&W.provider==="telegram"&&"accountId"in W&&typeof W.accountId==="string"&&"conversationId"in W&&typeof W.conversationId==="string"&&"messageId"in W&&typeof W.messageId==="string"}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_TELEGRAM_RESPONSE_INVALID",message:"Telegram returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW)return W.failure;if(W instanceof NO)return{...W.failure,message:jq(W.failure.message,O)};if(W instanceof c)return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required Telegram credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_TELEGRAM_UNAVAILABLE",message:"The Telegram adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function yq(W){return W.kind==="object"?W.fields:void 0}function Dq(W){if(W?.kind!=="array")return[];return W.items.flatMap((O)=>O.kind==="literal"&&typeof O.value==="string"?[O.value]:[])}function Xj(W,O){return W.triggers.filter((M)=>M.handler==="trigger.telegram").map((M)=>{let L=yq(M.config),$=Dq(L?.events),Y=L?.botToken?.kind==="secretReference"?L.botToken.name:void 0;if(L===void 0||$.length!==1||$[0]!=="message"||Y===void 0)throw Error(`Compiled Telegram trigger "${M.id}" does not match Model v15.`);return{workflowId:W.workflowId,definitionHash:O,triggerId:M.id,events:["message"],credentialNames:{botToken:Y}}})}import{randomUUID as wG}from"crypto";class kq{provider="telegram";#W;#O=`telegram_${wG()}`;#M=[];#L=[];#X=!1;#$=!1;constructor(W){if(W.registrations.length===0&&(W.credentialNames?.length??0)===0)throw Error("TelegramTriggerHost requires a trigger or notification credential.");this.#W=W}async start(){if(this.#X||this.#$)throw Error("Telegram trigger host cannot be started twice.");this.#X=!0;let W=new Set([...this.#W.registrations.map((O)=>O.credentialNames.botToken),...this.#W.credentialNames??[]]);try{for(let O of W){let M=await this.#W.secretStore.get(O);if(M===void 0||M.length===0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required secret: ${O}. Configure it with: woml secrets set ${O}`);this.#L.push(this.#W.transport.subscribe(O,`${this.#O}:${O}`,($)=>this.#Y(O,$)));let L=await this.#W.transport.ensurePolling(O,M);for(let $ of this.#W.registrations)if($.credentialNames.botToken===O)this.#M.push({...$,botId:L.botId});this.#W.diagnostic?.("WOML_TELEGRAM_READY",`Telegram bot${L.username===void 0?"":` @${L.username}`} is ready.`)}}catch(O){throw await this.close(),O}}async close(){if(this.#$)return;this.#$=!0;for(let W of this.#L.splice(0))W();this.#M.splice(0)}async#Y(W,O){if(O.kind==="callback"){if(this.#W.resolveApproval===void 0)return;let L=await this.#W.resolveApproval(O);try{await this.#W.transport.answerCallback(W,O.callbackQueryId,L==="already-resolved"?"This approval was already resolved.":L==="expired"?"This approval has expired.":O.decision==="approved"?"Approved":"Rejected")}catch($){let Y=$ instanceof NO?$.failure.code:"WOML_TELEGRAM_CALLBACK_ACK_FAILED";this.#W.diagnostic?.(Y,"The approval decision was saved, but Telegram could not acknowledge the button press.")}return}let M=this.#M.filter((L)=>L.credentialNames.botToken===W&&L.botId===O.payload.providerData.botId&&L.events.includes("message"));for(let L of M){let $={contract:"woml.trigger-ingress",contractVersion:1,messageType:"admit",requestId:`request_telegram_${wG()}`,workflowId:L.workflowId,definitionHash:L.definitionHash,triggerId:L.triggerId,triggerHandler:"trigger.telegram",sourceIdentity:`telegram:${L.botId}:${O.updateId}:${L.workflowId}:${L.triggerId}`,payload:{...O.payload},receivedAt:new Date().toISOString()},Y=await this.#W.submit($);if(Y.messageType==="rejected")throw new NO({kind:"provider_unavailable",code:Y.failure.code,message:Y.failure.message,retryable:Y.failure.retryable});this.#W.diagnostic?.(Y.duplicate?"WOML_TELEGRAM_TRIGGER_DUPLICATE":"WOML_TELEGRAM_TRIGGER_ACCEPTED",`${Y.duplicate?"Recognized duplicate":"Accepted"} Telegram message ${O.updateId} for trigger "${L.triggerId}": ${Y.runId}.`)}}}function Vj(W){if(W instanceof c)return{code:W.code,message:W.message};if(W instanceof NO)return{code:W.failure.code,message:W.failure.message};return{code:"WOML_TELEGRAM_TRIGGER_UNAVAILABLE",message:"The Telegram long-polling host could not start safely."}}var bq="https://discord.com/api/v10",fq="wss://gateway.discord.gg/?v=10&encoding=json",vq=30000,gq=30000,xq=37377;function DW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}function _O(W){return typeof W==="string"&&/^[0-9]{17,20}$/.test(W)}class jO extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="DiscordTransportError"}}function YW(W,O,M,L,$){return new jO({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}class N9{#W;#O;#M;#L;#X;#$;#Y;#Z;#A=new Map;#G=new Map;#Q=new Map;#S=new Set;#J=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.createWebSocket??((O)=>new WebSocket(O)),this.#M=W.apiBase??bq,this.#L=W.gatewayUrl??fq,this.#X=W.reconnectDelayMs??1000,this.#$=W.readyTimeoutMs??gq,this.#Y=W.log??(()=>{}),this.#Z=W.onFatal??(()=>{})}subscribe(W,O,M){if(this.#J)throw this.#K();if(this.#P()>=Z1)throw YW("size_limit_exceeded","WOML_DISCORD_SUBSCRIBER_LIMIT",`Discord supports at most ${Z1} active trigger subscriptions per runtime.`,!1);let L=this.#G.get(W),$=L?.listeners??this.#Q.get(W)??new Map;if($.has(O))throw Error(`Discord listener "${O}" is already registered.`);if($.set(O,M),L===void 0)this.#Q.set(W,$);return()=>$.delete(O)}async ensureConnected(W,O){if(this.#J)throw this.#K();let M=this.#G.get(W);if(M!==void 0){if(M.token!==O)throw this.#K();return M.identity}let L=this.#A.get(O);if(L===void 0){if(this.#A.size>=A1)throw YW("size_limit_exceeded","WOML_DISCORD_CONNECTION_LIMIT",`Discord supports at most ${A1} bot connections per runtime.`,!1);let Y=await this.botIdentity(O);L={token:O,references:new Set([W]),listeners:this.#Q.get(W)??new Map,identity:Y,awaitingHeartbeatAck:!1,dispatchChain:Promise.resolve(),fatal:!1},this.#A.set(O,L),this.#G.set(W,L),this.#Q.delete(W);try{await this.#R(L)}catch(J){throw this.#A.delete(O),this.#G.delete(W),J}return L.identity}L.references.add(W),this.#G.set(W,L);let $=this.#Q.get(W);if($!==void 0){for(let[Y,J]of $)L.listeners.set(Y,J);this.#Q.delete(W)}return L.identity}async botIdentity(W){let O=await this.#T(W,"/users/@me","GET",void 0,"read");if(!DW(O)||!_O(O.id)||typeof O.username!=="string"||O.username.length===0||O.bot!==!0)throw YW("request_invalid","WOML_DISCORD_RESPONSE_INVALID","Discord returned an invalid bot identity.",!1);return{botId:O.id,username:O.username}}async sendMessage(W){let O=W.decisionCapability===void 0?void 0:[{type:1,components:[{type:2,style:3,label:"Approve",custom_id:`a:${W.decisionCapability}`},{type:2,style:4,label:"Reject",custom_id:`r:${W.decisionCapability}`}]}],M=await this.#T(W.botToken,`/channels/${W.conversationId}/messages`,"POST",{content:W.text,...W.replyToMessageId===void 0?{}:{message_reference:{message_id:W.replyToMessageId,fail_if_not_exists:!1}},...O===void 0?{}:{components:O}},"delivery");if(!DW(M)||!_O(M.id)||!_O(M.channel_id))throw YW("delivery_ambiguous","WOML_DISCORD_RESPONSE_INVALID","Discord returned an invalid message identity.",!1);return{provider:"discord",accountId:W.accountId,conversationId:M.channel_id,messageId:M.id}}async updateMessage(W){await this.#T(W.botToken,`/channels/${W.conversationId}/messages/${W.messageId}`,"PATCH",{components:[]},"update")}async acknowledgeInteraction(W,O){await this.#T(void 0,`/interactions/${W.interactionId}/${W.interactionToken}/callback`,"POST",{type:4,data:{content:O,flags:64}},"read")}async close(){if(this.#J)return;this.#J=!0;for(let W of this.#S)W.abort();for(let W of this.#A.values())this.#U(W),W.socket?.close(1000,"WOML runtime stopped");await Promise.allSettled([...this.#A.values()].flatMap((W)=>W.reconnectTask===void 0?[]:[W.reconnectTask])),this.#G.clear(),this.#A.clear(),this.#Q.clear()}async#R(W){if(this.#J||W.fatal)throw this.#K();let O=W.sessionId===void 0?this.#L:`${W.resumeGatewayUrl??this.#L.replace(/\?.*$/,"")}?v=10&encoding=json`,M=this.#O(O);W.socket=M,M.binaryType="arraybuffer";let L=!1,$=!1,Y,J,A=new Promise((Q,R)=>{Y=Q,J=R}),Z=setTimeout(()=>{if(L)return;L=!0,J(YW("provider_unavailable","WOML_DISCORD_GATEWAY_TIMEOUT","Discord Gateway did not become ready before the startup deadline.",!0)),M.close(4000,"Gateway startup timeout")},this.#$),G=()=>{if(L)return;L=!0,$=!0,clearTimeout(Z),Y()},X=(Q)=>{if(L)return;L=!0,clearTimeout(Z),J(Q)};M.onopen=()=>{},M.onerror=()=>{if(!L)X(YW("provider_unavailable","WOML_DISCORD_GATEWAY_UNAVAILABLE","Discord Gateway could not be reached.",!0)),M.close(4000,"Gateway connection error")},M.onmessage=(Q)=>{W.dispatchChain=W.dispatchChain.then(()=>this.#V(W,Q.data,G)).catch((R)=>this.#B(W,R))},M.onclose=(Q)=>{if(this.#U(W),W.socket===M)W.socket=void 0;let R=this.#C(Q.code);if(!L)X(R);if(this.#J||W.fatal||Q.code===1000)return;if(!R.failure.retryable){W.fatal=!0,this.#Z(R.failure);return}if(!$)return;this.#q(W,R.failure.retryAfterMs)},await A}async#V(W,O,M){let L=typeof O==="string"?O:O instanceof ArrayBuffer?new TextDecoder().decode(O):ArrayBuffer.isView(O)?new TextDecoder().decode(O):void 0;if(L===void 0||Buffer.byteLength(L,"utf8")>1048576)throw YW("size_limit_exceeded","WOML_DISCORD_GATEWAY_FRAME_TOO_LARGE","Discord sent an invalid or oversized Gateway frame.",!1);let $;try{$=JSON.parse(L)}catch{throw YW("request_invalid","WOML_DISCORD_GATEWAY_FRAME_INVALID","Discord sent invalid Gateway JSON.",!1)}if(!DW($)||typeof $.op!=="number")return;if(typeof $.s==="number"&&Number.isSafeInteger($.s))W.sequence=$.s;if($.op===10){if(!DW($.d)||typeof $.d.heartbeat_interval!=="number")throw YW("request_invalid","WOML_DISCORD_GATEWAY_HELLO_INVALID","Discord sent an invalid Gateway hello.",!1);if(this.#F(W,$.d.heartbeat_interval),W.sessionId!==void 0&&W.sequence!==void 0)this.#E(W,{op:6,d:{token:W.token,session_id:W.sessionId,seq:W.sequence}});else this.#E(W,{op:2,d:{token:W.token,intents:xq,properties:{os:process.platform,browser:"woml",device:"woml"}}});return}if($.op===11){W.awaitingHeartbeatAck=!1;return}if($.op===1){this.#z(W);return}if($.op===7){W.socket?.close(4000,"Discord requested reconnect");return}if($.op===9){if($.d!==!0)W.sessionId=void 0,W.sequence=void 0,W.resumeGatewayUrl=void 0;W.socket?.close(4000,"Discord invalidated the session");return}if($.op!==0||typeof $.t!=="string")return;if($.t==="READY"){if(!DW($.d)||typeof $.d.session_id!=="string"||typeof $.d.resume_gateway_url!=="string"||!DW($.d.user)||$.d.user.id!==W.identity.botId)throw YW("request_invalid","WOML_DISCORD_GATEWAY_READY_INVALID","Discord returned an invalid Gateway ready identity.",!1);W.sessionId=$.d.session_id,W.resumeGatewayUrl=$.d.resume_gateway_url,M();return}if($.t==="RESUMED"){M();return}let Y=this.#H($.t,$.d,W.identity);if(Y===void 0)return;for(let J of W.listeners.values())await J(Y)}#H(W,O,M){if(!DW(O))return;if(W==="INTERACTION_CREATE"){if(O.type!==3||!_O(O.id)||typeof O.token!=="string"||!DW(O.data)||typeof O.data.custom_id!=="string")return;let Z=/^(a|r):(ncap_[a-f0-9]+\.[a-f0-9]+)$/.exec(O.data.custom_id),G=DW(O.member)&&DW(O.member.user)?O.member.user.id:DW(O.user)?O.user.id:void 0;if(Z===null||!_O(G))return;return{kind:"interaction",eventId:O.id,interactionId:O.id,interactionToken:O.token,actorId:G,decisionCapability:Z[2],decision:Z[1]==="a"?"approved":"rejected"}}if(W!=="MESSAGE_CREATE")return;if(!_O(O.id)||!_O(O.channel_id)||typeof O.content!=="string"||Buffer.byteLength(O.content,"utf8")>iL||typeof O.timestamp!=="string"||!DW(O.author)||!_O(O.author.id)||O.author.bot===!0||O.author.id===M.botId)return;let L=O.guild_id===void 0||O.guild_id===null,$=Array.isArray(O.mentions)&&O.mentions.some((Z)=>DW(Z)&&Z.id===M.botId);if(!L&&!$)return;let Y=new Date(O.timestamp);if(Number.isNaN(Y.getTime()))return;let J=DW(O.message_reference)&&_O(O.message_reference.message_id)?O.message_reference.message_id:void 0,A=typeof O.author.global_name==="string"&&O.author.global_name.length>0?O.author.global_name:typeof O.author.username==="string"&&O.author.username.length>0?O.author.username:void 0;return{kind:"message",eventId:O.id,payload:{provider:"discord",event:L?"direct-message":"app-mention",text:O.content,senderId:O.author.id,...A===void 0?{}:{senderName:A},conversationId:O.channel_id,conversationType:L?"direct":"group",messageId:O.id,...J===void 0?{}:{replyToMessageId:J},occurredAt:Y.toISOString(),providerData:{botId:M.botId,..._O(O.guild_id)?{guildId:O.guild_id}:{}}}}}#F(W,O){if(!Number.isFinite(O)||O<1000)throw YW("request_invalid","WOML_DISCORD_GATEWAY_HELLO_INVALID","Discord returned an invalid heartbeat interval.",!1);this.#U(W),W.awaitingHeartbeatAck=!1,this.#z(W),W.heartbeatTimer=setInterval(()=>this.#z(W),Math.floor(O))}#z(W){if(W.awaitingHeartbeatAck){W.socket?.close(4000,"Heartbeat acknowledgement missed");return}W.awaitingHeartbeatAck=!0,this.#E(W,{op:1,d:W.sequence??null})}#U(W){if(W.heartbeatTimer!==void 0)clearInterval(W.heartbeatTimer),W.heartbeatTimer=void 0;W.awaitingHeartbeatAck=!1}#E(W,O){if(W.socket?.readyState!==1)return;W.socket.send(JSON.stringify(O))}#q(W,O){if(W.reconnectTask!==void 0||this.#J)return;let M=async()=>{if(await Bun.sleep(O??this.#X),this.#J||W.fatal)return;try{await this.#R(W),this.#Y(`Discord bot ${W.identity.username} resumed Gateway events.`)}catch(L){if(this.#J||W.fatal)return;let $=L instanceof jO?L.failure:this.#K().failure;if(!$.retryable){W.fatal=!0,this.#Z($);return}this.#Y(`${$.message} Retrying Discord Gateway.`),setTimeout(()=>this.#q(W,$.retryAfterMs),0)}};W.reconnectTask=M(),W.reconnectTask.finally(()=>{W.reconnectTask=void 0})}#B(W,O){let M=O instanceof jO?O.failure:{kind:"provider_unavailable",code:"WOML_DISCORD_TRIGGER_UNAVAILABLE",message:"The durable WOML trigger authority rejected the Discord event.",retryable:!1};if(!M.retryable){W.fatal=!0,this.#Z(M),W.socket?.close(1000,"Fatal trigger admission failure");return}W.socket?.close(4000,"Retryable trigger admission failure")}#C(W){if(W===4004)return YW("provider_auth_failed","WOML_DISCORD_AUTH_FAILED","Discord rejected the configured bot token.",!1);if(W===4013||W===4014)return YW("permission_denied","WOML_DISCORD_INTENTS_MISSING","Discord rejected the required Gateway intents. Enable Message Content Intent for the bot and verify its server permissions.",!1);if(W===4008)return YW("rate_limited","WOML_DISCORD_GATEWAY_RATE_LIMITED","Discord rate-limited the Gateway connection.",!0,5000);return YW("provider_unavailable","WOML_DISCORD_GATEWAY_UNAVAILABLE","The Discord Gateway connection closed and will be resumed safely.",!0)}async#T(W,O,M,L,$){if(W!==void 0&&!G1(W))throw YW("provider_auth_failed","WOML_DISCORD_CREDENTIAL_INVALID","The configured Discord bot token has an invalid shape or exceeds the credential limit.",!1);let Y;try{Y=L===void 0?void 0:Q1(L)}catch{throw YW("size_limit_exceeded","WOML_DISCORD_REQUEST_TOO_LARGE","The Discord request exceeds the 64 KiB provider limit.",!1)}let J=new AbortController;this.#S.add(J);let A=setTimeout(()=>J.abort(),vq),Z;try{Z=await this.#W(`${this.#M}${O}`,{method:M,headers:{...W===void 0?{}:{authorization:`Bot ${W}`},...L===void 0?{}:{"content-type":"application/json"}},...Y===void 0?{}:{body:Y},signal:J.signal})}catch{throw YW($==="delivery"?"delivery_ambiguous":"provider_unavailable",$==="delivery"?"WOML_DISCORD_DELIVERY_AMBIGUOUS":"WOML_DISCORD_UNAVAILABLE",$==="delivery"?"The Discord delivery connection ended without a confirmed result.":"Discord is temporarily unavailable.",$!=="delivery")}finally{clearTimeout(A),this.#S.delete(J)}let G;if(Z.status===204)G=void 0;else{let X;try{X=await X1(Z)}catch(Q){if(Q instanceof pO)throw YW("size_limit_exceeded","WOML_DISCORD_RESPONSE_TOO_LARGE","Discord returned a response larger than the 1 MiB provider limit.",!1);G=void 0,X=""}if(X.length>0)try{G=JSON.parse(X)}catch{G=void 0}}if(!Z.ok)throw this.#w(Z.status,G,$);return G}#w(W,O,M){if(W===429){let L=DW(O)?O.retry_after:void 0;return YW("rate_limited","WOML_DISCORD_RATE_LIMITED","Discord rate-limited the bot request.",!0,typeof L==="number"&&Number.isFinite(L)?Math.max(0,Math.ceil(L*1000)):void 0)}if(W===401)return YW("provider_auth_failed","WOML_DISCORD_AUTH_FAILED","Discord rejected the configured bot token.",!1);if(W===403)return YW("permission_denied","WOML_DISCORD_PERMISSION_DENIED","Discord denied the bot permission to access the configured channel.",!1);if(W===404)return YW("destination_invalid","WOML_DISCORD_DESTINATION_INVALID","Discord could not find the configured channel or message.",!1);if(M==="delivery")return YW("delivery_ambiguous","WOML_DISCORD_DELIVERY_AMBIGUOUS","Discord did not confirm whether the message was created.",!1);return YW(M==="update"?"update_failed":"provider_unavailable",M==="update"?"WOML_DISCORD_UPDATE_FAILED":"WOML_DISCORD_UNAVAILABLE",M==="update"?"Discord could not update the message.":"Discord could not complete the request.",!0)}#K(){return YW("provider_unavailable","WOML_DISCORD_UNAVAILABLE","The Discord transport is closed or has conflicting credentials.",!0)}#P(){let W=0;for(let O of this.#A.values())W+=O.listeners.size;for(let O of this.#Q.values())W+=O.size;return W}}function hq(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The Discord provider failed safely."}function uq(W){if("mode"in W)return W.message;return[W.message.approvalName,W.message.approvalDescription,`Workflow: ${W.message.workflowId}`,W.message.expiresAt===void 0?void 0:`Deadline: ${W.message.expiresAt}`].filter((O)=>O!==void 0&&O.length>0).join(`
258
+ `)}class _9{provider="discord";#W;#O=new Map;#M=new Map;constructor(W){this.#W=W}async resolveCredentials(W,O){let M=O.credentials,L=await W.get(M.botToken.name);if(L===void 0||L.length===0)throw new c("WOML_SECRET_NOT_FOUND","A required Discord bot token is not available.");return{credentials:{botToken:L},secretValues:[L]}}async prepare(W,O){if(this.#O.has(O.botToken))return;let M=await this.#W.botIdentity(O.botToken);this.#O.set(O.botToken,M.botId)}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A Discord update cannot be delivered as a new message.");let M=this.#M.get(W.idempotencyKey);if(M!==void 0)return M;let L=this.#O.get(O.botToken);if(L===void 0)throw Error("Discord bot identity is unavailable.");let $=await this.#W.sendMessage({botToken:O.botToken,accountId:L,conversationId:W.destination,text:uq(W),..."mode"in W?{}:{decisionCapability:W.decisionCapability}});return this.#M.set(W.idempotencyKey,$),$}async update(W,O){if(W.messageType!=="update"||!("provider"in W.providerMessage)||W.providerMessage.provider!=="discord")throw Error("Discord received an invalid message update identity.");await this.#W.updateMessage({botToken:O.botToken,conversationId:W.providerMessage.conversationId,messageId:W.providerMessage.messageId,resolution:W.resolution})}validMessageIdentity(W){return typeof W==="object"&&W!==null&&"provider"in W&&W.provider==="discord"&&"accountId"in W&&typeof W.accountId==="string"&&"conversationId"in W&&typeof W.conversationId==="string"&&"messageId"in W&&typeof W.messageId==="string"}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_DISCORD_RESPONSE_INVALID",message:"Discord returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW)return W.failure;if(W instanceof jO){let M=W.failure.kind==="permission_denied"?"destination_invalid":W.failure.kind;return{...W.failure,kind:M,message:hq(W.failure.message,O)}}if(W instanceof c)return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required Discord credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_DISCORD_UNAVAILABLE",message:"The Discord adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function lq(W){return W.kind==="object"?W.fields:void 0}function PG(W){if(W?.kind!=="array")return[];return W.items.flatMap((O)=>O.kind==="literal"&&typeof O.value==="string"?[O.value]:[])}function yj(W,O){return W.triggers.filter((M)=>M.handler==="trigger.discord").map((M)=>{let L=lq(M.config),$=PG(L?.events),Y=PG(L?.channels),J=L?.botToken?.kind==="secretReference"?L.botToken.name:void 0;if(L===void 0||$.length===0||$.some((A)=>A!=="app-mention"&&A!=="direct-message")||Y.some((A)=>!/^[0-9]{17,20}$/.test(A))||J===void 0)throw Error(`Compiled Discord trigger "${M.id}" does not match Model v15.`);return{workflowId:W.workflowId,definitionHash:O,triggerId:M.id,events:$,channels:Y,credentialNames:{botToken:J}}})}import{randomUUID as NG}from"crypto";class pq{provider="discord";#W;#O=`discord_${NG()}`;#M=[];#L=[];#X=!1;#$=!1;constructor(W){if(W.registrations.length===0&&(W.credentialNames?.length??0)===0)throw Error("DiscordTriggerHost requires a trigger or notification credential.");this.#W=W}async start(){if(this.#X||this.#$)throw Error("Discord trigger host cannot be started twice.");this.#X=!0;let W=new Set([...this.#W.registrations.map((O)=>O.credentialNames.botToken),...this.#W.credentialNames??[]]);try{for(let O of W){let M=await this.#W.secretStore.get(O);if(M===void 0||M.length===0)throw new c("WOML_SECRET_NOT_FOUND",`Missing required secret: ${O}. Configure it with: woml secrets set ${O}`);this.#L.push(this.#W.transport.subscribe(O,`${this.#O}:${O}`,($)=>this.#Y(O,$)));let L=await this.#W.transport.ensureConnected(O,M);for(let $ of this.#W.registrations)if($.credentialNames.botToken===O)this.#M.push({...$,botId:L.botId});this.#W.diagnostic?.("WOML_DISCORD_READY",`Discord bot @${L.username} is ready.`)}}catch(O){throw await this.close(),O}}async close(){if(this.#$)return;this.#$=!0;for(let W of this.#L.splice(0))W();this.#M.splice(0)}async#Y(W,O){if(O.kind==="interaction"){if(this.#W.resolveApproval===void 0)return;let L=await this.#W.resolveApproval(O);try{await this.#W.transport.acknowledgeInteraction(O,L==="already-resolved"?"This approval was already resolved.":L==="expired"?"This approval has expired.":O.decision==="approved"?"Approved":"Rejected")}catch($){let Y=$ instanceof jO?$.failure.code:"WOML_DISCORD_INTERACTION_ACK_FAILED";this.#W.diagnostic?.(Y,"The approval decision was saved, but Discord could not acknowledge the button interaction.")}return}let M=this.#M.filter((L)=>{if(L.credentialNames.botToken!==W||L.botId!==O.payload.providerData.botId||!L.events.includes(O.payload.event))return!1;return O.payload.event!=="app-mention"||L.channels.length===0||L.channels.includes(O.payload.conversationId)});for(let L of M){let $={contract:"woml.trigger-ingress",contractVersion:1,messageType:"admit",requestId:`request_discord_${NG()}`,workflowId:L.workflowId,definitionHash:L.definitionHash,triggerId:L.triggerId,triggerHandler:"trigger.discord",sourceIdentity:`discord:${L.botId}:${O.eventId}:${L.workflowId}:${L.triggerId}`,payload:{...O.payload},receivedAt:new Date().toISOString()},Y=await this.#W.submit($);if(Y.messageType==="rejected")throw new jO({kind:"provider_unavailable",code:Y.failure.code,message:Y.failure.message,retryable:!1});this.#W.diagnostic?.(Y.duplicate?"WOML_DISCORD_TRIGGER_DUPLICATE":"WOML_DISCORD_TRIGGER_ACCEPTED",`${Y.duplicate?"Recognized duplicate":"Accepted"} Discord ${O.payload.event} ${O.eventId} for trigger "${L.triggerId}": ${Y.runId}.`)}}}function gj(W){if(W instanceof c)return{code:W.code,message:W.message};if(W instanceof jO)return{code:W.failure.code,message:W.failure.message};return{code:"WOML_DISCORD_TRIGGER_UNAVAILABLE",message:"The Discord Gateway host could not start safely."}}var mq="https://graph.facebook.com/v23.0",dq=30000;function W$(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}class O$ extends Error{failure;constructor(W){super(W.message);this.failure=W;this.name="WhatsAppTransportError"}}function YO(W,O,M,L,$){return new O$({kind:W,code:O,message:M,retryable:L,...$===void 0?{}:{retryAfterMs:$}})}function cq(W,O){let M=W$(O.error)?O.error:{},L=typeof M.code==="number"?M.code:void 0;if(W===429||L===4)return YO("rate_limited","WOML_WHATSAPP_RATE_LIMITED","WhatsApp rate-limited the message request.",!0);if(W===401||W===403||L===190)return YO("provider_auth_failed","WOML_WHATSAPP_AUTH_FAILED","Meta rejected the configured WhatsApp access token or permission.",!1);if(W===400)return YO("destination_invalid","WOML_WHATSAPP_REQUEST_REJECTED","WhatsApp rejected the recipient or approved-template request.",!1);return YO("delivery_ambiguous","WOML_WHATSAPP_DELIVERY_AMBIGUOUS","Meta did not confirm whether the WhatsApp message was accepted; WOML will not replay the uncertain delivery automatically.",!1)}class j9{#W;#O;#M=new Set;#L=!1;constructor(W={}){this.#W=W.fetch??globalThis.fetch,this.#O=W.apiBase??mq}async sendTemplate(W){if(this.#L)throw YO("provider_unavailable","WOML_WHATSAPP_UNAVAILABLE","The WhatsApp transport is closed.",!0);if(!G1(W.accessToken))throw YO("provider_auth_failed","WOML_WHATSAPP_CREDENTIAL_INVALID","The configured WhatsApp access token has an invalid shape or exceeds the credential limit.",!1);let O=W.parameters.length===0?[]:[{type:"body",parameters:W.parameters.map((X)=>({type:"text",text:X}))}];if(W.decisionCapability!==void 0)O.push({type:"button",sub_type:"quick_reply",index:"0",parameters:[{type:"payload",payload:`woml_approve:${W.decisionCapability}`}]},{type:"button",sub_type:"quick_reply",index:"1",parameters:[{type:"payload",payload:`woml_reject:${W.decisionCapability}`}]});let M;try{M=Q1({messaging_product:"whatsapp",recipient_type:"individual",to:W.conversationId,type:"template",template:{name:W.templateName,language:{code:W.language},...O.length===0?{}:{components:O}}})}catch{throw YO("size_limit_exceeded","WOML_WHATSAPP_REQUEST_TOO_LARGE","The WhatsApp request exceeds the 64 KiB provider limit.",!1)}let L=new AbortController;this.#M.add(L);let $=setTimeout(()=>L.abort(),dq),Y;try{Y=await this.#W(`${this.#O}/${W.phoneNumberId}/messages`,{method:"POST",headers:{authorization:`Bearer ${W.accessToken}`,"content-type":"application/json"},body:M,signal:L.signal})}catch{throw YO("delivery_ambiguous","WOML_WHATSAPP_DELIVERY_AMBIGUOUS","The WhatsApp request ended before Meta confirmed delivery.",!1)}finally{clearTimeout($),this.#M.delete(L)}let J;try{J=await X1(Y)}catch(X){if(X instanceof pO)throw YO("size_limit_exceeded","WOML_WHATSAPP_RESPONSE_TOO_LARGE","Meta returned a response larger than the 1 MiB provider limit.",!1);throw YO("delivery_ambiguous","WOML_WHATSAPP_RESPONSE_INVALID","Meta returned an unreadable WhatsApp response.",!1)}let A;try{A=J.length===0?{}:JSON.parse(J)}catch{throw YO("delivery_ambiguous","WOML_WHATSAPP_RESPONSE_INVALID","Meta returned an invalid WhatsApp response.",!1)}if(!Y.ok)throw cq(Y.status,W$(A)?A:{});let Z=W$(A)&&Array.isArray(A.messages)?A.messages:[],G=W$(Z[0])?Z[0]:void 0;if(typeof G?.id!=="string"||G.id.length===0)throw YO("delivery_ambiguous","WOML_WHATSAPP_RESPONSE_INVALID","Meta accepted the request but returned no valid message identity.",!1);return{provider:"whatsapp",accountId:W.phoneNumberId,conversationId:W.conversationId,messageId:G.id}}async close(){this.#L=!0;for(let W of this.#M)W.abort();this.#M.clear()}}function iq(W,O){let M=W;for(let L of O)if(L.length>0)M=M.split(L).join("[REDACTED]");return M.slice(0,1024)||"The WhatsApp provider failed safely."}class I9{provider="whatsapp";#W;#O=new Map;constructor(W){this.#W=W}async resolveCredentials(W,O){let M=O.credentials,L=await W.get(M.accessToken.name);if(L===void 0||L.length===0)throw new c("WOML_SECRET_NOT_FOUND","A required WhatsApp access token is not available.");return{credentials:{accessToken:L,phoneNumberId:M.phoneNumberId},secretValues:[L]}}async prepare(){}async deliver(W,O){if(W.messageType!=="deliver")throw Error("A WhatsApp update cannot be delivered as a new message.");let M=this.#O.get(W.idempotencyKey);if(M!==void 0)return M;if(W.templateName===void 0||W.language===void 0)throw Error("WhatsApp delivery is missing approved-template metadata.");let L=!("mode"in W),$=L?[W.message.approvalName,W.message.approvalDescription??"",W.message.workflowId,W.message.expiresAt??"No deadline"]:[W.message],Y=await this.#W.sendTemplate({accessToken:O.accessToken,phoneNumberId:O.phoneNumberId,conversationId:W.destination,templateName:W.templateName,language:W.language,parameters:$,...L?{decisionCapability:W.decisionCapability}:{}});return this.#O.set(W.idempotencyKey,Y),Y}async update(){throw new dW({kind:"update_failed",code:"WOML_WHATSAPP_UPDATE_UNAVAILABLE",message:"WhatsApp template messages cannot be edited after delivery; the approval decision was still recorded.",retryable:!1})}validMessageIdentity(W){return typeof W==="object"&&W!==null&&"provider"in W&&W.provider==="whatsapp"&&"accountId"in W&&typeof W.accountId==="string"&&"conversationId"in W&&typeof W.conversationId==="string"&&"messageId"in W&&typeof W.messageId==="string"}invalidMessageIdentityFailure(){return{kind:"request_invalid",code:"WOML_WHATSAPP_RESPONSE_INVALID",message:"WhatsApp returned an invalid message identity.",retryable:!1}}safeFailure(W,O){if(W instanceof dW)return W.failure;if(W instanceof O$)return{...W.failure,message:iq(W.failure.message,O)};if(W instanceof c)return{kind:"secret_not_found",code:"WOML_SECRET_NOT_FOUND",message:"A required WhatsApp credential is not available.",retryable:!1};return{kind:"provider_unavailable",code:"WOML_WHATSAPP_UNAVAILABLE",message:"The WhatsApp adapter failed without exposing provider details.",retryable:!0}}async close(){await this.#W.close()}}function nq(){let W=process.env.WOML_FAKE_SLACK_DECISION;if(W===void 0||W==="")return;if(W==="approved"||W==="rejected")return W;throw Error("WOML_FAKE_SLACK_DECISION must be approved or rejected.")}function rq(){let W=process.env.WOML_FAKE_SLACK_ACTION_DELAY_MS??"0",O=Number(W);if(!Number.isSafeInteger(O)||O<0||O>60000)throw Error("WOML_FAKE_SLACK_ACTION_DELAY_MS must be an integer from 0 through 60000.");return O}function aq(){let W=process.env.WOML_FAKE_SLACK_DELIVERY_FAILURES??"0",O=Number(W);if(!Number.isSafeInteger(O)||O<0||O>2)throw Error("WOML_FAKE_SLACK_DELIVERY_FAILURES must be an integer from 0 through 2.");return O}function oq(){return(process.env.WOML_FAKE_SLACK_FAILED_DESTINATIONS??"").split(",").map((W)=>W.trim()).filter((W)=>W.length>0)}async function tq(W){await new Promise((O,M)=>{process.stdout.write(W,(L)=>{if(L===null||L===void 0)O();else M(L)})})}async function eq(W={}){let O=W.protocolVersion??(process.env.WOML_NOTIFICATION_PROTOCOL_VERSION==="2"?zM:PO),M=new $$(tq),L=new L$({maxFrameBytes:cL}),$=(X)=>M.send(X),Y=W.createTransport?.($)??(W.adapter==="fake"?new T9({emit:$,automaticDecision:nq(),automaticActorId:process.env.WOML_FAKE_SLACK_ACTOR_ID??"U12345678",automaticDelayMs:rq(),deliveryFailuresBeforeSuccess:aq(),failedDestinations:oq()}):new B9({emit:$,log:(X)=>process.stderr.write(`[woml] ${X}
259
+ `)})),J=[new HM(Y)];if(W.adapter!=="fake")J.push(new P9(W.createTelegramTransport?.()??new w9)),J.push(new _9(W.createDiscordTransport?.()??new N9)),J.push(new I9(W.createWhatsAppTransport?.()??new j9));let A=new E9({secretStore:YG(),adapters:J,send:(X)=>M.send(X),protocolVersion:O}),Z=J.map((X)=>X.provider);if(!Z.every((X)=>X==="slack"||X==="telegram"||X==="discord"||X==="whatsapp"))throw Error("The notification host contains an unavailable provider adapter.");let G={protocol:UO,protocolVersion:O,messageType:"ready",hostInstanceId:`notification_host_${sq()}`,providers:Z};try{await M.send(G);let X=Bun.stdin.stream().getReader();while(!0){let{done:Q,value:R}=await X.read();if(Q)break;for(let U of L.push(R))A.accept(U)}L.finish(),await A.close(),await M.drain()}catch(X){await A.close().catch(()=>{});let Q=X instanceof Error?X.message:String(X);process.stderr.write(`WOML notification provider host failed: ${Q}
260
+ `),process.exitCode=1}}if(import.meta.main)await eq({adapter:"real"});export{eq as runNotificationProviderHost};
261
261
 
262
- //# debugId=2B476F6C7DD3FC9564756E2164756E21
262
+ //# debugId=9FB91128EF1C670464756E2164756E21