yaml-flow 8.5.0 → 8.5.2

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.
Files changed (44) hide show
  1. package/browser/asset-integrity.json +3 -3
  2. package/browser/board-livecards-client.js +1 -1
  3. package/cli/browser-api/board-live-cards-browser-adapter.d.ts +1 -1
  4. package/cli/bundled/board-live-cards-cli.mjs +14 -14
  5. package/cli/bundled/chat-store-cli.mjs +13 -13
  6. package/cli/{types-D2s3VzyY.d.ts → types-H3EMBPY2.d.ts} +7 -2
  7. package/examples/board/demo-shell-with-server.html +2 -2
  8. package/examples/board/doc.html +2 -2
  9. package/examples/board/server/README-mcp-api.md +680 -0
  10. package/examples/board/test/server-http-mcp-test.js +406 -34
  11. package/examples/board-local/demo-shell-localstorage.html +3 -3
  12. package/lib/artifacts-store-public.d.cts +1 -1
  13. package/lib/artifacts-store-public.d.ts +1 -1
  14. package/lib/board-live-cards-mcp.cjs +1 -1
  15. package/lib/board-live-cards-mcp.d.cts +42 -5
  16. package/lib/board-live-cards-mcp.d.ts +42 -5
  17. package/lib/board-live-cards-mcp.js +1 -1
  18. package/lib/board-live-cards-node.cjs +14 -14
  19. package/lib/board-live-cards-node.d.cts +4 -4
  20. package/lib/board-live-cards-node.d.ts +4 -4
  21. package/lib/board-live-cards-node.js +14 -14
  22. package/lib/{board-live-cards-public-CvkDfZQ7.d.cts → board-live-cards-public-B13InXhC.d.cts} +7 -2
  23. package/lib/{board-live-cards-public-DdVhH4M-.d.ts → board-live-cards-public-BGS22cMb.d.ts} +7 -2
  24. package/lib/board-live-cards-public.cjs +2 -2
  25. package/lib/board-live-cards-public.d.cts +1 -1
  26. package/lib/board-live-cards-public.d.ts +1 -1
  27. package/lib/board-live-cards-public.js +2 -2
  28. package/lib/board-live-cards-server-runtime.cjs +4 -4
  29. package/lib/board-live-cards-server-runtime.d.cts +2 -2
  30. package/lib/board-live-cards-server-runtime.d.ts +2 -2
  31. package/lib/board-live-cards-server-runtime.js +4 -4
  32. package/lib/card-store-public.d.cts +1 -1
  33. package/lib/card-store-public.d.ts +1 -1
  34. package/lib/chat-store-public.cjs +1 -1
  35. package/lib/chat-store-public.d.cts +6 -1
  36. package/lib/chat-store-public.d.ts +6 -1
  37. package/lib/chat-store-public.js +1 -1
  38. package/lib/server-runtime/index.cjs +4 -4
  39. package/lib/server-runtime/index.d.cts +3 -3
  40. package/lib/server-runtime/index.d.ts +3 -3
  41. package/lib/server-runtime/index.js +4 -4
  42. package/lib/{types-QNI__eAf.d.ts → types-30R357js.d.ts} +1 -1
  43. package/lib/{types-NM_d_1oZ.d.cts → types-CIgsh56O.d.cts} +1 -1
  44. package/package.json +1 -1
@@ -1,20 +1,20 @@
1
- import {spawnSync,spawn,execFile,execFileSync}from'child_process';import*as C from'fs';import {existsSync}from'fs';import*as Xn from'os';import*as te from'path';import {dirname,resolve}from'path';import*as ma from'net';import {fileURLToPath}from'url';import {createHash,randomUUID}from'crypto';import {createRequire}from'module';import {lockSync}from'proper-lockfile';import Rh from'ajv-formats';var cd=Object.create;var da=Object.defineProperty;var ud=Object.getOwnPropertyDescriptor;var dd=Object.getOwnPropertyNames;var ld=Object.getPrototypeOf,fd=Object.prototype.hasOwnProperty;var j=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var pd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dd(t))!fd.call(e,s)&&s!==r&&da(e,s,{get:()=>t[s],enumerable:!(n=ud(t,s))||n.enumerable});return e};var md=(e,t,r)=>(r=e!=null?cd(ld(e)):{},pd(da(r,"default",{value:e,enumerable:true}),e));var pr=j(se=>{Object.defineProperty(se,"__esModule",{value:true});se.regexpCode=se.getEsmExportName=se.getProperty=se.safeStringify=se.stringify=se.strConcat=se.addCodeArg=se.str=se._=se.nil=se._Code=se.Name=se.IDENTIFIER=se._CodeOrName=void 0;var lr=class{};se._CodeOrName=lr;se.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ot=class extends lr{constructor(t){if(super(),!se.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};se.Name=Ot;var Ke=class extends lr{constructor(t){super(),this._items=typeof t=="string"?[t]:t;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let t=this._items[0];return t===""||t==='""'}get str(){var t;return (t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return (t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Ot&&(r[n.str]=(r[n.str]||0)+1),r),{})}};se._Code=Ke;se.nil=new Ke("");function Da(e,...t){let r=[e[0]],n=0;for(;n<t.length;)ls(r,t[n]),r.push(e[++n]);return new Ke(r)}se._=Da;var ds=new Ke("+");function Ma(e,...t){let r=[fr(e[0])],n=0;for(;n<t.length;)r.push(ds),ls(r,t[n]),r.push(ds,fr(e[++n]));return Xd(r),new Ke(r)}se.str=Ma;function ls(e,t){t instanceof Ke?e.push(...t._items):t instanceof Ot?e.push(t):e.push(el(t));}se.addCodeArg=ls;function Xd(e){let t=1;for(;t<e.length-1;){if(e[t]===ds){let r=Qd(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function Qd(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Ot||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Ot))return `"${e}${t.slice(1)}`}function Zd(e,t){return t.emptyStr()?e:e.emptyStr()?t:Ma`${e}${t}`}se.strConcat=Zd;function el(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:fr(Array.isArray(e)?e.join(","):e)}function tl(e){return new Ke(fr(e))}se.stringify=tl;function fr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}se.safeStringify=fr;function rl(e){return typeof e=="string"&&se.IDENTIFIER.test(e)?new Ke(`.${e}`):Da`[${e}]`}se.getProperty=rl;function nl(e){if(typeof e=="string"&&se.IDENTIFIER.test(e))return new Ke(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}se.getEsmExportName=nl;function sl(e){return new Ke(e.toString())}se.regexpCode=sl;});var ms=j(qe=>{Object.defineProperty(qe,"__esModule",{value:true});qe.ValueScope=qe.ValueScopeName=qe.Scope=qe.varKinds=qe.UsedValueState=void 0;var Ne=pr(),fs=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value;}},rn;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed";})(rn||(qe.UsedValueState=rn={}));qe.varKinds={const:new Ne.Name("const"),let:new Ne.Name("let"),var:new Ne.Name("var")};var nn=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof Ne.Name?t:this.name(t)}name(t){return new Ne.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return `${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};qe.Scope=nn;var sn=class extends Ne.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, Ne._)`.${new Ne.Name(r)}[${n}]`;}};qe.ValueScopeName=sn;var ol=(0, Ne._)`\n`,ps=class extends nn{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ol:Ne.nil};}get(){return this._scope}name(t){return new sn(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(t),{prefix:o}=s,a=(n=r.key)!==null&&n!==void 0?n:r.ref,i=this._values[o];if(i){let d=i.get(a);if(d)return d}else i=this._values[o]=new Map;i.set(a,s);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,s.setValue(r,{property:o,itemIndex:c}),s}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return (0, Ne._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(t,r,n={},s){let o=Ne.nil;for(let a in t){let i=t[a];if(!i)continue;let u=n[a]=n[a]||new Map;i.forEach(c=>{if(u.has(c))return;u.set(c,rn.Started);let d=r(c);if(d){let l=this.opts.es5?qe.varKinds.var:qe.varKinds.const;o=(0, Ne._)`${o}${l} ${c} = ${d};${this.opts._n}`;}else if(d=s?.(c))o=(0, Ne._)`${o}${d}${this.opts._n}`;else throw new fs(c);u.set(c,rn.Completed);});}return o}};qe.ValueScope=ps;});var H=j(z=>{Object.defineProperty(z,"__esModule",{value:true});z.or=z.and=z.not=z.CodeGen=z.operators=z.varKinds=z.ValueScopeName=z.ValueScope=z.Scope=z.Name=z.regexpCode=z.stringify=z.getProperty=z.nil=z.strConcat=z.str=z._=void 0;var ee=pr(),Ze=ms(),yt=pr();Object.defineProperty(z,"_",{enumerable:true,get:function(){return yt._}});Object.defineProperty(z,"str",{enumerable:true,get:function(){return yt.str}});Object.defineProperty(z,"strConcat",{enumerable:true,get:function(){return yt.strConcat}});Object.defineProperty(z,"nil",{enumerable:true,get:function(){return yt.nil}});Object.defineProperty(z,"getProperty",{enumerable:true,get:function(){return yt.getProperty}});Object.defineProperty(z,"stringify",{enumerable:true,get:function(){return yt.stringify}});Object.defineProperty(z,"regexpCode",{enumerable:true,get:function(){return yt.regexpCode}});Object.defineProperty(z,"Name",{enumerable:true,get:function(){return yt.Name}});var un=ms();Object.defineProperty(z,"Scope",{enumerable:true,get:function(){return un.Scope}});Object.defineProperty(z,"ValueScope",{enumerable:true,get:function(){return un.ValueScope}});Object.defineProperty(z,"ValueScopeName",{enumerable:true,get:function(){return un.ValueScopeName}});Object.defineProperty(z,"varKinds",{enumerable:true,get:function(){return un.varKinds}});z.operators={GT:new ee._Code(">"),GTE:new ee._Code(">="),LT:new ee._Code("<"),LTE:new ee._Code("<="),EQ:new ee._Code("==="),NEQ:new ee._Code("!=="),NOT:new ee._Code("!"),OR:new ee._Code("||"),AND:new ee._Code("&&"),ADD:new ee._Code("+")};var ut=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},gs=class extends ut{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n;}render({es5:t,_n:r}){let n=t?Ze.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return `${n} ${this.name}${s};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Yt(this.rhs,t,r)),this}get names(){return this.rhs instanceof ee._CodeOrName?this.rhs.names:{}}},on=class extends ut{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n;}render({_n:t}){return `${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof ee.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Yt(this.rhs,t,r),this}get names(){let t=this.lhs instanceof ee.Name?{}:{...this.lhs.names};return cn(t,this.rhs)}},hs=class extends on{constructor(t,r,n,s){super(t,n,s),this.op=r;}render({_n:t}){return `${this.lhs} ${this.op}= ${this.rhs};`+t}},ys=class extends ut{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},vs=class extends ut{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},Ss=class extends ut{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},ws=class extends ut{constructor(t){super(),this.code=t;}render({_n:t}){return `${this.code};`+t}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Yt(this.code,t,r),this}get names(){return this.code instanceof ee._CodeOrName?this.code.names:{}}},mr=class extends ut{constructor(t=[]){super(),this.nodes=t;}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1);}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(t,r)||(al(t,o.names),n.splice(s,1));}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>qt(t,r.names),{})}},dt=class extends mr{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},bs=class extends mr{},Wt=class extends dt{};Wt.kind="else";var Pt=class e extends dt{constructor(t,r){super(r),this.condition=t;}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===true)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Wt(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(La(t),r instanceof e?[r]:r.nodes);if(!(t===false||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Yt(this.condition,t,r),this}get names(){let t=super.names;return cn(t,this.condition),this.else&&qt(t,this.else.names),t}};Pt.kind="if";var Nt=class extends dt{};Nt.kind="for";var ks=class extends Nt{constructor(t){super(),this.iteration=t;}render(t){return `for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Yt(this.iteration,t,r),this}get names(){return qt(super.names,this.iteration.names)}},_s=class extends Nt{constructor(t,r,n,s){super(),this.varKind=t,this.name=r,this.from=n,this.to=s;}render(t){let r=t.es5?Ze.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return `for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=cn(super.names,this.from);return cn(t,this.to)}},an=class extends Nt{constructor(t,r,n,s){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=s;}render(t){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Yt(this.iterable,t,r),this}get names(){return qt(super.names,this.iterable.names)}},gr=class extends dt{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n;}render(t){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};gr.kind="func";var hr=class extends mr{render(t){return "return "+super.render(t)}};hr.kind="return";var Rs=class extends dt{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,s;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(s=this.finally)===null||s===void 0||s.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&qt(t,this.catch.names),this.finally&&qt(t,this.finally.names),t}},yr=class extends dt{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};yr.kind="catch";var vr=class extends dt{render(t){return "finally"+super.render(t)}};vr.kind="finally";var Cs=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
- `:""},this._extScope=t,this._scope=new Ze.Scope({parent:t}),this._nodes=[new bs];}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return (this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new gs(t,o,n)),o}const(t,r,n){return this._def(Ze.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ze.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ze.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new on(t,r,n))}add(t,r){return this._leafNode(new hs(t,z.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==ee.nil&&this._leafNode(new ws(t)),this}object(...t){let r=["{"];for(let[n,s]of t)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0, ee.addCodeArg)(r,s));return r.push("}"),new ee._Code(r)}if(t,r,n){if(this._blockNode(new Pt(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Pt(t))}else(){return this._elseNode(new Wt)}endIf(){return this._endBlockNode(Pt,Wt)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new ks(t),r)}forRange(t,r,n,s,o=this.opts.es5?Ze.varKinds.var:Ze.varKinds.let){let a=this._scope.toName(t);return this._for(new _s(o,a,r,n),()=>s(a))}forOf(t,r,n,s=Ze.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof ee.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, ee._)`${a}.length`,i=>{this.var(o,(0, ee._)`${a}[${i}]`),n(o);})}return this._for(new an("of",s,o,r),()=>n(o))}forIn(t,r,n,s=this.opts.es5?Ze.varKinds.var:Ze.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0, ee._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new an("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(Nt)}label(t){return this._leafNode(new ys(t))}break(t){return this._leafNode(new vs(t))}return(t){let r=new hr;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(hr)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Rs;if(this._blockNode(s),this.code(t),r){let o=this.name("e");this._currNode=s.catch=new yr(o),r(o);}return n&&(this._currNode=s.finally=new vr,this.code(n)),this._endBlockNode(yr,vr)}throw(t){return this._leafNode(new Ss(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=ee.nil,n,s){return this._blockNode(new gr(t,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(gr)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t);}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Pt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t;}};z.CodeGen=Cs;function qt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function cn(e,t){return t instanceof ee._CodeOrName?qt(e,t.names):e}function Yt(e,t,r){if(e instanceof ee.Name)return n(e);if(!s(e))return e;return new ee._Code(e._items.reduce((o,a)=>(a instanceof ee.Name&&(a=n(a)),a instanceof ee._Code?o.push(...a._items):o.push(a),o),[]));function n(o){let a=r[o.str];return a===void 0||t[o.str]!==1?o:(delete t[o.str],a)}function s(o){return o instanceof ee._Code&&o._items.some(a=>a instanceof ee.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function al(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0);}function La(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, ee._)`!${Es(e)}`}z.not=La;var il=Ba(z.operators.AND);function cl(...e){return e.reduce(il)}z.and=cl;var ul=Ba(z.operators.OR);function dl(...e){return e.reduce(ul)}z.or=dl;function Ba(e){return (t,r)=>t===ee.nil?r:r===ee.nil?t:(0, ee._)`${Es(t)} ${e} ${Es(r)}`}function Es(e){return e instanceof ee.Name?e:(0, ee._)`(${e})`}});var re=j(W=>{Object.defineProperty(W,"__esModule",{value:true});W.checkStrictMode=W.getErrorPath=W.Type=W.useFunc=W.setEvaluated=W.evaluatedPropsToName=W.mergeEvaluated=W.eachItem=W.unescapeJsonPointer=W.escapeJsonPointer=W.escapeFragment=W.unescapeFragment=W.schemaRefOrVal=W.schemaHasRulesButRef=W.schemaHasRules=W.checkUnknownRules=W.alwaysValidSchema=W.toHash=void 0;var le=H(),ll=pr();function fl(e){let t={};for(let r of e)t[r]=true;return t}W.toHash=fl;function pl(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(Ka(e,t),!Ga(t,e.self.RULES.all))}W.alwaysValidSchema=pl;function Ka(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let s=n.RULES.keywords;for(let o in t)s[o]||Ha(e,`unknown keyword: "${o}"`);}W.checkUnknownRules=Ka;function Ga(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}W.schemaHasRules=Ga;function ml(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(r!=="$ref"&&t.all[r])return true;return false}W.schemaHasRulesButRef=ml;function gl({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, le._)`${r}`}return (0, le._)`${e}${t}${(0, le.getProperty)(n)}`}W.schemaRefOrVal=gl;function hl(e){return Ja(decodeURIComponent(e))}W.unescapeFragment=hl;function yl(e){return encodeURIComponent(xs(e))}W.escapeFragment=yl;function xs(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}W.escapeJsonPointer=xs;function Ja(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}W.unescapeJsonPointer=Ja;function vl(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}W.eachItem=vl;function Va({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof le.Name?(o instanceof le.Name?e(s,o,a):t(s,o,a),a):o instanceof le.Name?(t(s,a,o),o):r(o,a);return i===le.Name&&!(u instanceof le.Name)?n(s,u):u}}W.mergeEvaluated={props:Va({mergeNames:(e,t,r)=>e.if((0, le._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, le._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, le._)`${r} || {}`).code((0, le._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, le._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, le._)`${r} || {}`),As(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:za}),items:Va({mergeNames:(e,t,r)=>e.if((0, le._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, le._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, le._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, le._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function za(e,t){if(t===true)return e.var("props",true);let r=e.var("props",(0, le._)`{}`);return t!==void 0&&As(e,r,t),r}W.evaluatedPropsToName=za;function As(e,t,r){Object.keys(r).forEach(n=>e.assign((0, le._)`${t}${(0, le.getProperty)(n)}`,true));}W.setEvaluated=As;var Ua={};function Sl(e,t){return e.scopeValue("func",{ref:t,code:Ua[t.code]||(Ua[t.code]=new ll._Code(t.code))})}W.useFunc=Sl;var $s;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})($s||(W.Type=$s={}));function wl(e,t,r){if(e instanceof le.Name){let n=t===$s.Num;return r?n?(0, le._)`"[" + ${e} + "]"`:(0, le._)`"['" + ${e} + "']"`:n?(0, le._)`"/" + ${e}`:(0, le._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, le.getProperty)(e).toString():"/"+xs(e)}W.getErrorPath=wl;function Ha(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}W.checkStrictMode=Ha;});var lt=j(Ts=>{Object.defineProperty(Ts,"__esModule",{value:true});var Ce=H(),bl={data:new Ce.Name("data"),valCxt:new Ce.Name("valCxt"),instancePath:new Ce.Name("instancePath"),parentData:new Ce.Name("parentData"),parentDataProperty:new Ce.Name("parentDataProperty"),rootData:new Ce.Name("rootData"),dynamicAnchors:new Ce.Name("dynamicAnchors"),vErrors:new Ce.Name("vErrors"),errors:new Ce.Name("errors"),this:new Ce.Name("this"),self:new Ce.Name("self"),scope:new Ce.Name("scope"),json:new Ce.Name("json"),jsonPos:new Ce.Name("jsonPos"),jsonLen:new Ce.Name("jsonLen"),jsonPart:new Ce.Name("jsonPart")};Ts.default=bl;});var Sr=j(Ee=>{Object.defineProperty(Ee,"__esModule",{value:true});Ee.extendErrors=Ee.resetErrorsCount=Ee.reportExtraError=Ee.reportError=Ee.keyword$DataError=Ee.keywordError=void 0;var ne=H(),dn=re(),Ie=lt();Ee.keywordError={message:({keyword:e})=>(0, ne.str)`must pass "${e}" keyword validation`};Ee.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, ne.str)`"${e}" keyword must be ${t} ($data)`:(0, ne.str)`"${e}" keyword is invalid ($data)`};function kl(e,t=Ee.keywordError,r,n){let{it:s}=e,{gen:o,compositeRule:a,allErrors:i}=s,u=Xa(e,t,r);n??(a||i)?Wa(o,u):Ya(s,(0, ne._)`[${u}]`);}Ee.reportError=kl;function _l(e,t=Ee.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=Xa(e,t,r);Wa(s,i),o||a||Ya(n,Ie.default.vErrors);}Ee.reportExtraError=_l;function Rl(e,t){e.assign(Ie.default.errors,t),e.if((0, ne._)`${Ie.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, ne._)`${Ie.default.vErrors}.length`,t),()=>e.assign(Ie.default.vErrors,null)));}Ee.resetErrorsCount=Rl;function Cl({gen:e,keyword:t,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",s,Ie.default.errors,i=>{e.const(a,(0, ne._)`${Ie.default.vErrors}[${i}]`),e.if((0, ne._)`${a}.instancePath === undefined`,()=>e.assign((0, ne._)`${a}.instancePath`,(0, ne.strConcat)(Ie.default.instancePath,o.errorPath))),e.assign((0, ne._)`${a}.schemaPath`,(0, ne.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, ne._)`${a}.schema`,r),e.assign((0, ne._)`${a}.data`,n));});}Ee.extendErrors=Cl;function Wa(e,t){let r=e.const("err",t);e.if((0, ne._)`${Ie.default.vErrors} === null`,()=>e.assign(Ie.default.vErrors,(0, ne._)`[${r}]`),(0, ne._)`${Ie.default.vErrors}.push(${r})`),e.code((0, ne._)`${Ie.default.errors}++`);}function Ya(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, ne._)`new ${e.ValidationError}(${t})`):(r.assign((0, ne._)`${n}.errors`,t),r.return(false));}var Ft={keyword:new ne.Name("keyword"),schemaPath:new ne.Name("schemaPath"),params:new ne.Name("params"),propertyName:new ne.Name("propertyName"),message:new ne.Name("message"),schema:new ne.Name("schema"),parentSchema:new ne.Name("parentSchema")};function Xa(e,t,r){let{createErrors:n}=e.it;return n===false?(0, ne._)`{}`:El(e,t,r)}function El(e,t,r={}){let{gen:n,it:s}=e,o=[$l(s,r),xl(e,r)];return Al(e,t,o),n.object(...o)}function $l({errorPath:e},{instancePath:t}){let r=t?(0, ne.str)`${e}${(0, dn.getErrorPath)(t,dn.Type.Str)}`:e;return [Ie.default.instancePath,(0, ne.strConcat)(Ie.default.instancePath,r)]}function xl({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, ne.str)`${t}/${e}`;return r&&(s=(0, ne.str)`${s}${(0, dn.getErrorPath)(r,dn.Type.Str)}`),[Ft.schemaPath,s]}function Al(e,{params:t,message:r},n){let{keyword:s,data:o,schemaValue:a,it:i}=e,{opts:u,propertyName:c,topSchemaRef:d,schemaPath:l}=i;n.push([Ft.keyword,s],[Ft.params,typeof t=="function"?t(e):t||(0, ne._)`{}`]),u.messages&&n.push([Ft.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([Ft.schema,a],[Ft.parentSchema,(0, ne._)`${d}${l}`],[Ie.default.data,o]),c&&n.push([Ft.propertyName,c]);}});var Za=j(Xt=>{Object.defineProperty(Xt,"__esModule",{value:true});Xt.boolOrEmptySchema=Xt.topBoolOrEmptySchema=void 0;var Tl=Sr(),Il=H(),jl=lt(),Ol={message:"boolean schema is false"};function Pl(e){let{gen:t,schema:r,validateName:n}=e;r===false?Qa(e,false):typeof r=="object"&&r.$async===true?t.return(jl.default.data):(t.assign((0, Il._)`${n}.errors`,null),t.return(true));}Xt.topBoolOrEmptySchema=Pl;function Nl(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),Qa(e)):r.var(t,true);}Xt.boolOrEmptySchema=Nl;function Qa(e,t){let{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:false,schemaCode:false,schemaValue:false,params:{},it:e};(0, Tl.reportError)(s,Ol,void 0,t);}});var Is=j(Qt=>{Object.defineProperty(Qt,"__esModule",{value:true});Qt.getRules=Qt.isJSONType=void 0;var ql=["string","number","integer","boolean","null","object","array"],Fl=new Set(ql);function Dl(e){return typeof e=="string"&&Fl.has(e)}Qt.isJSONType=Dl;function Ml(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...e,integer:true,boolean:true,null:true},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Qt.getRules=Ml;});var js=j(vt=>{Object.defineProperty(vt,"__esModule",{value:true});vt.shouldUseRule=vt.shouldUseGroup=vt.schemaHasRulesForType=void 0;function Ll({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&ei(e,n)}vt.schemaHasRulesForType=Ll;function ei(e,t){return t.rules.some(r=>ti(e,r))}vt.shouldUseGroup=ei;function ti(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}vt.shouldUseRule=ti;});var wr=j($e=>{Object.defineProperty($e,"__esModule",{value:true});$e.reportTypeError=$e.checkDataTypes=$e.checkDataType=$e.coerceAndCheckDataType=$e.getJSONTypes=$e.getSchemaTypes=$e.DataType=void 0;var Bl=Is(),Vl=js(),Ul=Sr(),G=H(),ri=re(),Zt;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(Zt||($e.DataType=Zt={}));function Kl(e){let t=ni(e.type);if(t.includes("null")){if(e.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===true&&t.push("null");}return t}$e.getSchemaTypes=Kl;function ni(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Bl.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}$e.getJSONTypes=ni;function Gl(e,t){let{gen:r,data:n,opts:s}=e,o=Jl(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0, Vl.schemaHasRulesForType)(e,t[0]));if(a){let i=Ps(t,n,s.strictNumbers,Zt.Wrong);r.if(i,()=>{o.length?zl(e,t,o):Ns(e);});}return a}$e.coerceAndCheckDataType=Gl;var si=new Set(["string","number","integer","boolean","null"]);function Jl(e,t){return t?e.filter(r=>si.has(r)||t==="array"&&r==="array"):[]}function zl(e,t,r){let{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0, G._)`typeof ${s}`),i=n.let("coerced",(0, G._)`undefined`);o.coerceTypes==="array"&&n.if((0, G._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0, G._)`${s}[0]`).assign(a,(0, G._)`typeof ${s}`).if(Ps(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, G._)`${i} !== undefined`);for(let c of r)(si.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),Ns(e),n.endIf(),n.if((0, G._)`${i} !== undefined`,()=>{n.assign(s,i),Hl(e,i);});function u(c){switch(c){case "string":n.elseIf((0, G._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, G._)`"" + ${s}`).elseIf((0, G._)`${s} === null`).assign(i,(0, G._)`""`);return;case "number":n.elseIf((0, G._)`${a} == "boolean" || ${s} === null
3
- || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0, G._)`+${s}`);return;case "integer":n.elseIf((0, G._)`${a} === "boolean" || ${s} === null
4
- || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0, G._)`+${s}`);return;case "boolean":n.elseIf((0, G._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,false).elseIf((0, G._)`${s} === "true" || ${s} === 1`).assign(i,true);return;case "null":n.elseIf((0, G._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case "array":n.elseIf((0, G._)`${a} === "string" || ${a} === "number"
5
- || ${a} === "boolean" || ${s} === null`).assign(i,(0, G._)`[${s}]`);}}}function Hl({gen:e,parentData:t,parentDataProperty:r},n){e.if((0, G._)`${t} !== undefined`,()=>e.assign((0, G._)`${t}[${r}]`,n));}function Os(e,t,r,n=Zt.Correct){let s=n===Zt.Correct?G.operators.EQ:G.operators.NEQ,o;switch(e){case "null":return (0, G._)`${t} ${s} null`;case "array":o=(0, G._)`Array.isArray(${t})`;break;case "object":o=(0, G._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case "integer":o=a((0, G._)`!(${t} % 1) && !isNaN(${t})`);break;case "number":o=a();break;default:return (0, G._)`typeof ${t} ${s} ${e}`}return n===Zt.Correct?o:(0, G.not)(o);function a(i=G.nil){return (0, G.and)((0, G._)`typeof ${t} == "number"`,i,r?(0, G._)`isFinite(${t})`:G.nil)}}$e.checkDataType=Os;function Ps(e,t,r,n){if(e.length===1)return Os(e[0],t,r,n);let s,o=(0, ri.toHash)(e);if(o.array&&o.object){let a=(0, G._)`typeof ${t} != "object"`;s=o.null?a:(0, G._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object;}else s=G.nil;o.number&&delete o.integer;for(let a in o)s=(0, G.and)(s,Os(a,t,r,n));return s}$e.checkDataTypes=Ps;var Wl={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0, G._)`{type: ${e}}`:(0, G._)`{type: ${t}}`};function Ns(e){let t=Yl(e);(0, Ul.reportError)(t,Wl);}$e.reportTypeError=Ns;function Yl(e){let{gen:t,data:r,schema:n}=e,s=(0, ri.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var ai=j(ln=>{Object.defineProperty(ln,"__esModule",{value:true});ln.assignDefaults=void 0;var er=H(),Xl=re();function Ql(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)oi(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>oi(e,o,s.default));}ln.assignDefaults=Ql;function oi(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, er._)`${o}${(0, er.getProperty)(t)}`;if(s){(0, Xl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, er._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, er._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, er._)`${i} = ${(0, er.stringify)(r)}`);}});var Ge=j(ce=>{Object.defineProperty(ce,"__esModule",{value:true});ce.validateUnion=ce.validateArray=ce.usePattern=ce.callValidateCode=ce.schemaProperties=ce.allSchemaProperties=ce.noPropertyInData=ce.propertyInData=ce.isOwnProperty=ce.hasPropFunc=ce.reportMissingProp=ce.checkMissingProp=ce.checkReportMissingProp=void 0;var ge=H(),qs=re(),St=lt(),Zl=re();function ef(e,t){let{gen:r,data:n,it:s}=e;r.if(Ds(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, ge._)`${t}`},true),e.error();});}ce.checkReportMissingProp=ef;function tf({gen:e,data:t,it:{opts:r}},n,s){return (0, ge.or)(...n.map(o=>(0, ge.and)(Ds(e,t,o,r.ownProperties),(0, ge._)`${s} = ${o}`)))}ce.checkMissingProp=tf;function rf(e,t){e.setParams({missingProperty:t},true),e.error();}ce.reportMissingProp=rf;function ii(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, ge._)`Object.prototype.hasOwnProperty`})}ce.hasPropFunc=ii;function Fs(e,t,r){return (0, ge._)`${ii(e)}.call(${t}, ${r})`}ce.isOwnProperty=Fs;function nf(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} !== undefined`;return n?(0, ge._)`${s} && ${Fs(e,t,r)}`:s}ce.propertyInData=nf;function Ds(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} === undefined`;return n?(0, ge.or)(s,(0, ge.not)(Fs(e,t,r))):s}ce.noPropertyInData=Ds;function ci(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ce.allSchemaProperties=ci;function sf(e,t){return ci(t).filter(r=>!(0, qs.alwaysValidSchema)(e,t[r]))}ce.schemaProperties=sf;function of({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let d=c?(0, ge._)`${e}, ${t}, ${n}${s}`:t,l=[[St.default.instancePath,(0, ge.strConcat)(St.default.instancePath,o)],[St.default.parentData,a.parentData],[St.default.parentDataProperty,a.parentDataProperty],[St.default.rootData,St.default.rootData]];a.opts.dynamicRef&&l.push([St.default.dynamicAnchors,St.default.dynamicAnchors]);let h=(0, ge._)`${d}, ${r.object(...l)}`;return u!==ge.nil?(0, ge._)`${i}.call(${u}, ${h})`:(0, ge._)`${i}(${h})`}ce.callValidateCode=of;var af=(0, ge._)`new RegExp`;function cf({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0, ge._)`${s.code==="new RegExp"?af:(0, Zl.useFunc)(e,s)}(${r}, ${n})`})}ce.usePattern=cf;function uf(e){let{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){let i=t.let("valid",true);return a(()=>t.assign(i,false)),i}return t.var(o,true),a(()=>t.break()),o;function a(i){let u=t.const("len",(0, ge._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:qs.Type.Num},o),t.if((0, ge.not)(o),i);});}}ce.validateArray=uf;function df(e){let{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0, qs.alwaysValidSchema)(s,u))&&!s.opts.unevaluated)return;let a=t.let("valid",false),i=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let d=e.subschema({keyword:n,schemaProp:c,compositeRule:true},i);t.assign(a,(0, ge._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0, ge.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}ce.validateUnion=df;});var li=j(nt=>{Object.defineProperty(nt,"__esModule",{value:true});nt.validateKeywordUsage=nt.validSchemaType=nt.funcKeywordCode=nt.macroKeywordCode=void 0;var je=H(),Dt=lt(),lf=Ge(),ff=Sr();function pf(e,t){let{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),u=di(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:je.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}nt.macroKeywordCode=pf;function mf(e,t){var r;let{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:u}=e;hf(u,t);let c=!i&&t.compile?t.compile.call(u.self,o,a,u):t.validate,d=di(n,s,c),l=n.let("valid");e.block$data(l,h),e.ok((r=t.valid)!==null&&r!==void 0?r:l);function h(){if(t.errors===false)m(),t.modifying&&ui(e),b(()=>e.error());else {let R=t.async?v():p();t.modifying&&ui(e),b(()=>gf(e,R));}}function v(){let R=n.let("ruleErrs",null);return n.try(()=>m((0, je._)`await `),N=>n.assign(l,false).if((0, je._)`${N} instanceof ${u.ValidationError}`,()=>n.assign(R,(0, je._)`${N}.errors`),()=>n.throw(N))),R}function p(){let R=(0, je._)`${d}.errors`;return n.assign(R,null),m(je.nil),R}function m(R=t.async?(0, je._)`await `:je.nil){let N=u.opts.passContext?Dt.default.this:Dt.default.self,_=!("compile"in t&&!i||t.schema===false);n.assign(l,(0, je._)`${R}${(0, lf.callValidateCode)(e,d,N,_)}`,t.modifying);}function b(R){var N;n.if((0, je.not)((N=t.valid)!==null&&N!==void 0?N:l),R);}}nt.funcKeywordCode=mf;function ui(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, je._)`${n.parentData}[${n.parentDataProperty}]`));}function gf(e,t){let{gen:r}=e;r.if((0, je._)`Array.isArray(${t})`,()=>{r.assign(Dt.default.vErrors,(0, je._)`${Dt.default.vErrors} === null ? ${t} : ${Dt.default.vErrors}.concat(${t})`).assign(Dt.default.errors,(0, je._)`${Dt.default.vErrors}.length`),(0, ff.extendErrors)(e);},()=>e.error());}function hf({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function di(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0, je.stringify)(r)})}function yf(e,t,r=false){return !t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}nt.validSchemaType=yf;function vf({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let a=s.dependencies;if(a?.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}nt.validateKeywordUsage=vf;});var pi=j(wt=>{Object.defineProperty(wt,"__esModule",{value:true});wt.extendSubschemaMode=wt.extendSubschemaData=wt.getSubschema=void 0;var st=H(),fi=re();function Sf(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0, st._)`${e.schemaPath}${(0, st.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, st._)`${e.schemaPath}${(0, st.getProperty)(t)}${(0, st.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, fi.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}wt.getSubschema=Sf;function wf(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:i}=t;if(r!==void 0){let{errorPath:c,dataPathArr:d,opts:l}=t,h=i.let("data",(0, st._)`${t.data}${(0, st.getProperty)(r)}`,true);u(h),e.errorPath=(0, st.str)`${c}${(0, fi.getErrorPath)(r,n,l.jsPropertySyntax)}`,e.parentDataProperty=(0, st._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty];}if(s!==void 0){let c=s instanceof st.Name?s:i.let("data",s,true);u(c),a!==void 0&&(e.propertyName=a);}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c];}}wt.extendSubschemaData=wf;function bf(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r;}wt.extendSubschemaMode=bf;});var Ms=j((kv,mi)=>{mi.exports=function e(t,r){if(t===r)return true;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return false;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return false;for(s=n;s--!==0;)if(!e(t[s],r[s]))return false;return true}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return false;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return false;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return false}return true}return t!==t&&r!==r};});var hi=j((_v,gi)=>{var bt=gi.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};fn(t,n,s,e,"",e);};bt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};bt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};bt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};bt.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function fn(e,t,r,n,s,o,a,i,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,u,c);for(var d in n){var l=n[d];if(Array.isArray(l)){if(d in bt.arrayKeywords)for(var h=0;h<l.length;h++)fn(e,t,r,l[h],s+"/"+d+"/"+h,o,s,d,n,h);}else if(d in bt.propsKeywords){if(l&&typeof l=="object")for(var v in l)fn(e,t,r,l[v],s+"/"+d+"/"+kf(v),o,s,d,n,v);}else (d in bt.keywords||e.allKeys&&!(d in bt.skipKeywords))&&fn(e,t,r,l,s+"/"+d,o,s,d,n);}r(n,s,o,a,i,u,c);}}function kf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var br=j(Fe=>{Object.defineProperty(Fe,"__esModule",{value:true});Fe.getSchemaRefs=Fe.resolveUrl=Fe.normalizeId=Fe._getFullPath=Fe.getFullPath=Fe.inlineRef=void 0;var _f=re(),Rf=Ms(),Cf=hi(),Ef=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function $f(e,t=true){return typeof e=="boolean"?true:t===true?!Ls(e):t?yi(e)<=t:false}Fe.inlineRef=$f;var xf=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ls(e){for(let t in e){if(xf.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(Ls)||typeof r=="object"&&Ls(r))return true}return false}function yi(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Ef.has(r)&&(typeof e[r]=="object"&&(0, _f.eachItem)(e[r],n=>t+=yi(n)),t===1/0))return 1/0}return t}function vi(e,t="",r){r!==false&&(t=tr(t));let n=e.parse(t);return Si(e,n)}Fe.getFullPath=vi;function Si(e,t){return e.serialize(t).split("#")[0]+"#"}Fe._getFullPath=Si;var Af=/#\/?$/;function tr(e){return e?e.replace(Af,""):""}Fe.normalizeId=tr;function Tf(e,t,r){return r=tr(r),e.resolve(t,r)}Fe.resolveUrl=Tf;var If=/^[a-z_][-a-z0-9._]*$/i;function jf(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=tr(e[r]||t),o={"":s},a=vi(n,s,false),i={},u=new Set;return Cf(e,{allKeys:true},(l,h,v,p)=>{if(p===void 0)return;let m=a+h,b=o[p];typeof l[r]=="string"&&(b=R.call(this,l[r])),N.call(this,l.$anchor),N.call(this,l.$dynamicAnchor),o[h]=b;function R(_){let A=this.opts.uriResolver.resolve;if(_=tr(b?A(b,_):_),u.has(_))throw d(_);u.add(_);let S=this.refs[_];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(l,S.schema,_):_!==tr(m)&&(_[0]==="#"?(c(l,i[_],_),i[_]=l):this.refs[_]=m),_}function N(_){if(typeof _=="string"){if(!If.test(_))throw new Error(`invalid anchor "${_}"`);R.call(this,`#${_}`);}}}),i;function c(l,h,v){if(h!==void 0&&!Rf(l,h))throw d(v)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}Fe.getSchemaRefs=jf;});var Rr=j(kt=>{Object.defineProperty(kt,"__esModule",{value:true});kt.getData=kt.KeywordCxt=kt.validateFunctionCode=void 0;var Ri=Za(),wi=wr(),Vs=js(),pn=wr(),Of=ai(),_r=li(),Bs=pi(),q=H(),U=lt(),Pf=br(),ft=re(),kr=Sr();function Nf(e){if($i(e)&&(xi(e),Ei(e))){Df(e);return}Ci(e,()=>(0, Ri.topBoolOrEmptySchema)(e));}kt.validateFunctionCode=Nf;function Ci({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, q._)`${U.default.data}, ${U.default.valCxt}`,n.$async,()=>{e.code((0, q._)`"use strict"; ${bi(r,s)}`),Ff(e,s),e.code(o);}):e.func(t,(0, q._)`${U.default.data}, ${qf(s)}`,n.$async,()=>e.code(bi(r,s)).code(o));}function qf(e){return (0, q._)`{${U.default.instancePath}="", ${U.default.parentData}, ${U.default.parentDataProperty}, ${U.default.rootData}=${U.default.data}${e.dynamicRef?(0, q._)`, ${U.default.dynamicAnchors}={}`:q.nil}}={}`}function Ff(e,t){e.if(U.default.valCxt,()=>{e.var(U.default.instancePath,(0, q._)`${U.default.valCxt}.${U.default.instancePath}`),e.var(U.default.parentData,(0, q._)`${U.default.valCxt}.${U.default.parentData}`),e.var(U.default.parentDataProperty,(0, q._)`${U.default.valCxt}.${U.default.parentDataProperty}`),e.var(U.default.rootData,(0, q._)`${U.default.valCxt}.${U.default.rootData}`),t.dynamicRef&&e.var(U.default.dynamicAnchors,(0, q._)`${U.default.valCxt}.${U.default.dynamicAnchors}`);},()=>{e.var(U.default.instancePath,(0, q._)`""`),e.var(U.default.parentData,(0, q._)`undefined`),e.var(U.default.parentDataProperty,(0, q._)`undefined`),e.var(U.default.rootData,U.default.data),t.dynamicRef&&e.var(U.default.dynamicAnchors,(0, q._)`{}`);});}function Df(e){let{schema:t,opts:r,gen:n}=e;Ci(e,()=>{r.$comment&&t.$comment&&Ti(e),Uf(e),n.let(U.default.vErrors,null),n.let(U.default.errors,0),r.unevaluated&&Mf(e),Ai(e),Jf(e);});}function Mf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, q._)`${r}.evaluated`),t.if((0, q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, q._)`${e.evaluated}.props`,(0, q._)`undefined`)),t.if((0, q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, q._)`${e.evaluated}.items`,(0, q._)`undefined`));}function bi(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, q._)`/*# sourceURL=${r} */`:q.nil}function Lf(e,t){if($i(e)&&(xi(e),Ei(e))){Bf(e,t);return}(0, Ri.boolOrEmptySchema)(e,t);}function Ei({schema:e,self:t}){if(typeof e=="boolean")return !e;for(let r in e)if(t.RULES.all[r])return true;return false}function $i(e){return typeof e.schema!="boolean"}function Bf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Ti(e),Kf(e),Gf(e);let o=n.const("_errs",U.default.errors);Ai(e,o),n.var(t,(0, q._)`${o} === ${U.default.errors}`);}function xi(e){(0, ft.checkUnknownRules)(e),Vf(e);}function Ai(e,t){if(e.opts.jtd)return ki(e,[],false,t);let r=(0, wi.getSchemaTypes)(e.schema),n=(0, wi.coerceAndCheckDataType)(e,r);ki(e,r,!n,t);}function Vf(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, ft.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function Uf(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, ft.checkStrictMode)(e,"default is ignored in the schema root");}function Kf(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0, Pf.resolveUrl)(e.opts.uriResolver,e.baseId,t));}function Gf(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Ti({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, q._)`${U.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, q.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, q._)`${U.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function Jf(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0, q._)`${U.default.errors} === 0`,()=>t.return(U.default.data),()=>t.throw((0, q._)`new ${s}(${U.default.vErrors})`)):(t.assign((0, q._)`${n}.errors`,U.default.vErrors),o.unevaluated&&zf(e),t.return((0, q._)`${U.default.errors} === 0`));}function zf({gen:e,evaluated:t,props:r,items:n}){r instanceof q.Name&&e.assign((0, q._)`${t}.props`,r),n instanceof q.Name&&e.assign((0, q._)`${t}.items`,n);}function ki(e,t,r,n){let{gen:s,schema:o,data:a,allErrors:i,opts:u,self:c}=e,{RULES:d}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0, ft.schemaHasRulesButRef)(o,d))){s.block(()=>ji(e,"$ref",d.all.$ref.definition));return}u.jtd||Hf(e,t),s.block(()=>{for(let h of d.rules)l(h);l(d.post);});function l(h){(0, Vs.shouldUseGroup)(o,h)&&(h.type?(s.if((0, pn.checkDataType)(h.type,a,u.strictNumbers)),_i(e,h),t.length===1&&t[0]===h.type&&r&&(s.else(),(0, pn.reportTypeError)(e)),s.endIf()):_i(e,h),i||s.if((0, q._)`${U.default.errors} === ${n||0}`));}}function _i(e,t){let{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0, Of.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0, Vs.shouldUseRule)(n,o)&&ji(e,o.keyword,o.definition,t.type);});}function Hf(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Wf(e,t),e.opts.allowUnionTypes||Yf(e,t),Xf(e,e.dataTypes));}function Wf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Ii(e.dataTypes,r)||Us(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`);}),Zf(e,t);}}function Yf(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Us(e,"use allowUnionTypes to allow union type keyword");}function Xf(e,t){let r=e.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0, Vs.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>Qf(t,a))&&Us(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function Qf(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Ii(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Zf(e,t){let r=[];for(let n of e.dataTypes)Ii(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function Us(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, ft.checkStrictMode)(e,t,e.opts.strictTypes);}var mn=class{constructor(t,r,n){if((0, _r.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, ft.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Oi(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0, _r.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==false)&&(this.errsCount=t.gen.const("_errs",U.default.errors));}result(t,r,n){this.failResult((0, q.not)(t),r,n);}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(t,r){this.failResult((0, q.not)(t),void 0,r);}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0, q._)`${r} !== undefined && (${(0, q.or)(this.invalid$data(),t)})`);}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n);}_error(t,r){(t?kr.reportExtraError:kr.reportError)(this,this.def.error,r);}$dataError(){(0, kr.reportError)(this,this.def.$dataError||kr.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, kr.resetErrorsCount)(this.gen,this.errsCount);}ok(t){this.allErrors||this.gen.if(t);}setParams(t,r){r?Object.assign(this.params,t):this.params=t;}block$data(t,r,n=q.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=q.nil,r=q.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, q.or)((0, q._)`${s} === undefined`,r)),t!==q.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==q.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, q.or)(a(),i());function a(){if(n.length){if(!(r instanceof q.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, q._)`${(0, pn.checkDataTypes)(u,r,o.opts.strictNumbers,pn.DataType.Wrong)}`}return q.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, q._)`!${u}(${r})`}return q.nil}}subschema(t,r){let n=(0, Bs.getSubschema)(this.it,t);(0, Bs.extendSubschemaData)(n,this.it,t),(0, Bs.extendSubschemaMode)(n,t);let s={...this.it,...n,items:void 0,props:void 0};return Lf(s,r),s}mergeEvaluated(t,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==true&&t.props!==void 0&&(n.props=ft.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=ft.mergeEvaluated.items(s,t.items,n.items,r)));}mergeValidEvaluated(t,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==true||n.items!==true))return s.if(r,()=>this.mergeEvaluated(t,q.Name)),true}};kt.KeywordCxt=mn;function ji(e,t,r,n){let s=new mn(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0, _r.funcKeywordCode)(s,r):"macro"in r?(0, _r.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0, _r.funcKeywordCode)(s,r);}var ep=/^\/(?:[^~]|~0|~1)*$/,tp=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Oi(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return U.default.rootData;if(e[0]==="/"){if(!ep.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=U.default.rootData;}else {let c=tp.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let d=+c[1];if(s=c[2],s==="#"){if(d>=t)throw new Error(u("property/index",d));return n[t-d]}if(d>t)throw new Error(u("data",d));if(o=r[t-d],!s)return o}let a=o,i=s.split("/");for(let c of i)c&&(o=(0, q._)`${o}${(0, q.getProperty)((0, ft.unescapeJsonPointer)(c))}`,a=(0, q._)`${a} && ${o}`);return a;function u(c,d){return `Cannot access ${c} ${d} levels up, current level is ${t}`}}kt.getData=Oi;});var gn=j(Gs=>{Object.defineProperty(Gs,"__esModule",{value:true});var Ks=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Gs.default=Ks;});var Cr=j(Hs=>{Object.defineProperty(Hs,"__esModule",{value:true});var Js=br(),zs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, Js.resolveUrl)(t,r,n),this.missingSchema=(0, Js.normalizeId)((0, Js.getFullPath)(t,this.missingRef));}};Hs.default=zs;});var yn=j(Je=>{Object.defineProperty(Je,"__esModule",{value:true});Je.resolveSchema=Je.getCompilingSchema=Je.resolveRef=Je.compileSchema=Je.SchemaEnv=void 0;var et=H(),rp=gn(),Mt=lt(),tt=br(),Pi=re(),np=Rr(),rr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0, tt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={};}};Je.SchemaEnv=rr;function Ys(e){let t=Ni.call(this,e);if(t)return t;let r=(0, tt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new et.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),i;e.$async&&(i=a.scopeValue("Error",{ref:rp.default,code:(0, et._)`require("ajv/dist/runtime/validation_error").default`}));let u=a.scopeName("validate");e.validateName=u;let c={gen:a,allErrors:this.opts.allErrors,data:Mt.default.data,parentData:Mt.default.parentData,parentDataProperty:Mt.default.parentDataProperty,dataNames:[Mt.default.data],dataPathArr:[et.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0, et.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:et.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, et._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,np.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let l=a.toString();d=`${a.scopeRefs(Mt.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let v=new Function(`${Mt.default.self}`,`${Mt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(u,{ref:v}),v.errors=null,v.schema=e.schema,v.schemaEnv=e,e.$async&&(v.$async=!0),this.opts.code.source===!0&&(v.source={validateName:u,validateCode:l,scopeValues:a._values}),this.opts.unevaluated){let{props:p,items:m}=c;v.evaluated={props:p instanceof et.Name?void 0:p,items:m instanceof et.Name?void 0:m,dynamicProps:p instanceof et.Name,dynamicItems:m instanceof et.Name},v.source&&(v.source.evaluated=(0,et.stringify)(v.evaluated));}return e.validate=v,e}catch(l){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),l}finally{this._compilations.delete(e);}}Je.compileSchema=Ys;function sp(e,t,r){var n;r=(0, tt.resolveUrl)(this.opts.uriResolver,t,r);let s=e.refs[r];if(s)return s;let o=ip.call(this,e,r);if(o===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new rr({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=op.call(this,o)}Je.resolveRef=sp;function op(e){return (0, tt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ys.call(this,e)}function Ni(e){for(let t of this._compilations)if(ap(t,e))return t}Je.getCompilingSchema=Ni;function ap(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ip(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||hn.call(this,e,t)}function hn(e,t){let r=this.opts.uriResolver.parse(t),n=(0, tt._getFullPath)(this.opts.uriResolver,r),s=(0, tt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Ws.call(this,r,e);let o=(0, tt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=hn.call(this,e,a);return typeof i?.schema!="object"?void 0:Ws.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Ys.call(this,a),o===(0, tt.normalizeId)(t)){let{schema:i}=a,{schemaId:u}=this.opts,c=i[u];return c&&(s=(0, tt.resolveUrl)(this.opts.uriResolver,s,c)),new rr({schema:i,schemaId:u,root:e,baseId:s})}return Ws.call(this,r,a)}}Je.resolveSchema=hn;var cp=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ws(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0, Pi.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!cp.has(i)&&c&&(t=(0, tt.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, Pi.schemaHasRulesButRef)(r,this.RULES)){let i=(0, tt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=hn.call(this,n,i);}let{schemaId:a}=this.opts;if(o=o||new rr({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var qi=j((Av,up)=>{up.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:false};});var Qs=j((Tv,Li)=>{var dp=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Di=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);function Xs(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];}return t}var lp=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Fi(e){return e.length=0,true}function fp(e,t,r){if(e.length){let n=Xs(e);if(n!=="")t.push(n);else return r.error=true,false;e.length=0;}return true}function pp(e){let t=0,r={error:false,address:"",zone:""},n=[],s=[],o=false,a=false,i=fp;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===true&&(a=true),!i(s,n,r))break;if(++t>7){r.error=true;break}u>0&&e[u-1]===":"&&(o=true),n.push(":");continue}else if(c==="%"){if(!i(s,n,r))break;i=Fi;}else {s.push(c);continue}}return s.length&&(i===Fi?r.zone=s.join(""):a?n.push(s.join("")):n.push(Xs(s))),r.address=n.join(""),r}function Mi(e){if(mp(e,":")<2)return {host:e,isIPV6:false};let t=pp(e);if(t.error)return {host:e,isIPV6:false};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:true,escapedHost:n}}}function mp(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function gp(e){let t=e,r=[],n=-1,s=0;for(;s=t.length;){if(s===1){if(t===".")break;if(t==="/"){r.push("/");break}else {r.push(t);break}}else if(s===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(s===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n);}return r.join("")}function hp(e,t){let r=t!==true?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function yp(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Di(r)){let n=Mi(r);n.isIPV6===true?r=`[${n.escapedHost}]`:r=e.host;}t.push(r);}return (typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Li.exports={nonSimpleDomain:lp,recomposeAuthority:yp,normalizeComponentEncoding:hp,removeDotSegments:gp,isIPv4:Di,isUUID:dp,normalizeIPv6:Mi,stringArrayToHexStripped:Xs};});var Gi=j((Iv,Ki)=>{var{isUUID:vp}=Qs(),Sp=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,wp=["http","https","ws","wss","urn","urn:uuid"];function bp(e){return wp.indexOf(e)!==-1}function Zs(e){return e.secure===true?true:e.secure===false?false:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):false}function Bi(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Vi(e){let t=String(e.scheme).toLowerCase()==="https";return (e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function kp(e){return e.secure=Zs(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function _p(e){if((e.port===(Zs(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0;}return e.fragment=void 0,e}function Rp(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Sp);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let s=`${n}:${t.nid||e.nid}`,o=eo(s);e.path=void 0,o&&(e=o.parse(e,t));}else e.error=e.error||"URN can not be parsed.";return e}function Cp(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),s=`${r}:${t.nid||n}`,o=eo(s);o&&(e=o.serialize(e,t));let a=e,i=e.nss;return a.path=`${n||t.nid}:${i}`,t.skipEscape=true,a}function Ep(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!vp(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function $p(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Ui={scheme:"http",domainHost:true,parse:Bi,serialize:Vi},xp={scheme:"https",domainHost:Ui.domainHost,parse:Bi,serialize:Vi},vn={scheme:"ws",domainHost:true,parse:kp,serialize:_p},Ap={scheme:"wss",domainHost:vn.domainHost,parse:vn.parse,serialize:vn.serialize},Tp={scheme:"urn",parse:Rp,serialize:Cp,skipNormalize:true},Ip={scheme:"urn:uuid",parse:Ep,serialize:$p,skipNormalize:true},Sn={http:Ui,https:xp,ws:vn,wss:Ap,urn:Tp,"urn:uuid":Ip};Object.setPrototypeOf(Sn,null);function eo(e){return e&&(Sn[e]||Sn[e.toLowerCase()])||void 0}Ki.exports={wsIsSecure:Zs,SCHEMES:Sn,isValidSchemeName:bp,getSchemeHandler:eo};});var Hi=j((jv,bn)=>{var{normalizeIPv6:jp,removeDotSegments:Er,recomposeAuthority:Op,normalizeComponentEncoding:wn,isIPv4:Pp,nonSimpleDomain:Np}=Qs(),{SCHEMES:qp,getSchemeHandler:Ji}=Gi();function Fp(e,t){return typeof e=="string"?e=ot(pt(e,t),t):typeof e=="object"&&(e=pt(ot(e,t),t)),e}function Dp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=zi(pt(e,n),pt(t,n),n,true);return n.skipEscape=true,ot(s,n)}function zi(e,t,r,n){let s={};return n||(e=pt(ot(e,r),r),t=pt(ot(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(s.scheme=t.scheme,s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.path?(t.path[0]==="/"?s.path=Er(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?s.path="/"+t.path:e.path?s.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:s.path=t.path,s.path=Er(s.path)),s.query=t.query):(s.path=e.path,t.query!==void 0?s.query=t.query:s.query=e.query),s.userinfo=e.userinfo,s.host=e.host,s.port=e.port),s.scheme=e.scheme),s.fragment=t.fragment,s}function Mp(e,t,r){return typeof e=="string"?(e=unescape(e),e=ot(wn(pt(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=ot(wn(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=ot(wn(pt(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=ot(wn(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function ot(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),s=[],o=Ji(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let a=Op(r);if(a!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(a),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let i=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(i=Er(i)),a===void 0&&i[0]==="/"&&i[1]==="/"&&(i="/%2F"+i.slice(2)),s.push(i);}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var Lp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function pt(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=false;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(Lp);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(Pp(n.host)===false){let u=jp(n.host);n.host=u.host.toLowerCase(),s=u.isIPV6;}else s=true;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=Ji(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===false&&Np(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase());}catch(i){n.error=n.error||"Host's domain name can not be converted to ASCII: "+i;}(!a||a&&!a.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r);}else n.error=n.error||"URI can not be parsed.";return n}var to={SCHEMES:qp,normalize:Fp,resolve:Dp,resolveComponent:zi,equal:Mp,serialize:ot,parse:pt};bn.exports=to;bn.exports.default=to;bn.exports.fastUri=to;});var Yi=j(ro=>{Object.defineProperty(ro,"__esModule",{value:true});var Wi=Hi();Wi.code='require("ajv/dist/runtime/uri").default';ro.default=Wi;});var sc=j(_e=>{Object.defineProperty(_e,"__esModule",{value:true});_e.CodeGen=_e.Name=_e.nil=_e.stringify=_e.str=_e._=_e.KeywordCxt=void 0;var Bp=Rr();Object.defineProperty(_e,"KeywordCxt",{enumerable:true,get:function(){return Bp.KeywordCxt}});var nr=H();Object.defineProperty(_e,"_",{enumerable:true,get:function(){return nr._}});Object.defineProperty(_e,"str",{enumerable:true,get:function(){return nr.str}});Object.defineProperty(_e,"stringify",{enumerable:true,get:function(){return nr.stringify}});Object.defineProperty(_e,"nil",{enumerable:true,get:function(){return nr.nil}});Object.defineProperty(_e,"Name",{enumerable:true,get:function(){return nr.Name}});Object.defineProperty(_e,"CodeGen",{enumerable:true,get:function(){return nr.CodeGen}});var Vp=gn(),tc=Cr(),Up=Is(),$r=yn(),Kp=H(),xr=br(),kn=wr(),so=re(),Xi=qi(),Gp=Yi(),rc=(e,t)=>new RegExp(e,t);rc.code="new RegExp";var Jp=["removeAdditional","useDefaults","coerceTypes"],zp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Hp={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."},Wp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Qi=200;function Yp(e){var t,r,n,s,o,a,i,u,c,d,l,h,v,p,m,b,R,N,_,A,S,w,f,g,k;let x=e.strict,E=(t=e.code)===null||t===void 0?void 0:t.optimize,T=E===true||E===void 0?1:E||0,O=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:rc,Z=(s=e.uriResolver)!==null&&s!==void 0?s:Gp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:x)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:x)!==null&&u!==void 0?u:true,strictTypes:(d=(c=e.strictTypes)!==null&&c!==void 0?c:x)!==null&&d!==void 0?d:"log",strictTuples:(h=(l=e.strictTuples)!==null&&l!==void 0?l:x)!==null&&h!==void 0?h:"log",strictRequired:(p=(v=e.strictRequired)!==null&&v!==void 0?v:x)!==null&&p!==void 0?p:false,code:e.code?{...e.code,optimize:T,regExp:O}:{optimize:T,regExp:O},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:Qi,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:Qi,meta:(R=e.meta)!==null&&R!==void 0?R:true,messages:(N=e.messages)!==null&&N!==void 0?N:true,inlineRefs:(_=e.inlineRefs)!==null&&_!==void 0?_:true,schemaId:(A=e.schemaId)!==null&&A!==void 0?A:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:(w=e.validateSchema)!==null&&w!==void 0?w:true,validateFormats:(f=e.validateFormats)!==null&&f!==void 0?f:true,unicodeRegExp:(g=e.unicodeRegExp)!==null&&g!==void 0?g:true,int32range:(k=e.int32range)!==null&&k!==void 0?k:true,uriResolver:Z}}var Ar=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Yp(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Kp.ValueScope({scope:{},prefixes:zp,es5:r,lines:n}),this.logger=rm(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, Up.getRules)(),Zi.call(this,Hp,t,"NOT SUPPORTED"),Zi.call(this,Wp,t,"DEPRECATED","warn"),this._metaOpts=em.call(this),t.formats&&Qp.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Zp.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Xp.call(this),t.validateFormats=s;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,s=Xi;n==="id"&&(s={...Xi},s.id=s.$id,delete s.$id),r&&t&&this.addMetaSchema(s,s[n],false);}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let s=n(r);return "$async"in n||(this.errors=n.errors),s}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,t,r);async function s(d,l){await o.call(this,d.$schema);let h=this._addSchema(d,l);return h.validate||a.call(this,h)}async function o(d){d&&!this.getSchema(d)&&await s.call(this,{$ref:d},true);}async function a(d){try{return this._compileSchemaEnv(d)}catch(l){if(!(l instanceof tc.default))throw l;return i.call(this,l),await u.call(this,l.missingSchema),a.call(this,d)}}function i({missingSchema:d,missingRef:l}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${l} cannot be resolved`)}async function u(d){let l=await c.call(this,d);this.refs[d]||await o.call(this,l.$schema),this.refs[d]||this.addSchema(l,d,r);}async function c(d){let l=this._loading[d];if(l)return l;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d];}}}addSchema(t,r,n,s=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,s);return this}let o;if(typeof t=="object"){let{schemaId:a}=this.opts;if(o=t[a],o!==void 0&&typeof o!="string")throw new Error(`schema ${a} must be string`)}return r=(0, xr.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,s,true),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,true,n),this}validateSchema(t,r){if(typeof t=="boolean")return true;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,true;let s=this.validate(n,t);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(t){let r;for(;typeof(r=ec.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,s=new $r.SchemaEnv({schema:{},schemaId:n});if(r=$r.resolveSchema.call(this,s,t),!r)return;this.refs[t]=r;}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let r=ec.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case "object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0, xr.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(sm.call(this,n,r),!r)return (0, so.eachItem)(n,o=>no.call(this,o)),this;am.call(this,r);let s={...r,type:(0, kn.getJSONTypes)(r.type),schemaType:(0, kn.getJSONTypes)(r.schemaType)};return (0, so.eachItem)(n,s.type.length===0?o=>no.call(this,o,s):o=>s.type.forEach(a=>no.call(this,o,s,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===t);s>=0&&n.rules.splice(s,1);}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return !t||t.length===0?"No errors":t.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let s of r){let o=s.split("/").slice(1),a=t;for(let i of o)a=a[i];for(let i in n){let u=n[i];if(typeof u!="object")continue;let{$data:c}=u.definition,d=a[i];c&&d&&(a[i]=nc(d));}}return t}_removeAllSchemas(t,r){for(let n in t){let s=t[n];(!r||r.test(n))&&(typeof s=="string"?delete t[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete t[n]));}}_addSchema(t,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let a,{schemaId:i}=this.opts;if(typeof t=="object")a=t[i];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0, xr.normalizeId)(a||n);let c=xr.getSchemaRefs.call(this,t,n);return u=new $r.SchemaEnv({schema:t,schemaId:i,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),s&&this.validateSchema(t,true),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):$r.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{$r.compileSchema.call(this,t);}finally{this.opts=r;}}};Ar.ValidationError=Vp.default;Ar.MissingRefError=tc.default;_e.default=Ar;function Zi(e,t,r,n="error"){for(let s in e){let o=s;o in t&&this.logger[n](`${r}: option ${s}. ${e[o]}`);}}function ec(e){return e=(0, xr.normalizeId)(e),this.schemas[e]||this.refs[e]}function Xp(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t);}function Qp(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t);}}function Zp(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r);}}function em(){let e={...this.opts};for(let t of Jp)delete e[t];return e}var tm={log(){},warn(){},error(){}};function rm(e){if(e===false)return tm;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var nm=/^[a-z_$][a-z0-9_$:-]*$/i;function sm(e,t){let{RULES:r}=this;if((0, so.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!nm.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function no(e,t,r){var n;let s=t?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,a=s?o.post:o.rules.find(({type:u})=>u===r);if(a||(a={type:r,rules:[]},o.rules.push(a)),o.keywords[e]=true,!t)return;let i={keyword:e,definition:{...t,type:(0, kn.getJSONTypes)(t.type),schemaType:(0, kn.getJSONTypes)(t.schemaType)}};t.before?om.call(this,a,i,t.before):a.rules.push(i),o.all[e]=i,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u));}function om(e,t,r){let n=e.rules.findIndex(s=>s.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`));}function am(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=nc(t)),e.validateSchema=this.compile(t,true));}var im={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function nc(e){return {anyOf:[e,im]}}});var oc=j(oo=>{Object.defineProperty(oo,"__esModule",{value:true});var cm={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};oo.default=cm;});var uc=j(Lt=>{Object.defineProperty(Lt,"__esModule",{value:true});Lt.callRef=Lt.getValidate=void 0;var um=Cr(),ac=Ge(),De=H(),sr=lt(),ic=yn(),_n=re(),dm={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&s===c.baseId)return l();let d=ic.resolveRef.call(u,c,s,r);if(d===void 0)throw new um.default(n.opts.uriResolver,s,r);if(d instanceof ic.SchemaEnv)return h(d);return v(d);function l(){if(o===c)return Rn(e,a,o,o.$async);let p=t.scopeValue("root",{ref:c});return Rn(e,(0, De._)`${p}.validate`,c,c.$async)}function h(p){let m=cc(e,p);Rn(e,m,p,p.$async);}function v(p){let m=t.scopeValue("schema",i.code.source===true?{ref:p,code:(0, De.stringify)(p)}:{ref:p}),b=t.name("valid"),R=e.subschema({schema:p,dataTypes:[],schemaPath:De.nil,topSchemaRef:m,errSchemaPath:r},b);e.mergeEvaluated(R),e.ok(b);}}};function cc(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, De._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Lt.getValidate=cc;function Rn(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?sr.default.this:De.nil;n?d():l();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");let p=s.let("valid");s.try(()=>{s.code((0, De._)`await ${(0, ac.callValidateCode)(e,t,c)}`),v(t),a||s.assign(p,true);},m=>{s.if((0, De._)`!(${m} instanceof ${o.ValidationError})`,()=>s.throw(m)),h(m),a||s.assign(p,false);}),e.ok(p);}function l(){e.result((0, ac.callValidateCode)(e,t,c),()=>v(t),()=>h(t));}function h(p){let m=(0, De._)`${p}.errors`;s.assign(sr.default.vErrors,(0, De._)`${sr.default.vErrors} === null ? ${m} : ${sr.default.vErrors}.concat(${m})`),s.assign(sr.default.errors,(0, De._)`${sr.default.vErrors}.length`);}function v(p){var m;if(!o.opts.unevaluated)return;let b=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==true)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=_n.mergeEvaluated.props(s,b.props,o.props));else {let R=s.var("props",(0, De._)`${p}.evaluated.props`);o.props=_n.mergeEvaluated.props(s,R,o.props,De.Name);}if(o.items!==true)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=_n.mergeEvaluated.items(s,b.items,o.items));else {let R=s.var("items",(0, De._)`${p}.evaluated.items`);o.items=_n.mergeEvaluated.items(s,R,o.items,De.Name);}}}Lt.callRef=Rn;Lt.default=dm;});var dc=j(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var lm=oc(),fm=uc(),pm=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",lm.default,fm.default];ao.default=pm;});var lc=j(io=>{Object.defineProperty(io,"__esModule",{value:true});var Cn=H(),_t=Cn.operators,En={maximum:{okStr:"<=",ok:_t.LTE,fail:_t.GT},minimum:{okStr:">=",ok:_t.GTE,fail:_t.LT},exclusiveMaximum:{okStr:"<",ok:_t.LT,fail:_t.GTE},exclusiveMinimum:{okStr:">",ok:_t.GT,fail:_t.LTE}},mm={message:({keyword:e,schemaCode:t})=>(0, Cn.str)`must be ${En[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0, Cn._)`{comparison: ${En[e].okStr}, limit: ${t}}`},gm={keyword:Object.keys(En),type:"number",schemaType:"number",$data:true,error:mm,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0, Cn._)`${r} ${En[t].fail} ${n} || isNaN(${r})`);}};io.default=gm;});var fc=j(co=>{Object.defineProperty(co,"__esModule",{value:true});var Tr=H(),hm={message:({schemaCode:e})=>(0, Tr.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, Tr._)`{multipleOf: ${e}}`},ym={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:hm,code(e){let{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0, Tr._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, Tr._)`${a} !== parseInt(${a})`;e.fail$data((0, Tr._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};co.default=ym;});var mc=j(uo=>{Object.defineProperty(uo,"__esModule",{value:true});function pc(e){let t=e.length,r=0,n=0,s;for(;n<t;)r++,s=e.charCodeAt(n++),s>=55296&&s<=56319&&n<t&&(s=e.charCodeAt(n),(s&64512)===56320&&n++);return r}uo.default=pc;pc.code='require("ajv/dist/runtime/ucs2length").default';});var gc=j(lo=>{Object.defineProperty(lo,"__esModule",{value:true});var Bt=H(),vm=re(),Sm=mc(),wm={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return (0, Bt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0, Bt._)`{limit: ${e}}`},bm={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:wm,code(e){let{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?Bt.operators.GT:Bt.operators.LT,a=s.opts.unicode===false?(0, Bt._)`${r}.length`:(0, Bt._)`${(0, vm.useFunc)(e.gen,Sm.default)}(${r})`;e.fail$data((0, Bt._)`${a} ${o} ${n}`);}};lo.default=bm;});var hc=j(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var km=Ge(),_m=re(),or=H(),Rm={message:({schemaCode:e})=>(0, or.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, or._)`{pattern: ${e}}`},Cm={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:Rm,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){let{regExp:u}=a.opts.code,c=u.code==="new RegExp"?(0, or._)`new RegExp`:(0, _m.useFunc)(t,u),d=t.let("valid");t.try(()=>t.assign(d,(0, or._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(d,false)),e.fail$data((0, or._)`!${d}`);}else {let u=(0, km.usePattern)(e,s);e.fail$data((0, or._)`!${u}.test(${r})`);}}};fo.default=Cm;});var yc=j(po=>{Object.defineProperty(po,"__esModule",{value:true});var Ir=H(),Em={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, Ir.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, Ir._)`{limit: ${e}}`},$m={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:Em,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?Ir.operators.GT:Ir.operators.LT;e.fail$data((0, Ir._)`Object.keys(${r}).length ${s} ${n}`);}};po.default=$m;});var vc=j(mo=>{Object.defineProperty(mo,"__esModule",{value:true});var jr=Ge(),Or=H(),xm=re(),Am={message:({params:{missingProperty:e}})=>(0, Or.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, Or._)`{missingProperty: ${e}}`},Tm={keyword:"required",type:"object",schemaType:"array",$data:true,error:Am,code(e){let{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;let u=r.length>=i.loopRequired;if(a.allErrors?c():d(),i.strictRequired){let v=e.parentSchema.properties,{definedProperties:p}=e.it;for(let m of r)if(v?.[m]===void 0&&!p.has(m)){let b=a.schemaEnv.baseId+a.errSchemaPath,R=`required property "${m}" is not defined at "${b}" (strictRequired)`;(0, xm.checkStrictMode)(a,R,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(Or.nil,l);else for(let v of r)(0, jr.checkReportMissingProp)(e,v);}function d(){let v=t.let("missing");if(u||o){let p=t.let("valid",true);e.block$data(p,()=>h(v,p)),e.ok(p);}else t.if((0, jr.checkMissingProp)(e,r,v)),(0, jr.reportMissingProp)(e,v),t.else();}function l(){t.forOf("prop",n,v=>{e.setParams({missingProperty:v}),t.if((0, jr.noPropertyInData)(t,s,v,i.ownProperties),()=>e.error());});}function h(v,p){e.setParams({missingProperty:v}),t.forOf(v,n,()=>{t.assign(p,(0, jr.propertyInData)(t,s,v,i.ownProperties)),t.if((0, Or.not)(p),()=>{e.error(),t.break();});},Or.nil);}}};mo.default=Tm;});var Sc=j(go=>{Object.defineProperty(go,"__esModule",{value:true});var Pr=H(),Im={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return (0, Pr.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0, Pr._)`{limit: ${e}}`},jm={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Im,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?Pr.operators.GT:Pr.operators.LT;e.fail$data((0, Pr._)`${r}.length ${s} ${n}`);}};go.default=jm;});var $n=j(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var wc=Ms();wc.code='require("ajv/dist/runtime/equal").default';ho.default=wc;});var bc=j(vo=>{Object.defineProperty(vo,"__esModule",{value:true});var yo=wr(),Re=H(),Om=re(),Pm=$n(),Nm={message:({params:{i:e,j:t}})=>(0, Re.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, Re._)`{i: ${e}, j: ${t}}`},qm={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:Nm,code(e){let{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;let u=t.let("valid"),c=o.items?(0, yo.getSchemaTypes)(o.items):[];e.block$data(u,d,(0, Re._)`${a} === false`),e.ok(u);function d(){let p=t.let("i",(0, Re._)`${r}.length`),m=t.let("j");e.setParams({i:p,j:m}),t.assign(u,true),t.if((0, Re._)`${p} > 1`,()=>(l()?h:v)(p,m));}function l(){return c.length>0&&!c.some(p=>p==="object"||p==="array")}function h(p,m){let b=t.name("item"),R=(0, yo.checkDataTypes)(c,b,i.opts.strictNumbers,yo.DataType.Wrong),N=t.const("indices",(0, Re._)`{}`);t.for((0, Re._)`;${p}--;`,()=>{t.let(b,(0, Re._)`${r}[${p}]`),t.if(R,(0, Re._)`continue`),c.length>1&&t.if((0, Re._)`typeof ${b} == "string"`,(0, Re._)`${b} += "_"`),t.if((0, Re._)`typeof ${N}[${b}] == "number"`,()=>{t.assign(m,(0, Re._)`${N}[${b}]`),e.error(),t.assign(u,false).break();}).code((0, Re._)`${N}[${b}] = ${p}`);});}function v(p,m){let b=(0, Om.useFunc)(t,Pm.default),R=t.name("outer");t.label(R).for((0, Re._)`;${p}--;`,()=>t.for((0, Re._)`${m} = ${p}; ${m}--;`,()=>t.if((0, Re._)`${b}(${r}[${p}], ${r}[${m}])`,()=>{e.error(),t.assign(u,false).break(R);})));}}};vo.default=qm;});var kc=j(wo=>{Object.defineProperty(wo,"__esModule",{value:true});var So=H(),Fm=re(),Dm=$n(),Mm={message:"must be equal to constant",params:({schemaCode:e})=>(0, So._)`{allowedValue: ${e}}`},Lm={keyword:"const",$data:true,error:Mm,code(e){let{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0, So._)`!${(0, Fm.useFunc)(t,Dm.default)}(${r}, ${s})`):e.fail((0, So._)`${o} !== ${r}`);}};wo.default=Lm;});var _c=j(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var Nr=H(),Bm=re(),Vm=$n(),Um={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, Nr._)`{allowedValues: ${e}}`},Km={keyword:"enum",schemaType:"array",$data:true,error:Um,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let i=s.length>=a.opts.loopEnum,u,c=()=>u??(u=(0, Bm.useFunc)(t,Vm.default)),d;if(i||n)d=t.let("valid"),e.block$data(d,l);else {if(!Array.isArray(s))throw new Error("ajv implementation error");let v=t.const("vSchema",o);d=(0, Nr.or)(...s.map((p,m)=>h(v,m)));}e.pass(d);function l(){t.assign(d,false),t.forOf("v",o,v=>t.if((0, Nr._)`${c()}(${r}, ${v})`,()=>t.assign(d,true).break()));}function h(v,p){let m=s[p];return typeof m=="object"&&m!==null?(0, Nr._)`${c()}(${r}, ${v}[${p}])`:(0, Nr._)`${r} === ${m}`}}};bo.default=Km;});var Rc=j(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var Gm=lc(),Jm=fc(),zm=gc(),Hm=hc(),Wm=yc(),Ym=vc(),Xm=Sc(),Qm=bc(),Zm=kc(),eg=_c(),tg=[Gm.default,Jm.default,zm.default,Hm.default,Wm.default,Ym.default,Xm.default,Qm.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Zm.default,eg.default];ko.default=tg;});var Ro=j(qr=>{Object.defineProperty(qr,"__esModule",{value:true});qr.validateAdditionalItems=void 0;var Vt=H(),_o=re(),rg={message:({params:{len:e}})=>(0, Vt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Vt._)`{limit: ${e}}`},ng={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:rg,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, _o.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Cc(e,n);}};function Cc(e,t){let{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=true;let i=r.const("len",(0, Vt._)`${s}.length`);if(n===false)e.setParams({len:t.length}),e.pass((0, Vt._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0, _o.alwaysValidSchema)(a,n)){let c=r.var("valid",(0, Vt._)`${i} <= ${t.length}`);r.if((0, Vt.not)(c),()=>u(c)),e.ok(c);}function u(c){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:_o.Type.Num},c),a.allErrors||r.if((0, Vt.not)(c),()=>r.break());});}}qr.validateAdditionalItems=Cc;qr.default=ng;});var Co=j(Fr=>{Object.defineProperty(Fr,"__esModule",{value:true});Fr.validateTuple=void 0;var Ec=H(),xn=re(),sg=Ge(),og={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return $c(e,"additionalItems",t);r.items=true,!(0, xn.alwaysValidSchema)(r,t)&&e.ok((0, sg.validateArray)(e));}};function $c(e,t,r=e.schema){let{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==true&&(i.items=xn.mergeEvaluated.items(n,r.length,i.items));let u=n.name("valid"),c=n.const("len",(0, Ec._)`${o}.length`);r.forEach((l,h)=>{(0, xn.alwaysValidSchema)(i,l)||(n.if((0, Ec._)`${c} > ${h}`,()=>e.subschema({keyword:a,schemaProp:h,dataProp:h},u)),e.ok(u));});function d(l){let{opts:h,errSchemaPath:v}=i,p=r.length,m=p===l.minItems&&(p===l.maxItems||l[t]===false);if(h.strictTuples&&!m){let b=`"${a}" is ${p}-tuple, but minItems or maxItems/${t} are not specified or different at path "${v}"`;(0, xn.checkStrictMode)(i,b,h.strictTuples);}}}Fr.validateTuple=$c;Fr.default=og;});var xc=j(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});var ag=Co(),ig={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, ag.validateTuple)(e,"items")};Eo.default=ig;});var Tc=j($o=>{Object.defineProperty($o,"__esModule",{value:true});var Ac=H(),cg=re(),ug=Ge(),dg=Ro(),lg={message:({params:{len:e}})=>(0, Ac.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Ac._)`{limit: ${e}}`},fg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:lg,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=true,!(0, cg.alwaysValidSchema)(n,t)&&(s?(0, dg.validateAdditionalItems)(e,s):e.ok((0, ug.validateArray)(e)));}};$o.default=fg;});var Ic=j(xo=>{Object.defineProperty(xo,"__esModule",{value:true});var ze=H(),An=re(),pg={message:({params:{min:e,max:t}})=>t===void 0?(0, ze.str)`must contain at least ${e} valid item(s)`:(0, ze.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0, ze._)`{minContains: ${e}}`:(0, ze._)`{minContains: ${e}, maxContains: ${t}}`},mg={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:pg,code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e,a,i,{minContains:u,maxContains:c}=n;o.opts.next?(a=u===void 0?1:u,i=c):a=1;let d=t.const("len",(0, ze._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0, An.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, An.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0, An.alwaysValidSchema)(o,r)){let m=(0, ze._)`${d} >= ${a}`;i!==void 0&&(m=(0, ze._)`${m} && ${d} <= ${i}`),e.pass(m);return}o.items=true;let l=t.name("valid");i===void 0&&a===1?v(l,()=>t.if(l,()=>t.break())):a===0?(t.let(l,true),i!==void 0&&t.if((0, ze._)`${s}.length > 0`,h)):(t.let(l,false),h()),e.result(l,()=>e.reset());function h(){let m=t.name("_valid"),b=t.let("count",0);v(m,()=>t.if(m,()=>p(b)));}function v(m,b){t.forRange("i",0,d,R=>{e.subschema({keyword:"contains",dataProp:R,dataPropType:An.Type.Num,compositeRule:true},m),b();});}function p(m){t.code((0, ze._)`${m}++`),i===void 0?t.if((0, ze._)`${m} >= ${a}`,()=>t.assign(l,true).break()):(t.if((0, ze._)`${m} > ${i}`,()=>t.assign(l,false).break()),a===1?t.assign(l,true):t.if((0, ze._)`${m} >= ${a}`,()=>t.assign(l,true)));}}};xo.default=mg;});var Pc=j(at=>{Object.defineProperty(at,"__esModule",{value:true});at.validateSchemaDeps=at.validatePropertyDeps=at.error=void 0;var Ao=H(),gg=re(),Dr=Ge();at.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, Ao.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, Ao._)`{property: ${e},
1
+ import {spawnSync,spawn,execFile,execFileSync}from'child_process';import*as $ from'fs';import {existsSync}from'fs';import*as Qn from'os';import*as oe from'path';import {dirname,resolve}from'path';import*as ya from'net';import {fileURLToPath}from'url';import {createHash,randomUUID}from'crypto';import {createRequire}from'module';import {lockSync}from'proper-lockfile';import $h from'ajv-formats';var dd=Object.create;var pa=Object.defineProperty;var ld=Object.getOwnPropertyDescriptor;var fd=Object.getOwnPropertyNames;var pd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var gd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of fd(t))!md.call(e,s)&&s!==r&&pa(e,s,{get:()=>t[s],enumerable:!(n=ld(t,s))||n.enumerable});return e};var hd=(e,t,r)=>(r=e!=null?dd(pd(e)):{},gd(pa(r,"default",{value:e,enumerable:true}),e));var mr=O(ce=>{Object.defineProperty(ce,"__esModule",{value:true});ce.regexpCode=ce.getEsmExportName=ce.getProperty=ce.safeStringify=ce.stringify=ce.strConcat=ce.addCodeArg=ce.str=ce._=ce.nil=ce._Code=ce.Name=ce.IDENTIFIER=ce._CodeOrName=void 0;var fr=class{};ce._CodeOrName=fr;ce.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Pt=class extends fr{constructor(t){if(super(),!ce.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};ce.Name=Pt;var ze=class extends fr{constructor(t){super(),this._items=typeof t=="string"?[t]:t;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let t=this._items[0];return t===""||t==='""'}get str(){var t;return (t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return (t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Pt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ce._Code=ze;ce.nil=new ze("");function Ba(e,...t){let r=[e[0]],n=0;for(;n<t.length;)fs(r,t[n]),r.push(e[++n]);return new ze(r)}ce._=Ba;var ls=new ze("+");function Va(e,...t){let r=[pr(e[0])],n=0;for(;n<t.length;)r.push(ls),fs(r,t[n]),r.push(ls,pr(e[++n]));return Zd(r),new ze(r)}ce.str=Va;function fs(e,t){t instanceof ze?e.push(...t._items):t instanceof Pt?e.push(t):e.push(rl(t));}ce.addCodeArg=fs;function Zd(e){let t=1;for(;t<e.length-1;){if(e[t]===ls){let r=el(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+";}t++;}}function el(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Pt||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Pt))return `"${e}${t.slice(1)}`}function tl(e,t){return t.emptyStr()?e:e.emptyStr()?t:Va`${e}${t}`}ce.strConcat=tl;function rl(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:pr(Array.isArray(e)?e.join(","):e)}function nl(e){return new ze(pr(e))}ce.stringify=nl;function pr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ce.safeStringify=pr;function sl(e){return typeof e=="string"&&ce.IDENTIFIER.test(e)?new ze(`.${e}`):Ba`[${e}]`}ce.getProperty=sl;function ol(e){if(typeof e=="string"&&ce.IDENTIFIER.test(e))return new ze(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}ce.getEsmExportName=ol;function al(e){return new ze(e.toString())}ce.regexpCode=al;});var gs=O(Me=>{Object.defineProperty(Me,"__esModule",{value:true});Me.ValueScope=Me.ValueScopeName=Me.Scope=Me.varKinds=Me.UsedValueState=void 0;var Fe=mr(),ps=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value;}},sn;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed";})(sn||(Me.UsedValueState=sn={}));Me.varKinds={const:new Fe.Name("const"),let:new Fe.Name("let"),var:new Fe.Name("var")};var on=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r;}toName(t){return t instanceof Fe.Name?t:this.name(t)}name(t){return new Fe.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return `${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Me.Scope=on;var an=class extends Fe.Name{constructor(t,r){super(r),this.prefix=t;}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0, Fe._)`.${new Fe.Name(r)}[${n}]`;}};Me.ValueScopeName=an;var il=(0, Fe._)`\n`,ms=class extends on{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?il:Fe.nil};}get(){return this._scope}name(t){return new an(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(t),{prefix:o}=s,a=(n=r.key)!==null&&n!==void 0?n:r.ref,i=this._values[o];if(i){let d=i.get(a);if(d)return d}else i=this._values[o]=new Map;i.set(a,s);let u=this._scope[o]||(this._scope[o]=[]),c=u.length;return u[c]=r.ref,s.setValue(r,{property:o,itemIndex:c}),s}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return (0, Fe._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(t,r,n={},s){let o=Fe.nil;for(let a in t){let i=t[a];if(!i)continue;let u=n[a]=n[a]||new Map;i.forEach(c=>{if(u.has(c))return;u.set(c,sn.Started);let d=r(c);if(d){let l=this.opts.es5?Me.varKinds.var:Me.varKinds.const;o=(0, Fe._)`${o}${l} ${c} = ${d};${this.opts._n}`;}else if(d=s?.(c))o=(0, Fe._)`${o}${d}${this.opts._n}`;else throw new ps(c);u.set(c,sn.Completed);});}return o}};Me.ValueScope=ms;});var W=O(z=>{Object.defineProperty(z,"__esModule",{value:true});z.or=z.and=z.not=z.CodeGen=z.operators=z.varKinds=z.ValueScopeName=z.ValueScope=z.Scope=z.Name=z.regexpCode=z.stringify=z.getProperty=z.nil=z.strConcat=z.str=z._=void 0;var re=mr(),tt=gs(),St=mr();Object.defineProperty(z,"_",{enumerable:true,get:function(){return St._}});Object.defineProperty(z,"str",{enumerable:true,get:function(){return St.str}});Object.defineProperty(z,"strConcat",{enumerable:true,get:function(){return St.strConcat}});Object.defineProperty(z,"nil",{enumerable:true,get:function(){return St.nil}});Object.defineProperty(z,"getProperty",{enumerable:true,get:function(){return St.getProperty}});Object.defineProperty(z,"stringify",{enumerable:true,get:function(){return St.stringify}});Object.defineProperty(z,"regexpCode",{enumerable:true,get:function(){return St.regexpCode}});Object.defineProperty(z,"Name",{enumerable:true,get:function(){return St.Name}});var ln=gs();Object.defineProperty(z,"Scope",{enumerable:true,get:function(){return ln.Scope}});Object.defineProperty(z,"ValueScope",{enumerable:true,get:function(){return ln.ValueScope}});Object.defineProperty(z,"ValueScopeName",{enumerable:true,get:function(){return ln.ValueScopeName}});Object.defineProperty(z,"varKinds",{enumerable:true,get:function(){return ln.varKinds}});z.operators={GT:new re._Code(">"),GTE:new re._Code(">="),LT:new re._Code("<"),LTE:new re._Code("<="),EQ:new re._Code("==="),NEQ:new re._Code("!=="),NOT:new re._Code("!"),OR:new re._Code("||"),AND:new re._Code("&&"),ADD:new re._Code("+")};var lt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},hs=class extends lt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n;}render({es5:t,_n:r}){let n=t?tt.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return `${n} ${this.name}${s};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Xt(this.rhs,t,r)),this}get names(){return this.rhs instanceof re._CodeOrName?this.rhs.names:{}}},cn=class extends lt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n;}render({_n:t}){return `${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof re.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Xt(this.rhs,t,r),this}get names(){let t=this.lhs instanceof re.Name?{}:{...this.lhs.names};return dn(t,this.rhs)}},ys=class extends cn{constructor(t,r,n,s){super(t,n,s),this.op=r;}render({_n:t}){return `${this.lhs} ${this.op}= ${this.rhs};`+t}},vs=class extends lt{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `${this.label}:`+t}},Ss=class extends lt{constructor(t){super(),this.label=t,this.names={};}render({_n:t}){return `break${this.label?` ${this.label}`:""};`+t}},ws=class extends lt{constructor(t){super(),this.error=t;}render({_n:t}){return `throw ${this.error};`+t}get names(){return this.error.names}},ks=class extends lt{constructor(t){super(),this.code=t;}render({_n:t}){return `${this.code};`+t}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Xt(this.code,t,r),this}get names(){return this.code instanceof re._CodeOrName?this.code.names:{}}},gr=class extends lt{constructor(t=[]){super(),this.nodes=t;}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1);}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(t,r)||(cl(t,o.names),n.splice(s,1));}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Ft(t,r.names),{})}},ft=class extends gr{render(t){return "{"+t._n+super.render(t)+"}"+t._n}},bs=class extends gr{},Yt=class extends ft{};Yt.kind="else";var Nt=class e extends ft{constructor(t,r){super(r),this.condition=t;}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===true)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Yt(n):n;}if(r)return t===false?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Ua(t),r instanceof e?[r]:r.nodes);if(!(t===false||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Xt(this.condition,t,r),this}get names(){let t=super.names;return dn(t,this.condition),this.else&&Ft(t,this.else.names),t}};Nt.kind="if";var qt=class extends ft{};qt.kind="for";var Rs=class extends qt{constructor(t){super(),this.iteration=t;}render(t){return `for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Xt(this.iteration,t,r),this}get names(){return Ft(super.names,this.iteration.names)}},_s=class extends qt{constructor(t,r,n,s){super(),this.varKind=t,this.name=r,this.from=n,this.to=s;}render(t){let r=t.es5?tt.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return `for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=dn(super.names,this.from);return dn(t,this.to)}},un=class extends qt{constructor(t,r,n,s){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=s;}render(t){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Xt(this.iterable,t,r),this}get names(){return Ft(super.names,this.iterable.names)}},hr=class extends ft{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n;}render(t){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};hr.kind="func";var yr=class extends gr{render(t){return "return "+super.render(t)}};yr.kind="return";var Cs=class extends ft{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,s;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(s=this.finally)===null||s===void 0||s.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Ft(t,this.catch.names),this.finally&&Ft(t,this.finally.names),t}},vr=class extends ft{constructor(t){super(),this.error=t;}render(t){return `catch(${this.error})`+super.render(t)}};vr.kind="catch";var Sr=class extends ft{render(t){return "finally"+super.render(t)}};Sr.kind="finally";var $s=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
+ `:""},this._extScope=t,this._scope=new tt.Scope({parent:t}),this._nodes=[new bs];}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return (this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new hs(t,o,n)),o}const(t,r,n){return this._def(tt.varKinds.const,t,r,n)}let(t,r,n){return this._def(tt.varKinds.let,t,r,n)}var(t,r,n){return this._def(tt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new cn(t,r,n))}add(t,r){return this._leafNode(new ys(t,z.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==re.nil&&this._leafNode(new ks(t)),this}object(...t){let r=["{"];for(let[n,s]of t)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0, re.addCodeArg)(r,s));return r.push("}"),new re._Code(r)}if(t,r,n){if(this._blockNode(new Nt(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Nt(t))}else(){return this._elseNode(new Yt)}endIf(){return this._endBlockNode(Nt,Yt)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Rs(t),r)}forRange(t,r,n,s,o=this.opts.es5?tt.varKinds.var:tt.varKinds.let){let a=this._scope.toName(t);return this._for(new _s(o,a,r,n),()=>s(a))}forOf(t,r,n,s=tt.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof re.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0, re._)`${a}.length`,i=>{this.var(o,(0, re._)`${a}[${i}]`),n(o);})}return this._for(new un("of",s,o,r),()=>n(o))}forIn(t,r,n,s=this.opts.es5?tt.varKinds.var:tt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0, re._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new un("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(qt)}label(t){return this._leafNode(new vs(t))}break(t){return this._leafNode(new Ss(t))}return(t){let r=new yr;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(yr)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Cs;if(this._blockNode(s),this.code(t),r){let o=this.name("e");this._currNode=s.catch=new vr(o),r(o);}return n&&(this._currNode=s.finally=new Sr,this.code(n)),this._endBlockNode(vr,Sr)}throw(t){return this._leafNode(new ws(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=re.nil,n,s){return this._blockNode(new hr(t,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(hr)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t);}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Nt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t;}};z.CodeGen=$s;function Ft(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function dn(e,t){return t instanceof re._CodeOrName?Ft(e,t.names):e}function Xt(e,t,r){if(e instanceof re.Name)return n(e);if(!s(e))return e;return new re._Code(e._items.reduce((o,a)=>(a instanceof re.Name&&(a=n(a)),a instanceof re._Code?o.push(...a._items):o.push(a),o),[]));function n(o){let a=r[o.str];return a===void 0||t[o.str]!==1?o:(delete t[o.str],a)}function s(o){return o instanceof re._Code&&o._items.some(a=>a instanceof re.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function cl(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0);}function Ua(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0, re._)`!${Es(e)}`}z.not=Ua;var ul=Ka(z.operators.AND);function dl(...e){return e.reduce(ul)}z.and=dl;var ll=Ka(z.operators.OR);function fl(...e){return e.reduce(ll)}z.or=fl;function Ka(e){return (t,r)=>t===re.nil?r:r===re.nil?t:(0, re._)`${Es(t)} ${e} ${Es(r)}`}function Es(e){return e instanceof re.Name?e:(0, re._)`(${e})`}});var ae=O(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var fe=W(),pl=mr();function ml(e){let t={};for(let r of e)t[r]=true;return t}Y.toHash=ml;function gl(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?true:(za(e,t),!Ha(t,e.self.RULES.all))}Y.alwaysValidSchema=gl;function za(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let s=n.RULES.keywords;for(let o in t)s[o]||Xa(e,`unknown keyword: "${o}"`);}Y.checkUnknownRules=za;function Ha(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(t[r])return true;return false}Y.schemaHasRules=Ha;function hl(e,t){if(typeof e=="boolean")return !e;for(let r in e)if(r!=="$ref"&&t.all[r])return true;return false}Y.schemaHasRulesButRef=hl;function yl({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return (0, fe._)`${r}`}return (0, fe._)`${e}${t}${(0, fe.getProperty)(n)}`}Y.schemaRefOrVal=yl;function vl(e){return Wa(decodeURIComponent(e))}Y.unescapeFragment=vl;function Sl(e){return encodeURIComponent(As(e))}Y.escapeFragment=Sl;function As(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=As;function Wa(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Wa;function wl(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e);}Y.eachItem=wl;function Ga({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return (s,o,a,i)=>{let u=a===void 0?o:a instanceof fe.Name?(o instanceof fe.Name?e(s,o,a):t(s,o,a),a):o instanceof fe.Name?(t(s,a,o),o):r(o,a);return i===fe.Name&&!(u instanceof fe.Name)?n(s,u):u}}Y.mergeEvaluated={props:Ga({mergeNames:(e,t,r)=>e.if((0, fe._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0, fe._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0, fe._)`${r} || {}`).code((0, fe._)`Object.assign(${r}, ${t})`));}),mergeToName:(e,t,r)=>e.if((0, fe._)`${r} !== true`,()=>{t===true?e.assign(r,true):(e.assign(r,(0, fe._)`${r} || {}`),Ts(e,r,t));}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:Ya}),items:Ga({mergeNames:(e,t,r)=>e.if((0, fe._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0, fe._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0, fe._)`${r} !== true`,()=>e.assign(r,t===true?true:(0, fe._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Ya(e,t){if(t===true)return e.var("props",true);let r=e.var("props",(0, fe._)`{}`);return t!==void 0&&Ts(e,r,t),r}Y.evaluatedPropsToName=Ya;function Ts(e,t,r){Object.keys(r).forEach(n=>e.assign((0, fe._)`${t}${(0, fe.getProperty)(n)}`,true));}Y.setEvaluated=Ts;var Ja={};function kl(e,t){return e.scopeValue("func",{ref:t,code:Ja[t.code]||(Ja[t.code]=new pl._Code(t.code))})}Y.useFunc=kl;var xs;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str";})(xs||(Y.Type=xs={}));function bl(e,t,r){if(e instanceof fe.Name){let n=t===xs.Num;return r?n?(0, fe._)`"[" + ${e} + "]"`:(0, fe._)`"['" + ${e} + "']"`:n?(0, fe._)`"/" + ${e}`:(0, fe._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0, fe.getProperty)(e).toString():"/"+As(e)}Y.getErrorPath=bl;function Xa(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===true)throw new Error(t);e.self.logger.warn(t);}}Y.checkStrictMode=Xa;});var pt=O(Is=>{Object.defineProperty(Is,"__esModule",{value:true});var Ee=W(),Rl={data:new Ee.Name("data"),valCxt:new Ee.Name("valCxt"),instancePath:new Ee.Name("instancePath"),parentData:new Ee.Name("parentData"),parentDataProperty:new Ee.Name("parentDataProperty"),rootData:new Ee.Name("rootData"),dynamicAnchors:new Ee.Name("dynamicAnchors"),vErrors:new Ee.Name("vErrors"),errors:new Ee.Name("errors"),this:new Ee.Name("this"),self:new Ee.Name("self"),scope:new Ee.Name("scope"),json:new Ee.Name("json"),jsonPos:new Ee.Name("jsonPos"),jsonLen:new Ee.Name("jsonLen"),jsonPart:new Ee.Name("jsonPart")};Is.default=Rl;});var wr=O(xe=>{Object.defineProperty(xe,"__esModule",{value:true});xe.extendErrors=xe.resetErrorsCount=xe.reportExtraError=xe.reportError=xe.keyword$DataError=xe.keywordError=void 0;var ie=W(),fn=ae(),je=pt();xe.keywordError={message:({keyword:e})=>(0, ie.str)`must pass "${e}" keyword validation`};xe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0, ie.str)`"${e}" keyword must be ${t} ($data)`:(0, ie.str)`"${e}" keyword is invalid ($data)`};function _l(e,t=xe.keywordError,r,n){let{it:s}=e,{gen:o,compositeRule:a,allErrors:i}=s,u=ei(e,t,r);n??(a||i)?Qa(o,u):Za(s,(0, ie._)`[${u}]`);}xe.reportError=_l;function Cl(e,t=xe.keywordError,r){let{it:n}=e,{gen:s,compositeRule:o,allErrors:a}=n,i=ei(e,t,r);Qa(s,i),o||a||Za(n,je.default.vErrors);}xe.reportExtraError=Cl;function $l(e,t){e.assign(je.default.errors,t),e.if((0, ie._)`${je.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0, ie._)`${je.default.vErrors}.length`,t),()=>e.assign(je.default.vErrors,null)));}xe.resetErrorsCount=$l;function El({gen:e,keyword:t,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",s,je.default.errors,i=>{e.const(a,(0, ie._)`${je.default.vErrors}[${i}]`),e.if((0, ie._)`${a}.instancePath === undefined`,()=>e.assign((0, ie._)`${a}.instancePath`,(0, ie.strConcat)(je.default.instancePath,o.errorPath))),e.assign((0, ie._)`${a}.schemaPath`,(0, ie.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0, ie._)`${a}.schema`,r),e.assign((0, ie._)`${a}.data`,n));});}xe.extendErrors=El;function Qa(e,t){let r=e.const("err",t);e.if((0, ie._)`${je.default.vErrors} === null`,()=>e.assign(je.default.vErrors,(0, ie._)`[${r}]`),(0, ie._)`${je.default.vErrors}.push(${r})`),e.code((0, ie._)`${je.default.errors}++`);}function Za(e,t){let{gen:r,validateName:n,schemaEnv:s}=e;s.$async?r.throw((0, ie._)`new ${e.ValidationError}(${t})`):(r.assign((0, ie._)`${n}.errors`,t),r.return(false));}var Mt={keyword:new ie.Name("keyword"),schemaPath:new ie.Name("schemaPath"),params:new ie.Name("params"),propertyName:new ie.Name("propertyName"),message:new ie.Name("message"),schema:new ie.Name("schema"),parentSchema:new ie.Name("parentSchema")};function ei(e,t,r){let{createErrors:n}=e.it;return n===false?(0, ie._)`{}`:xl(e,t,r)}function xl(e,t,r={}){let{gen:n,it:s}=e,o=[Al(s,r),Tl(e,r)];return Il(e,t,o),n.object(...o)}function Al({errorPath:e},{instancePath:t}){let r=t?(0, ie.str)`${e}${(0, fn.getErrorPath)(t,fn.Type.Str)}`:e;return [je.default.instancePath,(0, ie.strConcat)(je.default.instancePath,r)]}function Tl({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let s=n?t:(0, ie.str)`${t}/${e}`;return r&&(s=(0, ie.str)`${s}${(0, fn.getErrorPath)(r,fn.Type.Str)}`),[Mt.schemaPath,s]}function Il(e,{params:t,message:r},n){let{keyword:s,data:o,schemaValue:a,it:i}=e,{opts:u,propertyName:c,topSchemaRef:d,schemaPath:l}=i;n.push([Mt.keyword,s],[Mt.params,typeof t=="function"?t(e):t||(0, ie._)`{}`]),u.messages&&n.push([Mt.message,typeof r=="function"?r(e):r]),u.verbose&&n.push([Mt.schema,a],[Mt.parentSchema,(0, ie._)`${d}${l}`],[je.default.data,o]),c&&n.push([Mt.propertyName,c]);}});var ri=O(Qt=>{Object.defineProperty(Qt,"__esModule",{value:true});Qt.boolOrEmptySchema=Qt.topBoolOrEmptySchema=void 0;var jl=wr(),Ol=W(),Pl=pt(),Nl={message:"boolean schema is false"};function ql(e){let{gen:t,schema:r,validateName:n}=e;r===false?ti(e,false):typeof r=="object"&&r.$async===true?t.return(Pl.default.data):(t.assign((0, Ol._)`${n}.errors`,null),t.return(true));}Qt.topBoolOrEmptySchema=ql;function Fl(e,t){let{gen:r,schema:n}=e;n===false?(r.var(t,false),ti(e)):r.var(t,true);}Qt.boolOrEmptySchema=Fl;function ti(e,t){let{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:false,schemaCode:false,schemaValue:false,params:{},it:e};(0, jl.reportError)(s,Nl,void 0,t);}});var js=O(Zt=>{Object.defineProperty(Zt,"__esModule",{value:true});Zt.getRules=Zt.isJSONType=void 0;var Ml=["string","number","integer","boolean","null","object","array"],Dl=new Set(Ml);function Ll(e){return typeof e=="string"&&Dl.has(e)}Zt.isJSONType=Ll;function Bl(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...e,integer:true,boolean:true,null:true},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Zt.getRules=Bl;});var Os=O(wt=>{Object.defineProperty(wt,"__esModule",{value:true});wt.shouldUseRule=wt.shouldUseGroup=wt.schemaHasRulesForType=void 0;function Vl({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==true&&ni(e,n)}wt.schemaHasRulesForType=Vl;function ni(e,t){return t.rules.some(r=>si(e,r))}wt.shouldUseGroup=ni;function si(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}wt.shouldUseRule=si;});var kr=O(Ae=>{Object.defineProperty(Ae,"__esModule",{value:true});Ae.reportTypeError=Ae.checkDataTypes=Ae.checkDataType=Ae.coerceAndCheckDataType=Ae.getJSONTypes=Ae.getSchemaTypes=Ae.DataType=void 0;var Ul=js(),Kl=Os(),Gl=wr(),J=W(),oi=ae(),er;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong";})(er||(Ae.DataType=er={}));function Jl(e){let t=ai(e.type);if(t.includes("null")){if(e.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===true&&t.push("null");}return t}Ae.getSchemaTypes=Jl;function ai(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Ul.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ae.getJSONTypes=ai;function zl(e,t){let{gen:r,data:n,opts:s}=e,o=Hl(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0, Kl.schemaHasRulesForType)(e,t[0]));if(a){let i=Ns(t,n,s.strictNumbers,er.Wrong);r.if(i,()=>{o.length?Wl(e,t,o):qs(e);});}return a}Ae.coerceAndCheckDataType=zl;var ii=new Set(["string","number","integer","boolean","null"]);function Hl(e,t){return t?e.filter(r=>ii.has(r)||t==="array"&&r==="array"):[]}function Wl(e,t,r){let{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0, J._)`typeof ${s}`),i=n.let("coerced",(0, J._)`undefined`);o.coerceTypes==="array"&&n.if((0, J._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0, J._)`${s}[0]`).assign(a,(0, J._)`typeof ${s}`).if(Ns(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0, J._)`${i} !== undefined`);for(let c of r)(ii.has(c)||c==="array"&&o.coerceTypes==="array")&&u(c);n.else(),qs(e),n.endIf(),n.if((0, J._)`${i} !== undefined`,()=>{n.assign(s,i),Yl(e,i);});function u(c){switch(c){case "string":n.elseIf((0, J._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0, J._)`"" + ${s}`).elseIf((0, J._)`${s} === null`).assign(i,(0, J._)`""`);return;case "number":n.elseIf((0, J._)`${a} == "boolean" || ${s} === null
3
+ || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0, J._)`+${s}`);return;case "integer":n.elseIf((0, J._)`${a} === "boolean" || ${s} === null
4
+ || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0, J._)`+${s}`);return;case "boolean":n.elseIf((0, J._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,false).elseIf((0, J._)`${s} === "true" || ${s} === 1`).assign(i,true);return;case "null":n.elseIf((0, J._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case "array":n.elseIf((0, J._)`${a} === "string" || ${a} === "number"
5
+ || ${a} === "boolean" || ${s} === null`).assign(i,(0, J._)`[${s}]`);}}}function Yl({gen:e,parentData:t,parentDataProperty:r},n){e.if((0, J._)`${t} !== undefined`,()=>e.assign((0, J._)`${t}[${r}]`,n));}function Ps(e,t,r,n=er.Correct){let s=n===er.Correct?J.operators.EQ:J.operators.NEQ,o;switch(e){case "null":return (0, J._)`${t} ${s} null`;case "array":o=(0, J._)`Array.isArray(${t})`;break;case "object":o=(0, J._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case "integer":o=a((0, J._)`!(${t} % 1) && !isNaN(${t})`);break;case "number":o=a();break;default:return (0, J._)`typeof ${t} ${s} ${e}`}return n===er.Correct?o:(0, J.not)(o);function a(i=J.nil){return (0, J.and)((0, J._)`typeof ${t} == "number"`,i,r?(0, J._)`isFinite(${t})`:J.nil)}}Ae.checkDataType=Ps;function Ns(e,t,r,n){if(e.length===1)return Ps(e[0],t,r,n);let s,o=(0, oi.toHash)(e);if(o.array&&o.object){let a=(0, J._)`typeof ${t} != "object"`;s=o.null?a:(0, J._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object;}else s=J.nil;o.number&&delete o.integer;for(let a in o)s=(0, J.and)(s,Ps(a,t,r,n));return s}Ae.checkDataTypes=Ns;var Xl={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0, J._)`{type: ${e}}`:(0, J._)`{type: ${t}}`};function qs(e){let t=Ql(e);(0, Gl.reportError)(t,Xl);}Ae.reportTypeError=qs;function Ql(e){let{gen:t,data:r,schema:n}=e,s=(0, oi.schemaRefOrVal)(e,n,"type");return {gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}});var ui=O(pn=>{Object.defineProperty(pn,"__esModule",{value:true});pn.assignDefaults=void 0;var tr=W(),Zl=ae();function ef(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let s in r)ci(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ci(e,o,s.default));}pn.assignDefaults=ef;function ci(e,t,r){let{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;let i=(0, tr._)`${o}${(0, tr.getProperty)(t)}`;if(s){(0, Zl.checkStrictMode)(e,`default is ignored for: ${i}`);return}let u=(0, tr._)`${i} === undefined`;a.useDefaults==="empty"&&(u=(0, tr._)`${u} || ${i} === null || ${i} === ""`),n.if(u,(0, tr._)`${i} = ${(0, tr.stringify)(r)}`);}});var He=O(le=>{Object.defineProperty(le,"__esModule",{value:true});le.validateUnion=le.validateArray=le.usePattern=le.callValidateCode=le.schemaProperties=le.allSchemaProperties=le.noPropertyInData=le.propertyInData=le.isOwnProperty=le.hasPropFunc=le.reportMissingProp=le.checkMissingProp=le.checkReportMissingProp=void 0;var ge=W(),Fs=ae(),kt=pt(),tf=ae();function rf(e,t){let{gen:r,data:n,it:s}=e;r.if(Ds(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0, ge._)`${t}`},true),e.error();});}le.checkReportMissingProp=rf;function nf({gen:e,data:t,it:{opts:r}},n,s){return (0, ge.or)(...n.map(o=>(0, ge.and)(Ds(e,t,o,r.ownProperties),(0, ge._)`${s} = ${o}`)))}le.checkMissingProp=nf;function sf(e,t){e.setParams({missingProperty:t},true),e.error();}le.reportMissingProp=sf;function di(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0, ge._)`Object.prototype.hasOwnProperty`})}le.hasPropFunc=di;function Ms(e,t,r){return (0, ge._)`${di(e)}.call(${t}, ${r})`}le.isOwnProperty=Ms;function of(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} !== undefined`;return n?(0, ge._)`${s} && ${Ms(e,t,r)}`:s}le.propertyInData=of;function Ds(e,t,r,n){let s=(0, ge._)`${t}${(0, ge.getProperty)(r)} === undefined`;return n?(0, ge.or)(s,(0, ge.not)(Ms(e,t,r))):s}le.noPropertyInData=Ds;function li(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}le.allSchemaProperties=li;function af(e,t){return li(t).filter(r=>!(0, Fs.alwaysValidSchema)(e,t[r]))}le.schemaProperties=af;function cf({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,u,c){let d=c?(0, ge._)`${e}, ${t}, ${n}${s}`:t,l=[[kt.default.instancePath,(0, ge.strConcat)(kt.default.instancePath,o)],[kt.default.parentData,a.parentData],[kt.default.parentDataProperty,a.parentDataProperty],[kt.default.rootData,kt.default.rootData]];a.opts.dynamicRef&&l.push([kt.default.dynamicAnchors,kt.default.dynamicAnchors]);let g=(0, ge._)`${d}, ${r.object(...l)}`;return u!==ge.nil?(0, ge._)`${i}.call(${u}, ${g})`:(0, ge._)`${i}(${g})`}le.callValidateCode=cf;var uf=(0, ge._)`new RegExp`;function df({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0, ge._)`${s.code==="new RegExp"?uf:(0, tf.useFunc)(e,s)}(${r}, ${n})`})}le.usePattern=df;function lf(e){let{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){let i=t.let("valid",true);return a(()=>t.assign(i,false)),i}return t.var(o,true),a(()=>t.break()),o;function a(i){let u=t.const("len",(0, ge._)`${r}.length`);t.forRange("i",0,u,c=>{e.subschema({keyword:n,dataProp:c,dataPropType:Fs.Type.Num},o),t.if((0, ge.not)(o),i);});}}le.validateArray=lf;function ff(e){let{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(u=>(0, Fs.alwaysValidSchema)(s,u))&&!s.opts.unevaluated)return;let a=t.let("valid",false),i=t.name("_valid");t.block(()=>r.forEach((u,c)=>{let d=e.subschema({keyword:n,schemaProp:c,compositeRule:true},i);t.assign(a,(0, ge._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0, ge.not)(a));})),e.result(a,()=>e.reset(),()=>e.error(true));}le.validateUnion=ff;});var mi=O(ot=>{Object.defineProperty(ot,"__esModule",{value:true});ot.validateKeywordUsage=ot.validSchemaType=ot.funcKeywordCode=ot.macroKeywordCode=void 0;var Oe=W(),Dt=pt(),pf=He(),mf=wr();function gf(e,t){let{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),u=pi(r,n,i);a.opts.validateSchema!==false&&a.self.validateSchema(i,true);let c=r.name("valid");e.subschema({schema:i,schemaPath:Oe.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:u,compositeRule:true},c),e.pass(c,()=>e.error(true));}ot.macroKeywordCode=gf;function hf(e,t){var r;let{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:u}=e;vf(u,t);let c=!i&&t.compile?t.compile.call(u.self,o,a,u):t.validate,d=pi(n,s,c),l=n.let("valid");e.block$data(l,g),e.ok((r=t.valid)!==null&&r!==void 0?r:l);function g(){if(t.errors===false)m(),t.modifying&&fi(e),b(()=>e.error());else {let C=t.async?v():f();t.modifying&&fi(e),b(()=>yf(e,C));}}function v(){let C=n.let("ruleErrs",null);return n.try(()=>m((0, Oe._)`await `),q=>n.assign(l,false).if((0, Oe._)`${q} instanceof ${u.ValidationError}`,()=>n.assign(C,(0, Oe._)`${q}.errors`),()=>n.throw(q))),C}function f(){let C=(0, Oe._)`${d}.errors`;return n.assign(C,null),m(Oe.nil),C}function m(C=t.async?(0, Oe._)`await `:Oe.nil){let q=u.opts.passContext?Dt.default.this:Dt.default.self,_=!("compile"in t&&!i||t.schema===false);n.assign(l,(0, Oe._)`${C}${(0, pf.callValidateCode)(e,d,q,_)}`,t.modifying);}function b(C){var q;n.if((0, Oe.not)((q=t.valid)!==null&&q!==void 0?q:l),C);}}ot.funcKeywordCode=hf;function fi(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0, Oe._)`${n.parentData}[${n.parentDataProperty}]`));}function yf(e,t){let{gen:r}=e;r.if((0, Oe._)`Array.isArray(${t})`,()=>{r.assign(Dt.default.vErrors,(0, Oe._)`${Dt.default.vErrors} === null ? ${t} : ${Dt.default.vErrors}.concat(${t})`).assign(Dt.default.errors,(0, Oe._)`${Dt.default.vErrors}.length`),(0, mf.extendErrors)(e);},()=>e.error());}function vf({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function pi(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0, Oe.stringify)(r)})}function Sf(e,t,r=false){return !t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}ot.validSchemaType=Sf;function wf({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let a=s.dependencies;if(a?.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){let u=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(u);else throw new Error(u)}}ot.validateKeywordUsage=wf;});var hi=O(bt=>{Object.defineProperty(bt,"__esModule",{value:true});bt.extendSubschemaMode=bt.extendSubschemaData=bt.getSubschema=void 0;var at=W(),gi=ae();function kf(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0, at._)`${e.schemaPath}${(0, at.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0, at._)`${e.schemaPath}${(0, at.getProperty)(t)}${(0, at.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0, gi.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return {schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}bt.getSubschema=kf;function bf(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:i}=t;if(r!==void 0){let{errorPath:c,dataPathArr:d,opts:l}=t,g=i.let("data",(0, at._)`${t.data}${(0, at.getProperty)(r)}`,true);u(g),e.errorPath=(0, at.str)`${c}${(0, gi.getErrorPath)(r,n,l.jsPropertySyntax)}`,e.parentDataProperty=(0, at._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty];}if(s!==void 0){let c=s instanceof at.Name?s:i.let("data",s,true);u(c),a!==void 0&&(e.propertyName=a);}o&&(e.dataTypes=o);function u(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c];}}bt.extendSubschemaData=bf;function Rf(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r;}bt.extendSubschemaMode=Rf;});var Ls=O((_v,yi)=>{yi.exports=function e(t,r){if(t===r)return true;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return false;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return false;for(s=n;s--!==0;)if(!e(t[s],r[s]))return false;return true}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return false;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return false;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return false}return true}return t!==t&&r!==r};});var Si=O((Cv,vi)=>{var Rt=vi.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};mn(t,n,s,e,"",e);};Rt.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};Rt.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};Rt.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};Rt.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function mn(e,t,r,n,s,o,a,i,u,c){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,u,c);for(var d in n){var l=n[d];if(Array.isArray(l)){if(d in Rt.arrayKeywords)for(var g=0;g<l.length;g++)mn(e,t,r,l[g],s+"/"+d+"/"+g,o,s,d,n,g);}else if(d in Rt.propsKeywords){if(l&&typeof l=="object")for(var v in l)mn(e,t,r,l[v],s+"/"+d+"/"+_f(v),o,s,d,n,v);}else (d in Rt.keywords||e.allKeys&&!(d in Rt.skipKeywords))&&mn(e,t,r,l,s+"/"+d,o,s,d,n);}r(n,s,o,a,i,u,c);}}function _f(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var br=O(De=>{Object.defineProperty(De,"__esModule",{value:true});De.getSchemaRefs=De.resolveUrl=De.normalizeId=De._getFullPath=De.getFullPath=De.inlineRef=void 0;var Cf=ae(),$f=Ls(),Ef=Si(),xf=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Af(e,t=true){return typeof e=="boolean"?true:t===true?!Bs(e):t?wi(e)<=t:false}De.inlineRef=Af;var Tf=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Bs(e){for(let t in e){if(Tf.has(t))return true;let r=e[t];if(Array.isArray(r)&&r.some(Bs)||typeof r=="object"&&Bs(r))return true}return false}function wi(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!xf.has(r)&&(typeof e[r]=="object"&&(0, Cf.eachItem)(e[r],n=>t+=wi(n)),t===1/0))return 1/0}return t}function ki(e,t="",r){r!==false&&(t=rr(t));let n=e.parse(t);return bi(e,n)}De.getFullPath=ki;function bi(e,t){return e.serialize(t).split("#")[0]+"#"}De._getFullPath=bi;var If=/#\/?$/;function rr(e){return e?e.replace(If,""):""}De.normalizeId=rr;function jf(e,t,r){return r=rr(r),e.resolve(t,r)}De.resolveUrl=jf;var Of=/^[a-z_][-a-z0-9._]*$/i;function Pf(e,t){if(typeof e=="boolean")return {};let{schemaId:r,uriResolver:n}=this.opts,s=rr(e[r]||t),o={"":s},a=ki(n,s,false),i={},u=new Set;return Ef(e,{allKeys:true},(l,g,v,f)=>{if(f===void 0)return;let m=a+g,b=o[f];typeof l[r]=="string"&&(b=C.call(this,l[r])),q.call(this,l.$anchor),q.call(this,l.$dynamicAnchor),o[g]=b;function C(_){let I=this.opts.uriResolver.resolve;if(_=rr(b?I(b,_):_),u.has(_))throw d(_);u.add(_);let S=this.refs[_];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(l,S.schema,_):_!==rr(m)&&(_[0]==="#"?(c(l,i[_],_),i[_]=l):this.refs[_]=m),_}function q(_){if(typeof _=="string"){if(!Of.test(_))throw new Error(`invalid anchor "${_}"`);C.call(this,`#${_}`);}}}),i;function c(l,g,v){if(g!==void 0&&!$f(l,g))throw d(v)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}De.getSchemaRefs=Pf;});var Cr=O(_t=>{Object.defineProperty(_t,"__esModule",{value:true});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;var Ei=ri(),Ri=kr(),Us=Os(),gn=kr(),Nf=ui(),_r=mi(),Vs=hi(),M=W(),G=pt(),qf=br(),mt=ae(),Rr=wr();function Ff(e){if(Ti(e)&&(Ii(e),Ai(e))){Lf(e);return}xi(e,()=>(0, Ei.topBoolOrEmptySchema)(e));}_t.validateFunctionCode=Ff;function xi({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0, M._)`${G.default.data}, ${G.default.valCxt}`,n.$async,()=>{e.code((0, M._)`"use strict"; ${_i(r,s)}`),Df(e,s),e.code(o);}):e.func(t,(0, M._)`${G.default.data}, ${Mf(s)}`,n.$async,()=>e.code(_i(r,s)).code(o));}function Mf(e){return (0, M._)`{${G.default.instancePath}="", ${G.default.parentData}, ${G.default.parentDataProperty}, ${G.default.rootData}=${G.default.data}${e.dynamicRef?(0, M._)`, ${G.default.dynamicAnchors}={}`:M.nil}}={}`}function Df(e,t){e.if(G.default.valCxt,()=>{e.var(G.default.instancePath,(0, M._)`${G.default.valCxt}.${G.default.instancePath}`),e.var(G.default.parentData,(0, M._)`${G.default.valCxt}.${G.default.parentData}`),e.var(G.default.parentDataProperty,(0, M._)`${G.default.valCxt}.${G.default.parentDataProperty}`),e.var(G.default.rootData,(0, M._)`${G.default.valCxt}.${G.default.rootData}`),t.dynamicRef&&e.var(G.default.dynamicAnchors,(0, M._)`${G.default.valCxt}.${G.default.dynamicAnchors}`);},()=>{e.var(G.default.instancePath,(0, M._)`""`),e.var(G.default.parentData,(0, M._)`undefined`),e.var(G.default.parentDataProperty,(0, M._)`undefined`),e.var(G.default.rootData,G.default.data),t.dynamicRef&&e.var(G.default.dynamicAnchors,(0, M._)`{}`);});}function Lf(e){let{schema:t,opts:r,gen:n}=e;xi(e,()=>{r.$comment&&t.$comment&&Oi(e),Gf(e),n.let(G.default.vErrors,null),n.let(G.default.errors,0),r.unevaluated&&Bf(e),ji(e),Hf(e);});}function Bf(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0, M._)`${r}.evaluated`),t.if((0, M._)`${e.evaluated}.dynamicProps`,()=>t.assign((0, M._)`${e.evaluated}.props`,(0, M._)`undefined`)),t.if((0, M._)`${e.evaluated}.dynamicItems`,()=>t.assign((0, M._)`${e.evaluated}.items`,(0, M._)`undefined`));}function _i(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0, M._)`/*# sourceURL=${r} */`:M.nil}function Vf(e,t){if(Ti(e)&&(Ii(e),Ai(e))){Uf(e,t);return}(0, Ei.boolOrEmptySchema)(e,t);}function Ai({schema:e,self:t}){if(typeof e=="boolean")return !e;for(let r in e)if(t.RULES.all[r])return true;return false}function Ti(e){return typeof e.schema!="boolean"}function Uf(e,t){let{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Oi(e),Jf(e),zf(e);let o=n.const("_errs",G.default.errors);ji(e,o),n.var(t,(0, M._)`${o} === ${G.default.errors}`);}function Ii(e){(0, mt.checkUnknownRules)(e),Kf(e);}function ji(e,t){if(e.opts.jtd)return Ci(e,[],false,t);let r=(0, Ri.getSchemaTypes)(e.schema),n=(0, Ri.coerceAndCheckDataType)(e,r);Ci(e,r,!n,t);}function Kf(e){let{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0, mt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`);}function Gf(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0, mt.checkStrictMode)(e,"default is ignored in the schema root");}function Jf(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0, qf.resolveUrl)(e.opts.uriResolver,e.baseId,t));}function zf(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Oi({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===true)e.code((0, M._)`${G.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let a=(0, M.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0, M._)`${G.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`);}}function Hf(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0, M._)`${G.default.errors} === 0`,()=>t.return(G.default.data),()=>t.throw((0, M._)`new ${s}(${G.default.vErrors})`)):(t.assign((0, M._)`${n}.errors`,G.default.vErrors),o.unevaluated&&Wf(e),t.return((0, M._)`${G.default.errors} === 0`));}function Wf({gen:e,evaluated:t,props:r,items:n}){r instanceof M.Name&&e.assign((0, M._)`${t}.props`,r),n instanceof M.Name&&e.assign((0, M._)`${t}.items`,n);}function Ci(e,t,r,n){let{gen:s,schema:o,data:a,allErrors:i,opts:u,self:c}=e,{RULES:d}=c;if(o.$ref&&(u.ignoreKeywordsWithRef||!(0, mt.schemaHasRulesButRef)(o,d))){s.block(()=>Ni(e,"$ref",d.all.$ref.definition));return}u.jtd||Yf(e,t),s.block(()=>{for(let g of d.rules)l(g);l(d.post);});function l(g){(0, Us.shouldUseGroup)(o,g)&&(g.type?(s.if((0, gn.checkDataType)(g.type,a,u.strictNumbers)),$i(e,g),t.length===1&&t[0]===g.type&&r&&(s.else(),(0, gn.reportTypeError)(e)),s.endIf()):$i(e,g),i||s.if((0, M._)`${G.default.errors} === ${n||0}`));}}function $i(e,t){let{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0, Nf.assignDefaults)(e,t.type),r.block(()=>{for(let o of t.rules)(0, Us.shouldUseRule)(n,o)&&Ni(e,o.keyword,o.definition,t.type);});}function Yf(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Xf(e,t),e.opts.allowUnionTypes||Qf(e,t),Zf(e,e.dataTypes));}function Xf(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Pi(e.dataTypes,r)||Ks(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`);}),tp(e,t);}}function Qf(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ks(e,"use allowUnionTypes to allow union type keyword");}function Zf(e,t){let r=e.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0, Us.shouldUseRule)(e.schema,s)){let{type:o}=s.definition;o.length&&!o.some(a=>ep(t,a))&&Ks(e,`missing type "${o.join(",")}" for keyword "${n}"`);}}}function ep(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Pi(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function tp(e,t){let r=[];for(let n of e.dataTypes)Pi(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r;}function Ks(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0, mt.checkStrictMode)(e,t,e.opts.strictTypes);}var hn=class{constructor(t,r,n){if((0, _r.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0, mt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",qi(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0, _r.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==false)&&(this.errsCount=t.gen.const("_errs",G.default.errors));}result(t,r,n){this.failResult((0, M.not)(t),r,n);}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else();}pass(t,r){this.failResult((0, M.not)(t),void 0,r);}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(false);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else();}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0, M._)`${r} !== undefined && (${(0, M.or)(this.invalid$data(),t)})`);}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n);}_error(t,r){(t?Rr.reportExtraError:Rr.reportError)(this,this.def.error,r);}$dataError(){(0, Rr.reportError)(this,this.def.$dataError||Rr.keyword$DataError);}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0, Rr.resetErrorsCount)(this.gen,this.errsCount);}ok(t){this.allErrors||this.gen.if(t);}setParams(t,r){r?Object.assign(this.params,t):this.params=t;}block$data(t,r,n=M.nil){this.gen.block(()=>{this.check$data(t,n),r();});}check$data(t=M.nil,r=M.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0, M.or)((0, M._)`${s} === undefined`,r)),t!==M.nil&&n.assign(t,true),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==M.nil&&n.assign(t,false)),n.else();}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return (0, M.or)(a(),i());function a(){if(n.length){if(!(r instanceof M.Name))throw new Error("ajv implementation error");let u=Array.isArray(n)?n:[n];return (0, M._)`${(0, gn.checkDataTypes)(u,r,o.opts.strictNumbers,gn.DataType.Wrong)}`}return M.nil}function i(){if(s.validateSchema){let u=t.scopeValue("validate$data",{ref:s.validateSchema});return (0, M._)`!${u}(${r})`}return M.nil}}subschema(t,r){let n=(0, Vs.getSubschema)(this.it,t);(0, Vs.extendSubschemaData)(n,this.it,t),(0, Vs.extendSubschemaMode)(n,t);let s={...this.it,...n,items:void 0,props:void 0};return Vf(s,r),s}mergeEvaluated(t,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==true&&t.props!==void 0&&(n.props=mt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==true&&t.items!==void 0&&(n.items=mt.mergeEvaluated.items(s,t.items,n.items,r)));}mergeValidEvaluated(t,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==true||n.items!==true))return s.if(r,()=>this.mergeEvaluated(t,M.Name)),true}};_t.KeywordCxt=hn;function Ni(e,t,r,n){let s=new hn(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0, _r.funcKeywordCode)(s,r):"macro"in r?(0, _r.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0, _r.funcKeywordCode)(s,r);}var rp=/^\/(?:[^~]|~0|~1)*$/,np=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function qi(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return G.default.rootData;if(e[0]==="/"){if(!rp.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=G.default.rootData;}else {let c=np.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let d=+c[1];if(s=c[2],s==="#"){if(d>=t)throw new Error(u("property/index",d));return n[t-d]}if(d>t)throw new Error(u("data",d));if(o=r[t-d],!s)return o}let a=o,i=s.split("/");for(let c of i)c&&(o=(0, M._)`${o}${(0, M.getProperty)((0, mt.unescapeJsonPointer)(c))}`,a=(0, M._)`${a} && ${o}`);return a;function u(c,d){return `Cannot access ${c} ${d} levels up, current level is ${t}`}}_t.getData=qi;});var yn=O(Js=>{Object.defineProperty(Js,"__esModule",{value:true});var Gs=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=true;}};Js.default=Gs;});var $r=O(Ws=>{Object.defineProperty(Ws,"__esModule",{value:true});var zs=br(),Hs=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0, zs.resolveUrl)(t,r,n),this.missingSchema=(0, zs.normalizeId)((0, zs.getFullPath)(t,this.missingRef));}};Ws.default=Hs;});var Sn=O(We=>{Object.defineProperty(We,"__esModule",{value:true});We.resolveSchema=We.getCompilingSchema=We.resolveRef=We.compileSchema=We.SchemaEnv=void 0;var rt=W(),sp=yn(),Lt=pt(),nt=br(),Fi=ae(),op=Cr(),nr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0, nt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={};}};We.SchemaEnv=nr;function Xs(e){let t=Mi.call(this,e);if(t)return t;let r=(0, nt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new rt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),i;e.$async&&(i=a.scopeValue("Error",{ref:sp.default,code:(0, rt._)`require("ajv/dist/runtime/validation_error").default`}));let u=a.scopeName("validate");e.validateName=u;let c={gen:a,allErrors:this.opts.allErrors,data:Lt.default.data,parentData:Lt.default.parentData,parentDataProperty:Lt.default.parentDataProperty,dataNames:[Lt.default.data],dataPathArr:[rt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0, rt.stringify)(e.schema)}:{ref:e.schema}),validateName:u,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:rt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0, rt._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(e),(0,op.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);let l=a.toString();d=`${a.scopeRefs(Lt.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,e));let v=new Function(`${Lt.default.self}`,`${Lt.default.scope}`,d)(this,this.scope.get());if(this.scope.value(u,{ref:v}),v.errors=null,v.schema=e.schema,v.schemaEnv=e,e.$async&&(v.$async=!0),this.opts.code.source===!0&&(v.source={validateName:u,validateCode:l,scopeValues:a._values}),this.opts.unevaluated){let{props:f,items:m}=c;v.evaluated={props:f instanceof rt.Name?void 0:f,items:m instanceof rt.Name?void 0:m,dynamicProps:f instanceof rt.Name,dynamicItems:m instanceof rt.Name},v.source&&(v.source.evaluated=(0,rt.stringify)(v.evaluated));}return e.validate=v,e}catch(l){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),l}finally{this._compilations.delete(e);}}We.compileSchema=Xs;function ap(e,t,r){var n;r=(0, nt.resolveUrl)(this.opts.uriResolver,t,r);let s=e.refs[r];if(s)return s;let o=up.call(this,e,r);if(o===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new nr({schema:a,schemaId:i,root:e,baseId:t}));}if(o!==void 0)return e.refs[r]=ip.call(this,o)}We.resolveRef=ap;function ip(e){return (0, nt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Xs.call(this,e)}function Mi(e){for(let t of this._compilations)if(cp(t,e))return t}We.getCompilingSchema=Mi;function cp(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function up(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||vn.call(this,e,t)}function vn(e,t){let r=this.opts.uriResolver.parse(t),n=(0, nt._getFullPath)(this.opts.uriResolver,r),s=(0, nt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return Ys.call(this,r,e);let o=(0, nt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){let i=vn.call(this,e,a);return typeof i?.schema!="object"?void 0:Ys.call(this,r,i)}if(typeof a?.schema=="object"){if(a.validate||Xs.call(this,a),o===(0, nt.normalizeId)(t)){let{schema:i}=a,{schemaId:u}=this.opts,c=i[u];return c&&(s=(0, nt.resolveUrl)(this.opts.uriResolver,s,c)),new nr({schema:i,schemaId:u,root:e,baseId:s})}return Ys.call(this,r,a)}}We.resolveSchema=vn;var dp=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ys(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let u=r[(0, Fi.unescapeFragment)(i)];if(u===void 0)return;r=u;let c=typeof r=="object"&&r[this.opts.schemaId];!dp.has(i)&&c&&(t=(0, nt.resolveUrl)(this.opts.uriResolver,t,c));}let o;if(typeof r!="boolean"&&r.$ref&&!(0, Fi.schemaHasRulesButRef)(r,this.RULES)){let i=(0, nt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=vn.call(this,n,i);}let{schemaId:a}=this.opts;if(o=o||new nr({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}});var Di=O((Iv,lp)=>{lp.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:false};});var Zs=O((jv,Ui)=>{var fp=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Bi=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);function Qs(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return "";t+=e[n];}return t}var pp=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Li(e){return e.length=0,true}function mp(e,t,r){if(e.length){let n=Qs(e);if(n!=="")t.push(n);else return r.error=true,false;e.length=0;}return true}function gp(e){let t=0,r={error:false,address:"",zone:""},n=[],s=[],o=false,a=false,i=mp;for(let u=0;u<e.length;u++){let c=e[u];if(!(c==="["||c==="]"))if(c===":"){if(o===true&&(a=true),!i(s,n,r))break;if(++t>7){r.error=true;break}u>0&&e[u-1]===":"&&(o=true),n.push(":");continue}else if(c==="%"){if(!i(s,n,r))break;i=Li;}else {s.push(c);continue}}return s.length&&(i===Li?r.zone=s.join(""):a?n.push(s.join("")):n.push(Qs(s))),r.address=n.join(""),r}function Vi(e){if(hp(e,":")<2)return {host:e,isIPV6:false};let t=gp(e);if(t.error)return {host:e,isIPV6:false};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:true,escapedHost:n}}}function hp(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function yp(e){let t=e,r=[],n=-1,s=0;for(;s=t.length;){if(s===1){if(t===".")break;if(t==="/"){r.push("/");break}else {r.push(t);break}}else if(s===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(s===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n);}return r.join("")}function vp(e,t){let r=t!==true?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function Sp(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Bi(r)){let n=Vi(r);n.isIPV6===true?r=`[${n.escapedHost}]`:r=e.host;}t.push(r);}return (typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Ui.exports={nonSimpleDomain:pp,recomposeAuthority:Sp,normalizeComponentEncoding:vp,removeDotSegments:yp,isIPv4:Bi,isUUID:fp,normalizeIPv6:Vi,stringArrayToHexStripped:Qs};});var Hi=O((Ov,zi)=>{var{isUUID:wp}=Zs(),kp=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,bp=["http","https","ws","wss","urn","urn:uuid"];function Rp(e){return bp.indexOf(e)!==-1}function eo(e){return e.secure===true?true:e.secure===false?false:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):false}function Ki(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Gi(e){let t=String(e.scheme).toLowerCase()==="https";return (e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function _p(e){return e.secure=eo(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Cp(e){if((e.port===(eo(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0;}return e.fragment=void 0,e}function $p(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(kp);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let s=`${n}:${t.nid||e.nid}`,o=to(s);e.path=void 0,o&&(e=o.parse(e,t));}else e.error=e.error||"URN can not be parsed.";return e}function Ep(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),s=`${r}:${t.nid||n}`,o=to(s);o&&(e=o.serialize(e,t));let a=e,i=e.nss;return a.path=`${n||t.nid}:${i}`,t.skipEscape=true,a}function xp(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!wp(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Ap(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Ji={scheme:"http",domainHost:true,parse:Ki,serialize:Gi},Tp={scheme:"https",domainHost:Ji.domainHost,parse:Ki,serialize:Gi},wn={scheme:"ws",domainHost:true,parse:_p,serialize:Cp},Ip={scheme:"wss",domainHost:wn.domainHost,parse:wn.parse,serialize:wn.serialize},jp={scheme:"urn",parse:$p,serialize:Ep,skipNormalize:true},Op={scheme:"urn:uuid",parse:xp,serialize:Ap,skipNormalize:true},kn={http:Ji,https:Tp,ws:wn,wss:Ip,urn:jp,"urn:uuid":Op};Object.setPrototypeOf(kn,null);function to(e){return e&&(kn[e]||kn[e.toLowerCase()])||void 0}zi.exports={wsIsSecure:eo,SCHEMES:kn,isValidSchemeName:Rp,getSchemeHandler:to};});var Xi=O((Pv,Rn)=>{var{normalizeIPv6:Pp,removeDotSegments:Er,recomposeAuthority:Np,normalizeComponentEncoding:bn,isIPv4:qp,nonSimpleDomain:Fp}=Zs(),{SCHEMES:Mp,getSchemeHandler:Wi}=Hi();function Dp(e,t){return typeof e=="string"?e=it(gt(e,t),t):typeof e=="object"&&(e=gt(it(e,t),t)),e}function Lp(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=Yi(gt(e,n),gt(t,n),n,true);return n.skipEscape=true,it(s,n)}function Yi(e,t,r,n){let s={};return n||(e=gt(it(e,r),r),t=gt(it(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(s.scheme=t.scheme,s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(s.userinfo=t.userinfo,s.host=t.host,s.port=t.port,s.path=Er(t.path||""),s.query=t.query):(t.path?(t.path[0]==="/"?s.path=Er(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?s.path="/"+t.path:e.path?s.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:s.path=t.path,s.path=Er(s.path)),s.query=t.query):(s.path=e.path,t.query!==void 0?s.query=t.query:s.query=e.query),s.userinfo=e.userinfo,s.host=e.host,s.port=e.port),s.scheme=e.scheme),s.fragment=t.fragment,s}function Bp(e,t,r){return typeof e=="string"?(e=unescape(e),e=it(bn(gt(e,r),true),{...r,skipEscape:true})):typeof e=="object"&&(e=it(bn(e,true),{...r,skipEscape:true})),typeof t=="string"?(t=unescape(t),t=it(bn(gt(t,r),true),{...r,skipEscape:true})):typeof t=="object"&&(t=it(bn(t,true),{...r,skipEscape:true})),e.toLowerCase()===t.toLowerCase()}function it(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),s=[],o=Wi(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let a=Np(r);if(a!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(a),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let i=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(i=Er(i)),a===void 0&&i[0]==="/"&&i[1]==="/"&&(i="/%2F"+i.slice(2)),s.push(i);}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var Vp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function gt(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=false;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let o=e.match(Vp);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(qp(n.host)===false){let u=Pp(n.host);n.host=u.host.toLowerCase(),s=u.isIPV6;}else s=true;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=Wi(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===false&&Fp(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase());}catch(i){n.error=n.error||"Host's domain name can not be converted to ASCII: "+i;}(!a||a&&!a.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r);}else n.error=n.error||"URI can not be parsed.";return n}var ro={SCHEMES:Mp,normalize:Dp,resolve:Lp,resolveComponent:Yi,equal:Bp,serialize:it,parse:gt};Rn.exports=ro;Rn.exports.default=ro;Rn.exports.fastUri=ro;});var Zi=O(no=>{Object.defineProperty(no,"__esModule",{value:true});var Qi=Xi();Qi.code='require("ajv/dist/runtime/uri").default';no.default=Qi;});var ic=O(_e=>{Object.defineProperty(_e,"__esModule",{value:true});_e.CodeGen=_e.Name=_e.nil=_e.stringify=_e.str=_e._=_e.KeywordCxt=void 0;var Up=Cr();Object.defineProperty(_e,"KeywordCxt",{enumerable:true,get:function(){return Up.KeywordCxt}});var sr=W();Object.defineProperty(_e,"_",{enumerable:true,get:function(){return sr._}});Object.defineProperty(_e,"str",{enumerable:true,get:function(){return sr.str}});Object.defineProperty(_e,"stringify",{enumerable:true,get:function(){return sr.stringify}});Object.defineProperty(_e,"nil",{enumerable:true,get:function(){return sr.nil}});Object.defineProperty(_e,"Name",{enumerable:true,get:function(){return sr.Name}});Object.defineProperty(_e,"CodeGen",{enumerable:true,get:function(){return sr.CodeGen}});var Kp=yn(),sc=$r(),Gp=js(),xr=Sn(),Jp=W(),Ar=br(),_n=kr(),oo=ae(),ec=Di(),zp=Zi(),oc=(e,t)=>new RegExp(e,t);oc.code="new RegExp";var Hp=["removeAdditional","useDefaults","coerceTypes"],Wp=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Yp={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."},Xp={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},tc=200;function Qp(e){var t,r,n,s,o,a,i,u,c,d,l,g,v,f,m,b,C,q,_,I,S,k,w,p,h;let R=e.strict,x=(t=e.code)===null||t===void 0?void 0:t.optimize,A=x===true||x===void 0?1:x||0,T=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:oc,V=(s=e.uriResolver)!==null&&s!==void 0?s:zp.default;return {strictSchema:(a=(o=e.strictSchema)!==null&&o!==void 0?o:R)!==null&&a!==void 0?a:true,strictNumbers:(u=(i=e.strictNumbers)!==null&&i!==void 0?i:R)!==null&&u!==void 0?u:true,strictTypes:(d=(c=e.strictTypes)!==null&&c!==void 0?c:R)!==null&&d!==void 0?d:"log",strictTuples:(g=(l=e.strictTuples)!==null&&l!==void 0?l:R)!==null&&g!==void 0?g:"log",strictRequired:(f=(v=e.strictRequired)!==null&&v!==void 0?v:R)!==null&&f!==void 0?f:false,code:e.code?{...e.code,optimize:A,regExp:T}:{optimize:A,regExp:T},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:tc,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:tc,meta:(C=e.meta)!==null&&C!==void 0?C:true,messages:(q=e.messages)!==null&&q!==void 0?q:true,inlineRefs:(_=e.inlineRefs)!==null&&_!==void 0?_:true,schemaId:(I=e.schemaId)!==null&&I!==void 0?I:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:true,validateSchema:(k=e.validateSchema)!==null&&k!==void 0?k:true,validateFormats:(w=e.validateFormats)!==null&&w!==void 0?w:true,unicodeRegExp:(p=e.unicodeRegExp)!==null&&p!==void 0?p:true,int32range:(h=e.int32range)!==null&&h!==void 0?h:true,uriResolver:V}}var Tr=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Qp(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Jp.ValueScope({scope:{},prefixes:Wp,es5:r,lines:n}),this.logger=sm(t.logger);let s=t.validateFormats;t.validateFormats=false,this.RULES=(0, Gp.getRules)(),rc.call(this,Yp,t,"NOT SUPPORTED"),rc.call(this,Xp,t,"DEPRECATED","warn"),this._metaOpts=rm.call(this),t.formats&&em.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&tm.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Zp.call(this),t.validateFormats=s;}_addVocabularies(){this.addKeyword("$async");}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,s=ec;n==="id"&&(s={...ec},s.id=s.$id,delete s.$id),r&&t&&this.addMetaSchema(s,s[n],false);}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let s=n(r);return "$async"in n||(this.errors=n.errors),s}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,t,r);async function s(d,l){await o.call(this,d.$schema);let g=this._addSchema(d,l);return g.validate||a.call(this,g)}async function o(d){d&&!this.getSchema(d)&&await s.call(this,{$ref:d},true);}async function a(d){try{return this._compileSchemaEnv(d)}catch(l){if(!(l instanceof sc.default))throw l;return i.call(this,l),await u.call(this,l.missingSchema),a.call(this,d)}}function i({missingSchema:d,missingRef:l}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${l} cannot be resolved`)}async function u(d){let l=await c.call(this,d);this.refs[d]||await o.call(this,l.$schema),this.refs[d]||this.addSchema(l,d,r);}async function c(d){let l=this._loading[d];if(l)return l;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d];}}}addSchema(t,r,n,s=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,s);return this}let o;if(typeof t=="object"){let{schemaId:a}=this.opts;if(o=t[a],o!==void 0&&typeof o!="string")throw new Error(`schema ${a} must be string`)}return r=(0, Ar.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,s,true),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,true,n),this}validateSchema(t,r){if(typeof t=="boolean")return true;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,true;let s=this.validate(n,t);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(t){let r;for(;typeof(r=nc.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,s=new xr.SchemaEnv({schema:{},schemaId:n});if(r=xr.resolveSchema.call(this,s,t),!r)return;this.refs[t]=r;}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case "undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case "string":{let r=nc.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case "object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0, Ar.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(am.call(this,n,r),!r)return (0, oo.eachItem)(n,o=>so.call(this,o)),this;cm.call(this,r);let s={...r,type:(0, _n.getJSONTypes)(r.type),schemaType:(0, _n.getJSONTypes)(r.schemaType)};return (0, oo.eachItem)(n,s.type.length===0?o=>so.call(this,o,s):o=>s.type.forEach(a=>so.call(this,o,s,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===t);s>=0&&n.rules.splice(s,1);}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return !t||t.length===0?"No errors":t.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let s of r){let o=s.split("/").slice(1),a=t;for(let i of o)a=a[i];for(let i in n){let u=n[i];if(typeof u!="object")continue;let{$data:c}=u.definition,d=a[i];c&&d&&(a[i]=ac(d));}}return t}_removeAllSchemas(t,r){for(let n in t){let s=t[n];(!r||r.test(n))&&(typeof s=="string"?delete t[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete t[n]));}}_addSchema(t,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let a,{schemaId:i}=this.opts;if(typeof t=="object")a=t[i];else {if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let u=this._cache.get(t);if(u!==void 0)return u;n=(0, Ar.normalizeId)(a||n);let c=Ar.getSchemaRefs.call(this,t,n);return u=new xr.SchemaEnv({schema:t,schemaId:i,meta:r,baseId:n,localRefs:c}),this._cache.set(u.schema,u),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=u),s&&this.validateSchema(t,true),u}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):xr.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{xr.compileSchema.call(this,t);}finally{this.opts=r;}}};Tr.ValidationError=Kp.default;Tr.MissingRefError=sc.default;_e.default=Tr;function rc(e,t,r,n="error"){for(let s in e){let o=s;o in t&&this.logger[n](`${r}: option ${s}. ${e[o]}`);}}function nc(e){return e=(0, Ar.normalizeId)(e),this.schemas[e]||this.refs[e]}function Zp(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t);}function em(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t);}}function tm(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r);}}function rm(){let e={...this.opts};for(let t of Hp)delete e[t];return e}var nm={log(){},warn(){},error(){}};function sm(e){if(e===false)return nm;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var om=/^[a-z_$][a-z0-9_$:-]*$/i;function am(e,t){let{RULES:r}=this;if((0, oo.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!om.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function so(e,t,r){var n;let s=t?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,a=s?o.post:o.rules.find(({type:u})=>u===r);if(a||(a={type:r,rules:[]},o.rules.push(a)),o.keywords[e]=true,!t)return;let i={keyword:e,definition:{...t,type:(0, _n.getJSONTypes)(t.type),schemaType:(0, _n.getJSONTypes)(t.schemaType)}};t.before?im.call(this,a,i,t.before):a.rules.push(i),o.all[e]=i,(n=t.implements)===null||n===void 0||n.forEach(u=>this.addKeyword(u));}function im(e,t,r){let n=e.rules.findIndex(s=>s.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`));}function cm(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ac(t)),e.validateSchema=this.compile(t,true));}var um={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ac(e){return {anyOf:[e,um]}}});var cc=O(ao=>{Object.defineProperty(ao,"__esModule",{value:true});var dm={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ao.default=dm;});var fc=O(Bt=>{Object.defineProperty(Bt,"__esModule",{value:true});Bt.callRef=Bt.getValidate=void 0;var lm=$r(),uc=He(),Le=W(),or=pt(),dc=Sn(),Cn=ae(),fm={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:u}=n,{root:c}=o;if((r==="#"||r==="#/")&&s===c.baseId)return l();let d=dc.resolveRef.call(u,c,s,r);if(d===void 0)throw new lm.default(n.opts.uriResolver,s,r);if(d instanceof dc.SchemaEnv)return g(d);return v(d);function l(){if(o===c)return $n(e,a,o,o.$async);let f=t.scopeValue("root",{ref:c});return $n(e,(0, Le._)`${f}.validate`,c,c.$async)}function g(f){let m=lc(e,f);$n(e,m,f,f.$async);}function v(f){let m=t.scopeValue("schema",i.code.source===true?{ref:f,code:(0, Le.stringify)(f)}:{ref:f}),b=t.name("valid"),C=e.subschema({schema:f,dataTypes:[],schemaPath:Le.nil,topSchemaRef:m,errSchemaPath:r},b);e.mergeEvaluated(C),e.ok(b);}}};function lc(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0, Le._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Bt.getValidate=lc;function $n(e,t,r,n){let{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:u}=o,c=u.passContext?or.default.this:Le.nil;n?d():l();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");let f=s.let("valid");s.try(()=>{s.code((0, Le._)`await ${(0, uc.callValidateCode)(e,t,c)}`),v(t),a||s.assign(f,true);},m=>{s.if((0, Le._)`!(${m} instanceof ${o.ValidationError})`,()=>s.throw(m)),g(m),a||s.assign(f,false);}),e.ok(f);}function l(){e.result((0, uc.callValidateCode)(e,t,c),()=>v(t),()=>g(t));}function g(f){let m=(0, Le._)`${f}.errors`;s.assign(or.default.vErrors,(0, Le._)`${or.default.vErrors} === null ? ${m} : ${or.default.vErrors}.concat(${m})`),s.assign(or.default.errors,(0, Le._)`${or.default.vErrors}.length`);}function v(f){var m;if(!o.opts.unevaluated)return;let b=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==true)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=Cn.mergeEvaluated.props(s,b.props,o.props));else {let C=s.var("props",(0, Le._)`${f}.evaluated.props`);o.props=Cn.mergeEvaluated.props(s,C,o.props,Le.Name);}if(o.items!==true)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=Cn.mergeEvaluated.items(s,b.items,o.items));else {let C=s.var("items",(0, Le._)`${f}.evaluated.items`);o.items=Cn.mergeEvaluated.items(s,C,o.items,Le.Name);}}}Bt.callRef=$n;Bt.default=fm;});var pc=O(io=>{Object.defineProperty(io,"__esModule",{value:true});var pm=cc(),mm=fc(),gm=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",pm.default,mm.default];io.default=gm;});var mc=O(co=>{Object.defineProperty(co,"__esModule",{value:true});var En=W(),Ct=En.operators,xn={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},hm={message:({keyword:e,schemaCode:t})=>(0, En.str)`must be ${xn[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0, En._)`{comparison: ${xn[e].okStr}, limit: ${t}}`},ym={keyword:Object.keys(xn),type:"number",schemaType:"number",$data:true,error:hm,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0, En._)`${r} ${xn[t].fail} ${n} || isNaN(${r})`);}};co.default=ym;});var gc=O(uo=>{Object.defineProperty(uo,"__esModule",{value:true});var Ir=W(),vm={message:({schemaCode:e})=>(0, Ir.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0, Ir._)`{multipleOf: ${e}}`},Sm={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:vm,code(e){let{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0, Ir._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0, Ir._)`${a} !== parseInt(${a})`;e.fail$data((0, Ir._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`);}};uo.default=Sm;});var yc=O(lo=>{Object.defineProperty(lo,"__esModule",{value:true});function hc(e){let t=e.length,r=0,n=0,s;for(;n<t;)r++,s=e.charCodeAt(n++),s>=55296&&s<=56319&&n<t&&(s=e.charCodeAt(n),(s&64512)===56320&&n++);return r}lo.default=hc;hc.code='require("ajv/dist/runtime/ucs2length").default';});var vc=O(fo=>{Object.defineProperty(fo,"__esModule",{value:true});var Vt=W(),wm=ae(),km=yc(),bm={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return (0, Vt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0, Vt._)`{limit: ${e}}`},Rm={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:bm,code(e){let{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?Vt.operators.GT:Vt.operators.LT,a=s.opts.unicode===false?(0, Vt._)`${r}.length`:(0, Vt._)`${(0, wm.useFunc)(e.gen,km.default)}(${r})`;e.fail$data((0, Vt._)`${a} ${o} ${n}`);}};fo.default=Rm;});var Sc=O(po=>{Object.defineProperty(po,"__esModule",{value:true});var _m=He(),Cm=ae(),ar=W(),$m={message:({schemaCode:e})=>(0, ar.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0, ar._)`{pattern: ${e}}`},Em={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:$m,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){let{regExp:u}=a.opts.code,c=u.code==="new RegExp"?(0, ar._)`new RegExp`:(0, Cm.useFunc)(t,u),d=t.let("valid");t.try(()=>t.assign(d,(0, ar._)`${c}(${o}, ${i}).test(${r})`),()=>t.assign(d,false)),e.fail$data((0, ar._)`!${d}`);}else {let u=(0, _m.usePattern)(e,s);e.fail$data((0, ar._)`!${u}.test(${r})`);}}};po.default=Em;});var wc=O(mo=>{Object.defineProperty(mo,"__esModule",{value:true});var jr=W(),xm={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return (0, jr.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0, jr._)`{limit: ${e}}`},Am={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:xm,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?jr.operators.GT:jr.operators.LT;e.fail$data((0, jr._)`Object.keys(${r}).length ${s} ${n}`);}};mo.default=Am;});var kc=O(go=>{Object.defineProperty(go,"__esModule",{value:true});var Or=He(),Pr=W(),Tm=ae(),Im={message:({params:{missingProperty:e}})=>(0, Pr.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0, Pr._)`{missingProperty: ${e}}`},jm={keyword:"required",type:"object",schemaType:"array",$data:true,error:Im,code(e){let{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;let u=r.length>=i.loopRequired;if(a.allErrors?c():d(),i.strictRequired){let v=e.parentSchema.properties,{definedProperties:f}=e.it;for(let m of r)if(v?.[m]===void 0&&!f.has(m)){let b=a.schemaEnv.baseId+a.errSchemaPath,C=`required property "${m}" is not defined at "${b}" (strictRequired)`;(0, Tm.checkStrictMode)(a,C,a.opts.strictRequired);}}function c(){if(u||o)e.block$data(Pr.nil,l);else for(let v of r)(0, Or.checkReportMissingProp)(e,v);}function d(){let v=t.let("missing");if(u||o){let f=t.let("valid",true);e.block$data(f,()=>g(v,f)),e.ok(f);}else t.if((0, Or.checkMissingProp)(e,r,v)),(0, Or.reportMissingProp)(e,v),t.else();}function l(){t.forOf("prop",n,v=>{e.setParams({missingProperty:v}),t.if((0, Or.noPropertyInData)(t,s,v,i.ownProperties),()=>e.error());});}function g(v,f){e.setParams({missingProperty:v}),t.forOf(v,n,()=>{t.assign(f,(0, Or.propertyInData)(t,s,v,i.ownProperties)),t.if((0, Pr.not)(f),()=>{e.error(),t.break();});},Pr.nil);}}};go.default=jm;});var bc=O(ho=>{Object.defineProperty(ho,"__esModule",{value:true});var Nr=W(),Om={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return (0, Nr.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0, Nr._)`{limit: ${e}}`},Pm={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:Om,code(e){let{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?Nr.operators.GT:Nr.operators.LT;e.fail$data((0, Nr._)`${r}.length ${s} ${n}`);}};ho.default=Pm;});var An=O(yo=>{Object.defineProperty(yo,"__esModule",{value:true});var Rc=Ls();Rc.code='require("ajv/dist/runtime/equal").default';yo.default=Rc;});var _c=O(So=>{Object.defineProperty(So,"__esModule",{value:true});var vo=kr(),Ce=W(),Nm=ae(),qm=An(),Fm={message:({params:{i:e,j:t}})=>(0, Ce.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0, Ce._)`{i: ${e}, j: ${t}}`},Mm={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:Fm,code(e){let{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;let u=t.let("valid"),c=o.items?(0, vo.getSchemaTypes)(o.items):[];e.block$data(u,d,(0, Ce._)`${a} === false`),e.ok(u);function d(){let f=t.let("i",(0, Ce._)`${r}.length`),m=t.let("j");e.setParams({i:f,j:m}),t.assign(u,true),t.if((0, Ce._)`${f} > 1`,()=>(l()?g:v)(f,m));}function l(){return c.length>0&&!c.some(f=>f==="object"||f==="array")}function g(f,m){let b=t.name("item"),C=(0, vo.checkDataTypes)(c,b,i.opts.strictNumbers,vo.DataType.Wrong),q=t.const("indices",(0, Ce._)`{}`);t.for((0, Ce._)`;${f}--;`,()=>{t.let(b,(0, Ce._)`${r}[${f}]`),t.if(C,(0, Ce._)`continue`),c.length>1&&t.if((0, Ce._)`typeof ${b} == "string"`,(0, Ce._)`${b} += "_"`),t.if((0, Ce._)`typeof ${q}[${b}] == "number"`,()=>{t.assign(m,(0, Ce._)`${q}[${b}]`),e.error(),t.assign(u,false).break();}).code((0, Ce._)`${q}[${b}] = ${f}`);});}function v(f,m){let b=(0, Nm.useFunc)(t,qm.default),C=t.name("outer");t.label(C).for((0, Ce._)`;${f}--;`,()=>t.for((0, Ce._)`${m} = ${f}; ${m}--;`,()=>t.if((0, Ce._)`${b}(${r}[${f}], ${r}[${m}])`,()=>{e.error(),t.assign(u,false).break(C);})));}}};So.default=Mm;});var Cc=O(ko=>{Object.defineProperty(ko,"__esModule",{value:true});var wo=W(),Dm=ae(),Lm=An(),Bm={message:"must be equal to constant",params:({schemaCode:e})=>(0, wo._)`{allowedValue: ${e}}`},Vm={keyword:"const",$data:true,error:Bm,code(e){let{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0, wo._)`!${(0, Dm.useFunc)(t,Lm.default)}(${r}, ${s})`):e.fail((0, wo._)`${o} !== ${r}`);}};ko.default=Vm;});var $c=O(bo=>{Object.defineProperty(bo,"__esModule",{value:true});var qr=W(),Um=ae(),Km=An(),Gm={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0, qr._)`{allowedValues: ${e}}`},Jm={keyword:"enum",schemaType:"array",$data:true,error:Gm,code(e){let{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let i=s.length>=a.opts.loopEnum,u,c=()=>u??(u=(0, Um.useFunc)(t,Km.default)),d;if(i||n)d=t.let("valid"),e.block$data(d,l);else {if(!Array.isArray(s))throw new Error("ajv implementation error");let v=t.const("vSchema",o);d=(0, qr.or)(...s.map((f,m)=>g(v,m)));}e.pass(d);function l(){t.assign(d,false),t.forOf("v",o,v=>t.if((0, qr._)`${c()}(${r}, ${v})`,()=>t.assign(d,true).break()));}function g(v,f){let m=s[f];return typeof m=="object"&&m!==null?(0, qr._)`${c()}(${r}, ${v}[${f}])`:(0, qr._)`${r} === ${m}`}}};bo.default=Jm;});var Ec=O(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});var zm=mc(),Hm=gc(),Wm=vc(),Ym=Sc(),Xm=wc(),Qm=kc(),Zm=bc(),eg=_c(),tg=Cc(),rg=$c(),ng=[zm.default,Hm.default,Wm.default,Ym.default,Xm.default,Qm.default,Zm.default,eg.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},tg.default,rg.default];Ro.default=ng;});var Co=O(Fr=>{Object.defineProperty(Fr,"__esModule",{value:true});Fr.validateAdditionalItems=void 0;var Ut=W(),_o=ae(),sg={message:({params:{len:e}})=>(0, Ut.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, Ut._)`{limit: ${e}}`},og={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:sg,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0, _o.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}xc(e,n);}};function xc(e,t){let{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=true;let i=r.const("len",(0, Ut._)`${s}.length`);if(n===false)e.setParams({len:t.length}),e.pass((0, Ut._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0, _o.alwaysValidSchema)(a,n)){let c=r.var("valid",(0, Ut._)`${i} <= ${t.length}`);r.if((0, Ut.not)(c),()=>u(c)),e.ok(c);}function u(c){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:_o.Type.Num},c),a.allErrors||r.if((0, Ut.not)(c),()=>r.break());});}}Fr.validateAdditionalItems=xc;Fr.default=og;});var $o=O(Mr=>{Object.defineProperty(Mr,"__esModule",{value:true});Mr.validateTuple=void 0;var Ac=W(),Tn=ae(),ag=He(),ig={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Tc(e,"additionalItems",t);r.items=true,!(0, Tn.alwaysValidSchema)(r,t)&&e.ok((0, ag.validateArray)(e));}};function Tc(e,t,r=e.schema){let{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==true&&(i.items=Tn.mergeEvaluated.items(n,r.length,i.items));let u=n.name("valid"),c=n.const("len",(0, Ac._)`${o}.length`);r.forEach((l,g)=>{(0, Tn.alwaysValidSchema)(i,l)||(n.if((0, Ac._)`${c} > ${g}`,()=>e.subschema({keyword:a,schemaProp:g,dataProp:g},u)),e.ok(u));});function d(l){let{opts:g,errSchemaPath:v}=i,f=r.length,m=f===l.minItems&&(f===l.maxItems||l[t]===false);if(g.strictTuples&&!m){let b=`"${a}" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path "${v}"`;(0, Tn.checkStrictMode)(i,b,g.strictTuples);}}}Mr.validateTuple=Tc;Mr.default=ig;});var Ic=O(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});var cg=$o(),ug={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0, cg.validateTuple)(e,"items")};Eo.default=ug;});var Oc=O(xo=>{Object.defineProperty(xo,"__esModule",{value:true});var jc=W(),dg=ae(),lg=He(),fg=Co(),pg={message:({params:{len:e}})=>(0, jc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0, jc._)`{limit: ${e}}`},mg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:pg,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=true,!(0, dg.alwaysValidSchema)(n,t)&&(s?(0, fg.validateAdditionalItems)(e,s):e.ok((0, lg.validateArray)(e)));}};xo.default=mg;});var Pc=O(Ao=>{Object.defineProperty(Ao,"__esModule",{value:true});var Ye=W(),In=ae(),gg={message:({params:{min:e,max:t}})=>t===void 0?(0, Ye.str)`must contain at least ${e} valid item(s)`:(0, Ye.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0, Ye._)`{minContains: ${e}}`:(0, Ye._)`{minContains: ${e}, maxContains: ${t}}`},hg={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:gg,code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e,a,i,{minContains:u,maxContains:c}=n;o.opts.next?(a=u===void 0?1:u,i=c):a=1;let d=t.const("len",(0, Ye._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0, In.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0, In.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0, In.alwaysValidSchema)(o,r)){let m=(0, Ye._)`${d} >= ${a}`;i!==void 0&&(m=(0, Ye._)`${m} && ${d} <= ${i}`),e.pass(m);return}o.items=true;let l=t.name("valid");i===void 0&&a===1?v(l,()=>t.if(l,()=>t.break())):a===0?(t.let(l,true),i!==void 0&&t.if((0, Ye._)`${s}.length > 0`,g)):(t.let(l,false),g()),e.result(l,()=>e.reset());function g(){let m=t.name("_valid"),b=t.let("count",0);v(m,()=>t.if(m,()=>f(b)));}function v(m,b){t.forRange("i",0,d,C=>{e.subschema({keyword:"contains",dataProp:C,dataPropType:In.Type.Num,compositeRule:true},m),b();});}function f(m){t.code((0, Ye._)`${m}++`),i===void 0?t.if((0, Ye._)`${m} >= ${a}`,()=>t.assign(l,true).break()):(t.if((0, Ye._)`${m} > ${i}`,()=>t.assign(l,false).break()),a===1?t.assign(l,true):t.if((0, Ye._)`${m} >= ${a}`,()=>t.assign(l,true)));}}};Ao.default=hg;});var Fc=O(ct=>{Object.defineProperty(ct,"__esModule",{value:true});ct.validateSchemaDeps=ct.validatePropertyDeps=ct.error=void 0;var To=W(),yg=ae(),Dr=He();ct.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return (0, To.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0, To._)`{property: ${e},
6
6
  missingProperty: ${n},
7
7
  depsCount: ${t},
8
- deps: ${r}}`};var hg={keyword:"dependencies",type:"object",schemaType:"object",error:at.error,code(e){let[t,r]=yg(e);jc(e,t),Oc(e,r);}};function yg({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let s=Array.isArray(e[n])?t:r;s[n]=e[n];}return [t,r]}function jc(e,t=e.schema){let{gen:r,data:n,it:s}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let a in t){let i=t[a];if(i.length===0)continue;let u=(0, Dr.propertyInData)(r,n,a,s.opts.ownProperties);e.setParams({property:a,depsCount:i.length,deps:i.join(", ")}),s.allErrors?r.if(u,()=>{for(let c of i)(0, Dr.checkReportMissingProp)(e,c);}):(r.if((0, Ao._)`${u} && (${(0, Dr.checkMissingProp)(e,i,o)})`),(0, Dr.reportMissingProp)(e,o),r.else());}}at.validatePropertyDeps=jc;function Oc(e,t=e.schema){let{gen:r,data:n,keyword:s,it:o}=e,a=r.name("valid");for(let i in t)(0, gg.alwaysValidSchema)(o,t[i])||(r.if((0, Dr.propertyInData)(r,n,i,o.opts.ownProperties),()=>{let u=e.subschema({keyword:s,schemaProp:i},a);e.mergeValidEvaluated(u,a);},()=>r.var(a,true)),e.ok(a));}at.validateSchemaDeps=Oc;at.default=hg;});var qc=j(To=>{Object.defineProperty(To,"__esModule",{value:true});var Nc=H(),vg=re(),Sg={message:"property name must be valid",params:({params:e})=>(0, Nc._)`{propertyName: ${e.propertyName}}`},wg={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Sg,code(e){let{gen:t,schema:r,data:n,it:s}=e;if((0, vg.alwaysValidSchema)(s,r))return;let o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:true},o),t.if((0, Nc.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};To.default=wg;});var jo=j(Io=>{Object.defineProperty(Io,"__esModule",{value:true});var Tn=Ge(),rt=H(),bg=lt(),In=re(),kg={message:"must NOT have additional properties",params:({params:e})=>(0, rt._)`{additionalProperty: ${e.additionalProperty}}`},_g={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:kg,code(e){let{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:i,opts:u}=a;if(a.props=true,u.removeAdditional!=="all"&&(0, In.alwaysValidSchema)(a,r))return;let c=(0, Tn.allSchemaProperties)(n.properties),d=(0, Tn.allSchemaProperties)(n.patternProperties);l(),e.ok((0, rt._)`${o} === ${bg.default.errors}`);function l(){t.forIn("key",s,b=>{!c.length&&!d.length?p(b):t.if(h(b),()=>p(b));});}function h(b){let R;if(c.length>8){let N=(0, In.schemaRefOrVal)(a,n.properties,"properties");R=(0, Tn.isOwnProperty)(t,N,b);}else c.length?R=(0, rt.or)(...c.map(N=>(0, rt._)`${b} === ${N}`)):R=rt.nil;return d.length&&(R=(0, rt.or)(R,...d.map(N=>(0, rt._)`${(0, Tn.usePattern)(e,N)}.test(${b})`))),(0, rt.not)(R)}function v(b){t.code((0, rt._)`delete ${s}[${b}]`);}function p(b){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){v(b);return}if(r===false){e.setParams({additionalProperty:b}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0, In.alwaysValidSchema)(a,r)){let R=t.name("valid");u.removeAdditional==="failing"?(m(b,R,false),t.if((0, rt.not)(R),()=>{e.reset(),v(b);})):(m(b,R),i||t.if((0, rt.not)(R),()=>t.break()));}}function m(b,R,N){let _={keyword:"additionalProperties",dataProp:b,dataPropType:In.Type.Str};N===false&&Object.assign(_,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(_,R);}}};Io.default=_g;});var Mc=j(Po=>{Object.defineProperty(Po,"__esModule",{value:true});var Rg=Rr(),Fc=Ge(),Oo=re(),Dc=jo(),Cg={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Dc.default.code(new Rg.KeywordCxt(o,Dc.default,"additionalProperties"));let a=(0, Fc.allSchemaProperties)(r);for(let l of a)o.definedProperties.add(l);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=Oo.mergeEvaluated.props(t,(0, Oo.toHash)(a),o.props));let i=a.filter(l=>!(0, Oo.alwaysValidSchema)(o,r[l]));if(i.length===0)return;let u=t.name("valid");for(let l of i)c(l)?d(l):(t.if((0, Fc.propertyInData)(t,s,l,o.opts.ownProperties)),d(l),o.allErrors||t.else().var(u,true),t.endIf()),e.it.definedProperties.add(l),e.ok(u);function c(l){return o.opts.useDefaults&&!o.compositeRule&&r[l].default!==void 0}function d(l){e.subschema({keyword:"properties",schemaProp:l,dataProp:l},u);}}};Po.default=Cg;});var Uc=j(No=>{Object.defineProperty(No,"__esModule",{value:true});var Lc=Ge(),jn=H(),Bc=re(),Vc=re(),Eg={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0, Lc.allSchemaProperties)(r),u=i.filter(m=>(0, Bc.alwaysValidSchema)(o,r[m]));if(i.length===0||u.length===i.length&&(!o.opts.unevaluated||o.props===true))return;let c=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==true&&!(o.props instanceof jn.Name)&&(o.props=(0, Vc.evaluatedPropsToName)(t,o.props));let{props:l}=o;h();function h(){for(let m of i)c&&v(m),o.allErrors?p(m):(t.var(d,true),p(m),t.if(d));}function v(m){for(let b in c)new RegExp(m).test(b)&&(0, Bc.checkStrictMode)(o,`property ${b} matches pattern ${m} (use allowMatchingProperties)`);}function p(m){t.forIn("key",n,b=>{t.if((0, jn._)`${(0, Lc.usePattern)(e,m)}.test(${b})`,()=>{let R=u.includes(m);R||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:b,dataPropType:Vc.Type.Str},d),o.opts.unevaluated&&l!==true?t.assign((0, jn._)`${l}[${b}]`,true):!R&&!o.allErrors&&t.if((0, jn.not)(d),()=>t.break());});});}}};No.default=Eg;});var Kc=j(qo=>{Object.defineProperty(qo,"__esModule",{value:true});var $g=re(),xg={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){let{gen:t,schema:r,it:n}=e;if((0, $g.alwaysValidSchema)(n,r)){e.fail();return}let s=t.name("valid");e.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},s),e.failResult(s,()=>e.reset(),()=>e.error());},error:{message:"must NOT be valid"}};qo.default=xg;});var Gc=j(Fo=>{Object.defineProperty(Fo,"__esModule",{value:true});var Ag=Ge(),Tg={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Ag.validateUnion,error:{message:"must match a schema in anyOf"}};Fo.default=Tg;});var Jc=j(Do=>{Object.defineProperty(Do,"__esModule",{value:true});var On=H(),Ig=re(),jg={message:"must match exactly one schema in oneOf",params:({params:e})=>(0, On._)`{passingSchemas: ${e.passing}}`},Og={keyword:"oneOf",schemaType:"array",trackErrors:true,error:jg,code(e){let{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,a=t.let("valid",false),i=t.let("passing",null),u=t.name("_valid");e.setParams({passing:i}),t.block(c),e.result(a,()=>e.reset(),()=>e.error(true));function c(){o.forEach((d,l)=>{let h;(0, Ig.alwaysValidSchema)(s,d)?t.var(u,true):h=e.subschema({keyword:"oneOf",schemaProp:l,compositeRule:true},u),l>0&&t.if((0, On._)`${u} && ${a}`).assign(a,false).assign(i,(0, On._)`[${i}, ${l}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,l),h&&e.mergeEvaluated(h,On.Name);});});}}};Do.default=Og;});var zc=j(Mo=>{Object.defineProperty(Mo,"__esModule",{value:true});var Pg=re(),Ng={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=t.name("valid");r.forEach((o,a)=>{if((0, Pg.alwaysValidSchema)(n,o))return;let i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i);});}};Mo.default=Ng;});var Yc=j(Lo=>{Object.defineProperty(Lo,"__esModule",{value:true});var Pn=H(),Wc=re(),qg={message:({params:e})=>(0, Pn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, Pn._)`{failingKeyword: ${e.ifClause}}`},Fg={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:qg,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Wc.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Hc(n,"then"),o=Hc(n,"else");if(!s&&!o)return;let a=t.let("valid",true),i=t.name("_valid");if(u(),e.reset(),s&&o){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,c("then",d),c("else",d));}else s?t.if(i,c("then")):t.if((0, Pn.not)(i),c("else"));e.pass(a,()=>e.error(true));function u(){let d=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);e.mergeEvaluated(d);}function c(d,l){return ()=>{let h=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(h,a),l?t.assign(l,(0, Pn._)`${d}`):e.setParams({ifClause:d});}}}};function Hc(e,t){let r=e.schema[t];return r!==void 0&&!(0, Wc.alwaysValidSchema)(e,r)}Lo.default=Fg;});var Xc=j(Bo=>{Object.defineProperty(Bo,"__esModule",{value:true});var Dg=re(),Mg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, Dg.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};Bo.default=Mg;});var Qc=j(Vo=>{Object.defineProperty(Vo,"__esModule",{value:true});var Lg=Ro(),Bg=xc(),Vg=Co(),Ug=Tc(),Kg=Ic(),Gg=Pc(),Jg=qc(),zg=jo(),Hg=Mc(),Wg=Uc(),Yg=Kc(),Xg=Gc(),Qg=Jc(),Zg=zc(),eh=Yc(),th=Xc();function rh(e=false){let t=[Yg.default,Xg.default,Qg.default,Zg.default,eh.default,th.default,Jg.default,zg.default,Gg.default,Hg.default,Wg.default];return e?t.push(Bg.default,Ug.default):t.push(Lg.default,Vg.default),t.push(Kg.default),t}Vo.default=rh;});var Zc=j(Uo=>{Object.defineProperty(Uo,"__esModule",{value:true});var we=H(),nh={message:({schemaCode:e})=>(0, we.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, we._)`{format: ${e}}`},sh={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:nh,code(e,t){let{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:u,errSchemaPath:c,schemaEnv:d,self:l}=i;if(!u.validateFormats)return;s?h():v();function h(){let p=r.scopeValue("formats",{ref:l.formats,code:u.code.formats}),m=r.const("fDef",(0, we._)`${p}[${a}]`),b=r.let("fType"),R=r.let("format");r.if((0, we._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(b,(0, we._)`${m}.type || "string"`).assign(R,(0, we._)`${m}.validate`),()=>r.assign(b,(0, we._)`"string"`).assign(R,m)),e.fail$data((0, we.or)(N(),_()));function N(){return u.strictSchema===false?we.nil:(0, we._)`${a} && !${R}`}function _(){let A=d.$async?(0, we._)`(${m}.async ? await ${R}(${n}) : ${R}(${n}))`:(0, we._)`${R}(${n})`,S=(0, we._)`(typeof ${R} == "function" ? ${A} : ${R}.test(${n}))`;return (0, we._)`${R} && ${R} !== true && ${b} === ${t} && !${S}`}}function v(){let p=l.formats[o];if(!p){N();return}if(p===true)return;let[m,b,R]=_(p);m===t&&e.pass(A());function N(){if(u.strictSchema===false){l.logger.warn(S());return}throw new Error(S());function S(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function _(S){let w=S instanceof RegExp?(0, we.regexpCode)(S):u.code.formats?(0, we._)`${u.code.formats}${(0, we.getProperty)(o)}`:void 0,f=r.scopeValue("formats",{key:o,ref:S,code:w});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, we._)`${f}.validate`]:["string",S,f]}function A(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!d.$async)throw new Error("async format in sync schema");return (0, we._)`await ${R}(${n})`}return typeof b=="function"?(0, we._)`${R}(${n})`:(0, we._)`${R}.test(${n})`}}}};Uo.default=sh;});var eu=j(Ko=>{Object.defineProperty(Ko,"__esModule",{value:true});var oh=Zc(),ah=[oh.default];Ko.default=ah;});var tu=j(ar=>{Object.defineProperty(ar,"__esModule",{value:true});ar.contentVocabulary=ar.metadataVocabulary=void 0;ar.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ar.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var nu=j(Go=>{Object.defineProperty(Go,"__esModule",{value:true});var ih=dc(),ch=Rc(),uh=Qc(),dh=eu(),ru=tu(),lh=[ih.default,ch.default,(0, uh.default)(),dh.default,ru.metadataVocabulary,ru.contentVocabulary];Go.default=lh;});var ou=j(Nn=>{Object.defineProperty(Nn,"__esModule",{value:true});Nn.DiscrError=void 0;var su;(function(e){e.Tag="tag",e.Mapping="mapping";})(su||(Nn.DiscrError=su={}));});var iu=j(zo=>{Object.defineProperty(zo,"__esModule",{value:true});var ir=H(),Jo=ou(),au=yn(),fh=Cr(),ph=re(),mh={message:({params:{discrError:e,tagName:t}})=>e===Jo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, ir._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},gh={keyword:"discriminator",type:"object",schemaType:"object",error:mh,code(e){let{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",false),c=t.const("tag",(0, ir._)`${r}${(0, ir.getProperty)(i)}`);t.if((0, ir._)`typeof ${c} == "string"`,()=>d(),()=>e.error(false,{discrError:Jo.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function d(){let v=h();t.if(false);for(let p in v)t.elseIf((0, ir._)`${c} === ${p}`),t.assign(u,l(v[p]));t.else(),e.error(false,{discrError:Jo.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function l(v){let p=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:v},p);return e.mergeEvaluated(m,ir.Name),p}function h(){var v;let p={},m=R(s),b=true;for(let A=0;A<a.length;A++){let S=a[A];if(S?.$ref&&!(0, ph.schemaHasRulesButRef)(S,o.self.RULES)){let f=S.$ref;if(S=au.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,f),S instanceof au.SchemaEnv&&(S=S.schema),S===void 0)throw new fh.default(o.opts.uriResolver,o.baseId,f)}let w=(v=S?.properties)===null||v===void 0?void 0:v[i];if(typeof w!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);b=b&&(m||R(S)),N(w,A);}if(!b)throw new Error(`discriminator: "${i}" must be required`);return p;function R({required:A}){return Array.isArray(A)&&A.includes(i)}function N(A,S){if(A.const)_(A.const,S);else if(A.enum)for(let w of A.enum)_(w,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function _(A,S){if(typeof A!="string"||A in p)throw new Error(`discriminator: "${i}" values must be unique strings`);p[A]=S;}}}};zo.default=gh;});var cu=j((wS,hh)=>{hh.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:true,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:true};});var du=j((he,Ho)=>{Object.defineProperty(he,"__esModule",{value:true});he.MissingRefError=he.ValidationError=he.CodeGen=he.Name=he.nil=he.stringify=he.str=he._=he.KeywordCxt=he.Ajv=void 0;var yh=sc(),vh=nu(),Sh=iu(),uu=cu(),wh=["/properties"],qn="http://json-schema.org/draft-07/schema",cr=class extends yh.default{_addVocabularies(){super._addVocabularies(),vh.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Sh.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(uu,wh):uu;this.addMetaSchema(t,qn,false),this.refs["http://json-schema.org/schema"]=qn;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(qn)?qn:void 0)}};he.Ajv=cr;Ho.exports=he=cr;Ho.exports.Ajv=cr;Object.defineProperty(he,"__esModule",{value:true});he.default=cr;var bh=Rr();Object.defineProperty(he,"KeywordCxt",{enumerable:true,get:function(){return bh.KeywordCxt}});var ur=H();Object.defineProperty(he,"_",{enumerable:true,get:function(){return ur._}});Object.defineProperty(he,"str",{enumerable:true,get:function(){return ur.str}});Object.defineProperty(he,"stringify",{enumerable:true,get:function(){return ur.stringify}});Object.defineProperty(he,"nil",{enumerable:true,get:function(){return ur.nil}});Object.defineProperty(he,"Name",{enumerable:true,get:function(){return ur.Name}});Object.defineProperty(he,"CodeGen",{enumerable:true,get:function(){return ur.CodeGen}});var kh=gn();Object.defineProperty(he,"ValidationError",{enumerable:true,get:function(){return kh.default}});var _h=Cr();Object.defineProperty(he,"MissingRefError",{enumerable:true,get:function(){return _h.default}});});var Jr="b64:";function gd(e){let t=new TextEncoder().encode(e),r=globalThis.Buffer,n;if(r)n=r.from(t).toString("base64");else if(typeof btoa=="function"){let s="";for(let o of t)s+=String.fromCharCode(o);n=btoa(s);}else throw new Error("No base64 encoder available in this runtime");return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function hd(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let n=atob(t),s=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function pe(e){return `${Jr}${gd(JSON.stringify(e))}`}function Ye(e){if(!e.startsWith(Jr))throw new Error(`Invalid ref format (expected ${Jr}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(hd(e.slice(Jr.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:r.kind,value:r.value}}async function la(e,t,r){let n=e.tryAcquire();if(!n)return false;try{await t();}finally{n();}return r?.(),true}function Pe(...e){return te.join(...e)}function ga(e){return te.isAbsolute(e)}function Qn(){return randomUUID()}function ha(e){return createHash("sha256").update(e).digest("hex")}function ya(e){return te.dirname(fileURLToPath(e))}function kd(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=pa(r,n);return {...s,command:o.command,args:o.args}}let t=va(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return pa(t[0],t.slice(1))}function pa(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function va(e){let t=[],r="",n=null;for(let s of e.trim()){if(n){s===n?n=null:r+=s;continue}if(s==='"'||s==="'"){n=s;continue}if(/\s/.test(s)){r&&(t.push(r),r="");continue}r+=s;}if(n)throw new Error(`Unterminated quote in command: ${e}`);return r&&t.push(r),t}function Zn(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function Sa(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return execFileSync(r,n,{shell:Zn(r),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function _d(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a=3e4}=e;execFile(r,n,{shell:Zn(r),encoding:"utf8",windowsHide:true,timeout:a,maxBuffer:10*1024*1024,cwd:s,env:o?{...process.env,...o}:void 0},(i,u,c)=>t(i??null,u,c));}te.join(Xn.tmpdir(),".board-live-cards-git-bash-cache.json");function Hr(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){spawn(t,r,{stdio:"ignore",windowsHide:true,shell:Zn(t)}).unref();return}spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function es(e,t,r){let n=te.join(e,"board-live-cards-cli.js");if(C.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=te.join(e,"board-live-cards-cli.ts"),a=[te.join(e,"..","..","..","node_modules","tsx","dist","cli.mjs"),te.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),te.join(e,"..","..","..","node_modules",".bin","tsx"),te.join(e,"..","..","node_modules",".bin","tsx")].find(u=>C.existsSync(u));return C.existsSync(s)&&C.existsSync(a)?{cmd:process.execPath,args:[a,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function ts(e){let t=te.join(e,"board-live-cards-cli.mjs");if(C.existsSync(t))return t;let r=te.join(e,"..","..","..","dev","board-live-cards-cli.js");if(C.existsSync(r))return r;let n=te.join(e,"..","..","dev","board-live-cards-cli.js");if(C.existsSync(n))return n;let s=te.join(e,"board-live-cards-cli.js");if(C.existsSync(s))return s;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper, ${s}, or ${t})`)}function wa(e,t,r){let n=["--base-ref",pe(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=es(e,"process-accumulated-events",n);Hr({command:s,args:o});}function Rd(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:te.join(Xn.tmpdir(),`${e}.sock`)}var zr=new Map;function ba(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
8
+ deps: ${r}}`};var vg={keyword:"dependencies",type:"object",schemaType:"object",error:ct.error,code(e){let[t,r]=Sg(e);Nc(e,t),qc(e,r);}};function Sg({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let s=Array.isArray(e[n])?t:r;s[n]=e[n];}return [t,r]}function Nc(e,t=e.schema){let{gen:r,data:n,it:s}=e;if(Object.keys(t).length===0)return;let o=r.let("missing");for(let a in t){let i=t[a];if(i.length===0)continue;let u=(0, Dr.propertyInData)(r,n,a,s.opts.ownProperties);e.setParams({property:a,depsCount:i.length,deps:i.join(", ")}),s.allErrors?r.if(u,()=>{for(let c of i)(0, Dr.checkReportMissingProp)(e,c);}):(r.if((0, To._)`${u} && (${(0, Dr.checkMissingProp)(e,i,o)})`),(0, Dr.reportMissingProp)(e,o),r.else());}}ct.validatePropertyDeps=Nc;function qc(e,t=e.schema){let{gen:r,data:n,keyword:s,it:o}=e,a=r.name("valid");for(let i in t)(0, yg.alwaysValidSchema)(o,t[i])||(r.if((0, Dr.propertyInData)(r,n,i,o.opts.ownProperties),()=>{let u=e.subschema({keyword:s,schemaProp:i},a);e.mergeValidEvaluated(u,a);},()=>r.var(a,true)),e.ok(a));}ct.validateSchemaDeps=qc;ct.default=vg;});var Dc=O(Io=>{Object.defineProperty(Io,"__esModule",{value:true});var Mc=W(),wg=ae(),kg={message:"property name must be valid",params:({params:e})=>(0, Mc._)`{propertyName: ${e.propertyName}}`},bg={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:kg,code(e){let{gen:t,schema:r,data:n,it:s}=e;if((0, wg.alwaysValidSchema)(s,r))return;let o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:true},o),t.if((0, Mc.not)(o),()=>{e.error(true),s.allErrors||t.break();});}),e.ok(o);}};Io.default=bg;});var Oo=O(jo=>{Object.defineProperty(jo,"__esModule",{value:true});var jn=He(),st=W(),Rg=pt(),On=ae(),_g={message:"must NOT have additional properties",params:({params:e})=>(0, st._)`{additionalProperty: ${e.additionalProperty}}`},Cg={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:_g,code(e){let{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:i,opts:u}=a;if(a.props=true,u.removeAdditional!=="all"&&(0, On.alwaysValidSchema)(a,r))return;let c=(0, jn.allSchemaProperties)(n.properties),d=(0, jn.allSchemaProperties)(n.patternProperties);l(),e.ok((0, st._)`${o} === ${Rg.default.errors}`);function l(){t.forIn("key",s,b=>{!c.length&&!d.length?f(b):t.if(g(b),()=>f(b));});}function g(b){let C;if(c.length>8){let q=(0, On.schemaRefOrVal)(a,n.properties,"properties");C=(0, jn.isOwnProperty)(t,q,b);}else c.length?C=(0, st.or)(...c.map(q=>(0, st._)`${b} === ${q}`)):C=st.nil;return d.length&&(C=(0, st.or)(C,...d.map(q=>(0, st._)`${(0, jn.usePattern)(e,q)}.test(${b})`))),(0, st.not)(C)}function v(b){t.code((0, st._)`delete ${s}[${b}]`);}function f(b){if(u.removeAdditional==="all"||u.removeAdditional&&r===false){v(b);return}if(r===false){e.setParams({additionalProperty:b}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0, On.alwaysValidSchema)(a,r)){let C=t.name("valid");u.removeAdditional==="failing"?(m(b,C,false),t.if((0, st.not)(C),()=>{e.reset(),v(b);})):(m(b,C),i||t.if((0, st.not)(C),()=>t.break()));}}function m(b,C,q){let _={keyword:"additionalProperties",dataProp:b,dataPropType:On.Type.Str};q===false&&Object.assign(_,{compositeRule:true,createErrors:false,allErrors:false}),e.subschema(_,C);}}};jo.default=Cg;});var Vc=O(No=>{Object.defineProperty(No,"__esModule",{value:true});var $g=Cr(),Lc=He(),Po=ae(),Bc=Oo(),Eg={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Bc.default.code(new $g.KeywordCxt(o,Bc.default,"additionalProperties"));let a=(0, Lc.allSchemaProperties)(r);for(let l of a)o.definedProperties.add(l);o.opts.unevaluated&&a.length&&o.props!==true&&(o.props=Po.mergeEvaluated.props(t,(0, Po.toHash)(a),o.props));let i=a.filter(l=>!(0, Po.alwaysValidSchema)(o,r[l]));if(i.length===0)return;let u=t.name("valid");for(let l of i)c(l)?d(l):(t.if((0, Lc.propertyInData)(t,s,l,o.opts.ownProperties)),d(l),o.allErrors||t.else().var(u,true),t.endIf()),e.it.definedProperties.add(l),e.ok(u);function c(l){return o.opts.useDefaults&&!o.compositeRule&&r[l].default!==void 0}function d(l){e.subschema({keyword:"properties",schemaProp:l,dataProp:l},u);}}};No.default=Eg;});var Jc=O(qo=>{Object.defineProperty(qo,"__esModule",{value:true});var Uc=He(),Pn=W(),Kc=ae(),Gc=ae(),xg={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0, Uc.allSchemaProperties)(r),u=i.filter(m=>(0, Kc.alwaysValidSchema)(o,r[m]));if(i.length===0||u.length===i.length&&(!o.opts.unevaluated||o.props===true))return;let c=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==true&&!(o.props instanceof Pn.Name)&&(o.props=(0, Gc.evaluatedPropsToName)(t,o.props));let{props:l}=o;g();function g(){for(let m of i)c&&v(m),o.allErrors?f(m):(t.var(d,true),f(m),t.if(d));}function v(m){for(let b in c)new RegExp(m).test(b)&&(0, Kc.checkStrictMode)(o,`property ${b} matches pattern ${m} (use allowMatchingProperties)`);}function f(m){t.forIn("key",n,b=>{t.if((0, Pn._)`${(0, Uc.usePattern)(e,m)}.test(${b})`,()=>{let C=u.includes(m);C||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:b,dataPropType:Gc.Type.Str},d),o.opts.unevaluated&&l!==true?t.assign((0, Pn._)`${l}[${b}]`,true):!C&&!o.allErrors&&t.if((0, Pn.not)(d),()=>t.break());});});}}};qo.default=xg;});var zc=O(Fo=>{Object.defineProperty(Fo,"__esModule",{value:true});var Ag=ae(),Tg={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){let{gen:t,schema:r,it:n}=e;if((0, Ag.alwaysValidSchema)(n,r)){e.fail();return}let s=t.name("valid");e.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},s),e.failResult(s,()=>e.reset(),()=>e.error());},error:{message:"must NOT be valid"}};Fo.default=Tg;});var Hc=O(Mo=>{Object.defineProperty(Mo,"__esModule",{value:true});var Ig=He(),jg={keyword:"anyOf",schemaType:"array",trackErrors:true,code:Ig.validateUnion,error:{message:"must match a schema in anyOf"}};Mo.default=jg;});var Wc=O(Do=>{Object.defineProperty(Do,"__esModule",{value:true});var Nn=W(),Og=ae(),Pg={message:"must match exactly one schema in oneOf",params:({params:e})=>(0, Nn._)`{passingSchemas: ${e.passing}}`},Ng={keyword:"oneOf",schemaType:"array",trackErrors:true,error:Pg,code(e){let{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,a=t.let("valid",false),i=t.let("passing",null),u=t.name("_valid");e.setParams({passing:i}),t.block(c),e.result(a,()=>e.reset(),()=>e.error(true));function c(){o.forEach((d,l)=>{let g;(0, Og.alwaysValidSchema)(s,d)?t.var(u,true):g=e.subschema({keyword:"oneOf",schemaProp:l,compositeRule:true},u),l>0&&t.if((0, Nn._)`${u} && ${a}`).assign(a,false).assign(i,(0, Nn._)`[${i}, ${l}]`).else(),t.if(u,()=>{t.assign(a,true),t.assign(i,l),g&&e.mergeEvaluated(g,Nn.Name);});});}}};Do.default=Ng;});var Yc=O(Lo=>{Object.defineProperty(Lo,"__esModule",{value:true});var qg=ae(),Fg={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=t.name("valid");r.forEach((o,a)=>{if((0, qg.alwaysValidSchema)(n,o))return;let i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i);});}};Lo.default=Fg;});var Zc=O(Bo=>{Object.defineProperty(Bo,"__esModule",{value:true});var qn=W(),Qc=ae(),Mg={message:({params:e})=>(0, qn.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0, qn._)`{failingKeyword: ${e.ifClause}}`},Dg={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:Mg,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0, Qc.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Xc(n,"then"),o=Xc(n,"else");if(!s&&!o)return;let a=t.let("valid",true),i=t.name("_valid");if(u(),e.reset(),s&&o){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,c("then",d),c("else",d));}else s?t.if(i,c("then")):t.if((0, qn.not)(i),c("else"));e.pass(a,()=>e.error(true));function u(){let d=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},i);e.mergeEvaluated(d);}function c(d,l){return ()=>{let g=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(g,a),l?t.assign(l,(0, qn._)`${d}`):e.setParams({ifClause:d});}}}};function Xc(e,t){let r=e.schema[t];return r!==void 0&&!(0, Qc.alwaysValidSchema)(e,r)}Bo.default=Dg;});var eu=O(Vo=>{Object.defineProperty(Vo,"__esModule",{value:true});var Lg=ae(),Bg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0, Lg.checkStrictMode)(r,`"${e}" without "if" is ignored`);}};Vo.default=Bg;});var tu=O(Uo=>{Object.defineProperty(Uo,"__esModule",{value:true});var Vg=Co(),Ug=Ic(),Kg=$o(),Gg=Oc(),Jg=Pc(),zg=Fc(),Hg=Dc(),Wg=Oo(),Yg=Vc(),Xg=Jc(),Qg=zc(),Zg=Hc(),eh=Wc(),th=Yc(),rh=Zc(),nh=eu();function sh(e=false){let t=[Qg.default,Zg.default,eh.default,th.default,rh.default,nh.default,Hg.default,Wg.default,zg.default,Yg.default,Xg.default];return e?t.push(Ug.default,Gg.default):t.push(Vg.default,Kg.default),t.push(Jg.default),t}Uo.default=sh;});var ru=O(Ko=>{Object.defineProperty(Ko,"__esModule",{value:true});var Se=W(),oh={message:({schemaCode:e})=>(0, Se.str)`must match format "${e}"`,params:({schemaCode:e})=>(0, Se._)`{format: ${e}}`},ah={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:oh,code(e,t){let{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:u,errSchemaPath:c,schemaEnv:d,self:l}=i;if(!u.validateFormats)return;s?g():v();function g(){let f=r.scopeValue("formats",{ref:l.formats,code:u.code.formats}),m=r.const("fDef",(0, Se._)`${f}[${a}]`),b=r.let("fType"),C=r.let("format");r.if((0, Se._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(b,(0, Se._)`${m}.type || "string"`).assign(C,(0, Se._)`${m}.validate`),()=>r.assign(b,(0, Se._)`"string"`).assign(C,m)),e.fail$data((0, Se.or)(q(),_()));function q(){return u.strictSchema===false?Se.nil:(0, Se._)`${a} && !${C}`}function _(){let I=d.$async?(0, Se._)`(${m}.async ? await ${C}(${n}) : ${C}(${n}))`:(0, Se._)`${C}(${n})`,S=(0, Se._)`(typeof ${C} == "function" ? ${I} : ${C}.test(${n}))`;return (0, Se._)`${C} && ${C} !== true && ${b} === ${t} && !${S}`}}function v(){let f=l.formats[o];if(!f){q();return}if(f===true)return;let[m,b,C]=_(f);m===t&&e.pass(I());function q(){if(u.strictSchema===false){l.logger.warn(S());return}throw new Error(S());function S(){return `unknown format "${o}" ignored in schema at path "${c}"`}}function _(S){let k=S instanceof RegExp?(0, Se.regexpCode)(S):u.code.formats?(0, Se._)`${u.code.formats}${(0, Se.getProperty)(o)}`:void 0,w=r.scopeValue("formats",{key:o,ref:S,code:k});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0, Se._)`${w}.validate`]:["string",S,w]}function I(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!d.$async)throw new Error("async format in sync schema");return (0, Se._)`await ${C}(${n})`}return typeof b=="function"?(0, Se._)`${C}(${n})`:(0, Se._)`${C}.test(${n})`}}}};Ko.default=ah;});var nu=O(Go=>{Object.defineProperty(Go,"__esModule",{value:true});var ih=ru(),ch=[ih.default];Go.default=ch;});var su=O(ir=>{Object.defineProperty(ir,"__esModule",{value:true});ir.contentVocabulary=ir.metadataVocabulary=void 0;ir.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ir.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];});var au=O(Jo=>{Object.defineProperty(Jo,"__esModule",{value:true});var uh=pc(),dh=Ec(),lh=tu(),fh=nu(),ou=su(),ph=[uh.default,dh.default,(0, lh.default)(),fh.default,ou.metadataVocabulary,ou.contentVocabulary];Jo.default=ph;});var cu=O(Fn=>{Object.defineProperty(Fn,"__esModule",{value:true});Fn.DiscrError=void 0;var iu;(function(e){e.Tag="tag",e.Mapping="mapping";})(iu||(Fn.DiscrError=iu={}));});var du=O(Ho=>{Object.defineProperty(Ho,"__esModule",{value:true});var cr=W(),zo=cu(),uu=Sn(),mh=$r(),gh=ae(),hh={message:({params:{discrError:e,tagName:t}})=>e===zo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0, cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},yh={keyword:"discriminator",type:"object",schemaType:"object",error:hh,code(e){let{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",false),c=t.const("tag",(0, cr._)`${r}${(0, cr.getProperty)(i)}`);t.if((0, cr._)`typeof ${c} == "string"`,()=>d(),()=>e.error(false,{discrError:zo.DiscrError.Tag,tag:c,tagName:i})),e.ok(u);function d(){let v=g();t.if(false);for(let f in v)t.elseIf((0, cr._)`${c} === ${f}`),t.assign(u,l(v[f]));t.else(),e.error(false,{discrError:zo.DiscrError.Mapping,tag:c,tagName:i}),t.endIf();}function l(v){let f=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:v},f);return e.mergeEvaluated(m,cr.Name),f}function g(){var v;let f={},m=C(s),b=true;for(let I=0;I<a.length;I++){let S=a[I];if(S?.$ref&&!(0, gh.schemaHasRulesButRef)(S,o.self.RULES)){let w=S.$ref;if(S=uu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,w),S instanceof uu.SchemaEnv&&(S=S.schema),S===void 0)throw new mh.default(o.opts.uriResolver,o.baseId,w)}let k=(v=S?.properties)===null||v===void 0?void 0:v[i];if(typeof k!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);b=b&&(m||C(S)),q(k,I);}if(!b)throw new Error(`discriminator: "${i}" must be required`);return f;function C({required:I}){return Array.isArray(I)&&I.includes(i)}function q(I,S){if(I.const)_(I.const,S);else if(I.enum)for(let k of I.enum)_(k,S);else throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`)}function _(I,S){if(typeof I!="string"||I in f)throw new Error(`discriminator: "${i}" values must be unique strings`);f[I]=S;}}}};Ho.default=yh;});var lu=O((bS,vh)=>{vh.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:true,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:true};});var pu=O((he,Wo)=>{Object.defineProperty(he,"__esModule",{value:true});he.MissingRefError=he.ValidationError=he.CodeGen=he.Name=he.nil=he.stringify=he.str=he._=he.KeywordCxt=he.Ajv=void 0;var Sh=ic(),wh=au(),kh=du(),fu=lu(),bh=["/properties"],Mn="http://json-schema.org/draft-07/schema",ur=class extends Sh.default{_addVocabularies(){super._addVocabularies(),wh.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(kh.default);}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(fu,bh):fu;this.addMetaSchema(t,Mn,false),this.refs["http://json-schema.org/schema"]=Mn;}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Mn)?Mn:void 0)}};he.Ajv=ur;Wo.exports=he=ur;Wo.exports.Ajv=ur;Object.defineProperty(he,"__esModule",{value:true});he.default=ur;var Rh=Cr();Object.defineProperty(he,"KeywordCxt",{enumerable:true,get:function(){return Rh.KeywordCxt}});var dr=W();Object.defineProperty(he,"_",{enumerable:true,get:function(){return dr._}});Object.defineProperty(he,"str",{enumerable:true,get:function(){return dr.str}});Object.defineProperty(he,"stringify",{enumerable:true,get:function(){return dr.stringify}});Object.defineProperty(he,"nil",{enumerable:true,get:function(){return dr.nil}});Object.defineProperty(he,"Name",{enumerable:true,get:function(){return dr.Name}});Object.defineProperty(he,"CodeGen",{enumerable:true,get:function(){return dr.CodeGen}});var _h=yn();Object.defineProperty(he,"ValidationError",{enumerable:true,get:function(){return _h.default}});var Ch=$r();Object.defineProperty(he,"MissingRefError",{enumerable:true,get:function(){return Ch.default}});});var Hr="b64:";function yd(e){let t=new TextEncoder().encode(e),r=globalThis.Buffer,n;if(r)n=r.from(t).toString("base64");else if(typeof btoa=="function"){let s="";for(let o of t)s+=String.fromCharCode(o);n=btoa(s);}else throw new Error("No base64 encoder available in this runtime");return n.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vd(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let n=atob(t),s=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function pe(e){return `${Hr}${yd(JSON.stringify(e))}`}function Qe(e){if(!e.startsWith(Hr))throw new Error(`Invalid ref format (expected ${Hr}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(vd(e.slice(Hr.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return {kind:r.kind,value:r.value}}async function ma(e,t,r){let n=e.tryAcquire();if(!n)return false;try{await t();}finally{n();}return r?.(),true}function qe(...e){return oe.join(...e)}function va(e){return oe.isAbsolute(e)}function Zn(){return randomUUID()}function Sa(e){return createHash("sha256").update(e).digest("hex")}function wa(e){return oe.dirname(fileURLToPath(e))}function _d(e){if(typeof e=="object"&&e!==null){let{command:r,args:n=[],...s}=e,o=ha(r,n);return {...s,command:o.command,args:o.args}}let t=ka(e);if(t.length===0)throw new Error(`Empty command spec: ${JSON.stringify(e)}`);return ha(t[0],t.slice(1))}function ha(e,t){return /^(node|node\.exe)$/i.test(e)?{command:process.execPath,args:t}:/\.m?js$/i.test(e)?{command:process.execPath,args:[e,...t]}:{command:e,args:t}}function ka(e){let t=[],r="",n=null;for(let s of e.trim()){if(n){s===n?n=null:r+=s;continue}if(s==='"'||s==="'"){n=s;continue}if(/\s/.test(s)){r&&(t.push(r),r="");continue}r+=s;}if(n)throw new Error(`Unterminated quote in command: ${e}`);return r&&t.push(r),t}function es(e){return process.platform==="win32"&&/\.(cmd|bat)$/i.test(e)}function ba(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a}=e;return execFileSync(r,n,{shell:es(r),timeout:a,encoding:t?.encoding??"utf-8",cwd:s,windowsHide:true,env:o?{...process.env,...o}:void 0,input:t?.input})}function Cd(e,t){let{command:r,args:n=[],cwd:s,env:o,timeoutMs:a=3e4}=e;execFile(r,n,{shell:es(r),encoding:"utf8",windowsHide:true,timeout:a,maxBuffer:10*1024*1024,cwd:s,env:o?{...process.env,...o}:void 0},(i,u,c)=>t(i??null,u,c));}oe.join(Qn.tmpdir(),".board-live-cards-git-bash-cache.json");function Yr(e){let{command:t,args:r=[]}=e;if(process.platform==="win32"){spawn(t,r,{stdio:"ignore",windowsHide:true,shell:es(t)}).unref();return}spawn(t,r,{detached:true,stdio:"ignore"}).unref();}function ts(e,t,r){let n=oe.join(e,"board-live-cards-cli.js");if($.existsSync(n))return {cmd:process.execPath,args:[n,t,...r]};let s=oe.join(e,"board-live-cards-cli.ts"),a=[oe.join(e,"..","..","..","node_modules","tsx","dist","cli.mjs"),oe.join(e,"..","..","node_modules","tsx","dist","cli.mjs"),oe.join(e,"..","..","..","node_modules",".bin","tsx"),oe.join(e,"..","..","node_modules",".bin","tsx")].find(u=>$.existsSync(u));return $.existsSync(s)&&$.existsSync(a)?{cmd:process.execPath,args:[a,s,t,...r]}:{cmd:process.platform==="win32"?"npx.cmd":"npx",args:["tsx",s,t,...r]}}function rs(e){let t=oe.join(e,"board-live-cards-cli.mjs");if($.existsSync(t))return t;let r=oe.join(e,"..","..","..","dev","board-live-cards-cli.js");if($.existsSync(r))return r;let n=oe.join(e,"..","..","dev","board-live-cards-cli.js");if($.existsSync(n))return n;let s=oe.join(e,"board-live-cards-cli.js");if($.existsSync(s))return s;throw new Error(`resolveBoardCliCallbackTarget: cannot find callback target in ${e} (expected dev/board-live-cards-cli.js wrapper, ${s}, or ${t})`)}function Ra(e,t,r){let n=["--base-ref",pe(t)];r&&n.push("--notify-channel",r);let{cmd:s,args:o}=ts(e,"process-accumulated-events",n);Yr({command:s,args:o});}function $d(e){return process.platform==="win32"?`\\\\.\\pipe\\${e}`:oe.join(Qn.tmpdir(),`${e}.sock`)}var Wr=new Map;function _a(e,t,r){if(t.length===0)return;let n=t.map(i=>JSON.stringify(i)).join(`
9
9
  `)+`
10
- `,s=zr.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=Rd(e),a=ma.createConnection(o);s={socket:a,ready:false,queue:[n]},zr.set(e,s),a.on("connect",()=>{s.ready=true;for(let i of s.queue)a.write(i);s.queue.length=0;}),a.on("error",i=>{r?.(`[named-pipe publish] ${o}: ${i instanceof Error?i.message:String(i)}`),zr.delete(e);}),a.on("close",()=>{zr.delete(e);});}function Wr(){return {executeSync(e,t,r){return Sa({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){_d({command:e,args:t},r);},resolveInvocation(e,t){let r=kd({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:va,spawnDetached(e,t){Hr({command:e,args:t});}}}var _a=dirname(fileURLToPath(import.meta.url)),Ad=createRequire(import.meta.url);function Td(){let e=resolve(_a,"./jsonata-sync.cjs");return existsSync(e)?e:resolve(_a,"../../card-compute/jsonata-sync.cjs")}var It=Ad(Td());function dr(e){e.registerFunction("fsPathRef",t=>pe({kind:"fs-path",value:String(t)}),"<s:s>");}function rs(e,t,r){if(!e||typeof e!="object")return {};let n={};if(Array.isArray(e.cmdTemplate)){let s=[];for(let o of e.cmdTemplate)try{let a=It(o);dr(a),s.push(String(a.evaluate(t)));}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`[${r}] argsMassaging.cmdTemplate failed on "${o}": ${i}`)}n.cmdArgs=s;}if(typeof e.stdinTemplate=="string")try{let s=It(e.stdinTemplate);dr(s),n.stdin=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.stdinTemplate failed: ${o}`)}if(typeof e.urlTemplate=="string")try{let s=It(e.urlTemplate);dr(s),n.url=String(s.evaluate(t));}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.urlTemplate failed: ${o}`)}if(typeof e.headerTemplate=="string")try{let s=It(e.headerTemplate);dr(s);let o=s.evaluate(t);if(typeof o!="object"||o===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(o)}`);n.headers=o;}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.headerTemplate failed: ${o}`)}if(typeof e.bodyTemplate=="string")try{let s=It(e.bodyTemplate);dr(s),n.body=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.bodyTemplate failed: ${o}`)}return n}var jd=createRequire(import.meta.url);function Od(e){return typeof e=="object"?e:Ye(e)}function Ca(e){let t=te.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=te.dirname(jd.resolve("yaml-flow/package.json")),n=t.replace(/\.[^.]+$/,""),s=te.join(r,"cli","bundled",`${n}.mjs`);if(C.existsSync(s))return s;let o=te.join(r,"cli","node",t);if(C.existsSync(o))return o;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function Qe(e){let t=Od(e);return t.kind==="yaml-flow-cli"?Ca(t.value):t.value}function Pd(e,t){let r=Qe(e);switch(r){case "source-cli-task-executor":{let n=te.join(t,"source-cli-task-executor.js");if(C.existsSync(n))return {command:process.execPath,args:[n]};let s=te.join(t,"source-cli-task-executor.ts"),o=te.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=te.join(t,"..","..","node_modules",".bin","tsx"),i=C.existsSync(o)?o:a;return C.existsSync(s)&&C.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=es(t,"_",[]);return {command:n,args:s}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Ea(e,t){if(e.howToRun==="built-in"){let{command:n,args:s}=Pd(e.whatToRun,t);return {command:n,baseArgs:s}}let r=(typeof e.whatToRun=="object",Qe(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[r]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[r]};case "local-process":return {command:r,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function Nd(e,t){let r=[e.subcommand];return e.inRef&&r.push("--in-ref",e.inRef),e.outRef&&r.push("--out-ref",e.outRef),e.errRef&&r.push("--err-ref",e.errRef),t&&r.push("--extra",Buffer.from(JSON.stringify(t)).toString("base64")),r}function qd(e,t){return {subcommand:e.subcommand,...e.inRef?{inRef:e.inRef}:{},...e.outRef?{outRef:e.outRef}:{},...e.errRef?{errRef:e.errRef}:{},...t?{extra:t}:{}}}function Yr(e,t){return Ea(e,t)}function $a(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let r=t.split(/\r?\n/).filter(Boolean),n=r[r.length-1];return JSON.parse(n)}}function xa(e,t){return {...t,whatToRun:Qe(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function ns(e,t,r="invokeExecutionRef"){return rs(e,t,r)}function Aa(e){return e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e:{result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e}}}function ht(e){return {result:"failure",data:{error:e}}}function gt(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=ns(e.argsMassaging,xa(e,t),n);}catch(l){let h=l instanceof Error?l.message:String(l);return ht(h)}let a;try{a=Yr(e,s);}catch(l){let h=l instanceof Error?l.message:String(l);return ht(`[${n}] ref resolution failed: ${h}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=Wr(),d;try{d=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(l){let h=l,v=(h.stderr?String(h.stderr):"").trim(),p=typeof h.status=="number"?h.status:"unknown",m=v||h.message;return ht(`[${n}] ref exited with status ${p}${m?`: ${m}`:""}`)}try{return Aa($a(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function Ra(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=ns(e.argsMassaging,xa(e,t),n);}catch(c){let d=c instanceof Error?c.message:String(c);return ht(d)}let o=Qe(e.whatToRun),a=s.headers?{"Content-Type":"application/json",...s.headers}:{"Content-Type":"application/json"},i=s.url??o,u;if(e.howToRun==="http:get"){let c=s.body&&typeof s.body=="object"&&!Array.isArray(s.body)?s.body:t,d=new URLSearchParams(Object.entries(c).filter(([,l])=>l!=null).map(([l,h])=>[l,String(h)]));d.size>0&&(i=`${i}${i.includes("?")?"&":"?"}${d.toString()}`);}else u=JSON.stringify(s.body??t);try{let c=await fetch(i,{method:e.howToRun==="http:get"?"GET":"POST",headers:a,body:u});if(!c.ok){let l=await c.text().catch(()=>"");return ht(`[${n}] HTTP ${c.status}${l?`: ${l}`:""}`)}let d=await c.text();if(!d.trim())return {result:"success",data:{}};try{return Aa($a(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}catch(c){let d=c instanceof Error?c.message:String(c);return ht(`[${n}] ${d}`)}}var Fd={"local-node":async(e,t,r)=>gt(e,t,r),"local-python":async(e,t,r)=>gt(e,t,r),"local-process":async(e,t,r)=>gt(e,t,r),"built-in":async(e,t,r)=>gt(e,t,r),"http:post":Ra,"http:get":Ra},Dd={"local-node":gt,"local-python":gt,"local-process":gt,"built-in":gt};async function Ta(e,t,r){let n=r?.transports?.[e.howToRun]??Fd[e.howToRun];return n?n(e,t,r):ht(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function ss(e,t,r){let n=r?.syncTransports?.[e.howToRun]??Dd[e.howToRun];return n?n(e,t,r):ht(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function Md(e){return {invoke(t,r){return Ta(t,r,e)},invokeSync(t,r){return ss(t,r,e)}}}function Ld(e,t,r){return ss(e,t,r)}async function Bd(e,t){let r={...t,whatToRun:Qe(e.whatToRun)},n=rs(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??Qe(e.whatToRun),o=n.body?n.body:qd(t,e.extra),a={"Content-Type":"application/json"},i=n.headers?{...a,...n.headers}:a,u=await fetch(s,{method:e.howToRun==="http:get"?"GET":"POST",headers:i,body:JSON.stringify(o)});if(!u.ok){let d=await u.text().catch(()=>"");return {status:"error",error:`HTTP ${u.status}: ${d}`}}let c=await u.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function Ia(e,t,r){if(e.howToRun==="http:post"||e.howToRun==="http:get"){Bd(e,t).catch(i=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${i.message}`);});return}let{command:s,baseArgs:o}=Ea(e,r),a=Nd(t,e.extra);Hr({command:s,args:[...o,...a]});}function ct(e,t){if(process.platform!=="win32"){C.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{C.renameSync(e,t);return}catch(s){let o=s.code;if((o==="EPERM"||o==="EBUSY")&&n<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[n]);continue}throw s}}function Ht(e){function t(s){return te.join(e,...s.split("/"))}function r(s){return te.relative(e,s).replace(/\\/g,"/")}function n(s,o){if(C.existsSync(s))for(let a of C.readdirSync(s,{withFileTypes:true})){let i=te.join(s,a.name);if(a.isDirectory()){n(i,o);continue}a.isFile()&&o.push(r(i));}}return {read(s){let o=t(s);if(!C.existsSync(o))return null;try{return C.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(a),{recursive:true}),C.writeFileSync(i,o,"utf-8"),ct(i,a);},exists(s){return C.existsSync(t(s))},remove(s){let o=t(s);try{C.existsSync(o)&&C.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!C.existsSync(o))return null;try{return new Uint8Array(C.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(a),{recursive:true}),C.writeFileSync(i,Buffer.from(o)),ct(i,a);},listKeys(s){let o=[];n(e,o);let a=o.sort();return s?a.filter(i=>i.startsWith(s)):a},stat(s){let o=t(s);if(!C.existsSync(o))return null;try{let a=C.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}},keyRef(s){return {kind:"fs-path",value:t(s)}}}}function cs(){return {read(e){if(!C.existsSync(e))return null;try{return C.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(e),{recursive:true}),C.writeFileSync(r,t,"utf-8"),ct(r,e);},exists(e){return C.existsSync(e)},remove(e){try{C.existsSync(e)&&C.unlinkSync(e);}catch{}},readBytes(e){if(!C.existsSync(e))return null;try{return new Uint8Array(C.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(e),{recursive:true}),C.writeFileSync(r,Buffer.from(t)),ct(r,e);},stat(e){if(!C.existsSync(e))return null;try{let t=C.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []}}}var os="__scratch-marker",as="__scratch-config.json",Kd=1440*60*1e3,Gd=720*60*1e3,Jd=500;function ja(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function Zr(e){C.mkdirSync(e,{recursive:true});let t=te.join(e,os),r=te.join(e,as),n=!C.existsSync(t);if(n)try{C.writeFileSync(t,`scratch-store
10
+ `,s=Wr.get(e);if(s&&!s.socket.destroyed){s.ready?s.socket.write(n):s.queue.push(n);return}let o=$d(e),a=ya.createConnection(o);s={socket:a,ready:false,queue:[n]},Wr.set(e,s),a.on("connect",()=>{s.ready=true;for(let i of s.queue)a.write(i);s.queue.length=0;}),a.on("error",i=>{r?.(`[named-pipe publish] ${o}: ${i instanceof Error?i.message:String(i)}`),Wr.delete(e);}),a.on("close",()=>{Wr.delete(e);});}function Xr(){return {executeSync(e,t,r){return ba({command:e,args:t,cwd:r?.cwd,timeoutMs:r?.timeout,env:r?.env},{encoding:r?.encoding,input:r?.input})},executeAsync(e,t,r){Cd({command:e,args:t},r);},resolveInvocation(e,t){let r=_d({command:e,args:t});return {cmd:r.command,args:r.args??[]}},splitCommand:ka,spawnDetached(e,t){Yr({command:e,args:t});}}}var $a=dirname(fileURLToPath(import.meta.url)),Id=createRequire(import.meta.url);function jd(){let e=resolve($a,"./jsonata-sync.cjs");return existsSync(e)?e:resolve($a,"../../card-compute/jsonata-sync.cjs")}var jt=Id(jd());function lr(e){e.registerFunction("fsPathRef",t=>pe({kind:"fs-path",value:String(t)}),"<s:s>");}function ns(e,t,r){if(!e||typeof e!="object")return {};let n={};if(Array.isArray(e.cmdTemplate)){let s=[];for(let o of e.cmdTemplate)try{let a=jt(o);lr(a),s.push(String(a.evaluate(t)));}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`[${r}] argsMassaging.cmdTemplate failed on "${o}": ${i}`)}n.cmdArgs=s;}if(typeof e.stdinTemplate=="string")try{let s=jt(e.stdinTemplate);lr(s),n.stdin=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.stdinTemplate failed: ${o}`)}if(typeof e.urlTemplate=="string")try{let s=jt(e.urlTemplate);lr(s),n.url=String(s.evaluate(t));}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.urlTemplate failed: ${o}`)}if(typeof e.headerTemplate=="string")try{let s=jt(e.headerTemplate);lr(s);let o=s.evaluate(t);if(typeof o!="object"||o===null)throw new Error(`headerTemplate must produce an object, got: ${JSON.stringify(o)}`);n.headers=o;}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.headerTemplate failed: ${o}`)}if(typeof e.bodyTemplate=="string")try{let s=jt(e.bodyTemplate);lr(s),n.body=s.evaluate(t);}catch(s){let o=s instanceof Error?s.message:String(s);throw new Error(`[${r}] argsMassaging.bodyTemplate failed: ${o}`)}return n}var Pd=createRequire(import.meta.url);function Nd(e){return typeof e=="object"?e:Qe(e)}function xa(e){let t=oe.basename(String(e||"").trim());if(!t)throw new Error(`resolveYamlFlowCliPath: expected non-empty cli file name, got ${JSON.stringify(e)}`);let r=oe.dirname(Pd.resolve("yaml-flow/package.json")),n=t.replace(/\.[^.]+$/,""),s=oe.join(r,"cli","bundled",`${n}.mjs`);if($.existsSync(s))return s;let o=oe.join(r,"cli","node",t);if($.existsSync(o))return o;throw new Error(`resolveYamlFlowCliPath: could not find ${t} under cli/bundled or cli/node in ${r}`)}function et(e){let t=Nd(e);return t.kind==="yaml-flow-cli"?xa(t.value):t.value}function qd(e,t){let r=et(e);switch(r){case "source-cli-task-executor":{let n=oe.join(t,"source-cli-task-executor.js");if($.existsSync(n))return {command:process.execPath,args:[n]};let s=oe.join(t,"source-cli-task-executor.ts"),o=oe.join(t,"..","..","node_modules","tsx","dist","cli.mjs"),a=oe.join(t,"..","..","node_modules",".bin","tsx"),i=$.existsSync(o)?o:a;return $.existsSync(s)&&$.existsSync(i)?{command:process.execPath,args:[i,s]}:{command:process.execPath,args:[n]}}case "board-live-cards":{let{cmd:n,args:s}=ts(t,"_",[]);return {command:n,args:s}}default:throw new Error(`resolveBuiltIn: unknown built-in name "${r}". Supported: source-cli-task-executor, board-live-cards`)}}function Aa(e,t){if(e.howToRun==="built-in"){let{command:n,args:s}=qd(e.whatToRun,t);return {command:n,baseArgs:s}}let r=(typeof e.whatToRun=="object",et(e.whatToRun));switch(e.howToRun){case "local-node":return {command:process.execPath,baseArgs:[r]};case "local-python":return {command:process.platform==="win32"?"python":"python3",baseArgs:[r]};case "local-process":return {command:r,baseArgs:[]};default:throw new Error(`resolveBaseInvocation: howToRun "${e.howToRun}" is not a local transport`)}}function Fd(e,t){let r=[e.subcommand];return e.inRef&&r.push("--in-ref",e.inRef),e.outRef&&r.push("--out-ref",e.outRef),e.errRef&&r.push("--err-ref",e.errRef),t&&r.push("--extra",Buffer.from(JSON.stringify(t)).toString("base64")),r}function Md(e,t){return {subcommand:e.subcommand,...e.inRef?{inRef:e.inRef}:{},...e.outRef?{outRef:e.outRef}:{},...e.errRef?{errRef:e.errRef}:{},...t?{extra:t}:{}}}function Qr(e,t){return Aa(e,t)}function Ta(e){let t=e.trim();if(!t)throw new Error("empty stdout");try{return JSON.parse(t)}catch{let r=t.split(/\r?\n/).filter(Boolean),n=r[r.length-1];return JSON.parse(n)}}function Ia(e,t){return {...t,whatToRun:et(e.whatToRun),...e.extra?{extra:e.extra}:{}}}function ss(e,t,r="invokeExecutionRef"){return ns(e,t,r)}function ja(e){return e&&typeof e=="object"&&!Array.isArray(e)&&typeof e.result=="string"&&e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e:{result:"success",data:e&&typeof e=="object"&&!Array.isArray(e)?e:{stdout:e}}}function vt(e){return {result:"failure",data:{error:e}}}function yt(e,t,r){let n=r?.label??"invokeExecutionRefSync",s=r?.cliDir??r?.cwd??process.cwd(),o;try{o=ss(e.argsMassaging,Ia(e,t),n);}catch(l){let g=l instanceof Error?l.message:String(l);return vt(g)}let a;try{a=Qr(e,s);}catch(l){let g=l instanceof Error?l.message:String(l);return vt(`[${n}] ref resolution failed: ${g}`)}let i=[...a.baseArgs,...o.cmdArgs??[]],u=JSON.stringify(o.stdin??t),c=Xr(),d;try{d=c.executeSync(a.command,i,{timeout:r?.timeoutMs??3e4,encoding:"utf-8",cwd:r?.cwd,input:u});}catch(l){let g=l,v=(g.stderr?String(g.stderr):"").trim(),f=typeof g.status=="number"?g.status:"unknown",m=v||g.message;return vt(`[${n}] ref exited with status ${f}${m?`: ${m}`:""}`)}try{return ja(Ta(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}async function Ea(e,t,r){let n=r?.label??"invokeExecutionRef",s;try{s=ss(e.argsMassaging,Ia(e,t),n);}catch(c){let d=c instanceof Error?c.message:String(c);return vt(d)}let o=et(e.whatToRun),a=s.headers?{"Content-Type":"application/json",...s.headers}:{"Content-Type":"application/json"},i=s.url??o,u;if(e.howToRun==="http:get"){let c=s.body&&typeof s.body=="object"&&!Array.isArray(s.body)?s.body:t,d=new URLSearchParams(Object.entries(c).filter(([,l])=>l!=null).map(([l,g])=>[l,String(g)]));d.size>0&&(i=`${i}${i.includes("?")?"&":"?"}${d.toString()}`);}else u=JSON.stringify(s.body??t);try{let c=await fetch(i,{method:e.howToRun==="http:get"?"GET":"POST",headers:a,body:u});if(!c.ok){let l=await c.text().catch(()=>"");return vt(`[${n}] HTTP ${c.status}${l?`: ${l}`:""}`)}let d=await c.text();if(!d.trim())return {result:"success",data:{}};try{return ja(Ta(d))}catch{return {result:"success",data:{stdout:d.trim()}}}}catch(c){let d=c instanceof Error?c.message:String(c);return vt(`[${n}] ${d}`)}}var Dd={"local-node":async(e,t,r)=>yt(e,t,r),"local-python":async(e,t,r)=>yt(e,t,r),"local-process":async(e,t,r)=>yt(e,t,r),"built-in":async(e,t,r)=>yt(e,t,r),"http:post":Ea,"http:get":Ea},Ld={"local-node":yt,"local-python":yt,"local-process":yt,"built-in":yt};async function Oa(e,t,r){let n=r?.transports?.[e.howToRun]??Dd[e.howToRun];return n?n(e,t,r):vt(`[${r?.label??"invokeExecutionRef"}] unsupported howToRun: ${e.howToRun}`)}function os(e,t,r){let n=r?.syncTransports?.[e.howToRun]??Ld[e.howToRun];return n?n(e,t,r):vt(`[${r?.label??"invokeExecutionRefSync"}] unsupported sync howToRun: ${e.howToRun}`)}function Bd(e){return {invoke(t,r){return Oa(t,r,e)},invokeSync(t,r){return os(t,r,e)}}}function Vd(e,t,r){return os(e,t,r)}async function Ud(e,t){let r={...t,whatToRun:et(e.whatToRun)},n=ns(e.argsMassaging,r,"_invokeTaskExecutorHttp"),s=n.url??et(e.whatToRun),o=n.body?n.body:Md(t,e.extra),a={"Content-Type":"application/json"},i=n.headers?{...a,...n.headers}:a,u=await fetch(s,{method:e.howToRun==="http:get"?"GET":"POST",headers:i,body:JSON.stringify(o)});if(!u.ok){let d=await u.text().catch(()=>"");return {status:"error",error:`HTTP ${u.status}: ${d}`}}let c=await u.json().catch(()=>null);return c&&typeof c.status=="string"?c:{status:"success"}}function Pa(e,t,r){if(e.howToRun==="http:post"||e.howToRun==="http:get"){Ud(e,t).catch(i=>{console.error(`[dispatchTaskExecutorDetached] HTTP dispatch failed: ${i.message}`);});return}let{command:s,baseArgs:o}=Aa(e,r),a=Fd(t,e.extra);Yr({command:s,args:[...o,...a]});}function dt(e,t){if(process.platform!=="win32"){$.renameSync(e,t);return}let r=[10,20,40,80,160];for(let n=0;n<=r.length;n++)try{$.renameSync(e,t);return}catch(s){let o=s.code;if((o==="EPERM"||o==="EBUSY")&&n<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[n]);continue}throw s}}function Wt(e){function t(s){return oe.join(e,...s.split("/"))}function r(s){return oe.relative(e,s).replace(/\\/g,"/")}function n(s,o){if($.existsSync(s))for(let a of $.readdirSync(s,{withFileTypes:true})){let i=oe.join(s,a.name);if(a.isDirectory()){n(i,o);continue}a.isFile()&&o.push(r(i));}}return {read(s){let o=t(s);if(!$.existsSync(o))return null;try{return $.readFileSync(o,"utf-8")}catch{return null}},write(s,o){let a=t(s),i=`${a}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(a),{recursive:true}),$.writeFileSync(i,o,"utf-8"),dt(i,a);},exists(s){return $.existsSync(t(s))},remove(s){let o=t(s);try{$.existsSync(o)&&$.unlinkSync(o);}catch{}},readBytes(s){let o=t(s);if(!$.existsSync(o))return null;try{return new Uint8Array($.readFileSync(o))}catch{return null}},writeBytes(s,o){let a=t(s),i=`${a}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(a),{recursive:true}),$.writeFileSync(i,Buffer.from(o)),dt(i,a);},listKeys(s){let o=[];n(e,o);let a=o.sort();return s?a.filter(i=>i.startsWith(s)):a},stat(s){let o=t(s);if(!$.existsSync(o))return null;try{let a=$.statSync(o);return {key:s,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}},keyRef(s){return {kind:"fs-path",value:t(s)}}}}function us(){return {read(e){if(!$.existsSync(e))return null;try{return $.readFileSync(e,"utf-8")}catch{return null}},write(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(e),{recursive:true}),$.writeFileSync(r,t,"utf-8"),dt(r,e);},exists(e){return $.existsSync(e)},remove(e){try{$.existsSync(e)&&$.unlinkSync(e);}catch{}},readBytes(e){if(!$.existsSync(e))return null;try{return new Uint8Array($.readFileSync(e))}catch{return null}},writeBytes(e,t){let r=`${e}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(e),{recursive:true}),$.writeFileSync(r,Buffer.from(t)),dt(r,e);},stat(e){if(!$.existsSync(e))return null;try{let t=$.statSync(e);return {key:e,size:Number(t.size||0),updatedAt:new Date(t.mtimeMs).toISOString()}}catch{return null}},listKeys(e){return []}}}var as="__scratch-marker",is="__scratch-config.json",Jd=1440*60*1e3,zd=720*60*1e3,Hd=500;function Na(e,t){if(!e)return t;let r=e.replace(/[^A-Za-z0-9._-]/g,"_");return r.length>0?r:t}function tn(e){$.mkdirSync(e,{recursive:true});let t=oe.join(e,as),r=oe.join(e,is),n=!$.existsSync(t);if(n)try{$.writeFileSync(t,`scratch-store
11
11
  ${new Date().toISOString()}
12
- `,"utf-8");}catch{}function s(){if(!C.existsSync(r))return {};try{let c=C.readFileSync(r,"utf-8"),d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function o(c){let d=`${r}.${process.pid}.${randomUUID()}.tmp`;try{C.writeFileSync(d,JSON.stringify(c,null,2),"utf-8"),ct(d,r);}catch{}}if(n){let c=s();typeof c["retention.lastSweepAt"]!="number"&&(c["retention.lastSweepAt"]=Date.now(),o(c));}function a(){if(!C.existsSync(t))return;let c=s(),d=typeof c["retention.maxAgeMs"]=="number"?c["retention.maxAgeMs"]:Kd,l=typeof c["retention.sweepIntervalMs"]=="number"?c["retention.sweepIntervalMs"]:Gd;if(d<=0||l<=0)return;let h=typeof c["retention.lastSweepAt"]=="number"?c["retention.lastSweepAt"]:0,v=Date.now();if(v-h<l)return;c["retention.lastSweepAt"]=v,o(c);let p=v;try{let m=C.readdirSync(e,{withFileTypes:!0});for(let b of m){if(Date.now()-p>Jd)break;if(!b.isFile()||b.name===os||b.name===as)continue;let R=te.join(e,b.name);try{let N=C.statSync(R);if(v-N.mtimeMs>d)try{C.unlinkSync(R);}catch{}}catch{}}}catch{}}function i(c,d){let l=ja(c,"scratch"),h=ja(d,".json"),v=h.startsWith(".")?h:`.${h}`,p=`${l}-${Date.now()}-${randomUUID().slice(0,8)}${v}`;return te.join(e,p)}function u(c,d){let l=`${c}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(c),{recursive:true}),C.writeFileSync(l,d,"utf-8"),ct(l,c);}return {read(c){if(!C.existsSync(c))return null;try{return C.readFileSync(c,"utf-8")}catch{return null}},write(c,d){u(c,d);try{a();}catch{}},exists(c){return C.existsSync(c)},remove(c){try{C.existsSync(c)&&C.unlinkSync(c);}catch{}},readBytes(c){if(!C.existsSync(c))return null;try{return new Uint8Array(C.readFileSync(c))}catch{return null}},writeBytes(c,d){let l=`${c}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(c),{recursive:true}),C.writeFileSync(l,Buffer.from(d)),ct(l,c);try{a();}catch{}},stat(c){if(!C.existsSync(c))return null;try{let d=C.statSync(c);return {key:c,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},listKeys(c){try{let d=C.readdirSync(e,{withFileTypes:!0}),l=[];for(let h of d){if(!h.isFile()||h.name===os||h.name===as)continue;let v=te.join(e,h.name);(!c||v.startsWith(c))&&l.push(v);}return l.sort()}catch{return []}},getUniqueKey(c,d){return i(c,d)},create(c,d,l){let h=i(d,l);u(h,c);try{a();}catch{}return h},keyRef(c){return {kind:"fs-path",value:c}},config:{get(c){return s()[c]??null},set(c,d){let l=s();d==null?delete l[c]:l[c]=d,o(l);}}}}var zd="__archive-marker",Hd="__archive-config.json",Xr="streams",Qr="blobs",Wd=500;function Oa(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_");if(!t)throw new Error("Archive segment name cannot be empty after sanitization");return t}function en(e){C.mkdirSync(e,{recursive:true}),C.mkdirSync(te.join(e,Xr),{recursive:true}),C.mkdirSync(te.join(e,Qr),{recursive:true});let t=te.join(e,zd),r=te.join(e,Hd);if(!C.existsSync(t))try{C.writeFileSync(t,`archive-store
12
+ `,"utf-8");}catch{}function s(){if(!$.existsSync(r))return {};try{let c=$.readFileSync(r,"utf-8"),d=JSON.parse(c);return d&&typeof d=="object"&&!Array.isArray(d)?d:{}}catch{return {}}}function o(c){let d=`${r}.${process.pid}.${randomUUID()}.tmp`;try{$.writeFileSync(d,JSON.stringify(c,null,2),"utf-8"),dt(d,r);}catch{}}if(n){let c=s();typeof c["retention.lastSweepAt"]!="number"&&(c["retention.lastSweepAt"]=Date.now(),o(c));}function a(){if(!$.existsSync(t))return;let c=s(),d=typeof c["retention.maxAgeMs"]=="number"?c["retention.maxAgeMs"]:Jd,l=typeof c["retention.sweepIntervalMs"]=="number"?c["retention.sweepIntervalMs"]:zd;if(d<=0||l<=0)return;let g=typeof c["retention.lastSweepAt"]=="number"?c["retention.lastSweepAt"]:0,v=Date.now();if(v-g<l)return;c["retention.lastSweepAt"]=v,o(c);let f=v;try{let m=$.readdirSync(e,{withFileTypes:!0});for(let b of m){if(Date.now()-f>Hd)break;if(!b.isFile()||b.name===as||b.name===is)continue;let C=oe.join(e,b.name);try{let q=$.statSync(C);if(v-q.mtimeMs>d)try{$.unlinkSync(C);}catch{}}catch{}}}catch{}}function i(c,d){let l=Na(c,"scratch"),g=Na(d,".json"),v=g.startsWith(".")?g:`.${g}`,f=`${l}-${Date.now()}-${randomUUID().slice(0,8)}${v}`;return oe.join(e,f)}function u(c,d){let l=`${c}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(c),{recursive:true}),$.writeFileSync(l,d,"utf-8"),dt(l,c);}return {read(c){if(!$.existsSync(c))return null;try{return $.readFileSync(c,"utf-8")}catch{return null}},write(c,d){u(c,d);try{a();}catch{}},exists(c){return $.existsSync(c)},remove(c){try{$.existsSync(c)&&$.unlinkSync(c);}catch{}},readBytes(c){if(!$.existsSync(c))return null;try{return new Uint8Array($.readFileSync(c))}catch{return null}},writeBytes(c,d){let l=`${c}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(c),{recursive:true}),$.writeFileSync(l,Buffer.from(d)),dt(l,c);try{a();}catch{}},stat(c){if(!$.existsSync(c))return null;try{let d=$.statSync(c);return {key:c,size:Number(d.size||0),updatedAt:new Date(d.mtimeMs).toISOString()}}catch{return null}},listKeys(c){try{let d=$.readdirSync(e,{withFileTypes:!0}),l=[];for(let g of d){if(!g.isFile()||g.name===as||g.name===is)continue;let v=oe.join(e,g.name);(!c||v.startsWith(c))&&l.push(v);}return l.sort()}catch{return []}},getUniqueKey(c,d){return i(c,d)},create(c,d,l){let g=i(d,l);u(g,c);try{a();}catch{}return g},keyRef(c){return {kind:"fs-path",value:c}},config:{get(c){return s()[c]??null},set(c,d){let l=s();d==null?delete l[c]:l[c]=d,o(l);}}}}var Wd="__archive-marker",Yd="__archive-config.json",Zr="streams",en="blobs",Xd=500;function qa(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_");if(!t)throw new Error("Archive segment name cannot be empty after sanitization");return t}function rn(e){$.mkdirSync(e,{recursive:true}),$.mkdirSync(oe.join(e,Zr),{recursive:true}),$.mkdirSync(oe.join(e,en),{recursive:true});let t=oe.join(e,Wd),r=oe.join(e,Yd);if(!$.existsSync(t))try{$.writeFileSync(t,`archive-store
13
13
  ${new Date().toISOString()}
14
- `,"utf-8");}catch{}function n(){if(!C.existsSync(r))return {};try{let a=C.readFileSync(r,"utf-8"),i=JSON.parse(a);return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return {}}}function s(a){let i=`${r}.${process.pid}.${randomUUID()}.tmp`;try{C.writeFileSync(i,JSON.stringify(a,null,2),"utf-8"),ct(i,r);}catch{}}function o(){if(!C.existsSync(t))return;let a=n(),i=typeof a["retention.maxAgeMs"]=="number"?a["retention.maxAgeMs"]:0,u=typeof a["retention.sweepIntervalMs"]=="number"?a["retention.sweepIntervalMs"]:0;if(i<=0||u<=0)return;let c=typeof a["retention.lastSweepAt"]=="number"?a["retention.lastSweepAt"]:0,d=Date.now();if(d-c<u)return;a["retention.lastSweepAt"]=d,s(a);let l=d,h=v=>{let p;try{p=C.readdirSync(v,{withFileTypes:!0});}catch{return}for(let m of p){if(Date.now()-l>Wd)return;let b=te.join(v,m.name);if(m.isDirectory()){h(b);continue}if(m.isFile())try{let R=C.statSync(b);if(d-R.mtimeMs>i)try{C.unlinkSync(b);}catch{}}catch{}}};h(te.join(e,Xr)),h(te.join(e,Qr));}return {stream(a){let i=Oa(a),u=te.join(e,Xr,`${i}.jsonl`),c=us(u);return {append(d){let l=c.append(d);try{o();}catch{}return l},readAll:()=>c.readAll(),readAfter:d=>c.readAfter(d),clear:()=>{c.clear&&c.clear();}}},blob(a){let i=Oa(a),u=te.join(e,Qr,i);C.mkdirSync(u,{recursive:true});let c=Ht(u);return {read:d=>c.read(d),write:(d,l)=>{c.write(d,l);try{o();}catch{}},exists:d=>c.exists(d),remove:d=>c.remove(d),readBytes:c.readBytes?d=>c.readBytes(d):void 0,writeBytes:c.writeBytes?(d,l)=>{c.writeBytes(d,l);try{o();}catch{}}:void 0,listKeys:d=>c.listKeys(d),stat:c.stat?d=>c.stat(d):void 0}},listStreams(a){let i=te.join(e,Xr);try{return C.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isFile()&&u.name.endsWith(".jsonl")).map(u=>u.name.slice(0,-6)).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},listBlobs(a){let i=te.join(e,Qr);try{return C.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isDirectory()).map(u=>u.name).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},config:{get(a){return n()[a]??null},set(a,i){let u=n();i==null?delete u[a]:u[a]=i,s(u);}}}}function tn(e){function t(n){return te.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if(C.existsSync(n))for(let i of C.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(te.join(n,i.name),u,o,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!o||c.startsWith(o))&&a.push(c);}}return {read(n){let s=t(n);if(!C.existsSync(s))return null;try{return JSON.parse(C.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${randomUUID()}.tmp`;C.mkdirSync(te.dirname(o),{recursive:true}),C.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),ct(a,o);},delete(n){let s=t(n);try{C.existsSync(s)&&C.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function us(e){function t(){if(!C.existsSync(e))return [];let r=C.readFileSync(e,"utf-8").trim();return r?r.split(`
15
- `).filter(Boolean).map(n=>JSON.parse(n)):[]}return {append(r){let n={id:randomUUID(),payload:r};return C.mkdirSync(te.dirname(e),{recursive:true}),C.appendFileSync(e,JSON.stringify(n)+`
16
- `,"utf-8"),n},readAll(){return t()},readAfter(r){let n=t();if(!r)return {entries:n,newCursor:n.length>0?n[n.length-1].id:null};let s=n.findIndex(a=>a.id===r),o=s===-1?n:n.slice(s+1);return {entries:o,newCursor:o.length>0?o[o.length-1].id:r}},clear(){C.existsSync(e)&&C.truncateSync(e,0);}}}function is(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(is).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${is(t[n])}`).join(",")}}`}function Pa(e){return createHash("sha256").update(is(e)).digest("hex")}function Na(e){let t=te.join(e,"board-journal.jsonl");return {readAllEntries(){if(!C.existsSync(t))return [];let r=C.readFileSync(t,"utf-8").trim();return r?r.split(`
17
- `).filter(Boolean).map(n=>JSON.parse(n)):[]},appendEntry(r){C.appendFileSync(t,JSON.stringify(r)+`
18
- `,"utf-8");},generateId(){return randomUUID()}}}function qa(e){return {tryAcquire(){try{if(!C.existsSync(e)){C.mkdirSync(te.dirname(e),{recursive:!0});try{C.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return lockSync(e,{retries:0})}catch{return null}}}}var Fa={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var pu=md(du());var Eh=createRequire(import.meta.url),$h=Eh("./jsonata-sync.cjs"),Fn=null;var lu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,xh=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Ah(e){let t=new Set,r;for(lu.lastIndex=0;(r=lu.exec(e))!==null;)t.add(r[1]);return t}function mu(e){let t=xh.exec(e);return t?t[1]:null}function fu(e,t,r,n){try{$h(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Ah(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function Wo(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{Wo(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=mu(e);if(!s)return;new Set(["card_data","requires","computed_values"]).has(s)||r.push(`${t}: disallowed namespace "${s}" in view reference`);return}if(!e||typeof e!="object")return;let n=e;for(let[s,o]of Object.entries(n))Wo(o,`${t}/${s}`,r);}function Th(){if(Fn)return Fn;let e=new pu.default({allErrors:true});return Rh(e),Fn=e.compile(Fa),Fn}function gu(e){let t=Th(),r=t(e),n=(t.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.source_defs;if(Array.isArray(s)){let o=new Set,a=new Set;s.forEach((i,u)=>{if(!i||typeof i!="object"||Array.isArray(i))return;let c=i;typeof c.bindTo=="string"&&c.bindTo&&(o.has(c.bindTo)&&n.push(`/source_defs/${u}/bindTo: bindTo "${c.bindTo}" must be unique across all source_defs`),o.add(c.bindTo)),typeof c.outputFile=="string"&&c.outputFile&&(a.has(c.outputFile)&&n.push(`/source_defs/${u}/outputFile: outputFile "${c.outputFile}" must be unique across all source_defs`),a.add(c.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function hu(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let r=e,n=r.compute;Array.isArray(n)&&n.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.expr;typeof l!="string"||l.trim().length===0||fu(l,`/compute/${d}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let s=new Set(["card_data","requires","fetched_sources","computed_values"]),o=r.provides;Array.isArray(o)&&o.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.ref;if(typeof l!="string"||l.trim().length===0)return;let h=mu(l);h===null?t.push(`/provides/${d}/ref: path "${l}" must start with a valid namespace (${[...s].join(", ")})`):s.has(h)||t.push(`/provides/${d}/ref: disallowed namespace "${h}" in path "${l}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Wo(a,"/view",t);let i=new Set(["card_data","requires"]),u=r.source_defs;return Array.isArray(u)&&u.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.projections;if(!(!l||typeof l!="object"||Array.isArray(l)))for(let[h,v]of Object.entries(l))typeof v!="string"||v.trim().length===0||fu(v,`/source_defs/${d}/projections/${h}`,i,t);}),{ok:t.length===0,errors:t}}function Yo(e){let t=gu(e);if(!t.ok)return t;let r=hu(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}function yu(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function vu(e){let t=e.payload??{};return {id:e.id,role:typeof t.role=="string"?t.role:"system",text:typeof t.text=="string"?t.text:"",files:Array.isArray(t.files)?t.files:[],turn:typeof t.turn=="string"?t.turn:"",updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function Xo(e,t){let r=s=>`chats/${yu(s)}/processing`,n=s=>`chats/${yu(s)}/config`;return {append(s,o,a,i=[],u=""){return e(s).append({role:o,text:a,files:i,turn:u,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(vu)},readAfter(s,o){let a=e(s).readAfter(o);return {records:a.entries.map(vu),cursor:a.newCursor}},clear(s){e(s).clear?.();},setProcessing(s,o){o?t.write(r(s),true):t.delete(r(s));},isProcessing(s){return t.read(r(s))===true},getConfig(s){return t.read(n(s))??{}},setConfig(s,o){let a=t.read(n(s))??{};t.write(n(s),{...a,...o});}}}function Ih(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function jh(){let e=new Map,t=new Map;function r(n){return e.has(n)||e.set(n,[]),e.get(n)}return {append(n,s,o,a=[],i=""){let u={id:Ih(),role:s,text:o,files:a,turn:i,updated_at:new Date().toISOString()};return r(n).push(u),u.id},readAll(n){return r(n).slice()},readAfter(n,s){let o=r(n);if(!s)return {records:o.slice(),cursor:o.length>0?o[o.length-1].id:null};let a=o.findIndex(u=>u.id===s),i=a===-1?o.slice():o.slice(a+1);return {records:i,cursor:i.length>0?i[i.length-1].id:s}},clear(n){e.set(n,[]);},setProcessing(n,s){s?t.set(`p:${n}`,true):t.delete(`p:${n}`);},isProcessing(n){return t.get(`p:${n}`)===true},getConfig(n){return t.get(`c:${n}`)??{}},setConfig(n,s){let o=t.get(`c:${n}`)??{};t.set(`c:${n}`,{...o,...s});}}}var Rt={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function Be(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function Ct(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function Su(e){return e.tasks??{}}function Qo(e){return e?e.status===Rt.FAILED||e.status===Rt.INACTIVATED:false}function wu(e,t){return e.refreshStrategy??t?.refreshStrategy??"data-changed"}function bu(e){return e.maxExecutions}function ku(e,t){let r=new Set;for(let[n,s]of Object.entries(t))if(s.status===Rt.COMPLETED){let o=e.tasks[n];o&&Be(o).forEach(i=>r.add(i));}return Array.from(r)}function _u(e,t){let r={};return e.forEach(n=>{let s=t[n];if(!s)return;Be(s).forEach(a=>{r[a]||(r[a]=[]),r[a].push(n);});}),r}function Ru(e,t,r){let n=e.tasks[t]??Dn(),s={};if(r){let a=r.tasks[t],i=Ct(a);for(let u of i)for(let[c,d]of Object.entries(r.tasks))if(Be(d).includes(u)){let l=e.tasks[c];l?.lastDataHash&&(s[u]=l.lastDataHash);break}}let o={...n,status:"running",startedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),progress:0,error:void 0,startConsumedHashes:s};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function Cu(e,t,r,n,s,o){let a=e.tasks[r]??Dn(),i=t.tasks[r];if(!i)throw new Error(`Task "${r}" not found in graph`);let u;n&&i.on&&i.on[n]?u=i.on[n]:u=Be(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let h=i.requires??[];for(let v of h)for(let[p,m]of Object.entries(t.tasks))if(Be(m).includes(v)){let b=e.tasks[p];b?.lastDataHash&&(c[v]=b.lastDataHash);break}}let d={...a,status:"completed",completedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),executionCount:a.executionCount+1,lastEpoch:a.executionCount+1,lastDataHash:s,data:o,lastConsumedHashes:c,error:void 0},l=[...new Set([...e.availableOutputs,...u])];return {...e,tasks:{...e.tasks,[r]:d},availableOutputs:l,lastUpdated:new Date().toISOString()}}function Eu(e,t,r,n){let s=e.tasks[r]??Dn(),o=t.tasks[r];if(o?.retry){let u=s.retryCount+1;if(u<=o.retry.max_attempts){let c={...s,status:"not-started",retryCount:u,lastUpdated:new Date().toISOString(),error:n};return {...e,tasks:{...e.tasks,[r]:c},lastUpdated:new Date().toISOString()}}}let a={...s,status:"failed",failedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),error:n,executionCount:s.executionCount+1},i=e.availableOutputs;if(o?.on_failure&&o.on_failure.length>0&&(i=[...new Set([...e.availableOutputs,...o.on_failure])]),o?.circuit_breaker&&a.executionCount>=o.circuit_breaker.max_executions){let u=o.circuit_breaker.on_break;i=[...new Set([...i,...u])];}return {...e,tasks:{...e.tasks,[r]:a},availableOutputs:i,lastUpdated:new Date().toISOString()}}function $u(e,t,r,n){let s=e.tasks[t]??Dn(),o={...s,progress:typeof n=="number"?n:s.progress,messages:[...s.messages??[],...r?[{message:r,timestamp:new Date().toISOString(),status:s.status}]:[]],lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function xu(e,t){let r=e.tasks[t];if(!r)return e;let n={...r,status:"not-started",startedAt:void 0,completedAt:void 0,failedAt:void 0,error:void 0,data:void 0,progress:null,lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:n},lastUpdated:new Date().toISOString()}}function Dn(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Mn(e,t){let r=`live-${Date.now()}`,n={};for(let o of Object.keys(e.tasks))n[o]=Tu();let s={status:"running",tasks:n,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:r,executionConfig:{executionMode:e.settings.execution_mode??"eligibility-mode",conflictStrategy:e.settings.conflict_strategy??"alphabetical",completionStrategy:e.settings.completion}};return {config:e,state:s}}function Oh(e,t){let{config:r,state:n}=e;if("executionId"in t&&t.executionId&&t.executionId!==n.executionId)return e;switch(t.type){case "task-started":return {config:r,state:Ru(n,t.taskName,r)};case "task-completed":return {config:r,state:Cu(n,r,t.taskName,t.result,t.dataHash,t.data)};case "task-failed":return {config:r,state:Eu(n,r,t.taskName,t.error)};case "task-progress":return {config:r,state:$u(n,t.taskName,t.message,t.progress)};case "task-restart":return {config:r,state:xu(n,t.taskName)};case "inject-tokens":return {config:r,state:{...n,availableOutputs:[...new Set([...n.availableOutputs,...t.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:r,state:Lh(n,t.action)};case "task-upsert":return Ph(e,t.taskName,t.taskConfig);case "task-removal":return Nh(e,t.taskName);case "node-requires-add":return qh(e,t.nodeName,t.tokens);case "node-requires-remove":return Fh(e,t.nodeName,t.tokens);case "node-provides-add":return Dh(e,t.nodeName,t.tokens);case "node-provides-remove":return Mh(e,t.nodeName,t.tokens);default:return e}}function Au(e,t){return t.reduce((r,n)=>Oh(r,n),e)}function Ph(e,t,r){let n=!!e.config.tasks[t];return {config:{...e.config,tasks:{...e.config.tasks,[t]:r}},state:{...e.state,tasks:{...e.state.tasks,[t]:n?e.state.tasks[t]:Tu()},lastUpdated:new Date().toISOString()}}}function Nh(e,t){if(!e.config.tasks[t])return e;let{[t]:r,...n}=e.config.tasks,{[t]:s,...o}=e.state.tasks;return {config:{...e.config,tasks:n},state:{...e.state,tasks:o,lastUpdated:new Date().toISOString()}}}function qh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ct(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:[...s,...o]}}},state:e.state}}function Fh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ct(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:o}}},state:e.state}}function Dh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Be(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:[...s,...o]}}},state:e.state}}function Mh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Be(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:o}}},state:e.state}}function Mr(e){return {version:1,config:e.config,state:e.state,snapshotAt:new Date().toISOString()}}function Ln(e){if(!e||typeof e!="object")throw new Error("Invalid snapshot: expected an object");let t=e;if(!t.config||typeof t.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!t.state||typeof t.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let r=t.config,n=t.state;if(!r.settings||typeof r.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!r.tasks||typeof r.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!n.tasks||typeof n.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(n.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:r,state:n}}function Tu(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Lh(e,t){let r=new Date().toISOString();switch(t){case "stop":return {...e,status:"stopped",lastUpdated:r};case "pause":return {...e,status:"paused",lastUpdated:r};case "resume":return {...e,status:"running",lastUpdated:r};default:return e}}function Lr(e){let{config:t,state:r}=e,n=Su(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=Bh(n),a=ku(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],d=[],l=[];for(let[v,p]of Object.entries(n)){let m=r.tasks[v],b=wu(p,t.settings),R=b!=="once";if(m?.status===Rt.RUNNING||Qo(m))continue;let N=bu(p);if(N!==void 0&&m&&m.executionCount>=N||p.circuit_breaker&&m&&m.executionCount>=p.circuit_breaker.max_executions||!R&&m?.status===Rt.COMPLETED)continue;if(R&&m?.status===Rt.COMPLETED){let f=Ct(p),g=false;switch(b){case "data-changed":{f.length>0&&f.some(x=>{for(let[E,T]of Object.entries(n))if(Be(T).includes(x)){let O=r.tasks[E];if(!O)continue;let Z=m.lastConsumedHashes?.[x];return O.lastDataHash==null?O.executionCount>m.lastEpoch:O.lastDataHash!==Z}return false})||(g=true);break}case "epoch-changed":{f.length>0&&f.some(x=>{for(let[E,T]of Object.entries(n))if(Be(T).includes(x)){let O=r.tasks[E];if(O&&O.executionCount>m.lastEpoch)return true}return false})||(g=true);break}case "time-based":{let k=p.refreshInterval??0;if(k<=0){g=true;break}let x=m.completedAt;if(!x){g=true;break}(Date.now()-Date.parse(x))/1e3<k&&(g=true);break}case "manual":g=true;break}if(g)continue}let _=Ct(p);if(_.length===0){u.push(v);continue}let A=[],S=[],w=[];for(let f of _){if(i.has(f))continue;let g=o[f]||[];g.length===0?A.push(f):g.every(x=>Qo(r.tasks[x]))?w.push({token:f,failedProducer:g[0]}):S.push(f);}A.length>0?d.push({taskName:v,missingTokens:A}):w.length>0?l.push({taskName:v,failedTokens:w.map(f=>f.token),failedProducers:[...new Set(w.map(f=>f.failedProducer))]}):S.length>0?c.push({taskName:v,waitingOn:S}):u.push(v);}let h={};if(u.length>1){let v=_u(u,n);for(let[p,m]of Object.entries(v))m.length>1&&(h[p]=m);}return {eligible:u,pending:c,unresolved:d,blocked:l,conflicts:h}}function Bh(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of Be(n))t[s]||(t[s]=[]),t[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)t[o]||(t[o]=[]),t[o].includes(r)||t[o].push(r);if(n.on_failure)for(let s of n.on_failure)t[s]||(t[s]=[]),t[s].includes(r)||t[s].push(r);}return t}var Br=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function Zo(e){let t=ea(e);return Vh(t)}function ea(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(ea).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+ea(t[n])).join(",")+"}"}function Vh(e){let t=0xcbf29ce484222325n,r=0x100000001b3n,n=0xffffffffffffffffn;for(let s=0;s<e.length;s++)t^=BigInt(e.charCodeAt(s)),t=t*r&n;return t.toString(16).padStart(16,"0")}function Uh(e){if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64url");if(typeof btoa=="function"){let t=new TextEncoder().encode(e),r="";for(let n of t)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function Kh(e){if(typeof Buffer<"u")return Buffer.from(e,"base64url").toString("utf8");if(typeof atob=="function"){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function Iu(e){let t=JSON.stringify({t:e,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return Uh(t)}function Gh(e){try{let t=JSON.parse(Kh(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function ju(e,t,r){let{handlers:n,onNodeRemoved:s,onDrain:o}=t,a=new Br,i="state"in e&&"config"in e?e:Mn(e),u=false,c=new Set,d=new Map(Object.entries(n)),l=new Br,h=false,v=false;function p(){if(!u){if(h){v=true;return}h=true;try{do v=!1,m();while(v)}finally{h=false;}}}function m(){let _=l.drain(),A=a.drain(),S=[..._,...A];if(S.length>0&&(i=Au(i,S),s)){for(let f of S)if(f.type==="task-removal")try{s(f.taskName);}catch(g){console.warn("[reactive] onNodeRemoved failed:",g instanceof Error?g.message:String(g));}}let w=Lr(i);S.length>0&&o?.(S,i,w);for(let f of w.eligible)N(f);for(let f of S)if(f.type==="task-progress"){let{taskName:g,update:k}=f;if(!i.config.tasks[g])continue;let E=i.state.tasks[g];if(!E||E.status!=="running")continue;let T=Iu(g),O=R(g,T,k).catch(Z=>{u||(l.append({type:"task-failed",taskName:g,error:Z.message??String(Z),timestamp:new Date().toISOString()}),p());}).finally(()=>{c.delete(O);});c.add(O);}}function b(_){let S=i.config.tasks[_].requires??[],w=new Map;for(let[g,k]of Object.entries(i.config.tasks))for(let x of k.provides??[])w.set(x,g);let f={};for(let g of S){let k=w.get(g);k?f[g]=i.state.tasks[k]?.data:f[g]=void 0;}return f}async function R(_,A,S){let w=i.config.tasks[_],f=w.taskHandlers??[],g=b(_);for(let k of f){let x=d.get(k);if(!x)throw new Error(`Handler '${k}' not found in registry (task '${_}')`);let E={nodeId:_,state:g,taskState:i.state.tasks[_],config:w,callbackToken:A,update:S};if(await x(E)==="task-initiate-failure")throw new Error(`Handler '${k}' returned task-initiate-failure (task '${_}')`)}}function N(_){let S=i.config.tasks[_]?.taskHandlers;if(!S||S.length===0)return;l.append({type:"task-started",taskName:_,timestamp:new Date().toISOString()}),p();let w=Iu(_),f=R(_,w).catch(g=>{u||(l.append({type:"task-failed",taskName:_,error:g.message??String(g),timestamp:new Date().toISOString()}),p());}).finally(()=>{c.delete(f);});c.add(f);}return {push(_){u||(_.type==="task-completed"&&_.data&&!_.dataHash&&(_={..._,dataHash:Zo(_.data)}),a.append(_),p());},pushAll(_){if(!u){for(let A of _)A.type==="task-completed"&&A.data&&!A.dataHash?a.append({...A,dataHash:Zo(A.data)}):a.append(A);p();}},resolveCallback(_,A,S){if(u)return;let w=Gh(_);if(!w)return;let{taskName:f}=w;if(i.config.tasks[f]){if(S&&S.length>0)a.append({type:"task-failed",taskName:f,error:S.join("; "),timestamp:new Date().toISOString()});else {let g=A&&Object.keys(A).length>0?Zo(A):void 0;a.append({type:"task-completed",taskName:f,data:A,dataHash:g,timestamp:new Date().toISOString()});}p();}},addNode(_,A){u||(a.append({type:"task-upsert",taskName:_,taskConfig:A,timestamp:new Date().toISOString()}),p());},removeNode(_){u||(a.append({type:"task-removal",taskName:_,timestamp:new Date().toISOString()}),p());},addRequires(_,A){u||(a.append({type:"node-requires-add",nodeName:_,tokens:A,timestamp:new Date().toISOString()}),p());},removeRequires(_,A){u||(a.append({type:"node-requires-remove",nodeName:_,tokens:A,timestamp:new Date().toISOString()}),p());},addProvides(_,A){u||(a.append({type:"node-provides-add",nodeName:_,tokens:A,timestamp:new Date().toISOString()}),p());},removeProvides(_,A){u||(a.append({type:"node-provides-remove",nodeName:_,tokens:A,timestamp:new Date().toISOString()}),p());},registerHandler(_,A){d.set(_,A);},unregisterHandler(_){d.delete(_);},retrigger(_){u||i.config.tasks[_]&&(a.append({type:"task-restart",taskName:_,timestamp:new Date().toISOString()}),p());},retriggerAll(_){if(!u){for(let A of _)i.config.tasks[A]&&a.append({type:"task-restart",taskName:A,timestamp:new Date().toISOString()});p();}},snapshot(){return Mr(i)},getState(){return i},getSchedule(){return Lr(i)},async waitForHandlers(){c.size>0&&await Promise.allSettled([...c]);},async dispose(_){_?.wait&&c.size>0&&await Promise.allSettled([...c]),u=true;}}}var zh=createRequire(import.meta.url),Bn=zh("./jsonata-sync.cjs"),Nu=Bn;function Ou(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let s=0;s<r.length;s++){if(n==null)return;n=n[r[s]];}return n}function qu(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++)(s[n[o]]==null||typeof s[n[o]]!="object")&&(s[n[o]]={}),s=s[n[o]];s[n[n.length-1]]=r;}async function Hh(e,t){if(!e?.compute?.length)return e;e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values};for(let s of e.compute)try{let o=await Bn(s.expr).evaluate(n);qu(e.computed_values,s.bindTo,o),n.computed_values=e.computed_values;}catch{}return e}function Wh(e,t){if(!e?.compute?.length)return {ok:true,node:e};e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values},s=[];for(let o of e.compute)try{let a=Nu(o.expr).evaluate(n);qu(e.computed_values,o.bindTo,a),n.computed_values=e.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);s.push({bindTo:o.bindTo,error:i});}return s.length>0?{ok:true,node:e,errors:s}:{ok:true,node:e}}async function Yh(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return Bn(e).evaluate(n)}function Xh(e,t){return t.startsWith("fetched_sources.")?Ou(e._sourcesData??{},t.slice(16)):Ou(e,t)}var Pu=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),Qh=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function Zh(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:false,errors:["Node must be a non-null object"]};let r=e;(typeof r.id!="string"||!r.id)&&t.push("id: required, must be a non-empty string");for(let n of Object.keys(r))Qh.has(n)||t.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&t.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))t.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&t.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&t.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&t.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`provides[${s}]: must be an object with bindTo and ref`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`provides[${s}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&t.push(`provides[${s}]: missing required "ref" string`);}}):t.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`compute[${s}]: must be a compute step object`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`compute[${s}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&t.push(`compute[${s}]: missing required "expr" string (JSONata expression)`);}}):t.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))t.push("source_defs: must be an array");else {let n=new Set,s=new Set;r.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))t.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?t.push(`source_defs[${a}]: missing required "bindTo" property`):(n.has(i.bindTo)&&t.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),n.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?t.push(`source_defs[${a}]: missing required "outputFile" property`):(s.has(i.outputFile)&&t.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),s.add(i.outputFile)),i.optionalForCompletionGating!=null&&typeof i.optionalForCompletionGating!="boolean"&&t.push(`source_defs[${a}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))t.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?t.push("view.elements: required, must be a non-empty array"):n.elements.forEach((s,o)=>{if(!s||typeof s!="object"){t.push(`view.elements[${o}]: must be an object`);return}!s.kind||typeof s.kind!="string"?t.push(`view.elements[${o}].kind: required, must be a string`):Pu.has(s.kind)||t.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...Pu].join(", ")}`),s.data!=null&&(typeof s.data!="object"||Array.isArray(s.data))&&t.push(`view.elements[${o}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&t.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&t.push("view.features: must be an object");}return {ok:t.length===0,errors:t}}async function ey(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return Promise.all(e.map(async n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=await Bn(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function ty(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return e.map(n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=Nu(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var Et={run:Hh,runSync:Wh,eval:Yh,resolve:Xh,validate:Zh,enrichSources:ey,enrichSourcesSync:ty};function ry(e,t){let r;return /\.m?js$/i.test(e)?r="local-node":/\.py$/i.test(e)?r="local-python":r="local-process",{meta:"task-executor",howToRun:r,whatToRun:pe({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function ta(e){return JSON.stringify(e)}function ra(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}function Vn(e,t){function r(){return e.readIndex()??{}}function n(s,o,a){let i=String(o||"").split(".").filter(Boolean);if(i.length===0)return a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a};let u={...s},c=u;for(let d=0;d<i.length-1;d++){let l=i[d],h=c[l],v=h&&typeof h=="object"&&!Array.isArray(h)?{...h}:{};c[l]=v,c=v;}return c[i[i.length-1]]=a,u}return {readCard(s){let o=r()[s];return !o||!e.cardExists(o.key)?null:e.readCard(o.key)},readCardKey(s){return r()[s]?.key??null},readAllCards(){let s=[];for(let[o,a]of Object.entries(r())){if(!e.cardExists(a.key))continue;let i=e.readCard(a.key);i?s.push(i):t?.(`[card-store] could not read card "${o}" at key "${a.key}"`);}return s},readChecksumIndex(){let s={};for(let[o,a]of Object.entries(r()))s[o]=a.checksum;return s},changedSince(s){let o=r(),a=[];for(let[i,u]of Object.entries(o))s[i]!==u.checksum&&a.push(i);for(let i of Object.keys(s))o[i]||a.push(i);return a},validateUpsert(s,o){let a=r(),i=a[s],u=Object.entries(a).find(([,c])=>c.key===o);return i&&i.key!==o?{ok:false,error:`Card id "${s}" is already mapped to key "${i.key}", cannot remap to "${o}"`}:u&&u[0]!==s?{ok:false,error:`Key "${o}" is already mapped to card id "${u[0]}", cannot remap to "${s}"`}:{ok:true}},writeCard(s,o,a){let i=r(),u=a??i[s]?.key??e.defaultCardKey(s),c=e.writeCard(u,o);i[s]={key:u,checksum:c,updatedAt:new Date().toISOString()},e.writeIndex(i);},patchCard(s,o,a){let i=r(),u=i[s];if(!u||!e.cardExists(u.key))throw new Error(`card "${s}" not found`);let c=e.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${s}" is not patchable`);let d=n(c,o,a),l=e.writeCard(u.key,d);i[s]={key:u.key,checksum:l,updatedAt:new Date().toISOString()},e.writeIndex(i);},removeCard(s){let o=r(),a=o[s];a&&(e.removeCard(a.key),delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function Un(e,t){return {readSourceData(r,n){let s=e.read(`${r}/${n}`);if(s==null)return null;let o=s.trim();if(!o)return null;try{return JSON.parse(o)}catch{return o}},ingestSourceDataStaged(r,n,s,o){let a=t(s);e.write(`${r}/.staged/${o}/${n}`,a);},commitSourceData(r,n,s){let o=`${r}/.staged/${s}/${n}`,a=e.read(o);return a==null?false:(e.write(`${r}/${n}`,a),e.remove(o),true)},hasSource(r,n){return e.exists(`${r}/${n}`)},listSources(r){return e.listKeys(`${r}/`).filter(n=>!n.includes("/.staged/")).map(n=>n.slice(`${r}/`.length))}}}function Bu(e){function t(r){let n=e.readAllEntries();if(!r)return n;let s=n.findIndex(o=>o.id===r);return s===-1?n:n.slice(s+1)}return {readEntriesAfterCursor(r){let n=t(r);return n.length===0?{events:[],newCursor:r}:{events:n.map(s=>s.event),newCursor:n[n.length-1].id}},pendingCount(r){return t(r).length},appendEvent(r){e.appendEntry({id:e.generateId(),event:r});}}}function Vu(e,t){return {appendEntries(r,n){if(!r||n.length===0)return;let s=e.read(r)??[];e.write(r,[...s,...n]);},dispatchEntriesForJournalId(r,n){if(!r)return;let s=e.read(r);if(!(!s||s.length===0)){for(let o of s)try{n(o);}catch(a){let i=a instanceof Error?a.message:String(a);try{t(o,i);}catch{}}e.delete(r);}}}}var Vr="v1",$t="board/graph",Uu="board/lastJournalProcessedId";function Fu(e){return `cards/${e}/runtime`}function Ku(e){return {readRuntime(t){return e.read(Fu(t))??{_sources:{}}},writeRuntime(t,r){e.write(Fu(t),r);}}}function ny(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function Gu(e){return {readSnapshot(t){return e.readValues(t)},commitSnapshot(t,r){if(r.schemaVersion!==Vr)throw new Error(`Unsupported snapshot schema version: ${r.schemaVersion}`);let n=e.readValues(t);if(n.version!==r.expectedVersion)return {ok:false,reason:"version-mismatch",currentVersion:n.version};let s=ny(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function na(e){function t(r){let n=e.read(r);return n==null?null:typeof n=="string"?n:JSON.stringify(n)}return {readTaskExecutorRef(){let r=t("task-executor");if(r?.trim())return ra(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",ta(r));},readChatHandlerFlow(){return e.read("chat-handler-flow")},writeChatHandlerFlow(r){e.write("chat-handler-flow",r);},readCardStoreRef(){return t("card-store-ref")},writeCardStoreRef(r){e.write("card-store-ref",r);},readOutputsStoreRef(){return t("outputs-store-ref")},writeOutputsStoreRef(r){e.write("outputs-store-ref",r);},readScratchStoreRef(){return t("scratch-store-ref")},writeScratchStoreRef(r){e.write("scratch-store-ref",r);},readArchiveStoreRef(){return t("archive-store-ref")},writeArchiveStoreRef(r){e.write("archive-store-ref",r);},readChatStoreRef(){return t("chat-store-ref")},writeChatStoreRef(r){e.write("chat-store-ref",r);},readArtifactsStoreRef(){return t("artifacts-store-ref")},writeArtifactsStoreRef(r){e.write("artifacts-store-ref",r);}}}function Ju(e){return {writeComputedValues(t,r){e.write(`cards/${t}/computed_values`,r);},readComputedValues(t){return e.read(`cards/${t}/computed_values`)},readAllComputedValues(){let t={};for(let r of e.listKeys("cards/")){let n=r.match(/^cards\/([^/]+)\/computed_values$/);n&&(t[n[1]]=e.read(r));}return t},writeDataObjects(t){for(let[r,n]of Object.entries(t))r&&e.write(`data-objects/${r}`,n);},readDataObject(t){return e.read(`data-objects/${t}`)},readAllDataObjects(){let t={};for(let r of e.listKeys("data-objects/"))t[r.slice(13)]=e.read(r);return t},writeStatusSnapshot(t){e.write("status",t);},readStatusSnapshot(){return e.read("status")}}}function Du(e){return e?{lastRequestedToken:e.lastRequestedToken,lastCompletedToken:e.lastCompletedToken,lastCompletionStatus:e.lastCompletionStatus??(e.lastCompletedToken?"success":"not-started"),queueRequestedToken:e.queueRequestedToken}:{lastCompletionStatus:"not-started"}}function sy(e){return e?.lastRequestedToken?e.lastCompletedToken!==e.lastRequestedToken:false}function Mu(e,t){return e?.lastRequestedToken?sy(e)?"in-flight":!e.lastCompletedToken||e.lastCompletedToken<t?"dispatch":"idle":"dispatch"}function oy(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"success"}}function Lu(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"failure"}}function Kn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=Lr(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let p of o.pending)i.set(p.taskName,p.waitingOn);for(let p of o.unresolved)i.set(p.taskName,p.missingTokens);for(let p of o.blocked)i.set(p.taskName,p.failedTokens);let u=new Map;for(let[p,m]of Object.entries(n))for(let b of m.requires??[]){let R=u.get(b)??[];R.push(p),u.set(b,R);}let c=s.sort().map(p=>{let m=r[p],b=n[p]??{requires:[],provides:[]};m.status==="completed"?a.completed+=1:m.status==="failed"?a.failed+=1:m.status==="in-progress"&&(a.in_progress+=1);let R=b.requires??[],N=b.provides??[],_=Object.keys(m.data??{}).sort(),A=R.filter(x=>t.state.availableOutputs.includes(x)),S=R.filter(x=>!t.state.availableOutputs.includes(x)),w=i.get(p)??S,f=new Set;for(let x of N)for(let E of u.get(x)??[])E!==p&&f.add(E);let g=m.failedAt,k=m.error?{message:m.error,code:"TASK_FAILED",at:g,source:"task-runtime"}:void 0;return {name:p,status:m.status,error:k,requires:R,requires_satisfied:A,requires_missing:S,provides_declared:N,provides_runtime:_,blocked_by:w,unblocks:Array.from(f).sort(),runtime:{attempt_count:m.executionCount??0,restart_count:m.retryCount??0,in_progress_since:m.status==="in-progress"?m.startedAt??null:null,last_transition_at:m.lastUpdated??null,last_completed_at:m.completedAt??null,last_restarted_at:m.startedAt??null,status_age_ms:m.lastUpdated?0:null}}});a.pending=o.pending.length,a.blocked=o.blocked.length,a.unresolved=o.unresolved.length;let d=c.map(p=>({name:p.name,fanOut:p.unblocks.length})).sort((p,m)=>m.fanOut-p.fanOut||p.name.localeCompare(m.name)),l=d.length>0?d[0]:{name:null,fanOut:0},h=new Set;for(let p of Object.values(n))for(let m of p.requires??[])h.add(m);let v=0;for(let[p,m]of Object.entries(n)){let b=(m.requires??[]).length===0,N=(m.provides??[]).some(_=>(u.get(_)??[]).some(A=>A!==p));b&&!N&&(v+=1);}return {schema_version:"v1",meta:{board:{path:e}},summary:{card_count:s.length,completed:a.completed,eligible:o.eligible.length,pending:a.pending,blocked:a.blocked,unresolved:a.unresolved,failed:a.failed,in_progress:a.in_progress,orphan_cards:v,topology:{edge_count:Array.from(h).length,max_fan_out_card:l.name,max_fan_out:l.fanOut}},cards:c}}function ay(){return new Date().toISOString()}function zu(e,t,r,n,s,o,a){return async i=>{let u=[],c=r.cardStore.readCard(i.nodeId);if(!c)return "task-initiate-failure";let d=c.id,l=c.card_data??{},h=c.source_defs??[],v=h.filter(D=>D.optionalForCompletionGating!==true),p=r.cardRuntimeStore.readRuntime(d),m=false,b=()=>{m&&(r.cardRuntimeStore.writeRuntime(d,p),m=false);},R=D=>Du(p._sources[D]),N=(D,B)=>{p._sources[D]=Du(B),m=true;},_=i.taskState?.executionCount??0;if(p._lastExecutionCount!==_&&(p._sources={},p._lastExecutionCount=_,m=true),i.update){let D=i.update,B=D.outputFile;if(B){let M=R(B);if(D.failure){let oe=D.rqt??M.lastRequestedToken??M.queueRequestedToken;oe&&N(B,Lu(M,oe));}else {let oe=D.rqt;if(!M.lastCompletedToken||oe>M.lastCompletedToken){let de=typeof D.deliveryToken=="string"?D.deliveryToken:void 0,J=false;de&&(J=r.fetchedSourcesStore.commitSourceData(d,B,de)),J?N(B,oy(M,oe)):N(B,Lu(M,oe));}}b();}}let S={};for(let D of h)if(D.outputFile){let B=r.fetchedSourcesStore.readSourceData(d,D.outputFile);B!==null&&(S[D.bindTo]=B);}let w={};for(let[D,B]of Object.entries(i.state??{}))if(B!==null&&typeof B=="object"&&!Array.isArray(B)){let M=B[D];w[D]=M!==void 0?M:B;}else w[D]=B;let f={id:d,card_data:{...l},requires:w,source_defs:h,compute:c.compute};f._sourcesData=S,c.compute&&Et.runSync(f,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(d,f.computed_values??{});let g={...c},k=Et.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:w}),x=e.value;g.source_defs=Array.isArray(k)?k.map(D=>({...D,boardDir:typeof D.boardDir=="string"&&D.boardDir?D.boardDir:x})):k;let E=ay(),T=i.update?void 0:E,O=v.filter(D=>{let B=D.outputFile;if(typeof B!="string"||!B)return true;let M=R(B);T&&(M={...M,queueRequestedToken:T},N(B,M));let oe=M.queueRequestedToken??M.lastRequestedToken??E,de=Mu(M,oe);return de==="in-flight"?false:de==="dispatch"});if(b(),O.length>0){let D=false,B=E;for(let M of O){let oe=M.outputFile;if(typeof oe!="string"||!oe)continue;let de=R(oe),J=de.queueRequestedToken??E;N(oe,{...de,lastRequestedToken:J}),B=J,D=true;}return D&&b(),D&&(u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:g,callbackToken:i.callbackToken,rqt:B}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}if(v.some(D=>{let B=D.outputFile;if(typeof B!="string"||!B)return false;let M=R(B),oe=M.queueRequestedToken??M.lastRequestedToken??E;return Mu(M,oe)==="in-flight"}))return "task-initiated";let K=c.provides??[],ie={};for(let{bindTo:D,ref:B}of K)ie[D]=Et.resolve(f,B);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(ie),h.filter(D=>{if(D.optionalForCompletionGating!==true)return false;let B=R(D.outputFile);return !B.lastRequestedToken||!B.lastCompletedToken?true:B.lastCompletedToken<=B.lastRequestedToken}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:g,callbackToken:i.callbackToken,rqt:E}}),n(i.nodeId,ie),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var Gn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function Hu(e){return {[$t]:e.graph,[Uu]:e.lastDrainedJournalId}}function Wu(e){let t=e[$t],r=e[Uu];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${$t}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Yu(e){let t=e.requires,r=e.provides?.map(n=>n.bindTo)??[];return {requires:t&&t.length>0?t:void 0,provides:r,taskHandlers:["card-handler"],description:e.meta?.title??e.id}}function sa(e){function t(o){return {status:"success",data:o}}function r(o){return {status:"fail",error:o}}function n(o){return {status:"error",error:o instanceof Error?o.message:String(o)}}function s(o){if(Array.isArray(o))return o;if(o&&typeof o=="object"){let a=o;return Array.isArray(a.files)?a.files:[o]}return null}return {get(o){try{let a=o.params?.id;if(a){let i=e.readCard(a);return i?t({cards:[i]}):r(`card "${a}" not found`)}return t({cards:e.readAllCards()})}catch(a){return n(a)}},set(o){try{let a=o.body;if(a==null)return r("set requires a body (card object or array of cards)");let i=Array.isArray(a)?a:[a];for(let u of i){if(typeof u.id!="string")return r("each card must have a string `id` field");e.writeCard(u.id,u);}return t({count:i.length})}catch(a){return n(a)}},del(o){try{let a=o.body?.ids??[],i=o.params?.id,u=i?[...a,i]:a;if(u.length===0)return r("del requires body.ids (string[]) or params.id");for(let c of u)e.removeCard(c);return t({count:u.length})}catch(a){return n(a)}},patch(o){try{let a=o.params?.id,i=o.params?.path;if(!a)return r("patch requires params.id");if(!i)return r("patch requires params.path");let u=o.body,c=u&&Object.prototype.hasOwnProperty.call(u,"value")?u.value:o.body;return e.patchCard(a,i,c),t({count:1})}catch(a){return n(a)}},appendFiles(o){try{let a=o.params?.id;if(!a)return r("appendFiles requires params.id");let i=e.readCard(a);if(!i)return r(`card "${a}" not found`);let u=s(o.body);if(!u||u.length===0)return r("appendFiles requires a file metadata object, array, or body.files array");let c=i.card_data&&typeof i.card_data=="object"&&!Array.isArray(i.card_data)?i.card_data:{},d=Array.isArray(c.files)?c.files:[],l=[...d,...u],h=u.map((p,m)=>({idx:d.length+m,entry:p})),v=this.patch({params:{id:a,path:"card_data.files"},body:{value:l}});return v.status!=="success"?v:t({files_added:h})}catch(a){return n(a)}}}}function Y(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function L(e){return {status:"fail",error:e}}function Q(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function iy(e){let t=new TextEncoder().encode(e),r=Array.from(t,n=>String.fromCharCode(n)).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Qu(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=Uint8Array.from(n,o=>o.charCodeAt(0));return new TextDecoder().decode(s)}function Jn(e){try{let t=JSON.parse(Qu(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function cy(e){return iy(JSON.stringify(e))}function Xu(e){try{let t=JSON.parse(Qu(e));return typeof t?.cbk=="string"&&typeof t?.cid=="string"&&typeof t?.b=="string"&&typeof t?.d=="string"?t:null}catch{return null}}function xe(){return new Date().toISOString()}function uy(e,t){let r=t.onWarn??(()=>{}),n=pe(e);function s($){if($.length!==0)try{let y=t.publishBoardChangeNotifications?.($);y&&typeof y.catch=="function"&&y.catch(I=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${I instanceof Error?I.message:String(I)}`));}catch(y){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${y instanceof Error?y.message:String(y)}`);}}function o(){let $=i().readCardStoreRef();if(!$)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let y=t.kvStorageForRef($);return {readIndex(){return y.read("_index")},writeIndex(I){y.write("_index",I);},readCard(I){return y.read(I)},writeCard(I,F){return y.write(I,F),t.hashFn(F)},removeCard(I){y.delete(I);},cardExists(I){return y.read(I)!==null},defaultCardKey(I){return I}}}let a={readValues($){let y=t.kvStorage("state-snapshot"),I=y.listKeys().sort();if(I.length===0)return {version:null,values:{}};let F={};for(let X of I)F[X]=y.read(X);return {version:t.hashFn(F),values:F}},writeValues($,y,I){let F=t.kvStorage("state-snapshot");for(let X of I)F.delete(X);for(let[X,ae]of Object.entries(y))F.write(X,ae);return t.hashFn(y)}},i=()=>na(t.kvStorage("config")),u=()=>Gu(a),c=()=>Bu(t.journalAdapter()),d=()=>Vn(o(),r),l=()=>{let $=i().readOutputsStoreRef();if(!$)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return Ju(t.kvStorageForRef($))},h=()=>{let $=i().readArchiveStoreRef();return $?t.archiveFactoryForRef($):t.archiveFactory()};function v(){return !!u().readSnapshot(e.value).values[$t]}function p(){let $=u().readSnapshot(e.value);if(!$.values[$t])throw new Error(`Board not initialized at ${e.value}`);return Wu($.values)}function m($,y){let I=u().commitSnapshot(e.value,{schemaVersion:Vr,expectedVersion:y,commitId:t.genId(),committedAt:xe(),deleteKeys:[],shallowMerge:Hu($)});if(!I.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${y??"null"} current=${I.currentVersion??"null"}`)}function b($){c().appendEvent($);}async function R(){let $=(P,V)=>{let me=P.payload,We=(me?.enrichedCard??{}).id??me?.cardId??"unknown";b({type:"task-failed",taskName:We,error:V,timestamp:xe()});},y=Vu(t.kvStorage("execution-requests"),$),I=Ku(t.kvStorage("card-runtime")),F=Un(t.blobStorage("sources"),P=>t.resolveBlob(P)),X=new Map,ae={readRuntime(P){return X.get(P)??I.readRuntime(P)},writeRuntime(P,V){X.set(P,V);}},Oe=[],ye=new Map,Le={readSourceData(P,V){let me=`${P}/${V}`;return ye.has(me)?ye.get(me):F.readSourceData(P,V)},ingestSourceDataStaged(P,V,me,mt){F.ingestSourceDataStaged(P,V,me,mt);},commitSourceData(P,V,me){let mt=`${P}/.staged/${me}/${V}`,Gr=t.blobStorage("sources").read(mt);if(Gr==null)return false;let zt=`${P}/${V}`,ua=Gr.trim();try{ye.set(zt,JSON.parse(ua));}catch{ye.set(zt,ua);}return Oe.push({cardId:P,outputFile:V,deliveryToken:me}),true},hasSource(P,V){let me=`${P}/${V}`;return ye.has(me)?true:F.hasSource(P,V)},listSources(P){let V=F.listSources(P),me=new Set;for(let We of ye.keys())We.startsWith(`${P}/`)&&me.add(We.slice(`${P}/`.length));let mt=new Set([...V,...me]);return Array.from(mt)}},Te={cardStore:d(),cardRuntimeStore:ae,fetchedSourcesStore:Le,outputStore:l(),executionRequestStore:y},xt=p(),At=Ln(xt.graph),{events:Kt,newCursor:Gt}=c().readEntriesAfterCursor(xt.lastDrainedJournalId),Tt=[],Hn=[],Wn=[],Yn=new Map,aa=new Set,od=(P,V)=>{Tt.push({type:"task-completed",taskName:P,data:V,timestamp:xe()});try{h().stream("exec-history").append({taskName:P,status:"completed",completedAt:xe()});}catch{}},ia=(P,V)=>{b({type:"task-failed",taskName:P,error:V,timestamp:xe()});try{h().stream("exec-history").append({taskName:P,status:"failed",error:V,completedAt:xe()});}catch{}},Ur=ju(At,{handlers:{"card-handler":zu(e,Gt,Te,od,ia,(P,V)=>{Hn.push({cardId:P,values:V});},P=>{Wn.push(P);})},onNodeRemoved:P=>{Yn.delete(P),X.delete(P),aa.add(P);}});for(Tt=Kt;Tt.length>0;){let P=Tt;Tt=[];for(let V of P)if(V.type==="task-restart"){let me=Te.cardStore.readCard(V.taskName);me&&Yn.set(V.taskName,me);}Ur.pushAll(P),await Ur.waitForHandlers();}let ca=Ur.getState();await Ur.dispose({wait:true});let ad=u().readSnapshot(e.value).version;m({lastDrainedJournalId:Gt,graph:Mr(ca)},ad);for(let{cardId:P,values:V}of Hn)Te.outputStore.writeComputedValues(P,V);for(let P of Wn)Te.outputStore.writeDataObjects(P);for(let[P,V]of X)I.writeRuntime(P,V);for(let{cardId:P,outputFile:V,deliveryToken:me}of Oe)F.commitSourceData(P,V,me);let Kr;try{Kr=Kn(n,ca),Te.outputStore.writeStatusSnapshot(Kr);}catch(P){r(`[board-live-cards-public] status publish failed: ${P instanceof Error?P.message:String(P)}`);}let Jt=[];for(let{cardId:P,values:V}of Hn)Jt.push({kind:"computed_values",cardId:P,values:V});for(let P of Wn)for(let[V,me]of Object.entries(P))V&&Jt.push({kind:"data_object",key:V,payload:me});for(let[P,V]of Yn)Jt.push({kind:"card_refreshed",cardId:P,card:V});for(let P of aa)Jt.push({kind:"card_removed",cardId:P});Kr!==void 0&&Jt.push({kind:"status",status:Kr}),s(Jt);let id=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:pe({kind:"built-in",value:"source-cli-task-executor"})};y.dispatchEntriesForJournalId(Gt,P=>{if(P.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${P.taskKind}" \u2014 skipping`);return}let V=P.payload,me=V.enrichedCard?.id??"unknown",mt=V.enrichedCard?.source_defs??[];for(let We of mt){if(!We.outputFile){r(`[dispatch] source "${We.bindTo}" has no outputFile \u2014 skipping`);continue}let Gr=cy({cbk:V.callbackToken,rg:e.value,br:pe(e),cid:me,b:We.bindTo,d:We.outputFile,cs:void 0,rqt:V.rqt});t.dispatchExecution(id,{source_def:We,base_ref:pe(e),callback:{token:Gr,via:t.selfRef}}).catch(zt=>ia(me,zt instanceof Error?zt.message:String(zt)));}});}async function N(){try{let $=()=>{let I=p(),{events:F}=c().readEntriesAfterCursor(I.lastDrainedJournalId);F.length<=0||(N(),t.requestProcessAccumulated?.());},y=await la(t.lock,R,$);return Y({ran:y!==!1})}catch($){return Q($)}}function _(){N(),t.requestProcessAccumulated?.();}function A($){try{let y=$.params?.cardStoreRef;if(!y)return L("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!v()){let Te=Mn(Gn);m({lastDrainedJournalId:"",graph:Mr(Te)},null);}let I=$.params?.outputsStoreRef;if(!I)return L("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let F=$.params?.scratchStoreRef,X=$.params?.archiveStoreRef,ae=$.params?.chatStoreRef,Oe=$.params?.artifactsStoreRef,ye=i();ye.writeCardStoreRef(y),ye.writeOutputsStoreRef(I),F&&ye.writeScratchStoreRef(F),X&&ye.writeArchiveStoreRef(X),ae&&ye.writeChatStoreRef(ae),Oe&&ye.writeArtifactsStoreRef(Oe);let Le=$.body??{};Le["task-executor-ref"]&&ye.writeTaskExecutorRef(Le["task-executor-ref"]),Object.prototype.hasOwnProperty.call(Le,"chat-handler-flow")&&ye.writeChatHandlerFlow(Le["chat-handler-flow"]);try{l().writeStatusSnapshot(Kn(n,Ln(p().graph)));}catch{}return Y()}catch(y){return Q(y)}}function S($){try{let y=l().readStatusSnapshot();if(!y){y=Kn(n,Ln(p().graph));try{l().writeStatusSnapshot(y);}catch{}}return Y(y)}catch(y){return Q(y)}}function w($){try{let y=$.params?.id;return y?(b({type:"task-removal",taskName:y,timestamp:xe()}),_(),Y()):L("removeCard requires params.id")}catch(y){return Q(y)}}function f($){try{let y=$.params?.cardId;if(!y)return L("addCardFiles requires params.cardId");let I=sa(d()).appendFiles({params:{id:y},body:$.body});if(I.status!=="success")return I;let F=g({params:{cardId:y}});return F.status!=="success"?F:Y({cardId:y,files_added:I.data.files_added,notified:!0})}catch(y){return Q(y)}}function g($){try{let y=$.params?.cardId;if(!y)return L("cardRefreshedNotify requires params.cardId");let I=d().readCard(y);return I?(s([{kind:"card_refreshed",cardId:y,card:I}]),Y({cardId:y,notified:!0})):L(`Card "${y}" not found in board at ${e.value}`)}catch(y){return Q(y)}}function k($){try{let y=$.params?.id;return y?(b({type:"task-restart",taskName:y,timestamp:xe()}),_(),Y()):L("retrigger requires params.id")}catch(y){return Q(y)}}async function x($){return N()}function E($){try{let y=$.params?.cardId,I=$.params?.all,F=!!$.params?.restart;if(!y&&!I)return L("upsertCard requires --card-id <id> or --all");let X=I?d().readAllCards().map(ae=>ae.id):[y];for(let ae of X)if(!d().readCard(ae))return L(`Card "${ae}" not found in board at ${e.value}`);for(let ae of X){let Oe=d().readCard(ae),ye=Yu(Oe),Le=t.hashFn(ye),Te=t.kvStorage("card-upsert"),xt=Te.read(ae),At=xt?.taskConfigHash!==Le;if(!(!At&&!F)){if(At){let Kt=xt?.blobRef??d().readCardKey(ae)??ae;b({type:"task-upsert",taskName:ae,taskConfig:ye,timestamp:xe()}),Te.write(ae,{blobRef:Kt,taskConfigHash:Le,updatedAt:xe()});}F&&b({type:"task-restart",taskName:ae,timestamp:xe()});}}return _(),Y()}catch(y){return Q(y)}}function T($){try{let y=$.params?.token;if(!y)return L("taskFailed requires params.token");let I=$.params?.error??"unknown error",F=Jn(y);if(!F)return L("Invalid callback token");b({type:"task-failed",taskName:F.taskName,error:I,timestamp:xe()});try{h().stream("exec-history").append({taskName:F.taskName,status:"failed",error:I,completedAt:xe()});}catch{}return _(),Y()}catch(y){return Q(y)}}function O($){try{let y=$.params?.token;if(!y)return L("taskProgress requires params.token");let F=($.body??{}).update??{},X=Jn(y);return X?(b({type:"task-progress",taskName:X.taskName,update:F,timestamp:xe()}),_(),Y()):L("Invalid callback token")}catch(y){return Q(y)}}function Z($){try{let y=$.params?.token,I=$.params?.ref;if(!y)return L("sourceDataFetched requires params.token");if(!I)return L("sourceDataFetched requires params.ref");let F=Xu(y);if(!F)return L("Invalid source token");let{cbk:X,cid:ae,b:Oe,d:ye,cs:Le,rqt:Te}=F,xt=Un(t.blobStorage("sources"),Tt=>t.resolveBlob(Tt)),At=t.genId();xt.ingestSourceDataStaged(ae,ye,Ye(I),At);let Kt=Jn(X);if(!Kt)return L("Invalid callback token embedded in source token");let Gt=xe();return b({type:"task-progress",taskName:Kt.taskName,update:{bindTo:Oe,outputFile:ye,fetchedAt:Gt,deliveryToken:At,sourceChecksum:Le,rqt:Te},timestamp:Gt}),_(),Y()}catch(y){return Q(y)}}function K($){try{let y=$.params?.token,I=$.params?.reason??"unknown";if(!y)return L("sourceDataFetchFailure requires params.token");let F=Xu(y);if(!F)return L("Invalid source token");let{cbk:X,b:ae,d:Oe,cs:ye,rqt:Le}=F,Te=Jn(X);return Te?(b({type:"task-progress",taskName:Te.taskName,update:{bindTo:ae,outputFile:Oe,failure:!0,reason:I,sourceChecksum:ye,rqt:Le},timestamp:xe()}),_(),Y()):L("Invalid callback token embedded in source token")}catch(y){return Q(y)}}function ie($){try{let y=i().readCardStoreRef();return y?Y({storeRef:y}):L(`Board at ${e.value} has no card store configured`)}catch(y){return Q(y)}}function ve($){try{let y=i().readOutputsStoreRef();return y?Y({storeRef:y}):L(`Board at ${e.value} has no outputs store configured`)}catch(y){return Q(y)}}function D($){try{let y=i().readScratchStoreRef();return Y({storeRef:y})}catch(y){return Q(y)}}function B($){try{let y=i().readArchiveStoreRef();return Y({storeRef:y})}catch(y){return Q(y)}}function M($){try{let y=i().readChatStoreRef();return Y({storeRef:y})}catch(y){return Q(y)}}function oe($){try{let y=i().readArtifactsStoreRef();return Y({storeRef:y})}catch(y){return Q(y)}}function de($){try{let y=$.params?.key;if(!y)return L("getConfig requires params.key");let I=i(),F;switch(y){case "task-executor":F=I.readTaskExecutorRef()??null;break;case "chat-handler-flow":F=I.readChatHandlerFlow()??null;break;case "card-store-ref":F=I.readCardStoreRef();break;case "outputs-store-ref":F=I.readOutputsStoreRef();break;case "scratch-store-ref":F=I.readScratchStoreRef();break;case "archive-store-ref":F=I.readArchiveStoreRef();break;case "chat-store-ref":F=I.readChatStoreRef();break;case "artifacts-store-ref":F=I.readArtifactsStoreRef();break;default:return L(`getConfig: unknown key "${y}"`)}return Y({value:F})}catch(y){return Q(y)}}function J($){try{let y=$.params?.key;if(!y)return L("getOutputsDataObject requires params.key");let I=l().readDataObject(y);return Y(I)}catch(y){return Q(y)}}function Se($){try{return Y(l().readAllDataObjects())}catch(y){return Q(y)}}function fe($){try{let y=$.params?.key;if(!y)return L("getOutputsComputedValues requires params.key");let I=l().readComputedValues(y);return Y(I)}catch(y){return Q(y)}}function ke($){try{return Y(l().readAllComputedValues())}catch(y){return Q(y)}}function it(){return Un(t.blobStorage("sources"),$=>t.resolveBlob($))}function He($){let y=t.blobStorage("sources").keyRef?.($);return y?pe(y):$}function Ut($){try{let y=$.params?.key;if(!y)return L("getOutputsFetchedSources requires params.key");let I=it().listSources(y),F={};for(let X of I)F[X]=He(`${y}/${X}`);return Y(F)}catch(y){return Q(y)}}function sd($){try{let y=it(),I=new Set;for(let X of t.blobStorage("sources").listKeys()){let ae=X.indexOf("/");ae>0&&!X.includes("/.staged/")&&I.add(X.slice(0,ae));}let F={};for(let X of I){let ae=y.listSources(X);if(ae.length>0){F[X]={};for(let Oe of ae)F[X][Oe]=He(`${X}/${Oe}`);}}return Y(F)}catch(y){return Q(y)}}return {init:A,status:S,getCardStoreRef:ie,getOutputsStoreRef:ve,getScratchStoreRef:D,getArchiveStoreRef:B,getChatStoreRef:M,getArtifactsStoreRef:oe,getConfig:de,getOutputsDataObject:J,getAllOutputsDataObjects:Se,getOutputsComputedValues:fe,getAllOutputsComputedValues:ke,getOutputsFetchedSources:Ut,getAllOutputsFetchedSources:sd,removeCard:w,addCardFiles:f,cardRefreshedNotify:g,retrigger:k,processAccumulatedEvents:x,upsertCard:E,taskFailed:T,taskProgress:O,sourceDataFetched:Z,sourceDataFetchFailure:K}}function dy(e,t){let r=()=>na(t.kvStorage("config"));function n(){let S=r().readCardStoreRef();if(!S)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let w=t.kvStorageForRef(S);return {readIndex(){return w.read("_index")},writeIndex(f){w.write("_index",f);},readCard(f){return w.read(f)},writeCard(f,g){return w.write(f,g),t.hashFn(g)},removeCard(f){w.delete(f);},cardExists(f){return w.read(f)!==null},defaultCardKey(f){return f}}}let s=()=>Vn(n(),t.onWarn??(()=>{})),o=()=>{let S=r().readScratchStoreRef();return S?t.scratchStorageForRef(S):t.scratchStorage()};function a(S,w){let f=t.validateSchema(w),g=[],k=r().readTaskExecutorRef();if(k&&Array.isArray(w.source_defs))for(let E of w.source_defs){let T=typeof E.bindTo=="string"?E.bindTo:"(unknown)";try{let O;try{O=t.invokeExecutorSync(k,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(E)});}catch(K){let ie=K;if(O=typeof ie?.stdout=="string"?ie.stdout:"",!O.trim()){g.push(`source "${T}": executor validate-source-def failed \u2014 ${K instanceof Error?K.message:String(K)}`);continue}}let Z=JSON.parse(O.trim());if(!Z.ok&&Array.isArray(Z.errors))for(let K of Z.errors)g.push(`source "${T}": ${K}`);}catch(O){g.push(`source "${T}": executor validate-source-def failed \u2014 ${O instanceof Error?O.message:String(O)}`);}}let x=[...f.errors,...g];return Y({cardId:S,isValid:x.length===0,issues:x})}function i(S,w){let f=r().readTaskExecutorRef();if(!f)throw new Error("No task-executor registered for this board");let g=typeof S.bindTo=="string"?S.bindTo:"source",k=o(),x={...S,boardDir:e.value,_projections:w},E=k.create(JSON.stringify(x,null,2),`probe-in-${g}`,".json"),T=k.getUniqueKey(`probe-out-${g}`,".json"),O=k.getUniqueKey(`probe-err-${g}`,".txt"),Z=pe(k.keyRef(E)),K=pe(k.keyRef(T)),ie=pe(k.keyRef(O)),ve=null;try{if(t.invokeExecutorSync(f,"run-source-fetch",["--in-ref",Z,"--out-ref",K,"--err-ref",ie],{timeout:S.timeout??t.executorTimeouts?.probeMs??6e4}),ve=k.read(T),ve===null)throw new Error("Executor produced no output file")}catch(D){let B=k.read(O)?.trim()??(D instanceof Error?D.message:String(D));throw new Error(`Probe failed: ${B}`)}finally{try{k.remove(E);}catch{}try{k.remove(O);}catch{}}return {bindTo:g,result:ve}}function u(S,w,f){let g;try{g=i(S,w);}catch(k){return L(k instanceof Error?k.message:String(k))}if(f){let k=Ye(f);t.absoluteBlob.write(k.value,g.result);}return Y({bindTo:g.bindTo,resultSizeBytes:g.result.length})}function c(S,w){let f=S.params?.sourceIdx,g=S.params?.outRef;if(f===void 0)return L(`${w} requires params.sourceIdx`);if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L(`${w} requires card JSON object in body`);let k=S.body,x=k["card-content"]??k,E=k["mock-projections"]??{},T=x.source_defs??[];if(f<0||f>=T.length)return L(`sourceIdx ${f} out of range (card has ${T.length} source(s))`);let O=T[f],Z=typeof O.bindTo=="string"?O.bindTo:"source";return {src:O,bindTo:Z,outRef:g,mockProjections:E}}function d(S){try{let w=S.params?.cardId,f=S.params?.all;if(!w&&!f)return L("validateCard requires --card-id <id> or --all");let g=f?s().readAllCards().map(x=>x.id):[w],k=[];for(let x of g){let E=s().readCard(x);if(!E){k.push({cardId:x,isValid:!1,issues:[`Card "${x}" not found`]});continue}let T=a(x,E);if(T.status!=="success")return T;k.push(T.data);}return Y(k)}catch(w){return Q(w)}}function l(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("validateCardPreflight requires card JSON object in body");let w=S.body,f=w["card-content"]??w,g=typeof f.id=="string"?f.id:"(unknown)";return a(g,f)}catch(w){return Q(w)}}function h(S){try{let w=S.params?.cardId,f=S.params?.sourceIdx,g=S.params?.outRef;if(!w)return L("probeSource requires params.cardId");if(f===void 0)return L("probeSource requires params.sourceIdx");let x=(S.body??{})["mock-projections"]??{},E=s().readCard(w);if(!E)return L(`Card "${w}" not found`);let T=E.source_defs??[];return f<0||f>=T.length?L(`sourceIdx ${f} out of range (card has ${T.length} source(s))`):u(T[f],x,g)}catch(w){return Q(w)}}function v(S){try{let w=S.params?.outRef,f=S.body;if(!f)return L('probeTmpSource requires body with "source-def" and "mock-projections"');let g=f["source-def"],k=f["mock-projections"]??{};return g?u(g,k,w):L('probeTmpSource body requires "source-def"')}catch(w){return Q(w)}}function p(S){try{let w=c(S,"probeSourcePreflight");if("status"in w)return w;let f=r().readTaskExecutorRef();if(!f)return L("No task-executor registered for this board");try{let g={...w.src,_projections:w.mockProjections},k=t.invokeExecutorSync(f,"probe-source-preflight",[],{timeout:w.src.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(g)}),x=JSON.parse(k.trim());return x.ok?Y({bindTo:w.bindTo,reachable:x.reachable,latencyMs:x.latencyMs,note:x.note}):L(x.error??"Preflight probe failed")}catch{return L("Executor does not support probe-source-preflight")}}catch(w){return Q(w)}}function m(S){try{let w=c(S,"runSourcePreflight");if("status"in w)return w;let f=r().readTaskExecutorRef();if(f)try{let E={...w.src,_projections:w.mockProjections},T=t.invokeExecutorSync(f,"run-source-preflight",[],{timeout:w.src.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(E)}),O=JSON.parse(T.trim());return O.ok?Y({bindTo:O.bindTo??w.bindTo,reachable:O.reachable,latencyMs:O.latencyMs,kind:O.kind,resultValue:O.resultValue,note:O.note}):L(O.error??"Source preflight failed")}catch{}let g=Date.now(),k=i(w.src,w.mockProjections);if(w.outRef){let E=Ye(w.outRef);t.absoluteBlob.write(E.value,k.result);}let x=k.result;try{x=JSON.parse(k.result);}catch{}return Y({bindTo:k.bindTo,reachable:!0,latencyMs:Date.now()-g,resultValue:x,note:"Actual fetch preflight passed"})}catch(w){return Q(w)}}function b(S){try{let w=r().readTaskExecutorRef();if(!w)return L("No task-executor registered for this board");let f=t.invokeExecutorSync(w,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return Y(JSON.parse(f.trim()))}catch(w){return Q(w)}}function R(S){try{let w=S.body;if(!w||!Array.isArray(w.ops))return L("updatesInCardStore requires body.ops array");let f=w.ops,g=s();for(let k of f){let x=k.op,E=k.id;if(!E)return L('op is missing "id"');if(x==="update"){let T=k["card-content"];if(!T)return L(`update op for "${E}" is missing "card-content"`);g.writeCard(E,T);}else return L(`Unknown op type: "${x??"(none)"}"`)}return Y()}catch(w){return Q(w)}}function N(S){try{let w=S.body;if(!w||!Array.isArray(w.ids))return L("readFromCardStore requires body.ids array");let f=w.ids,g=s(),k=f.map(x=>({id:x,"card-content":g.readCard(x)}));return Y({cards:k})}catch(w){return Q(w)}}function _(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("evalCardCompute requires a JSON object in body");let w=S.body,f=w["card-content"]??w,g=typeof f.id=="string"?f.id:"(unknown)",k=w["mock-fetched-sources"]??{},x=w["mock-requires"]??{},E=f.compute;if(!E||!Array.isArray(E)||E.length===0)return Y({cardId:g,ok:!0,computed_values:{},errors:[]});let T={id:g,card_data:f.card_data??{},requires:x,source_defs:f.source_defs,compute:E},O=Et.runSync(T,{sourcesData:k}),Z=O.node.computed_values??{},K=O.errors??[];return Y({cardId:g,ok:K.length===0,computed_values:Z,errors:K})}catch(w){return Q(w)}}function A(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("simulateCardCycle requires a JSON object in body");let w=S.body,f=w["card-content"]??w,g=typeof f.id=="string"?f.id:"(unknown)",k=w["mock-fetched-sources"]??{},x=w["mock-requires"]??{},E=a(g,f),T=E.status==="success"?{isValid:E.data.isValid,issues:E.data.issues}:{isValid:!1,issues:[E.status==="fail"?E.error:"internal error"]},O=f.source_defs??[],Z=f.card_data??{},K=[],ie=[];if(O.length>0){K=Et.enrichSourcesSync(O,{card_data:Z,requires:x});for(let Se of K){let fe=Se.projections,ke=Se._projections;if(fe&&ke){for(let it of Object.keys(fe))if(ke[it]===void 0){let He=typeof Se.bindTo=="string"?Se.bindTo:"(unknown)";ie.push({bindTo:He,key:it,error:`Projection "${it}" resolved to undefined`});}}}}let ve=[],D=w["task-executor-ref"],B=(D?.howToRun&&D?.whatToRun?D:void 0)??r().readTaskExecutorRef();for(let Se=0;Se<K.length;Se++){let fe=K[Se],ke=typeof fe.bindTo=="string"?fe.bindTo:`source_${Se}`;if(!B){ve.push({bindTo:ke,skipped:!0,error:"No task executor configured"});continue}try{let it={...fe},He=t.invokeExecutorSync(B,"run-source-preflight",[],{timeout:fe.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(it)}),Ut=JSON.parse(He.trim());ve.push({bindTo:ke,reachable:Ut.reachable,latencyMs:Ut.latencyMs,error:Ut.ok?void 0:Ut.error});}catch{ve.push({bindTo:ke,skipped:!0,error:"Executor does not support run-source-preflight"});}}let M=f.compute,oe={},de=[];if(M&&Array.isArray(M)&&M.length>0){let Se={id:g,card_data:Z,requires:x,source_defs:f.source_defs,compute:M},fe=Et.runSync(Se,{sourcesData:k});oe=fe.node.computed_values??{},de=fe.errors??[];}let J=T.isValid&&ie.length===0&&de.length===0&&ve.every(Se=>Se.reachable!==!1);return Y({cardId:g,ok:J,validation:T,source_probes:ve,projection_errors:ie,computed_values:oe,compute_errors:de})}catch(w){return Q(w)}}return {validateCard:d,validateCardPreflight:l,probeSource:h,probeTmpSource:v,probeSourcePreflight:p,runSourcePreflight:m,evalCardCompute:_,simulateCardCycle:A,describeTaskExecutorCapabilities:b,updatesInCardStore:R,readFromCardStore:N}}function Ae(e,t){if(e?.status==="success")return Object.prototype.hasOwnProperty.call(e,"data")?e.data:void 0;throw e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function ue(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Me(e){return Array.isArray(e)?e:[]}function Zu(e,t){if(typeof t!="string"||t.length===0)return;let r=e,n=t;n.startsWith("fetched_sources.")&&(r=ue(e).fetched_sources,n=n.slice(16));for(let s of n.split(".")){if(r==null||typeof r!="object")return;r=r[s];}return r}function ly(e,t){let r=ue(e.view),n=Me(r.elements);return {layout:r.layout,features:r.features,elements:n.map((s,o)=>{let a=ue(s),i=ue(a.data),u=typeof a.visible=="string"?!!Zu(t,a.visible):true,c=typeof i.bind=="string"?i.bind:void 0,d=c?Zu(t,c):void 0,l={id:typeof a.id=="string"&&a.id?a.id:`element-${o}`,kind:a.kind,label:a.label,visible:u};return c&&(l.bind=c),Array.isArray(i.columns)&&(l.columns=i.columns),typeof i.maxRows=="number"&&(l.maxRows=i.maxRows),d!==void 0&&(l.resolved=Array.isArray(d)&&typeof l.maxRows=="number"?d.slice(0,l.maxRows):d),l})}}function fy(e){if(typeof e!="string"||!e.trim())return null;let t=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(e.trim());if(!t)return null;let r=Number.parseInt(t[2],10);return !Number.isInteger(r)||r<0?null:r}function py(e){return {"card-content":e}}function zn(e,t){let r=Ae(e.get({params:{id:t}}),"cardStore.get"),n=Array.isArray(r?.cards)?r.cards:[];if(n.length===0)throw new Error(`Card "${t}" not found`);return n[0]}function my(e){let{board:t,nonCore:r,cardStore:n,chatStore:s,uploadCardFile:o,buildFileDownloadUrl:a,readFetchedSourceJsonByRef:i}=e;function u(f){if(Array.isArray(f.bytes))return new Uint8Array(f.bytes.map(g=>Math.max(0,Math.min(255,Number(g)||0))));if(typeof f.text=="string")return new TextEncoder().encode(f.text);if(typeof f.base64=="string"){let g=String(f.base64).replace(/-/g,"+").replace(/_/g,"/"),k=g+"=".repeat((4-g.length%4)%4),x=atob(k);return Uint8Array.from(x,E=>E.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}function c(){let f=ue(Ae(r.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:f.version,commonSourceFields:ue(f.commonSourceDefFields),sourceKinds:ue(f.sourceKinds)}}function d(){let f=ue(Ae(t.status({}),"status")),g=ue(f.summary),k=Me(f.cards);return {meta:ue(f.meta),summary:{card_count:typeof g.card_count=="number"?g.card_count:0,completed:typeof g.completed=="number"?g.completed:0,eligible:typeof g.eligible=="number"?g.eligible:0,pending:typeof g.pending=="number"?g.pending:0,blocked:typeof g.blocked=="number"?g.blocked:0,in_progress:typeof g.in_progress=="number"?g.in_progress:0,failed:typeof g.failed=="number"?g.failed:0,unresolved:typeof g.unresolved=="number"?g.unresolved:0},cards:k.map(x=>{let E=ue(x);return {"card-id":typeof E.name=="string"?E.name:null,status:E.status??null,error:E.error??null,requires:Me(E.requires),requires_satisfied:Me(E.requires_satisfied),requires_missing:Me(E.requires_missing),provides_declared:Me(E.provides_declared),provides_runtime:Me(E.provides_runtime)}})}}function l(f){let g=String(f.cardId||"").trim();if(!g)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let k=ue(Ae(t.status({}),"status")),E=Me(k.cards).map(ue).find(J=>J.name===g);if(!E)throw new Error(`card "${g}" not found in board status`);let T=ue(zn(n,g)),O=Me(E.requires_satisfied).filter(J=>typeof J=="string"&&!!J),Z=Me(E.provides_runtime).filter(J=>typeof J=="string"&&!!J),K=Object.fromEntries(O.map(J=>[J,Ae(t.getOutputsDataObject({params:{key:J}}),`getOutputsDataObject(${J})`)])),ie=Object.fromEntries(Z.map(J=>[J,Ae(t.getOutputsDataObject({params:{key:J}}),`getOutputsDataObject(${J})`)])),ve=ue(Ae(t.getOutputsComputedValues({params:{key:g}}),"getOutputsComputedValues")),D=Ae(t.getOutputsFetchedSources({params:{key:g}}),"getOutputsFetchedSources"),B=Me(T.source_defs).map(ue),M={};for(let J of B)typeof J.bindTo=="string"&&typeof J.outputFile=="string"&&(M[J.outputFile]=J.bindTo);let oe={};for(let[J,Se]of Object.entries(D)){let fe=M[J]??J;if(!i||typeof Se!="string"){oe[fe]=null;continue}try{oe[fe]=i({cardId:g,ref:Se});}catch{oe[fe]=null;}}let de={card_data:ue(T.card_data),requires:K,fetched_sources:oe,computed_values:ve};return {cardId:g,card_status_in_board:E,card_definition_and_static_data:T,refs_for_fetched_source_files:D,runtime_data:{requires:K,provides:ie,computed_values:ve,rendered_view:ly(T,de)}}}function h(f){let g=String(f.cardId||"").trim();if(!g)throw new Error("inspectChatMessagesOnCards requires cardId");let k=typeof f.turnId=="string"?f.turnId:"",x=f.allTurns===true,E=typeof f.tailTurnsBeforeId=="string"?f.tailTurnsBeforeId:"",T=x?void 0:f.lastUserTurns??(k?void 0:1),O=f.tail,Z=T===void 0?{params:{cardId:g}}:{params:{cardId:g},body:{lastUserTurns:T}},K=Ae(s.readAll(Z),"chatStore.readAll"),ie=ue(zn(n,g)),ve=Me(ue(ie.card_data).files).map((M,oe)=>({idx:oe,stored_name:ue(M).stored_name})).filter(M=>typeof M.stored_name=="string"&&M.stored_name.length>0),D=(Array.isArray(K.records)?K.records:[]).filter(M=>k?typeof M?.turn=="string"?M.turn===k:k==="":true);if(E){if(T===void 0||!Number.isInteger(T)||T<=0)throw new Error("inspectChatMessagesOnCards requires tail-turns when tail-turns-before-id is provided");let M=new Map,oe=[];for(let fe of Array.isArray(K.records)?K.records:[]){let ke=typeof fe?.turn=="string"?fe.turn:"";M.has(ke)||(M.set(ke,[]),oe.push(ke)),M.get(ke).push(fe);}let de=oe.findIndex(fe=>fe===E),J=Math.max(0,de-T);D=(de===-1?[]:oe.slice(J,de)).flatMap(fe=>M.get(fe)??[]);}let B=D.map(M=>{let de=ue(M.payload),J={...M},Se=typeof M?.role=="string"?M.role:typeof de.role=="string"?String(de.role):"",fe=typeof M?.text=="string"?M.text:typeof de.text=="string"?String(de.text):"";if(Se==="system"){let ke=fy(fe);if(ke!==null&&ve.some(He=>He.idx===ke)){let He=`Retrieve using inspect-file-contents --card-id ${g} --file-idx ${ke}`;J.retrieval_hint=He,Object.keys(de).length>0&&typeof M.role!="string"&&(J.payload={...de,retrieval_hint:He});}}return J});return {cardId:g,messages:typeof O=="number"&&O>=0?B.slice(-O):B}}function v(f){let g=String(f.cardId||"").trim(),k=Number(f.fileIdx);if(!g)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(k)||k<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let x=ue(zn(n,g)),E=Me(ue(x.card_data).files).map(ue);if(k>=E.length)throw new Error(`attachment index ${k} is out of range for card "${g}"`);let T=E[k],O=typeof T.stored_name=="string"?T.stored_name:null;return {cardId:g,fileIdx:k,downloadUrl:a({cardId:g,fileIdx:k,storedName:O}),...typeof T.name=="string"?{name:T.name}:{},...typeof T.stored_name=="string"?{stored_name:T.stored_name}:{},...typeof T.mime_type=="string"?{mime_type:T.mime_type}:{},...typeof T.size=="number"?{size:T.size}:{},...typeof T.uploaded_at=="string"?{uploaded_at:T.uploaded_at}:{}}}function p(f){return r.validateCardPreflight({body:py(f.candidateCardContent)})}function m(f){return r.evalCardCompute({body:{"card-content":f.candidateCardContent,"mock-requires":f.mockRequires,"mock-fetched-sources":f.mockFetchedSources}})}function b(f){return r.probeSourcePreflight({params:{sourceIdx:f.sourceIdx},body:{"card-content":f.candidateCardContent,"mock-projections":f.mockProjections}})}function R(f){return r.runSourcePreflight({params:{sourceIdx:f.sourceIdx},body:{"card-content":f.candidateCardContent,"mock-projections":f.mockProjections}})}function N(f){return r.simulateCardCycle({body:{"card-content":f.candidateCardContent,"mock-requires":f.mockRequires}})}function _(f){let g=String(f.cardId||"").trim();if(!g)throw new Error("manageReadCard requires cardId");let k=Ae(n.get({params:{id:g}}),"cardStore.get");return Array.isArray(k.cards)?k.cards:[]}function A(f){let g=String(f.cardId||"").trim(),k=String(f.role||"").trim(),x=typeof f.text=="string"?f.text:"",E=typeof f.turn=="string"?f.turn:"";if(!g)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!k)throw new Error("manageAddChatEntryAndAnyAttachments requires role");let T=Me(f.files).map(Z=>{let K=ue(Z),ie=String(K.file_name??K.fileName??K.name??"").trim(),ve=String(K.content_type??K.contentType??"application/octet-stream");if(!ie)throw new Error("file entry requires file_name");return o({cardId:g,fileName:ie,contentType:ve,bytes:u(K)}).file});T.forEach((Z,K)=>{let ie=k==="assistant"?`AI generated: ${String(Z.name||"")} as ${String(Z.stored_name||"")} #${K}`:`file uploaded: ${String(Z.name||"")} as ${String(Z.stored_name||"")} #${K}`;Ae(s.append({params:{cardId:g},body:{role:"system",text:ie,files:[],turn:E}}),"chatStore.append(system attachment message)");});let O=Ae(s.append({params:{cardId:g},body:{role:k,text:x,files:T,turn:E}}),"chatStore.append");return {status:"success",data:{cardId:g,id:String(O.id),role:k,turn:E,files:T}}}function S(f){let g=String(f.cardId||"").trim(),k=ue(f.candidateCardContent);if(!g)throw new Error("manageUpsertCard requires cardId");if(typeof k.id!="string"||!k.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(k.id!==g)throw new Error(`candidateCardContent.id must match cardId (${g})`);let x=p({candidateCardContent:k}),E=ue(x),T=ue(E.data);if(E.status!=="success"||T.isValid!==true)return {status:"fail",step:"validate",validation:x};let O=null;try{O=zn(n,g);}catch{O=null;}let Z=n.set({body:k});Ae(Z,"cardStore.set");let K;try{K=t.upsertCard({params:{cardId:g,restart:!0}}),Ae(K,"upsertCard");}catch(ve){try{O&&n.set({body:O});}catch{}throw ve}let ie=null;try{ie=t.cardRefreshedNotify({params:{cardId:g}}),Ae(ie,"cardRefreshedNotify");}catch{ie=null;}return {status:"success",data:{validation:x,card_saved:null,board_result:K,refresh_notify:ie}}}function w(f){let g=String(f.cardId||"").trim();if(!g)throw new Error("manageDeprecate requires cardId");let k=t.removeCard({params:{id:g}});return Ae(k,"removeCard"),k}return {discoverSourceKinds:c,inspectBoardRuntimeStatus:d,inspectCardDefinitionAndRuntime:l,inspectChatMessagesOnCards:h,inspectFileContents:v,preflightValidateCandidateCardDefinition:p,preflightMaterializeCandidateCard:m,preflightProbeSingleSourceInCandidateCard:b,preflightRunSingleSourceInCandidateCard:R,preflightRunOneCycleWithCandidateCard:N,manageReadCard:_,manageAddChatEntryAndAnyAttachments:A,manageUpsertCard:S,manageDeprecate:w}}function gy(e){function t(s){return {status:"success",data:s}}function r(s){return {status:"fail",error:s}}function n(s){return {status:"error",error:s instanceof Error?s.message:String(s)}}return {list(s){try{let o=s.params?.prefix??"";return t({artifacts:e.list(o)})}catch(o){return n(o)}},head(s){try{let o=s.params?.key;return o?t({artifact:e.head(o)}):r("head requires params.key")}catch(o){return n(o)}},put(s){try{let o=s.params?.key,a=s.params?.contentType;if(!o)return r("put requires params.key");let i=s.body;if(typeof i=="string")return t({artifact:e.putText(o,i,a)});if(i&&typeof i=="object"&&typeof i.text=="string")return t({artifact:e.putText(o,i.text,a)});if(i&&typeof i=="object"&&Array.isArray(i.bytes)){let u=i.bytes,c=new Uint8Array(u.map(d=>Math.max(0,Math.min(255,Number(d)||0))));return t({artifact:e.putBytes(o,c,a)})}return r("put requires body as string, {text}, or {bytes:number[]}")}catch(o){return n(o)}},get(s){try{let o=s.params?.key,a=s.params?.as??"base64";if(!o)return r("get requires params.key");let i=e.head(o);if(!i)return r(`artifact "${o}" not found`);if(a==="text"){let c=e.getText(o);return c===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,text:c})}let u=e.getBytes(o);return u===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,bytes:[...u]})}catch(o){return n(o)}},del(s){try{let o=s.params?.key;return o?(e.remove(o),t({ok:!0})):r("del requires params.key")}catch(o){return n(o)}}}}function ed(){return new Date().toISOString()}function td(e){return new TextEncoder().encode(e).byteLength}function hy(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function yy(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function vy(e){let t=String(e||"").trim();if(!t)return "upload.bin";let r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return (r>=0?t.slice(r+1):t)||"upload.bin"}function Sy(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function wy(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function by(e){let t=vy(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function ky(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function oa(e){function t(r){let n=e.stat?hy(e.stat(r)):null;if(n)return n;if(!e.exists(r))return null;let s=e.read(r);return s===null?{key:r}:{key:r,size:td(s)}}return {exists(r){return e.exists(r)},putText(r,n,s="text/plain; charset=utf-8"){e.write(r,n);let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??ed(),o.size=o.size??td(n),o},putBytes(r,n,s="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,n);else {let a=JSON.stringify({__kind:"bytes-array",data:[...n]});e.write(r,a);}let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??ed(),o.size=o.size??n.byteLength,o},getText(r){let n=e.read(r);if(n===null){if(!e.readBytes)return null;let s=e.readBytes(r);return s===null?null:Buffer.from(s).toString("utf-8")}try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new TextDecoder("utf-8").decode(new Uint8Array(s.data))}catch{}return n},getBytes(r){if(e.readBytes){let s=e.readBytes(r);if(s!==null)return s}let n=e.read(r);if(n===null)return null;try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new Uint8Array(s.data)}catch{}return new TextEncoder().encode(n)},head:t,list(r=""){return e.listKeys(r).map(n=>t(n)??{key:n}).sort((n,s)=>n.key.localeCompare(s.key))},remove(r){e.remove(r);}}}function _y(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(ky(u.key));for(let u of i){let c=yy(u);Number.isFinite(c)&&c>a&&(a=c);}return a+1}function r(s,o,a){let i=Number(a?.maxLen||32),{stem:u,ext:c}=by(s),d=wy(c),l=Sy(u),h=`${String(o).padStart(3,"0")}-`,v=d,p=i-h.length-v.length;p<1&&(v="",p=i-h.length);let m=l.slice(0,Math.max(1,p)),b=`${h}${m}${v}`;return b.length>i&&(b=b.slice(0,i).replace(/\.$/,"")),b}function n(s,o,a){let i=t(s,a?.seedNames),u=r(o,i,{maxLen:a?.maxLen});for(;e.exists(`${s}/${u}`);)i+=1,u=r(o,i,{maxLen:a?.maxLen});return u}return {nextSerial:t,buildStoredName:r,allocateStoredName:n}}function Ry(){function e(s,o){if(!Array.isArray(s))return [];let a=[];for(let i of s){if(!i||typeof i!="object")continue;let u=i;typeof u.stored_name=="string"&&a.push({name:typeof u.name=="string"?u.name:u.stored_name,stored_name:u.stored_name,size:typeof u.size=="number"&&Number.isFinite(u.size)?u.size:null,mime_type:typeof u.mime_type=="string"?u.mime_type:null,uploaded_at:typeof u.uploaded_at=="string"?u.uploaded_at:o||null,chat:u.chat===true});}return a}function t(s){return !s||typeof s!="object"?[]:e(s.files,void 0)}function r(s,o){let a=t(s);if(o.length===0)return s.files=a,a;let i=new Set(a.map(u=>u.stored_name));for(let u of o)i.has(u.stored_name)||(a.push(u),i.add(u.stored_name));return s.files=a,a}function n(s,o,a){let i=t(s);if(!Number.isInteger(o)||o<0||o>=i.length)return {ok:false,reason:"index_out_of_range"};let u=i[o];return !u||!u.stored_name?{ok:false,reason:"missing_stored_name"}:a&&a!==u.stored_name?{ok:false,reason:"stale_reference"}:{ok:true,file:u}}return {read:t,normalizeIncoming:e,merge:r,resolve:n}}function Sw(){return {async invoke(e,t){if(e.howToRun!=="local-node")return {dispatched:false,error:`createNodeSpawnInvocationAdapter: unsupported howToRun "${e.howToRun}"`};let r="";try{let o=e.whatToRun;r=Qe(o);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let n={...t},s=Buffer.from(JSON.stringify(n)).toString("base64");try{return spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",s],{stdio:"ignore",windowsHide:!0}).unref(),{dispatched:!0}}catch(o){return {dispatched:false,error:o instanceof Error?o.message:String(o)}}},async describe(e){if(e.howToRun!=="local-node")return null;let t="";try{let r=e.whatToRun;t=Qe(r);}catch{t="";}if(!t)return null;try{let r=spawnSync(process.execPath,[t,"describe"],{timeout:5e3,encoding:"utf-8",windowsHide:!0});return r.status!==0?null:JSON.parse(String(r.stdout).trim())}catch{return null}}}}var $y=".board.lock";function rd(e,t){if(!e||!t)return false;let r=String(e).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===t}function xy(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Ay(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function nd(e){if(e)return e;let t=ya(import.meta.url),r=[t,Pe(t,"..","cli","node"),Pe(t,"..","..","cli","node")];for(let n of r)try{return ts(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function Ty(e,t,r){let{cliDir:n,opts:s}=xy(t,r),o=nd(n),a=e.value,u={meta:"board-live-cards",howToRun:"local-node",whatToRun:(s?.suppressSpawn?"":ts(o))?pe({kind:"yaml-flow-cli",value:"board-live-cards-cli.js"}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>tn(Pe(a,`.${c}`)),blobStorage:c=>c?Ht(Pe(a,c)):Ht(a),scratchStorage:()=>Zr(Pe(a,".tmp")),scratchStorageForRef:c=>Zr(Ye(c).value),archiveFactory:()=>en(Pe(a,"archive")),archiveFactoryForRef:c=>en(Ye(c).value),journalAdapter:()=>Na(a),lock:qa(Pe(a,$y)),selfRef:u,async dispatchExecution(c,d){if(s?.suppressSpawn)return {dispatched:false};try{let l=d.source_def?.bindTo??Qn().slice(0,8),h=Zr(Pe(a,".tmp")),v=h.create(JSON.stringify(d,null,2),`exec-in-${l}`,".json"),p=h.getUniqueKey(`exec-out-${l}`,".json"),m=h.getUniqueKey(`exec-err-${l}`,".txt"),b=pe(h.keyRef(v)),R=pe(h.keyRef(p)),N=pe(h.keyRef(m));return Ia(c,{subcommand:"run-source-fetch",inRef:b,outRef:R,errRef:N},o),{dispatched:!0}}catch(l){let h=l instanceof Error?l.message:String(l);try{let v=en(Pe(a,"archive")),p=new Date().toISOString().replace(/[:.]/g,"-"),m=d.source_def?.bindTo??"unknown";v.blob("exec-failures").write(`${p}-${m}.json`,JSON.stringify({error:h,args:d,ref:c,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:h}}},resolveBlob(c){let d=ga(c.value)?cs().read(c.value):Ht(a).read(c.value);if(d===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return d},hashFn:Pa,genId:()=>ha(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>tn(Ye(c).value),requestProcessAccumulated(){s?.suppressSpawn||wa(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let d=c.map(l=>({id:Qn(),ts:new Date().toISOString(),boardRef:pe(e),notification:l}));ba(s.notifyChannel,d,s.onWarn);},onWarn:s?.onWarn}}function ww(e,t,r){let{cliDir:n,opts:s}=Ay(t,r),o=nd(n),a=Ty(e,o,s),i=Wr();return {...a,invokeExecutorSync(u,c,d,l){let{command:h,baseArgs:v}=Yr(u,o),p=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(h,[...v,c,...d,...p],{timeout:l?.timeout??3e4,encoding:"utf-8",input:l?.input})},validateSchema(u){let c=Yo(u);return {ok:c.errors.length===0,errors:c.errors}},absoluteBlob:cs()}}function bw(e,t={}){let r=t.chatsSubdir??"chats",n=t.kvSubdir??".kv",s=n?[n,"chat"]:["chat"],o=r&&!rd(e,r)?Pe(e,r):e,a=tn(Pe(e,...s));return Xo(i=>{let c=`${String(i).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,d=Pe(o,c);return us(d)},a)}function kw(e,t={}){let r=t.filesSubdir??"files",n=r&&!rd(e,r)?Pe(e,r):e;return oa(Ht(n))}function _w(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
19
- export{$t as BOARD_GRAPH_KEY,Gn as EMPTY_CONFIG,Vr as SNAPSHOT_SCHEMA_VERSION_V1,Yr as buildLocalBaseSpec,oa as createArtifactsStore,gy as createArtifactsStorePublic,my as createBoardLiveCardsMcp,dy as createBoardLiveCardsNonCorePublic,uy as createBoardLiveCardsPublic,Ry as createCardFileMetadataStore,Vn as createCardStore,sa as createCardStorePublic,Xo as createChatStorage,Md as createExecutionRefInvoker,_y as createFileArtifactsStore,bw as createFsBoardChatStorage,kw as createFsBoardFileArtifactsStore,ww as createFsBoardNonCorePlatformAdapter,Ty as createFsBoardPlatformAdapter,jh as createInMemoryChatStorage,Sw as createNodeSpawnInvocationAdapter,_w as decodeBoardRefFromToken,ns as evaluateArgsMassaging,ry as executionRefFromScriptPath,Ta as invokeExecutionRef,ss as invokeExecutionRefSync,Ld as invokeRefSync,ra as parseExecutionRef,Ye as parseRef,Qe as resolveWhatToRunValue,Ca as resolveYamlFlowCliPath,ta as serializeExecutionRef,pe as serializeRef};//# sourceMappingURL=board-live-cards-node.js.map
14
+ `,"utf-8");}catch{}function n(){if(!$.existsSync(r))return {};try{let a=$.readFileSync(r,"utf-8"),i=JSON.parse(a);return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return {}}}function s(a){let i=`${r}.${process.pid}.${randomUUID()}.tmp`;try{$.writeFileSync(i,JSON.stringify(a,null,2),"utf-8"),dt(i,r);}catch{}}function o(){if(!$.existsSync(t))return;let a=n(),i=typeof a["retention.maxAgeMs"]=="number"?a["retention.maxAgeMs"]:0,u=typeof a["retention.sweepIntervalMs"]=="number"?a["retention.sweepIntervalMs"]:0;if(i<=0||u<=0)return;let c=typeof a["retention.lastSweepAt"]=="number"?a["retention.lastSweepAt"]:0,d=Date.now();if(d-c<u)return;a["retention.lastSweepAt"]=d,s(a);let l=d,g=v=>{let f;try{f=$.readdirSync(v,{withFileTypes:!0});}catch{return}for(let m of f){if(Date.now()-l>Xd)return;let b=oe.join(v,m.name);if(m.isDirectory()){g(b);continue}if(m.isFile())try{let C=$.statSync(b);if(d-C.mtimeMs>i)try{$.unlinkSync(b);}catch{}}catch{}}};g(oe.join(e,Zr)),g(oe.join(e,en));}return {stream(a){let i=qa(a),u=oe.join(e,Zr,`${i}.jsonl`),c=ds(u);return {append(d){let l=c.append(d);try{o();}catch{}return l},readAll:()=>c.readAll(),readAfter:d=>c.readAfter(d),clear:()=>{c.clear&&c.clear();}}},blob(a){let i=qa(a),u=oe.join(e,en,i);$.mkdirSync(u,{recursive:true});let c=Wt(u);return {read:d=>c.read(d),write:(d,l)=>{c.write(d,l);try{o();}catch{}},exists:d=>c.exists(d),remove:d=>c.remove(d),readBytes:c.readBytes?d=>c.readBytes(d):void 0,writeBytes:c.writeBytes?(d,l)=>{c.writeBytes(d,l);try{o();}catch{}}:void 0,listKeys:d=>c.listKeys(d),stat:c.stat?d=>c.stat(d):void 0}},listStreams(a){let i=oe.join(e,Zr);try{return $.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isFile()&&u.name.endsWith(".jsonl")).map(u=>u.name.slice(0,-6)).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},listBlobs(a){let i=oe.join(e,en);try{return $.readdirSync(i,{withFileTypes:!0}).filter(u=>u.isDirectory()).map(u=>u.name).filter(u=>!a||u.startsWith(a)).sort()}catch{return []}},config:{get(a){return n()[a]??null},set(a,i){let u=n();i==null?delete u[a]:u[a]=i,s(u);}}}}function nn(e){function t(n){return oe.join(e,...n.split("/"))+".json"}function r(n,s,o,a){if($.existsSync(n))for(let i of $.readdirSync(n,{withFileTypes:true})){let u=s?`${s}/${i.name}`:i.name;if(i.isDirectory()){r(oe.join(n,i.name),u,o,a);continue}if(!i.isFile()||!i.name.endsWith(".json"))continue;let c=u.replace(/\.json$/,"");(!o||c.startsWith(o))&&a.push(c);}}return {read(n){let s=t(n);if(!$.existsSync(s))return null;try{return JSON.parse($.readFileSync(s,"utf-8"))}catch{return null}},write(n,s){let o=t(n),a=`${o}.${process.pid}.${randomUUID()}.tmp`;$.mkdirSync(oe.dirname(o),{recursive:true}),$.writeFileSync(a,JSON.stringify(s,null,2),"utf-8"),dt(a,o);},delete(n){let s=t(n);try{$.existsSync(s)&&$.unlinkSync(s);}catch{}},listKeys(n){let s=[];return r(e,"",n,s),s.sort()}}}function ds(e){function t(){if(!$.existsSync(e))return [];let r=$.readFileSync(e,"utf-8").trim();return r?r.split(`
15
+ `).filter(Boolean).map(n=>JSON.parse(n)):[]}return {append(r){let n={id:randomUUID(),payload:r};return $.mkdirSync(oe.dirname(e),{recursive:true}),$.appendFileSync(e,JSON.stringify(n)+`
16
+ `,"utf-8"),n},readAll(){return t()},readAfter(r){let n=t();if(!r)return {entries:n,newCursor:n.length>0?n[n.length-1].id:null};let s=n.findIndex(a=>a.id===r),o=s===-1?n:n.slice(s+1);return {entries:o,newCursor:o.length>0?o[o.length-1].id:r}},clear(){$.existsSync(e)&&$.truncateSync(e,0);}}}function cs(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return `[${e.map(cs).join(",")}]`;let t=e;return `{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${cs(t[n])}`).join(",")}}`}function Fa(e){return createHash("sha256").update(cs(e)).digest("hex")}function Ma(e){let t=oe.join(e,"board-journal.jsonl");return {readAllEntries(){if(!$.existsSync(t))return [];let r=$.readFileSync(t,"utf-8").trim();return r?r.split(`
17
+ `).filter(Boolean).map(n=>JSON.parse(n)):[]},appendEntry(r){$.appendFileSync(t,JSON.stringify(r)+`
18
+ `,"utf-8");},generateId(){return randomUUID()}}}function Da(e){return {tryAcquire(){try{if(!$.existsSync(e)){$.mkdirSync(oe.dirname(e),{recursive:!0});try{$.writeFileSync(e,"{}",{flag:"wx"});}catch{}}return lockSync(e,{retries:0})}catch{return null}}}}var La={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://nsreehari.github.io/boards/live-cards.schema.json",definitions:{bind_ref:{description:"A card data path reference, e.g. 'card_data.raw_quotes' or 'requires.upstream'",type:"string",pattern:"^(card_data|requires|fetched_sources|computed_values)(\\.|$)"},bind_or_literal:{description:"A literal value or a bind reference object",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref"}},required:["bind"]}]},compute_expr:{description:"A declarative JSON compute expression",type:"object",required:["fn"],properties:{fn:{type:"string",description:"Function name from the built-in vocabulary",enum:["sum","avg","min","max","count","first","last","add","sub","mul","div","round","abs","mod","gt","gte","lt","lte","eq","neq","if","and","or","not","concat","upper","lower","template","filter","pluck","map","sort","slice","flat","unique","group","get","default","now","diff_days","format_date"]},input:{description:"card_data.path, literal, array of inputs, or nested compute_expr",oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array"},{$ref:"#/definitions/compute_expr"}]},field:{type:"string",description:"For pluck/sum/group \u2014 the object key to extract"},where:{$ref:"#/definitions/compute_expr",description:"For filter \u2014 predicate expression ($ = current item)"},cond:{$ref:"#/definitions/compute_expr",description:"For if \u2014 condition expression"},then:{description:"For if \u2014 value when cond is truthy"},else:{description:"For if \u2014 value when cond is falsy"},format:{type:"string",description:"For format_date \u2014 date format string"}}},meta:{type:"object",properties:{title:{type:"string"},tags:{type:"array",items:{type:"string"}}}},requires:{type:"array",items:{type:"string"},description:"IDs of upstream nodes this node depends on"},provides:{type:"array",items:{type:"object",required:["bindTo","ref"],properties:{bindTo:{type:"string",description:"Token name published downstream"},ref:{type:"string",description:"Path to read value from (card_data.*, requires.*, fetched_sources.*, computed_values.*)"}}},description:"Explicit bindings exposing computed or card_data values downstream as named tokens"},compute_step:{description:"A single ordered compute step: reads card_data.*/requires.*/computed_values.*, writes to computed_values[bindTo]",type:"object",required:["bindTo","expr"],properties:{bindTo:{type:"string",description:"Key in computed_values to write result"},expr:{type:"string",description:"JSONata expression evaluated against { card_data, requires, fetched_sources, computed_values }"}}},source_def:{description:"One source entry. The engine requires 'bindTo' (compute namespace key) and 'outputFile' (delivery signal path). bindTo and outputFile must be unique across all source_defs in a card. Every other property is yours \u2014 add whatever your task-executor needs: kind, url, headers, mailbox, channel, model, query, etc. The full object is passed verbatim as the --in JSON to the executor.",type:"object",required:["bindTo","outputFile"],additionalProperties:true,properties:{bindTo:{type:"string",description:"Key under fetched_sources.* available in compute expressions"},outputFile:{type:"string",description:"Board-relative path the executor writes its JSON result to. Presence of this file signals delivery."},projections:{type:"object",description:"Named data projections from card_data or requires, evaluated before the executor is called. Each key is a ref name; each value is a JSONata expression rooted at card_data or requires. The resolved values are passed to the executor as _projections. fetched_sources, computed_values, and source_defs are not accessible here \u2014 sources run before those exist.",additionalProperties:{type:"string"}},optionalForCompletionGating:{type:"boolean",default:false,description:"When true this source does not gate card completion. Default false when absent, so source_defs are completion-gating by default."},timeout:{type:"integer",minimum:0,default:12e4,description:"Executor/script timeout in ms. Default: 120 000 (2 min)."},script:{type:"string",description:"Legacy direct-run: shell command executed when no .task-executor is registered. stdout is captured as the result."}}},render_element:{type:"object",required:["kind"],properties:{id:{type:"string",description:"Optional element ID for targeted updates"},kind:{enum:["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]},label:{type:"string",description:"Heading above this element"},className:{type:"string",description:"Bootstrap grid class, e.g. 'col-12 col-md-6'"},visible:{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 element shown only if truthy"},data:{type:"object",properties:{bind:{$ref:"#/definitions/bind_ref",description:"card_data/requires/fetched_sources/computed_values path to read data from"},writeTo:{$ref:"#/definitions/bind_ref",description:"card_data path for user input (form, filter, todo, notes)"},columns:{type:"array",items:{type:"string"},description:"table: visible columns"},maxRows:{type:"integer",description:"table/list: max rows to display"},sortable:{type:"boolean",default:true,description:"table: enable click-to-sort"},placeholder:{type:"string",description:"Empty-state message"},chartType:{enum:["bar","line","pie","doughnut"]},chartOptions:{type:"object",description:"Chart.js options passthrough"},fields:{type:"object",description:"JSON Schema for form/filter fields"},thresholds:{type:"object",properties:{green:{type:"string"},amber:{type:"string"}}},colorMap:{type:"object",description:"badge: value \u2192 Bootstrap color"},style:{enum:["heading","muted","default"],description:"text: display style"},upload:{type:"boolean",default:true,description:"file-upload: show drop zone (false = read-only file list)"},accept:{type:"array",items:{type:"string"},description:"file-upload: allowed extensions"},multiple:{type:"boolean",default:true,description:"file-upload: allow multiple files"},fileAttach:{type:"boolean",default:false,description:"chat: enable inline file attachments"},fileAccept:{type:"array",items:{type:"string"},description:"chat: allowed attachment extensions"},buttons:{type:"array",description:"actions: button definitions",items:{type:"object",required:["id","label"],properties:{id:{type:"string"},label:{type:"string"},style:{type:"string",description:"Bootstrap button variant, e.g. 'success', 'outline-danger'"},size:{type:"string",default:"sm"},disabled:{oneOf:[{type:"boolean"},{type:"string",description:"card_data/requires/fetched_sources/computed_values path \u2014 truthy = disabled"}]}}}}}}}},view:{type:"object",required:["elements"],properties:{elements:{type:"array",minItems:1,items:{$ref:"#/definitions/render_element"}},layout:{type:"object",properties:{board:{type:"object",properties:{col:{type:"integer",minimum:1,maximum:12},order:{type:"integer"}}},canvas:{type:"object",properties:{x:{type:"number"},y:{type:"number"},w:{type:"number"},h:{type:"number"}}}}},features:{type:"object",properties:{chat:{type:"boolean",default:false},notes:{type:"boolean",default:false},refresh:{type:"boolean",default:true}}}}}},title:"LiveCard",description:"A unified card node. Behavior depends on which sections are present (source_defs, compute, view, etc.)",type:"object",required:["id"],additionalProperties:false,properties:{id:{type:"string"},requires:{$ref:"#/definitions/requires"},provides:{$ref:"#/definitions/provides"},meta:{$ref:"#/definitions/meta"},view:{$ref:"#/definitions/view"},card_data:{type:"object",description:"Authored card data and runtime metadata. Includes uploaded-file metadata maintained by host handlers and inference evaluation results.",properties:{files:{type:"array",description:"Optional uploaded-file metadata maintained by host handlers. Stored name is normalized and serial-prefixed (for example 001-my_file.pdf).",items:{type:"object",required:["name","stored_name"],properties:{name:{type:"string",minLength:1},stored_name:{type:"string",minLength:5,maxLength:32,pattern:"^[0-9]{3,}-[a-z0-9._-]+$"},size:{oneOf:[{type:"integer",minimum:0},{type:"null"}]},mime_type:{type:"string"},path:{type:"string",pattern:"^[^\\s]+/files/[0-9]{3,}-[a-z0-9._-]+$"},uploaded_at:{type:"string",format:"date-time"},chat:{type:"boolean",description:"Whether this file entry is associated with a chat interaction"}},additionalProperties:false}}},additionalProperties:true},source_defs:{type:"array",description:"Source entries. Each entry is passed verbatim to the board's .task-executor (registered via init --task-executor) as the --in JSON file. The executor fetches/generates the data and writes JSON to --out. If no executor is registered, the built-in executor runs the entry's 'cli' command directly. Sources gate completion by default. Set optionalForCompletionGating: true for enrichment-only source_defs that should not block task-completed.",items:{$ref:"#/definitions/source_def"}},compute:{type:"array",description:"Ordered array of compute steps. Each reads card_data.*/requires.*/fetched_sources.*/computed_values.* and writes to ephemeral computed_values[bindTo].",items:{$ref:"#/definitions/compute_step"}}}};var hu=hd(pu());var xh=createRequire(import.meta.url),Ah=xh("./jsonata-sync.cjs"),Dn=null;var mu=/\b(card_data|requires|fetched_sources|computed_values|source_defs)\b/g,Th=/^\s*(card_data|requires|fetched_sources|computed_values|source_defs)(\.|$)/;function Ih(e){let t=new Set,r;for(mu.lastIndex=0;(r=mu.exec(e))!==null;)t.add(r[1]);return t}function yu(e){let t=Th.exec(e);return t?t[1]:null}function gu(e,t,r,n){try{Ah(e);}catch(o){let a=o instanceof Error?o.message:String(o);n.push(`${t}: invalid JSONata expression (${a})`);return}let s=Ih(e);for(let o of s)r.has(o)||n.push(`${t}: disallowed namespace "${o}" in expression`);}function Yo(e,t,r){if(Array.isArray(e)){e.forEach((s,o)=>{Yo(s,`${t}/${o}`,r);});return}if(typeof e=="string"){let s=yu(e);if(!s)return;new Set(["card_data","requires","computed_values"]).has(s)||r.push(`${t}: disallowed namespace "${s}" in view reference`);return}if(!e||typeof e!="object")return;let n=e;for(let[s,o]of Object.entries(n))Yo(o,`${t}/${s}`,r);}function jh(){if(Dn)return Dn;let e=new hu.default({allErrors:true});return $h(e),Dn=e.compile(La),Dn}function vu(e){let t=jh(),r=t(e),n=(t.errors??[]).map(s=>`${s.instancePath||"/"}: ${s.message??"unknown error"}`);if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.source_defs;if(Array.isArray(s)){let o=new Set,a=new Set;s.forEach((i,u)=>{if(!i||typeof i!="object"||Array.isArray(i))return;let c=i;typeof c.bindTo=="string"&&c.bindTo&&(o.has(c.bindTo)&&n.push(`/source_defs/${u}/bindTo: bindTo "${c.bindTo}" must be unique across all source_defs`),o.add(c.bindTo)),typeof c.outputFile=="string"&&c.outputFile&&(a.has(c.outputFile)&&n.push(`/source_defs/${u}/outputFile: outputFile "${c.outputFile}" must be unique across all source_defs`),a.add(c.outputFile));});}}return !r||n.length>0?{ok:false,errors:n}:{ok:true,errors:[]}}function Su(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:true,errors:[]};let r=e,n=r.compute;Array.isArray(n)&&n.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.expr;typeof l!="string"||l.trim().length===0||gu(l,`/compute/${d}/expr`,new Set(["card_data","requires","fetched_sources","computed_values"]),t);});let s=new Set(["card_data","requires","fetched_sources","computed_values"]),o=r.provides;Array.isArray(o)&&o.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.ref;if(typeof l!="string"||l.trim().length===0)return;let g=yu(l);g===null?t.push(`/provides/${d}/ref: path "${l}" must start with a valid namespace (${[...s].join(", ")})`):s.has(g)||t.push(`/provides/${d}/ref: disallowed namespace "${g}" in path "${l}" (valid: ${[...s].join(", ")})`);});let a=r.view;a&&typeof a=="object"&&!Array.isArray(a)&&Yo(a,"/view",t);let i=new Set(["card_data","requires"]),u=r.source_defs;return Array.isArray(u)&&u.forEach((c,d)=>{if(!c||typeof c!="object"||Array.isArray(c))return;let l=c.projections;if(!(!l||typeof l!="object"||Array.isArray(l)))for(let[g,v]of Object.entries(l))typeof v!="string"||v.trim().length===0||gu(v,`/source_defs/${d}/projections/${g}`,i,t);}),{ok:t.length===0,errors:t}}function Xo(e){let t=vu(e);if(!t.ok)return t;let r=Su(e);return r.ok?{ok:true,errors:[]}:{ok:false,errors:r.errors}}function wu(e){return String(e).replace(/[^a-zA-Z0-9_-]/g,"_")}function ku(e){let t=e.payload??{};return {id:e.id,role:typeof t.role=="string"?t.role:"system",text:typeof t.text=="string"?t.text:"",files:Array.isArray(t.files)?t.files:[],turn:typeof t.turn=="string"?t.turn:"",updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function Qo(e,t){let r=s=>`chats/${wu(s)}/processing`,n=s=>`chats/${wu(s)}/config`;return {append(s,o,a,i=[],u=""){return e(s).append({role:o,text:a,files:i,turn:u,updated_at:new Date().toISOString()}).id},readAll(s){return e(s).readAll().map(ku)},readAfter(s,o){let a=e(s).readAfter(o);return {records:a.entries.map(ku),cursor:a.newCursor}},clear(s){e(s).clear?.();},setProcessing(s,o){o?t.write(r(s),true):t.delete(r(s));},isProcessing(s){return t.read(r(s))===true},getConfig(s){return t.read(n(s))??{}},setConfig(s,o){let a=t.read(n(s))??{};t.write(n(s),{...a,...o});}}}function Oh(){let e=globalThis.crypto;return typeof e?.randomUUID=="function"?String(e.randomUUID()):`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Ph(){let e=new Map,t=new Map;function r(n){return e.has(n)||e.set(n,[]),e.get(n)}return {append(n,s,o,a=[],i=""){let u={id:Oh(),role:s,text:o,files:a,turn:i,updated_at:new Date().toISOString()};return r(n).push(u),u.id},readAll(n){return r(n).slice()},readAfter(n,s){let o=r(n);if(!s)return {records:o.slice(),cursor:o.length>0?o[o.length-1].id:null};let a=o.findIndex(u=>u.id===s),i=a===-1?o.slice():o.slice(a+1);return {records:i,cursor:i.length>0?i[i.length-1].id:s}},clear(n){e.set(n,[]);},setProcessing(n,s){s?t.set(`p:${n}`,true):t.delete(`p:${n}`);},isProcessing(n){return t.get(`p:${n}`)===true},getConfig(n){return t.get(`c:${n}`)??{}},setConfig(n,s){let o=t.get(`c:${n}`)??{};t.set(`c:${n}`,{...o,...s});}}}var $t={RUNNING:"running",COMPLETED:"completed",FAILED:"failed",INACTIVATED:"inactivated"};function Ue(e){return e?Array.isArray(e.provides)?e.provides:[]:[]}function Et(e){return e?Array.isArray(e.requires)?e.requires:[]:[]}function bu(e){return e.tasks??{}}function Zo(e){return e?e.status===$t.FAILED||e.status===$t.INACTIVATED:false}function Ru(e,t){return e.refreshStrategy??t?.refreshStrategy??"data-changed"}function _u(e){return e.maxExecutions}function Cu(e,t){let r=new Set;for(let[n,s]of Object.entries(t))if(s.status===$t.COMPLETED){let o=e.tasks[n];o&&Ue(o).forEach(i=>r.add(i));}return Array.from(r)}function $u(e,t){let r={};return e.forEach(n=>{let s=t[n];if(!s)return;Ue(s).forEach(a=>{r[a]||(r[a]=[]),r[a].push(n);});}),r}function Eu(e,t,r){let n=e.tasks[t]??Ln(),s={};if(r){let a=r.tasks[t],i=Et(a);for(let u of i)for(let[c,d]of Object.entries(r.tasks))if(Ue(d).includes(u)){let l=e.tasks[c];l?.lastDataHash&&(s[u]=l.lastDataHash);break}}let o={...n,status:"running",startedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),progress:0,error:void 0,startConsumedHashes:s};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function xu(e,t,r,n,s,o){let a=e.tasks[r]??Ln(),i=t.tasks[r];if(!i)throw new Error(`Task "${r}" not found in graph`);let u;n&&i.on&&i.on[n]?u=i.on[n]:u=Ue(i);let c=a.startConsumedHashes?{...a.startConsumedHashes}:{...a.lastConsumedHashes};if(!a.startConsumedHashes){let g=i.requires??[];for(let v of g)for(let[f,m]of Object.entries(t.tasks))if(Ue(m).includes(v)){let b=e.tasks[f];b?.lastDataHash&&(c[v]=b.lastDataHash);break}}let d={...a,status:"completed",completedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),executionCount:a.executionCount+1,lastEpoch:a.executionCount+1,lastDataHash:s,data:o,lastConsumedHashes:c,error:void 0},l=[...new Set([...e.availableOutputs,...u])];return {...e,tasks:{...e.tasks,[r]:d},availableOutputs:l,lastUpdated:new Date().toISOString()}}function Au(e,t,r,n){let s=e.tasks[r]??Ln(),o=t.tasks[r];if(o?.retry){let u=s.retryCount+1;if(u<=o.retry.max_attempts){let c={...s,status:"not-started",retryCount:u,lastUpdated:new Date().toISOString(),error:n};return {...e,tasks:{...e.tasks,[r]:c},lastUpdated:new Date().toISOString()}}}let a={...s,status:"failed",failedAt:new Date().toISOString(),lastUpdated:new Date().toISOString(),error:n,executionCount:s.executionCount+1},i=e.availableOutputs;if(o?.on_failure&&o.on_failure.length>0&&(i=[...new Set([...e.availableOutputs,...o.on_failure])]),o?.circuit_breaker&&a.executionCount>=o.circuit_breaker.max_executions){let u=o.circuit_breaker.on_break;i=[...new Set([...i,...u])];}return {...e,tasks:{...e.tasks,[r]:a},availableOutputs:i,lastUpdated:new Date().toISOString()}}function Tu(e,t,r,n){let s=e.tasks[t]??Ln(),o={...s,progress:typeof n=="number"?n:s.progress,messages:[...s.messages??[],...r?[{message:r,timestamp:new Date().toISOString(),status:s.status}]:[]],lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:o},lastUpdated:new Date().toISOString()}}function Iu(e,t){let r=e.tasks[t];if(!r)return e;let n={...r,status:"not-started",startedAt:void 0,completedAt:void 0,failedAt:void 0,error:void 0,data:void 0,progress:null,lastUpdated:new Date().toISOString()};return {...e,tasks:{...e.tasks,[t]:n},lastUpdated:new Date().toISOString()}}function Ln(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Bn(e,t){let r=`live-${Date.now()}`,n={};for(let o of Object.keys(e.tasks))n[o]=Ou();let s={status:"running",tasks:n,availableOutputs:[],stuckDetection:{is_stuck:false,stuck_description:null,outputs_unresolvable:[],tasks_blocked:[]},lastUpdated:new Date().toISOString(),executionId:r,executionConfig:{executionMode:e.settings.execution_mode??"eligibility-mode",conflictStrategy:e.settings.conflict_strategy??"alphabetical",completionStrategy:e.settings.completion}};return {config:e,state:s}}function Nh(e,t){let{config:r,state:n}=e;if("executionId"in t&&t.executionId&&t.executionId!==n.executionId)return e;switch(t.type){case "task-started":return {config:r,state:Eu(n,t.taskName,r)};case "task-completed":return {config:r,state:xu(n,r,t.taskName,t.result,t.dataHash,t.data)};case "task-failed":return {config:r,state:Au(n,r,t.taskName,t.error)};case "task-progress":return {config:r,state:Tu(n,t.taskName,t.message,t.progress)};case "task-restart":return {config:r,state:Iu(n,t.taskName)};case "inject-tokens":return {config:r,state:{...n,availableOutputs:[...new Set([...n.availableOutputs,...t.tokens])],lastUpdated:new Date().toISOString()}};case "agent-action":return {config:r,state:Vh(n,t.action)};case "task-upsert":return qh(e,t.taskName,t.taskConfig);case "task-removal":return Fh(e,t.taskName);case "node-requires-add":return Mh(e,t.nodeName,t.tokens);case "node-requires-remove":return Dh(e,t.nodeName,t.tokens);case "node-provides-add":return Lh(e,t.nodeName,t.tokens);case "node-provides-remove":return Bh(e,t.nodeName,t.tokens);default:return e}}function ju(e,t){return t.reduce((r,n)=>Nh(r,n),e)}function qh(e,t,r){let n=!!e.config.tasks[t];return {config:{...e.config,tasks:{...e.config.tasks,[t]:r}},state:{...e.state,tasks:{...e.state.tasks,[t]:n?e.state.tasks[t]:Ou()},lastUpdated:new Date().toISOString()}}}function Fh(e,t){if(!e.config.tasks[t])return e;let{[t]:r,...n}=e.config.tasks,{[t]:s,...o}=e.state.tasks;return {config:{...e.config,tasks:n},state:{...e.state,tasks:o,lastUpdated:new Date().toISOString()}}}function Mh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Et(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:[...s,...o]}}},state:e.state}}function Dh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Et(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,requires:o}}},state:e.state}}function Lh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ue(n),o=r.filter(a=>!s.includes(a));return o.length===0?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:[...s,...o]}}},state:e.state}}function Bh(e,t,r){let n=e.config.tasks[t];if(!n)return e;let s=Ue(n),o=s.filter(a=>!r.includes(a));return o.length===s.length?e:{config:{...e.config,tasks:{...e.config.tasks,[t]:{...n,provides:o}}},state:e.state}}function Lr(e){return {version:1,config:e.config,state:e.state,snapshotAt:new Date().toISOString()}}function Vn(e){if(!e||typeof e!="object")throw new Error("Invalid snapshot: expected an object");let t=e;if(!t.config||typeof t.config!="object")throw new Error('Invalid snapshot: missing or invalid "config"');if(!t.state||typeof t.state!="object")throw new Error('Invalid snapshot: missing or invalid "state"');let r=t.config,n=t.state;if(!r.settings||typeof r.settings!="object")throw new Error("Invalid snapshot: config.settings missing");if(!r.tasks||typeof r.tasks!="object")throw new Error("Invalid snapshot: config.tasks missing");if(!n.tasks||typeof n.tasks!="object")throw new Error("Invalid snapshot: state.tasks missing");if(!Array.isArray(n.availableOutputs))throw new Error("Invalid snapshot: state.availableOutputs must be an array");return {config:r,state:n}}function Ou(){return {status:"not-started",executionCount:0,retryCount:0,lastEpoch:0,messages:[],progress:null}}function Vh(e,t){let r=new Date().toISOString();switch(t){case "stop":return {...e,status:"stopped",lastUpdated:r};case "pause":return {...e,status:"paused",lastUpdated:r};case "resume":return {...e,status:"running",lastUpdated:r};default:return e}}function Br(e){let{config:t,state:r}=e,n=bu(t);if(Object.keys(n).length===0)return {eligible:[],pending:[],unresolved:[],blocked:[],conflicts:{}};let o=Uh(n),a=Cu(t,r.tasks),i=new Set([...a,...r.availableOutputs]),u=[],c=[],d=[],l=[];for(let[v,f]of Object.entries(n)){let m=r.tasks[v],b=Ru(f,t.settings),C=b!=="once";if(m?.status===$t.RUNNING||Zo(m))continue;let q=_u(f);if(q!==void 0&&m&&m.executionCount>=q||f.circuit_breaker&&m&&m.executionCount>=f.circuit_breaker.max_executions||!C&&m?.status===$t.COMPLETED)continue;if(C&&m?.status===$t.COMPLETED){let w=Et(f),p=false;switch(b){case "data-changed":{w.length>0&&w.some(R=>{for(let[x,A]of Object.entries(n))if(Ue(A).includes(R)){let T=r.tasks[x];if(!T)continue;let V=m.lastConsumedHashes?.[R];return T.lastDataHash==null?T.executionCount>m.lastEpoch:T.lastDataHash!==V}return false})||(p=true);break}case "epoch-changed":{w.length>0&&w.some(R=>{for(let[x,A]of Object.entries(n))if(Ue(A).includes(R)){let T=r.tasks[x];if(T&&T.executionCount>m.lastEpoch)return true}return false})||(p=true);break}case "time-based":{let h=f.refreshInterval??0;if(h<=0){p=true;break}let R=m.completedAt;if(!R){p=true;break}(Date.now()-Date.parse(R))/1e3<h&&(p=true);break}case "manual":p=true;break}if(p)continue}let _=Et(f);if(_.length===0){u.push(v);continue}let I=[],S=[],k=[];for(let w of _){if(i.has(w))continue;let p=o[w]||[];p.length===0?I.push(w):p.every(R=>Zo(r.tasks[R]))?k.push({token:w,failedProducer:p[0]}):S.push(w);}I.length>0?d.push({taskName:v,missingTokens:I}):k.length>0?l.push({taskName:v,failedTokens:k.map(w=>w.token),failedProducers:[...new Set(k.map(w=>w.failedProducer))]}):S.length>0?c.push({taskName:v,waitingOn:S}):u.push(v);}let g={};if(u.length>1){let v=$u(u,n);for(let[f,m]of Object.entries(v))m.length>1&&(g[f]=m);}return {eligible:u,pending:c,unresolved:d,blocked:l,conflicts:g}}function Uh(e){let t={};for(let[r,n]of Object.entries(e)){for(let s of Ue(n))t[s]||(t[s]=[]),t[s].push(r);if(n.on)for(let s of Object.values(n.on))for(let o of s)t[o]||(t[o]=[]),t[o].includes(r)||t[o].push(r);if(n.on_failure)for(let s of n.on_failure)t[s]||(t[s]=[]),t[s].includes(r)||t[s].push(r);}return t}var Vr=class{buffer=[];append(t){this.buffer.push(t);}drain(){let t=this.buffer;return this.buffer=[],t}get size(){return this.buffer.length}};function ea(e){let t=ta(e);return Kh(t)}function ta(e){if(e==null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(ta).join(",")+"]";let t=e;return "{"+Object.keys(t).sort().map(n=>JSON.stringify(n)+":"+ta(t[n])).join(",")+"}"}function Kh(e){let t=0xcbf29ce484222325n,r=0x100000001b3n,n=0xffffffffffffffffn;for(let s=0;s<e.length;s++)t^=BigInt(e.charCodeAt(s)),t=t*r&n;return t.toString(16).padStart(16,"0")}function Gh(e){if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64url");if(typeof btoa=="function"){let t=new TextEncoder().encode(e),r="";for(let n of t)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}throw new Error("No base64 encoder available in this runtime")}function Jh(e){if(typeof Buffer<"u")return Buffer.from(e,"base64url").toString("utf8");if(typeof atob=="function"){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function Pu(e){let t=JSON.stringify({t:e,n:Date.now().toString(36)+Math.random().toString(36).slice(2,6)});return Gh(t)}function zh(e){try{let t=JSON.parse(Jh(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function Nu(e,t,r){let{handlers:n,onNodeRemoved:s,onDrain:o}=t,a=new Vr,i="state"in e&&"config"in e?e:Bn(e),u=false,c=new Set,d=new Map(Object.entries(n)),l=new Vr,g=false,v=false;function f(){if(!u){if(g){v=true;return}g=true;try{do v=!1,m();while(v)}finally{g=false;}}}function m(){let _=l.drain(),I=a.drain(),S=[..._,...I];if(S.length>0&&(i=ju(i,S),s)){for(let w of S)if(w.type==="task-removal")try{s(w.taskName);}catch(p){console.warn("[reactive] onNodeRemoved failed:",p instanceof Error?p.message:String(p));}}let k=Br(i);S.length>0&&o?.(S,i,k);for(let w of k.eligible)q(w);for(let w of S)if(w.type==="task-progress"){let{taskName:p,update:h}=w;if(!i.config.tasks[p])continue;let x=i.state.tasks[p];if(!x||x.status!=="running")continue;let A=Pu(p),T=C(p,A,h).catch(V=>{u||(l.append({type:"task-failed",taskName:p,error:V.message??String(V),timestamp:new Date().toISOString()}),f());}).finally(()=>{c.delete(T);});c.add(T);}}function b(_){let S=i.config.tasks[_].requires??[],k=new Map;for(let[p,h]of Object.entries(i.config.tasks))for(let R of h.provides??[])k.set(R,p);let w={};for(let p of S){let h=k.get(p);h?w[p]=i.state.tasks[h]?.data:w[p]=void 0;}return w}async function C(_,I,S){let k=i.config.tasks[_],w=k.taskHandlers??[],p=b(_);for(let h of w){let R=d.get(h);if(!R)throw new Error(`Handler '${h}' not found in registry (task '${_}')`);let x={nodeId:_,state:p,taskState:i.state.tasks[_],config:k,callbackToken:I,update:S};if(await R(x)==="task-initiate-failure")throw new Error(`Handler '${h}' returned task-initiate-failure (task '${_}')`)}}function q(_){let S=i.config.tasks[_]?.taskHandlers;if(!S||S.length===0)return;l.append({type:"task-started",taskName:_,timestamp:new Date().toISOString()}),f();let k=Pu(_),w=C(_,k).catch(p=>{u||(l.append({type:"task-failed",taskName:_,error:p.message??String(p),timestamp:new Date().toISOString()}),f());}).finally(()=>{c.delete(w);});c.add(w);}return {push(_){u||(_.type==="task-completed"&&_.data&&!_.dataHash&&(_={..._,dataHash:ea(_.data)}),a.append(_),f());},pushAll(_){if(!u){for(let I of _)I.type==="task-completed"&&I.data&&!I.dataHash?a.append({...I,dataHash:ea(I.data)}):a.append(I);f();}},resolveCallback(_,I,S){if(u)return;let k=zh(_);if(!k)return;let{taskName:w}=k;if(i.config.tasks[w]){if(S&&S.length>0)a.append({type:"task-failed",taskName:w,error:S.join("; "),timestamp:new Date().toISOString()});else {let p=I&&Object.keys(I).length>0?ea(I):void 0;a.append({type:"task-completed",taskName:w,data:I,dataHash:p,timestamp:new Date().toISOString()});}f();}},addNode(_,I){u||(a.append({type:"task-upsert",taskName:_,taskConfig:I,timestamp:new Date().toISOString()}),f());},removeNode(_){u||(a.append({type:"task-removal",taskName:_,timestamp:new Date().toISOString()}),f());},addRequires(_,I){u||(a.append({type:"node-requires-add",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},removeRequires(_,I){u||(a.append({type:"node-requires-remove",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},addProvides(_,I){u||(a.append({type:"node-provides-add",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},removeProvides(_,I){u||(a.append({type:"node-provides-remove",nodeName:_,tokens:I,timestamp:new Date().toISOString()}),f());},registerHandler(_,I){d.set(_,I);},unregisterHandler(_){d.delete(_);},retrigger(_){u||i.config.tasks[_]&&(a.append({type:"task-restart",taskName:_,timestamp:new Date().toISOString()}),f());},retriggerAll(_){if(!u){for(let I of _)i.config.tasks[I]&&a.append({type:"task-restart",taskName:I,timestamp:new Date().toISOString()});f();}},snapshot(){return Lr(i)},getState(){return i},getSchedule(){return Br(i)},async waitForHandlers(){c.size>0&&await Promise.allSettled([...c]);},async dispose(_){_?.wait&&c.size>0&&await Promise.allSettled([...c]),u=true;}}}var Wh=createRequire(import.meta.url),Un=Wh("./jsonata-sync.cjs"),Mu=Un;function qu(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let s=0;s<r.length;s++){if(n==null)return;n=n[r[s]];}return n}function Du(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++)(s[n[o]]==null||typeof s[n[o]]!="object")&&(s[n[o]]={}),s=s[n[o]];s[n[n.length-1]]=r;}async function Yh(e,t){if(!e?.compute?.length)return e;e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values};for(let s of e.compute)try{let o=await Un(s.expr).evaluate(n);Du(e.computed_values,s.bindTo,o),n.computed_values=e.computed_values;}catch{}return e}function Xh(e,t){if(!e?.compute?.length)return {ok:true,node:e};e.card_data||(e.card_data={}),e.computed_values={},e._sourcesData=t?.sourcesData??{};let r=e.requires??{},n={card_data:e.card_data,requires:r,expects_data:r,fetched_sources:e._sourcesData,data:e.computed_values,computed_values:e.computed_values},s=[];for(let o of e.compute)try{let a=Mu(o.expr).evaluate(n);Du(e.computed_values,o.bindTo,a),n.computed_values=e.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);s.push({bindTo:o.bindTo,error:i});}return s.length>0?{ok:true,node:e,errors:s}:{ok:true,node:e}}async function Qh(e,t,r){let n={...r??{},card_data:t.card_data??{},requires:t.requires??{},fetched_sources:t._sourcesData??{},computed_values:t.computed_values??{}};return Un(e).evaluate(n)}function Zh(e,t){return t.startsWith("fetched_sources.")?qu(e._sourcesData??{},t.slice(16)):qu(e,t)}var Fu=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),ey=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function ty(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return {ok:false,errors:["Node must be a non-null object"]};let r=e;(typeof r.id!="string"||!r.id)&&t.push("id: required, must be a non-empty string");for(let n of Object.keys(r))ey.has(n)||t.push(`Unknown top-level key: "${n}"`);if((r.card_data==null||typeof r.card_data!="object"||Array.isArray(r.card_data))&&t.push("card_data: required, must be an object"),r.meta!=null)if(typeof r.meta!="object"||Array.isArray(r.meta))t.push("meta: must be an object");else {let n=r.meta;n.title!=null&&typeof n.title!="string"&&t.push("meta.title: must be a string"),n.tags!=null&&!Array.isArray(n.tags)&&t.push("meta.tags: must be an array");}if(r.requires!=null&&!Array.isArray(r.requires)&&t.push("requires: must be an array of strings"),r.provides!=null&&(Array.isArray(r.provides)?r.provides.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`provides[${s}]: must be an object with bindTo and ref`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`provides[${s}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&t.push(`provides[${s}]: missing required "ref" string`);}}):t.push("provides: must be an array of { bindTo, ref } bindings")),r.compute!=null&&(Array.isArray(r.compute)?r.compute.forEach((n,s)=>{if(!n||typeof n!="object"||Array.isArray(n))t.push(`compute[${s}]: must be a compute step object`);else {let o=n;(typeof o.bindTo!="string"||!o.bindTo)&&t.push(`compute[${s}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&t.push(`compute[${s}]: missing required "expr" string (JSONata expression)`);}}):t.push("compute: must be an array of compute steps")),r.source_defs!=null)if(!Array.isArray(r.source_defs))t.push("source_defs: must be an array");else {let n=new Set,s=new Set;r.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))t.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?t.push(`source_defs[${a}]: missing required "bindTo" property`):(n.has(i.bindTo)&&t.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),n.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?t.push(`source_defs[${a}]: missing required "outputFile" property`):(s.has(i.outputFile)&&t.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),s.add(i.outputFile)),i.optionalForCompletionGating!=null&&typeof i.optionalForCompletionGating!="boolean"&&t.push(`source_defs[${a}]: optionalForCompletionGating must be a boolean`);}});}if(r.view!=null)if(typeof r.view!="object"||Array.isArray(r.view))t.push("view: must be an object");else {let n=r.view;!Array.isArray(n.elements)||n.elements.length===0?t.push("view.elements: required, must be a non-empty array"):n.elements.forEach((s,o)=>{if(!s||typeof s!="object"){t.push(`view.elements[${o}]: must be an object`);return}!s.kind||typeof s.kind!="string"?t.push(`view.elements[${o}].kind: required, must be a string`):Fu.has(s.kind)||t.push(`view.elements[${o}].kind: unknown kind "${s.kind}". Valid: ${[...Fu].join(", ")}`),s.data!=null&&(typeof s.data!="object"||Array.isArray(s.data))&&t.push(`view.elements[${o}].data: must be an object`);}),n.layout!=null&&(typeof n.layout!="object"||Array.isArray(n.layout))&&t.push("view.layout: must be an object"),n.features!=null&&(typeof n.features!="object"||Array.isArray(n.features))&&t.push("view.features: must be an object");}return {ok:t.length===0,errors:t}}async function ry(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return Promise.all(e.map(async n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=await Un(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}}))}function ny(e,t){if(!e||e.length===0)return [];let r={card_data:t.card_data??{},requires:t.requires??{}};return e.map(n=>{let s={};if(n.projections&&typeof n.projections=="object"&&!Array.isArray(n.projections)){for(let[o,a]of Object.entries(n.projections))if(typeof a=="string"&&a.trim().length>0)try{s[o]=Mu(a).evaluate(r);}catch{s[o]=void 0;}}return {...n,_projections:s}})}var ut={run:Yh,runSync:Xh,eval:Qh,resolve:Zh,validate:ty,enrichSources:ry,enrichSourcesSync:ny};function sy(e,t){let r;return /\.m?js$/i.test(e)?r="local-node":/\.py$/i.test(e)?r="local-python":r="local-process",{meta:"task-executor",howToRun:r,whatToRun:pe({kind:"fs-path",value:e}),...t?{extra:t}:{}}}function ra(e){return JSON.stringify(e)}function na(e){let t;try{t=JSON.parse(e);}catch{throw new Error(`parseExecutionRef: invalid JSON \u2014 ${e}`)}if(typeof t!="object"||t===null||typeof t.howToRun!="string"||typeof t.whatToRun!="string")throw new Error(`parseExecutionRef: missing required fields howToRun/whatToRun \u2014 ${e}`);return t}function Kn(e,t){function r(){return e.readIndex()??{}}function n(s,o,a){let i=String(o||"").split(".").filter(Boolean);if(i.length===0)return a&&typeof a=="object"&&!Array.isArray(a)?a:{value:a};let u={...s},c=u;for(let d=0;d<i.length-1;d++){let l=i[d],g=c[l],v=g&&typeof g=="object"&&!Array.isArray(g)?{...g}:{};c[l]=v,c=v;}return c[i[i.length-1]]=a,u}return {readCard(s){let o=r()[s];return !o||!e.cardExists(o.key)?null:e.readCard(o.key)},readCardKey(s){return r()[s]?.key??null},readAllCards(){let s=[];for(let[o,a]of Object.entries(r())){if(!e.cardExists(a.key))continue;let i=e.readCard(a.key);i?s.push(i):t?.(`[card-store] could not read card "${o}" at key "${a.key}"`);}return s},readChecksumIndex(){let s={};for(let[o,a]of Object.entries(r()))s[o]=a.checksum;return s},changedSince(s){let o=r(),a=[];for(let[i,u]of Object.entries(o))s[i]!==u.checksum&&a.push(i);for(let i of Object.keys(s))o[i]||a.push(i);return a},validateUpsert(s,o){let a=r(),i=a[s],u=Object.entries(a).find(([,c])=>c.key===o);return i&&i.key!==o?{ok:false,error:`Card id "${s}" is already mapped to key "${i.key}", cannot remap to "${o}"`}:u&&u[0]!==s?{ok:false,error:`Key "${o}" is already mapped to card id "${u[0]}", cannot remap to "${s}"`}:{ok:true}},writeCard(s,o,a){let i=r(),u=a??i[s]?.key??e.defaultCardKey(s),c=e.writeCard(u,o);i[s]={key:u,checksum:c,updatedAt:new Date().toISOString()},e.writeIndex(i);},patchCard(s,o,a){let i=r(),u=i[s];if(!u||!e.cardExists(u.key))throw new Error(`card "${s}" not found`);let c=e.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${s}" is not patchable`);let d=n(c,o,a),l=e.writeCard(u.key,d);i[s]={key:u.key,checksum:l,updatedAt:new Date().toISOString()},e.writeIndex(i);},removeCard(s){let o=r(),a=o[s];a&&(e.removeCard(a.key),delete o[s],e.writeIndex(o));},readIndex(){return r()}}}function Gn(e,t){return {readSourceData(r,n){let s=e.read(`${r}/${n}`);if(s==null)return null;let o=s.trim();if(!o)return null;try{return JSON.parse(o)}catch{return o}},ingestSourceDataStaged(r,n,s,o){let a=t(s);e.write(`${r}/.staged/${o}/${n}`,a);},commitSourceData(r,n,s){let o=`${r}/.staged/${s}/${n}`,a=e.read(o);return a==null?false:(e.write(`${r}/${n}`,a),e.remove(o),true)},hasSource(r,n){return e.exists(`${r}/${n}`)},listSources(r){return e.listKeys(`${r}/`).filter(n=>!n.includes("/.staged/")).map(n=>n.slice(`${r}/`.length))}}}function Ku(e){function t(r){let n=e.readAllEntries();if(!r)return n;let s=n.findIndex(o=>o.id===r);return s===-1?n:n.slice(s+1)}return {readEntriesAfterCursor(r){let n=t(r);return n.length===0?{events:[],newCursor:r}:{events:n.map(s=>s.event),newCursor:n[n.length-1].id}},pendingCount(r){return t(r).length},appendEvent(r){e.appendEntry({id:e.generateId(),event:r});}}}function Gu(e,t){return {appendEntries(r,n){if(!r||n.length===0)return;let s=e.read(r)??[];e.write(r,[...s,...n]);},dispatchEntriesForJournalId(r,n){if(!r)return;let s=e.read(r);if(!(!s||s.length===0)){for(let o of s)try{n(o);}catch(a){let i=a instanceof Error?a.message:String(a);try{t(o,i);}catch{}}e.delete(r);}}}}var Ur="v1",xt="board/graph",Ju="board/lastJournalProcessedId";function Lu(e){return `cards/${e}/runtime`}function zu(e){return {readRuntime(t){return e.read(Lu(t))??{_sources:{}}},writeRuntime(t,r){e.write(Lu(t),r);}}}function oy(e,t){let r={...e};for(let n of t.deleteKeys)delete r[n];return {...r,...t.shallowMerge}}function Hu(e){return {readSnapshot(t){return e.readValues(t)},commitSnapshot(t,r){if(r.schemaVersion!==Ur)throw new Error(`Unsupported snapshot schema version: ${r.schemaVersion}`);let n=e.readValues(t);if(n.version!==r.expectedVersion)return {ok:false,reason:"version-mismatch",currentVersion:n.version};let s=oy(n.values,r);return {ok:true,newVersion:e.writeValues(t,s,r.deleteKeys)}}}}function sa(e){function t(r){let n=e.read(r);return n==null?null:typeof n=="string"?n:JSON.stringify(n)}return {readTaskExecutorRef(){let r=t("task-executor");if(r?.trim())return na(r.trim())},writeTaskExecutorRef(r){e.write("task-executor",ra(r));},readChatHandlerFlow(){return e.read("chat-handler-flow")},writeChatHandlerFlow(r){e.write("chat-handler-flow",r);},readCardStoreRef(){return t("card-store-ref")},writeCardStoreRef(r){e.write("card-store-ref",r);},readOutputsStoreRef(){return t("outputs-store-ref")},writeOutputsStoreRef(r){e.write("outputs-store-ref",r);},readScratchStoreRef(){return t("scratch-store-ref")},writeScratchStoreRef(r){e.write("scratch-store-ref",r);},readArchiveStoreRef(){return t("archive-store-ref")},writeArchiveStoreRef(r){e.write("archive-store-ref",r);},readChatStoreRef(){return t("chat-store-ref")},writeChatStoreRef(r){e.write("chat-store-ref",r);},readArtifactsStoreRef(){return t("artifacts-store-ref")},writeArtifactsStoreRef(r){e.write("artifacts-store-ref",r);}}}function Wu(e){return {writeComputedValues(t,r){e.write(`cards/${t}/computed_values`,r);},readComputedValues(t){return e.read(`cards/${t}/computed_values`)},readAllComputedValues(){let t={};for(let r of e.listKeys("cards/")){let n=r.match(/^cards\/([^/]+)\/computed_values$/);n&&(t[n[1]]=e.read(r));}return t},writeDataObjects(t){for(let[r,n]of Object.entries(t))r&&e.write(`data-objects/${r}`,n);},readDataObject(t){return e.read(`data-objects/${t}`)},readAllDataObjects(){let t={};for(let r of e.listKeys("data-objects/"))t[r.slice(13)]=e.read(r);return t},writeStatusSnapshot(t){e.write("status",t);},readStatusSnapshot(){return e.read("status")}}}function Bu(e){return e?{lastRequestedToken:e.lastRequestedToken,lastCompletedToken:e.lastCompletedToken,lastCompletionStatus:e.lastCompletionStatus??(e.lastCompletedToken?"success":"not-started"),queueRequestedToken:e.queueRequestedToken}:{lastCompletionStatus:"not-started"}}function ay(e){return e?.lastRequestedToken?e.lastCompletedToken!==e.lastRequestedToken:false}function Vu(e,t){return e?.lastRequestedToken?ay(e)?"in-flight":!e.lastCompletedToken||e.lastCompletedToken<t?"dispatch":"idle":"dispatch"}function iy(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"success"}}function Uu(e,t){return {...e,lastCompletedToken:t,lastCompletionStatus:"failure"}}function Jn(e,t){let r=t.state.tasks,n=t.config.tasks,s=Object.keys(r),o=Br(t),a={completed:0,failed:0,in_progress:0,pending:0,blocked:0,unresolved:0},i=new Map;for(let f of o.pending)i.set(f.taskName,f.waitingOn);for(let f of o.unresolved)i.set(f.taskName,f.missingTokens);for(let f of o.blocked)i.set(f.taskName,f.failedTokens);let u=new Map;for(let[f,m]of Object.entries(n))for(let b of m.requires??[]){let C=u.get(b)??[];C.push(f),u.set(b,C);}let c=s.sort().map(f=>{let m=r[f],b=n[f]??{requires:[],provides:[]};m.status==="completed"?a.completed+=1:m.status==="failed"?a.failed+=1:m.status==="in-progress"&&(a.in_progress+=1);let C=b.requires??[],q=b.provides??[],_=Object.keys(m.data??{}).sort(),I=C.filter(R=>t.state.availableOutputs.includes(R)),S=C.filter(R=>!t.state.availableOutputs.includes(R)),k=i.get(f)??S,w=new Set;for(let R of q)for(let x of u.get(R)??[])x!==f&&w.add(x);let p=m.failedAt,h=m.error?{message:m.error,code:"TASK_FAILED",at:p,source:"task-runtime"}:void 0;return {name:f,status:m.status,error:h,requires:C,requires_satisfied:I,requires_missing:S,provides_declared:q,provides_runtime:_,blocked_by:k,unblocks:Array.from(w).sort(),runtime:{attempt_count:m.executionCount??0,restart_count:m.retryCount??0,in_progress_since:m.status==="in-progress"?m.startedAt??null:null,last_transition_at:m.lastUpdated??null,last_completed_at:m.completedAt??null,last_restarted_at:m.startedAt??null,status_age_ms:m.lastUpdated?0:null}}});a.pending=o.pending.length,a.blocked=o.blocked.length,a.unresolved=o.unresolved.length;let d=c.map(f=>({name:f.name,fanOut:f.unblocks.length})).sort((f,m)=>m.fanOut-f.fanOut||f.name.localeCompare(m.name)),l=d.length>0?d[0]:{name:null,fanOut:0},g=new Set;for(let f of Object.values(n))for(let m of f.requires??[])g.add(m);let v=0;for(let[f,m]of Object.entries(n)){let b=(m.requires??[]).length===0,q=(m.provides??[]).some(_=>(u.get(_)??[]).some(I=>I!==f));b&&!q&&(v+=1);}return {schema_version:"v1",meta:{board:{path:e}},summary:{card_count:s.length,completed:a.completed,eligible:o.eligible.length,pending:a.pending,blocked:a.blocked,unresolved:a.unresolved,failed:a.failed,in_progress:a.in_progress,orphan_cards:v,topology:{edge_count:Array.from(g).length,max_fan_out_card:l.name,max_fan_out:l.fanOut}},cards:c}}function cy(){return new Date().toISOString()}function Yu(e,t,r,n,s,o,a){return async i=>{let u=[],c=r.cardStore.readCard(i.nodeId);if(!c)return "task-initiate-failure";let d=c.id,l=c.card_data??{},g=c.source_defs??[],v=g.filter(N=>N.optionalForCompletionGating!==true),f=r.cardRuntimeStore.readRuntime(d),m=false,b=()=>{m&&(r.cardRuntimeStore.writeRuntime(d,f),m=false);},C=N=>Bu(f._sources[N]),q=(N,F)=>{f._sources[N]=Bu(F),m=true;},_=i.taskState?.executionCount??0;if(f._lastExecutionCount!==_&&(f._sources={},f._lastExecutionCount=_,m=true),i.update){let N=i.update,F=N.outputFile;if(F){let U=C(F);if(N.failure){let ne=N.rqt??U.lastRequestedToken??U.queueRequestedToken;ne&&q(F,Uu(U,ne));}else {let ne=N.rqt;if(!U.lastCompletedToken||ne>U.lastCompletedToken){let H=typeof N.deliveryToken=="string"?N.deliveryToken:void 0,be=false;H&&(be=r.fetchedSourcesStore.commitSourceData(d,F,H)),be?q(F,iy(U,ne)):q(F,Uu(U,ne));}}b();}}let S={};for(let N of g)if(N.outputFile){let F=r.fetchedSourcesStore.readSourceData(d,N.outputFile);F!==null&&(S[N.bindTo]=F);}let k={};for(let[N,F]of Object.entries(i.state??{}))if(F!==null&&typeof F=="object"&&!Array.isArray(F)){let U=F[N];k[N]=U!==void 0?U:F;}else k[N]=F;let w={id:d,card_data:{...l},requires:k,source_defs:g,compute:c.compute};w._sourcesData=S,c.compute&&ut.runSync(w,{sourcesData:S}),(o??r.outputStore.writeComputedValues.bind(r.outputStore))(d,w.computed_values??{});let p={...c},h=ut.enrichSourcesSync(Array.isArray(c.source_defs)?c.source_defs:void 0,{card_data:c.card_data,requires:k}),R=e.value;p.source_defs=Array.isArray(h)?h.map(N=>({...N,boardDir:typeof N.boardDir=="string"&&N.boardDir?N.boardDir:R})):h;let x=cy(),A=i.update?void 0:x,T=v.filter(N=>{let F=N.outputFile;if(typeof F!="string"||!F)return true;let U=C(F);A&&(U={...U,queueRequestedToken:A},q(F,U));let ne=U.queueRequestedToken??U.lastRequestedToken??x,H=Vu(U,ne);return H==="in-flight"?false:H==="dispatch"});if(b(),T.length>0){let N=false,F=x;for(let U of T){let ne=U.outputFile;if(typeof ne!="string"||!ne)continue;let H=C(ne),be=H.queueRequestedToken??x;q(ne,{...H,lastRequestedToken:be}),F=be,N=true;}return N&&b(),N&&(u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:p,callbackToken:i.callbackToken,rqt:F}}),r.executionRequestStore.appendEntries(t,u)),"task-initiated"}if(v.some(N=>{let F=N.outputFile;if(typeof F!="string"||!F)return false;let U=C(F),ne=U.queueRequestedToken??U.lastRequestedToken??x;return Vu(U,ne)==="in-flight"}))return "task-initiated";let Q=c.provides??[],te={};for(let{bindTo:N,ref:F}of Q)te[N]=ut.resolve(w,F);return (a??r.outputStore.writeDataObjects.bind(r.outputStore))(te),g.filter(N=>{if(N.optionalForCompletionGating!==true)return false;let F=C(N.outputFile);return !F.lastRequestedToken||!F.lastCompletedToken?true:F.lastCompletedToken<=F.lastRequestedToken}).length>0&&u.push({taskKind:"source-fetch",payload:{boardRef:pe(e),enrichedCard:p,callbackToken:i.callbackToken,rqt:x}}),n(i.nodeId,te),u.length>0&&r.executionRequestStore.appendEntries(t,u),"task-initiated"}}var zn={settings:{completion:"manual",refreshStrategy:"data-changed"},tasks:{}};function Xu(e){return {[xt]:e.graph,[Ju]:e.lastDrainedJournalId}}function Qu(e){let t=e[xt],r=e[Ju];if(!t||typeof t!="object")throw new Error(`State snapshot is missing required key: ${xt}`);return {graph:t,lastDrainedJournalId:typeof r=="string"?r:""}}function Zu(e){let t=e.requires,r=e.provides?.map(n=>n.bindTo)??[];return {requires:t&&t.length>0?t:void 0,provides:r,taskHandlers:["card-handler"],description:e.meta?.title??e.id}}function oa(e){function t(o){return {status:"success",data:o}}function r(o){return {status:"fail",error:o}}function n(o){return {status:"error",error:o instanceof Error?o.message:String(o)}}function s(o){if(Array.isArray(o))return o;if(o&&typeof o=="object"){let a=o;return Array.isArray(a.files)?a.files:[o]}return null}return {get(o){try{let a=o.params?.id;if(a){let i=e.readCard(a);return i?t({cards:[i]}):r(`card "${a}" not found`)}return t({cards:e.readAllCards()})}catch(a){return n(a)}},set(o){try{let a=o.body;if(a==null)return r("set requires a body (card object or array of cards)");let i=Array.isArray(a)?a:[a];for(let u of i){if(typeof u.id!="string")return r("each card must have a string `id` field");e.writeCard(u.id,u);}return t({count:i.length})}catch(a){return n(a)}},del(o){try{let a=o.body?.ids??[],i=o.params?.id,u=i?[...a,i]:a;if(u.length===0)return r("del requires body.ids (string[]) or params.id");for(let c of u)e.removeCard(c);return t({count:u.length})}catch(a){return n(a)}},patch(o){try{let a=o.params?.id,i=o.params?.path;if(!a)return r("patch requires params.id");if(!i)return r("patch requires params.path");let u=o.body,c=u&&Object.prototype.hasOwnProperty.call(u,"value")?u.value:o.body;return e.patchCard(a,i,c),t({count:1})}catch(a){return n(a)}},appendFiles(o){try{let a=o.params?.id;if(!a)return r("appendFiles requires params.id");let i=e.readCard(a);if(!i)return r(`card "${a}" not found`);let u=s(o.body);if(!u||u.length===0)return r("appendFiles requires a file metadata object, array, or body.files array");let c=i.card_data&&typeof i.card_data=="object"&&!Array.isArray(i.card_data)?i.card_data:{},d=Array.isArray(c.files)?c.files:[],l=[...d,...u],g=u.map((f,m)=>({idx:d.length+m,entry:f})),v=this.patch({params:{id:a,path:"card_data.files"},body:{value:l}});return v.status!=="success"?v:t({files_added:g})}catch(a){return n(a)}}}}function X(e){return e!==void 0?{status:"success",data:e}:{status:"success"}}function L(e){return {status:"fail",error:e}}function ee(e){return {status:"error",error:e instanceof Error?e.message:String(e)}}function uy(e){let t=new TextEncoder().encode(e),r=Array.from(t,n=>String.fromCharCode(n)).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function td(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=t+"=".repeat((4-t.length%4)%4),n=atob(r),s=Uint8Array.from(n,o=>o.charCodeAt(0));return new TextDecoder().decode(s)}function Hn(e){try{let t=JSON.parse(td(e));return typeof t?.t=="string"?{taskName:t.t}:null}catch{return null}}function dy(e){return uy(JSON.stringify(e))}function ed(e){try{let t=JSON.parse(td(e));return typeof t?.cbk=="string"&&typeof t?.cid=="string"&&typeof t?.b=="string"&&typeof t?.d=="string"?t:null}catch{return null}}function Te(){return new Date().toISOString()}function ly(e,t){let r=t.onWarn??(()=>{}),n=pe(e);function s(E){if(E.length!==0)try{let y=t.publishBoardChangeNotifications?.(E);y&&typeof y.catch=="function"&&y.catch(j=>r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${j instanceof Error?j.message:String(j)}`));}catch(y){r(`[board-live-cards-public] publishBoardChangeNotifications failed: ${y instanceof Error?y.message:String(y)}`);}}function o(){let E=i().readCardStoreRef();if(!E)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let y=t.kvStorageForRef(E);return {readIndex(){return y.read("_index")},writeIndex(j){y.write("_index",j);},readCard(j){return y.read(j)},writeCard(j,D){return y.write(j,D),t.hashFn(D)},removeCard(j){y.delete(j);},cardExists(j){return y.read(j)!==null},defaultCardKey(j){return j}}}let a={readValues(E){let y=t.kvStorage("state-snapshot"),j=y.listKeys().sort();if(j.length===0)return {version:null,values:{}};let D={};for(let Z of j)D[Z]=y.read(Z);return {version:t.hashFn(D),values:D}},writeValues(E,y,j){let D=t.kvStorage("state-snapshot");for(let Z of j)D.delete(Z);for(let[Z,de]of Object.entries(y))D.write(Z,de);return t.hashFn(y)}},i=()=>sa(t.kvStorage("config")),u=()=>Hu(a),c=()=>Ku(t.journalAdapter()),d=()=>Kn(o(),r),l=()=>{let E=i().readOutputsStoreRef();if(!E)throw new Error(`Board at ${e.value} has no outputs store configured. Run: init --outputs-store-ref <b64-ref>`);return Wu(t.kvStorageForRef(E))},g=()=>{let E=i().readArchiveStoreRef();return E?t.archiveFactoryForRef(E):t.archiveFactory()};function v(){return !!u().readSnapshot(e.value).values[xt]}function f(){let E=u().readSnapshot(e.value);if(!E.values[xt])throw new Error(`Board not initialized at ${e.value}`);return Qu(E.values)}function m(E,y){let j=u().commitSnapshot(e.value,{schemaVersion:Ur,expectedVersion:y,commitId:t.genId(),committedAt:Te(),deleteKeys:[],shallowMerge:Xu(E)});if(!j.ok)throw new Error(`Snapshot commit failed (version mismatch): expected=${y??"null"} current=${j.currentVersion??"null"}`)}function b(E){c().appendEvent(E);}async function C(){let E=(P,K)=>{let me=P.payload,Xe=(me?.enrichedCard??{}).id??me?.cardId??"unknown";b({type:"task-failed",taskName:Xe,error:K,timestamp:Te()});},y=Gu(t.kvStorage("execution-requests"),E),j=zu(t.kvStorage("card-runtime")),D=Gn(t.blobStorage("sources"),P=>t.resolveBlob(P)),Z=new Map,de={readRuntime(P){return Z.get(P)??j.readRuntime(P)},writeRuntime(P,K){Z.set(P,K);}},Ne=[],ye=new Map,Ve={readSourceData(P,K){let me=`${P}/${K}`;return ye.has(me)?ye.get(me):D.readSourceData(P,K)},ingestSourceDataStaged(P,K,me,ht){D.ingestSourceDataStaged(P,K,me,ht);},commitSourceData(P,K,me){let ht=`${P}/.staged/${me}/${K}`,zr=t.blobStorage("sources").read(ht);if(zr==null)return false;let Ht=`${P}/${K}`,fa=zr.trim();try{ye.set(Ht,JSON.parse(fa));}catch{ye.set(Ht,fa);}return Ne.push({cardId:P,outputFile:K,deliveryToken:me}),true},hasSource(P,K){let me=`${P}/${K}`;return ye.has(me)?true:D.hasSource(P,K)},listSources(P){let K=D.listSources(P),me=new Set;for(let Xe of ye.keys())Xe.startsWith(`${P}/`)&&me.add(Xe.slice(`${P}/`.length));let ht=new Set([...K,...me]);return Array.from(ht)}},Ie={cardStore:d(),cardRuntimeStore:de,fetchedSourcesStore:Ve,outputStore:l(),executionRequestStore:y},At=f(),Tt=Vn(At.graph),{events:Gt,newCursor:Jt}=c().readEntriesAfterCursor(At.lastDrainedJournalId),It=[],Wn=[],Yn=[],Xn=new Map,ua=new Set,id=(P,K)=>{It.push({type:"task-completed",taskName:P,data:K,timestamp:Te()});try{g().stream("exec-history").append({taskName:P,status:"completed",completedAt:Te()});}catch{}},da=(P,K)=>{b({type:"task-failed",taskName:P,error:K,timestamp:Te()});try{g().stream("exec-history").append({taskName:P,status:"failed",error:K,completedAt:Te()});}catch{}},Gr=Nu(Tt,{handlers:{"card-handler":Yu(e,Jt,Ie,id,da,(P,K)=>{Wn.push({cardId:P,values:K});},P=>{Yn.push(P);})},onNodeRemoved:P=>{Xn.delete(P),Z.delete(P),ua.add(P);}});for(It=Gt;It.length>0;){let P=It;It=[];for(let K of P)if(K.type==="task-restart"){let me=Ie.cardStore.readCard(K.taskName);me&&Xn.set(K.taskName,me);}Gr.pushAll(P),await Gr.waitForHandlers();}let la=Gr.getState();await Gr.dispose({wait:true});let cd=u().readSnapshot(e.value).version;m({lastDrainedJournalId:Jt,graph:Lr(la)},cd);for(let{cardId:P,values:K}of Wn)Ie.outputStore.writeComputedValues(P,K);for(let P of Yn)Ie.outputStore.writeDataObjects(P);for(let[P,K]of Z)j.writeRuntime(P,K);for(let{cardId:P,outputFile:K,deliveryToken:me}of Ne)D.commitSourceData(P,K,me);let Jr;try{Jr=Jn(n,la),Ie.outputStore.writeStatusSnapshot(Jr);}catch(P){r(`[board-live-cards-public] status publish failed: ${P instanceof Error?P.message:String(P)}`);}let zt=[];for(let{cardId:P,values:K}of Wn)zt.push({kind:"computed_values",cardId:P,values:K});for(let P of Yn)for(let[K,me]of Object.entries(P))K&&zt.push({kind:"data_object",key:K,payload:me});for(let[P,K]of Xn)zt.push({kind:"card_refreshed",cardId:P,card:K});for(let P of ua)zt.push({kind:"card_removed",cardId:P});Jr!==void 0&&zt.push({kind:"status",status:Jr}),s(zt);let ud=i().readTaskExecutorRef()??{howToRun:"built-in",whatToRun:pe({kind:"built-in",value:"source-cli-task-executor"})};y.dispatchEntriesForJournalId(Jt,P=>{if(P.taskKind!=="source-fetch"){r(`[process-accumulated-events] unknown taskKind "${P.taskKind}" \u2014 skipping`);return}let K=P.payload,me=K.enrichedCard?.id??"unknown",ht=K.enrichedCard?.source_defs??[];for(let Xe of ht){if(!Xe.outputFile){r(`[dispatch] source "${Xe.bindTo}" has no outputFile \u2014 skipping`);continue}let zr=dy({cbk:K.callbackToken,rg:e.value,br:pe(e),cid:me,b:Xe.bindTo,d:Xe.outputFile,cs:void 0,rqt:K.rqt});t.dispatchExecution(ud,{source_def:Xe,base_ref:pe(e),callback:{token:zr,via:t.selfRef}}).catch(Ht=>da(me,Ht instanceof Error?Ht.message:String(Ht)));}});}async function q(){try{let E=()=>{let j=f(),{events:D}=c().readEntriesAfterCursor(j.lastDrainedJournalId);D.length<=0||(q(),t.requestProcessAccumulated?.());},y=await ma(t.lock,C,E);return X({ran:y!==!1})}catch(E){return ee(E)}}function _(){q(),t.requestProcessAccumulated?.();}function I(E){try{let y=E.params?.cardStoreRef;if(!y)return L("init requires params.cardStoreRef \u2014 create a card store with card-store-cli and pass its ref here");if(!v()){let Ie=Bn(zn);m({lastDrainedJournalId:"",graph:Lr(Ie)},null);}let j=E.params?.outputsStoreRef;if(!j)return L("init requires params.outputsStoreRef \u2014 pass the outputs store ref here");let D=E.params?.scratchStoreRef,Z=E.params?.archiveStoreRef,de=E.params?.chatStoreRef,Ne=E.params?.artifactsStoreRef,ye=i();ye.writeCardStoreRef(y),ye.writeOutputsStoreRef(j),D&&ye.writeScratchStoreRef(D),Z&&ye.writeArchiveStoreRef(Z),de&&ye.writeChatStoreRef(de),Ne&&ye.writeArtifactsStoreRef(Ne);let Ve=E.body??{};Ve["task-executor-ref"]&&ye.writeTaskExecutorRef(Ve["task-executor-ref"]),Object.prototype.hasOwnProperty.call(Ve,"chat-handler-flow")&&ye.writeChatHandlerFlow(Ve["chat-handler-flow"]);try{l().writeStatusSnapshot(Jn(n,Vn(f().graph)));}catch{}return X()}catch(y){return ee(y)}}function S(E){try{let y=l().readStatusSnapshot();if(!y){y=Jn(n,Vn(f().graph));try{l().writeStatusSnapshot(y);}catch{}}return X(y)}catch(y){return ee(y)}}function k(E){try{let y=E.params?.id;return y?(b({type:"task-removal",taskName:y,timestamp:Te()}),_(),X()):L("removeCard requires params.id")}catch(y){return ee(y)}}function w(E){try{let y=E.params?.cardId;if(!y)return L("addCardFiles requires params.cardId");let j=oa(d()).appendFiles({params:{id:y},body:E.body});if(j.status!=="success")return j;let D=p({params:{cardId:y}});return D.status!=="success"?D:X({cardId:y,files_added:j.data.files_added,notified:!0})}catch(y){return ee(y)}}function p(E){try{let y=E.params?.cardId;if(!y)return L("cardRefreshedNotify requires params.cardId");let j=d().readCard(y);return j?(s([{kind:"card_refreshed",cardId:y,card:j}]),X({cardId:y,notified:!0})):L(`Card "${y}" not found in board at ${e.value}`)}catch(y){return ee(y)}}function h(E){try{let y=E.params?.id;return y?(b({type:"task-restart",taskName:y,timestamp:Te()}),_(),X()):L("retrigger requires params.id")}catch(y){return ee(y)}}async function R(E){return q()}function x(E){try{let y=E.params?.cardId,j=E.params?.all,D=!!E.params?.restart;if(!y&&!j)return L("upsertCard requires --card-id <id> or --all");let Z=j?d().readAllCards().map(de=>de.id):[y];for(let de of Z)if(!d().readCard(de))return L(`Card "${de}" not found in board at ${e.value}`);for(let de of Z){let Ne=d().readCard(de),ye=Zu(Ne),Ve=t.hashFn(ye),Ie=t.kvStorage("card-upsert"),At=Ie.read(de),Tt=At?.taskConfigHash!==Ve;if(!(!Tt&&!D)){if(Tt){let Gt=At?.blobRef??d().readCardKey(de)??de;b({type:"task-upsert",taskName:de,taskConfig:ye,timestamp:Te()}),Ie.write(de,{blobRef:Gt,taskConfigHash:Ve,updatedAt:Te()});}D&&b({type:"task-restart",taskName:de,timestamp:Te()});}}return _(),X()}catch(y){return ee(y)}}function A(E){try{let y=E.params?.token;if(!y)return L("taskFailed requires params.token");let j=E.params?.error??"unknown error",D=Hn(y);if(!D)return L("Invalid callback token");b({type:"task-failed",taskName:D.taskName,error:j,timestamp:Te()});try{g().stream("exec-history").append({taskName:D.taskName,status:"failed",error:j,completedAt:Te()});}catch{}return _(),X()}catch(y){return ee(y)}}function T(E){try{let y=E.params?.token;if(!y)return L("taskProgress requires params.token");let D=(E.body??{}).update??{},Z=Hn(y);return Z?(b({type:"task-progress",taskName:Z.taskName,update:D,timestamp:Te()}),_(),X()):L("Invalid callback token")}catch(y){return ee(y)}}function V(E){try{let y=E.params?.token,j=E.params?.ref;if(!y)return L("sourceDataFetched requires params.token");if(!j)return L("sourceDataFetched requires params.ref");let D=ed(y);if(!D)return L("Invalid source token");let{cbk:Z,cid:de,b:Ne,d:ye,cs:Ve,rqt:Ie}=D,At=Gn(t.blobStorage("sources"),It=>t.resolveBlob(It)),Tt=t.genId();At.ingestSourceDataStaged(de,ye,Qe(j),Tt);let Gt=Hn(Z);if(!Gt)return L("Invalid callback token embedded in source token");let Jt=Te();return b({type:"task-progress",taskName:Gt.taskName,update:{bindTo:Ne,outputFile:ye,fetchedAt:Jt,deliveryToken:Tt,sourceChecksum:Ve,rqt:Ie},timestamp:Jt}),_(),X()}catch(y){return ee(y)}}function Q(E){try{let y=E.params?.token,j=E.params?.reason??"unknown";if(!y)return L("sourceDataFetchFailure requires params.token");let D=ed(y);if(!D)return L("Invalid source token");let{cbk:Z,b:de,d:Ne,cs:ye,rqt:Ve}=D,Ie=Hn(Z);return Ie?(b({type:"task-progress",taskName:Ie.taskName,update:{bindTo:de,outputFile:Ne,failure:!0,reason:j,sourceChecksum:ye,rqt:Ve},timestamp:Te()}),_(),X()):L("Invalid callback token embedded in source token")}catch(y){return ee(y)}}function te(E){try{let y=i().readCardStoreRef();return y?X({storeRef:y}):L(`Board at ${e.value} has no card store configured`)}catch(y){return ee(y)}}function ue(E){try{let y=i().readOutputsStoreRef();return y?X({storeRef:y}):L(`Board at ${e.value} has no outputs store configured`)}catch(y){return ee(y)}}function N(E){try{let y=i().readScratchStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function F(E){try{let y=i().readArchiveStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function U(E){try{let y=i().readChatStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function ne(E){try{let y=i().readArtifactsStoreRef();return X({storeRef:y})}catch(y){return ee(y)}}function H(E){try{let y=E.params?.key;if(!y)return L("getConfig requires params.key");let j=i(),D;switch(y){case "task-executor":D=j.readTaskExecutorRef()??null;break;case "chat-handler-flow":D=j.readChatHandlerFlow()??null;break;case "card-store-ref":D=j.readCardStoreRef();break;case "outputs-store-ref":D=j.readOutputsStoreRef();break;case "scratch-store-ref":D=j.readScratchStoreRef();break;case "archive-store-ref":D=j.readArchiveStoreRef();break;case "chat-store-ref":D=j.readChatStoreRef();break;case "artifacts-store-ref":D=j.readArtifactsStoreRef();break;default:return L(`getConfig: unknown key "${y}"`)}return X({value:D})}catch(y){return ee(y)}}function be(E){try{let y=E.params?.key;if(!y)return L("getOutputsDataObject requires params.key");let j=l().readDataObject(y);return X(j)}catch(y){return ee(y)}}function se(E){try{return X(l().readAllDataObjects())}catch(y){return ee(y)}}function ve(E){try{let y=E.params?.key;if(!y)return L("getOutputsComputedValues requires params.key");let j=l().readComputedValues(y);return X(j)}catch(y){return ee(y)}}function Re(E){try{return X(l().readAllComputedValues())}catch(y){return ee(y)}}function Be(){return Gn(t.blobStorage("sources"),E=>t.resolveBlob(E))}function Ke(E){let y=t.blobStorage("sources").keyRef?.(E);return y?pe(y):E}function Kt(E){try{let y=E.params?.key;if(!y)return L("getOutputsFetchedSources requires params.key");let j=Be().listSources(y),D={};for(let Z of j)D[Z]=Ke(`${y}/${Z}`);return X(D)}catch(y){return ee(y)}}function Pe(E){try{let y=Be(),j=new Set;for(let Z of t.blobStorage("sources").listKeys()){let de=Z.indexOf("/");de>0&&!Z.includes("/.staged/")&&j.add(Z.slice(0,de));}let D={};for(let Z of j){let de=y.listSources(Z);if(de.length>0){D[Z]={};for(let Ne of de)D[Z][Ne]=Ke(`${Z}/${Ne}`);}}return X(D)}catch(y){return ee(y)}}return {init:I,status:S,getCardStoreRef:te,getOutputsStoreRef:ue,getScratchStoreRef:N,getArchiveStoreRef:F,getChatStoreRef:U,getArtifactsStoreRef:ne,getConfig:H,getOutputsDataObject:be,getAllOutputsDataObjects:se,getOutputsComputedValues:ve,getAllOutputsComputedValues:Re,getOutputsFetchedSources:Kt,getAllOutputsFetchedSources:Pe,removeCard:k,addCardFiles:w,cardRefreshedNotify:p,retrigger:h,processAccumulatedEvents:R,upsertCard:x,taskFailed:A,taskProgress:T,sourceDataFetched:V,sourceDataFetchFailure:Q}}function fy(e,t){let r=()=>sa(t.kvStorage("config"));function n(){let S=r().readCardStoreRef();if(!S)throw new Error(`Board at ${e.value} has no card store configured. Run: init --base-ref <ref> --store-ref <b64-ref>`);let k=t.kvStorageForRef(S);return {readIndex(){return k.read("_index")},writeIndex(w){k.write("_index",w);},readCard(w){return k.read(w)},writeCard(w,p){return k.write(w,p),t.hashFn(p)},removeCard(w){k.delete(w);},cardExists(w){return k.read(w)!==null},defaultCardKey(w){return w}}}let s=()=>Kn(n(),t.onWarn??(()=>{})),o=()=>{let S=r().readScratchStoreRef();return S?t.scratchStorageForRef(S):t.scratchStorage()};function a(S,k){let w=t.validateSchema(k),p=[],h=r().readTaskExecutorRef();if(h&&Array.isArray(k.source_defs))for(let x of k.source_defs){let A=typeof x.bindTo=="string"?x.bindTo:"(unknown)";try{let T;try{T=t.invokeExecutorSync(h,"validate-source-def",[],{timeout:t.executorTimeouts?.validationMs??1e4,input:JSON.stringify(x)});}catch(Q){let te=Q;if(T=typeof te?.stdout=="string"?te.stdout:"",!T.trim()){p.push(`source "${A}": executor validate-source-def failed \u2014 ${Q instanceof Error?Q.message:String(Q)}`);continue}}let V=JSON.parse(T.trim());if(!V.ok&&Array.isArray(V.errors))for(let Q of V.errors)p.push(`source "${A}": ${Q}`);}catch(T){p.push(`source "${A}": executor validate-source-def failed \u2014 ${T instanceof Error?T.message:String(T)}`);}}let R=[...w.errors,...p];return X({cardId:S,isValid:R.length===0,issues:R})}function i(S,k){let w=r().readTaskExecutorRef();if(!w)throw new Error("No task-executor registered for this board");let p=typeof S.bindTo=="string"?S.bindTo:"source",h=o(),R={...S,boardDir:e.value,_projections:k},x=h.create(JSON.stringify(R,null,2),`probe-in-${p}`,".json"),A=h.getUniqueKey(`probe-out-${p}`,".json"),T=h.getUniqueKey(`probe-err-${p}`,".txt"),V=pe(h.keyRef(x)),Q=pe(h.keyRef(A)),te=pe(h.keyRef(T)),ue=null;try{if(t.invokeExecutorSync(w,"run-source-fetch",["--in-ref",V,"--out-ref",Q,"--err-ref",te],{timeout:S.timeout??t.executorTimeouts?.probeMs??6e4}),ue=h.read(A),ue===null)throw new Error("Executor produced no output file")}catch(N){let F=h.read(T)?.trim()??(N instanceof Error?N.message:String(N));throw new Error(`Probe failed: ${F}`)}finally{try{h.remove(x);}catch{}try{h.remove(T);}catch{}}return {bindTo:p,result:ue}}function u(S,k,w){let p;try{p=i(S,k);}catch(h){return L(h instanceof Error?h.message:String(h))}if(w){let h=Qe(w);t.absoluteBlob.write(h.value,p.result);}return X({bindTo:p.bindTo,resultSizeBytes:p.result.length})}function c(S,k){let w=S.params?.sourceIdx,p=S.params?.outRef;if(w===void 0)return L(`${k} requires params.sourceIdx`);if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L(`${k} requires card JSON object in body`);let h=S.body,R=h["card-content"]??h,x=h["mock-projections"]??{},A=R.source_defs??[];if(w<0||w>=A.length)return L(`sourceIdx ${w} out of range (card has ${A.length} source(s))`);let T=A[w],V=typeof T.bindTo=="string"?T.bindTo:"source";return {src:T,bindTo:V,outRef:p,mockProjections:x}}function d(S){try{let k=S.params?.cardId,w=S.params?.all;if(!k&&!w)return L("validateCard requires --card-id <id> or --all");let p=w?s().readAllCards().map(R=>R.id):[k],h=[];for(let R of p){let x=s().readCard(R);if(!x){h.push({cardId:R,isValid:!1,issues:[`Card "${R}" not found`]});continue}let A=a(R,x);if(A.status!=="success")return A;h.push(A.data);}return X(h)}catch(k){return ee(k)}}function l(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("validateCardPreflight requires card JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)";return a(p,w)}catch(k){return ee(k)}}function g(S){try{let k=S.params?.cardId,w=S.params?.sourceIdx,p=S.params?.outRef;if(!k)return L("probeSource requires params.cardId");if(w===void 0)return L("probeSource requires params.sourceIdx");let R=(S.body??{})["mock-projections"]??{},x=s().readCard(k);if(!x)return L(`Card "${k}" not found`);let A=x.source_defs??[];return w<0||w>=A.length?L(`sourceIdx ${w} out of range (card has ${A.length} source(s))`):u(A[w],R,p)}catch(k){return ee(k)}}function v(S){try{let k=S.params?.outRef,w=S.body;if(!w)return L('probeTmpSource requires body with "source-def" and "mock-projections"');let p=w["source-def"],h=w["mock-projections"]??{};return p?u(p,h,k):L('probeTmpSource body requires "source-def"')}catch(k){return ee(k)}}function f(S){try{let k=c(S,"probeSourcePreflight");if("status"in k)return k;let w=r().readTaskExecutorRef();if(!w)return L("No task-executor registered for this board");try{let p={...k.src,_projections:k.mockProjections},h=t.invokeExecutorSync(w,"probe-source-preflight",[],{timeout:k.src.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(p)}),R=JSON.parse(h.trim());return R.ok?X({bindTo:k.bindTo,reachable:R.reachable,latencyMs:R.latencyMs,note:R.note}):L(R.error??"Preflight probe failed")}catch{return L("Executor does not support probe-source-preflight")}}catch(k){return ee(k)}}function m(S){try{let k=c(S,"runSourcePreflight");if("status"in k)return k;try{let w=i(k.src,k.mockProjections);if(k.outRef){let h=Qe(k.outRef);t.absoluteBlob.write(h.value,w.result);}let p=w.result;try{p=JSON.parse(w.result);}catch{}return X({bindTo:w.bindTo,ok:!0,result:p,issues:[]})}catch(w){let p=w instanceof Error?w.message:String(w);return p==="No task-executor registered for this board"?L(p):X({bindTo:k.bindTo,ok:!1,result:null,issues:[p]})}}catch(k){return ee(k)}}function b(S){try{let k=r().readTaskExecutorRef();if(!k)return L("No task-executor registered for this board");let w=t.invokeExecutorSync(k,"describe-capabilities",[],{timeout:t.executorTimeouts?.describeMs??1e4});return X(JSON.parse(w.trim()))}catch(k){return ee(k)}}function C(S){try{let k=S.body;if(!k||!Array.isArray(k.ops))return L("updatesInCardStore requires body.ops array");let w=k.ops,p=s();for(let h of w){let R=h.op,x=h.id;if(!x)return L('op is missing "id"');if(R==="update"){let A=h["card-content"];if(!A)return L(`update op for "${x}" is missing "card-content"`);p.writeCard(x,A);}else return L(`Unknown op type: "${R??"(none)"}"`)}return X()}catch(k){return ee(k)}}function q(S){try{let k=S.body;if(!k||!Array.isArray(k.ids))return L("readFromCardStore requires body.ids array");let w=k.ids,p=s(),h=w.map(R=>({id:R,"card-content":p.readCard(R)}));return X({cards:h})}catch(k){return ee(k)}}function _(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("evalCardCompute requires a JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)",h=k["mock-fetched-sources"]??{},R=k["mock-requires"]??{},x=w.compute;if(!x||!Array.isArray(x)||x.length===0)return X({cardId:p,ok:!0,computed_values:{},errors:[]});let A={id:p,card_data:w.card_data??{},requires:R,source_defs:w.source_defs,compute:x},T=ut.runSync(A,{sourcesData:h}),V=T.node.computed_values??{},Q=T.errors??[];return X({cardId:p,ok:Q.length===0,computed_values:V,errors:Q})}catch(k){return ee(k)}}function I(S){try{if(!S.body||typeof S.body!="object"||Array.isArray(S.body))return L("simulateCardCycle requires a JSON object in body");let k=S.body,w=k["card-content"]??k,p=typeof w.id=="string"?w.id:"(unknown)",h=k["mock-fetched-sources"]??{},R=k["mock-requires"]??{},x=a(p,w),A=x.status==="success"?{isValid:x.data.isValid,issues:x.data.issues}:{isValid:!1,issues:[x.status==="fail"?x.error:"internal error"]},T=w.source_defs??[],V=w.card_data??{},Q=[],te=[];if(T.length>0){Q=ut.enrichSourcesSync(T,{card_data:V,requires:R});for(let ve of Q){let Re=ve.projections,Be=ve._projections;if(Re&&Be){for(let Ke of Object.keys(Re))if(Be[Ke]===void 0){let Kt=typeof ve.bindTo=="string"?ve.bindTo:"(unknown)";te.push({bindTo:Kt,key:Ke,error:`Projection "${Ke}" resolved to undefined`});}}}}let ue=[],N={...h},F=k["task-executor-ref"],U=(F?.howToRun&&F?.whatToRun?F:void 0)??r().readTaskExecutorRef();for(let ve=0;ve<Q.length;ve++){let Re=Q[ve],Be=typeof Re.bindTo=="string"?Re.bindTo:`source_${ve}`;if(!U){ue.push({bindTo:Be,skipped:!0,error:"No task executor configured"});continue}try{let Ke={...Re},Kt=t.invokeExecutorSync(U,"run-source-preflight",[],{timeout:Re.timeout??t.executorTimeouts?.preflightMs??6e4,input:JSON.stringify(Ke)}),Pe=JSON.parse(Kt.trim());Pe.ok&&!Object.prototype.hasOwnProperty.call(h,Be)&&Object.prototype.hasOwnProperty.call(Pe,"resultValue")&&(N[Be]=Pe.resultValue),ue.push({bindTo:Be,reachable:Pe.reachable,latencyMs:Pe.latencyMs,error:Pe.ok?void 0:Pe.error});}catch{ue.push({bindTo:Be,skipped:!0,error:"Executor does not support run-source-preflight"});}}let ne=w.compute,H={},be=[];if(ne&&Array.isArray(ne)&&ne.length>0){let ve={id:p,card_data:V,requires:R,source_defs:w.source_defs,compute:ne},Re=ut.runSync(ve,{sourcesData:N});H=Re.node.computed_values??{},be=Re.errors??[];}let se=A.isValid&&te.length===0&&be.length===0&&ue.every(ve=>ve.reachable!==!1);return X({cardId:p,ok:se,validation:A,source_probes:ue,projection_errors:te,fetched_sources:N,computed_values:H,compute_errors:be})}catch(k){return ee(k)}}return {validateCard:d,validateCardPreflight:l,probeSource:g,probeTmpSource:v,probeSourcePreflight:f,runSourcePreflight:m,evalCardCompute:_,simulateCardCycle:I,describeTaskExecutorCapabilities:b,updatesInCardStore:C,readFromCardStore:q}}function $e(e,t){if(e?.status==="success")return Object.prototype.hasOwnProperty.call(e,"data")?e.data:void 0;throw e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function py(e,t){if(e?.status==="success"&&Object.prototype.hasOwnProperty.call(e,"data"))return e.data;throw e?.status==="success"?new Error(`${t} returned success without data`):e?.status==="fail"||e?.status==="error"?new Error(e.error||`${t} failed`):new Error(`${t} returned an unexpected response`)}function B(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function we(e){return Array.isArray(e)?e:[]}function ia(e,t){if(typeof t!="string"||t.length===0)return;let r=e,n=t;n.startsWith("fetched_sources.")&&(r=B(e).fetched_sources,n=n.slice(16));for(let s of n.split(".")){if(r==null||typeof r!="object")return;r=r[s];}return r}function aa(e,t){let r=B(e.view),n=we(r.elements);return {layout:r.layout,features:r.features,elements:n.map((s,o)=>{let a=B(s),i=B(a.data),u=typeof a.visible=="string"?!!ia(t,a.visible):true,c=typeof i.bind=="string"?i.bind:void 0,d=typeof i.maxRows=="number"?i.maxRows:void 0,l=c?ia(t,c):void 0,g={id:typeof a.id=="string"&&a.id?a.id:`element-${o}`,kind:a.kind,label:a.label,visible:u};return l!==void 0&&(g.resolved=Array.isArray(l)&&typeof d=="number"?l.slice(0,d):l),g})}}function rd(e,t){let r=typeof e.id=="string"&&e.id?e.id:"card",n=we(e.provides),s=n.length>0?n:[{bindTo:r,ref:"card_data"}],o={};for(let a of s){let i=B(a),u=typeof i.bindTo=="string"?i.bindTo:"",c=typeof i.ref=="string"?i.ref:"";if(!u||!c)continue;let d=ia(t,c);d!==void 0&&(o[u]=d);}return o}function my(e){if(typeof e!="string"||!e.trim())return null;let t=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(e.trim());if(!t)return null;let r=Number.parseInt(t[2],10);return !Number.isInteger(r)||r<0?null:r}function gy(e){return {"card-content":e}}function Kr(e,t){let r=$e(e.get({params:{id:t}}),"cardStore.get"),n=Array.isArray(r?.cards)?r.cards:[];if(n.length===0)throw new Error(`Card "${t}" not found`);return n[0]}function hy(e){let{board:t,nonCore:r,cardStore:n,chatStore:s,uploadCardFile:o,buildFileDownloadUrl:a,readFetchedSourceJsonByRef:i}=e;function u(p){if(Array.isArray(p.bytes))return new Uint8Array(p.bytes.map(h=>Math.max(0,Math.min(255,Number(h)||0))));if(typeof p.text=="string")return new TextEncoder().encode(p.text);if(typeof p.base64=="string"){let h=String(p.base64).replace(/-/g,"+").replace(/_/g,"/"),R=h+"=".repeat((4-h.length%4)%4),x=atob(R);return Uint8Array.from(x,A=>A.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}function c(){let p=B($e(r.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:p.version,commonSourceFields:B(p.commonSourceDefFields),sourceKinds:B(p.sourceKinds)}}function d(){let p=B($e(t.status({}),"status")),h=B(p.summary),R=we(p.cards);return {meta:B(p.meta),summary:{card_count:typeof h.card_count=="number"?h.card_count:0,completed:typeof h.completed=="number"?h.completed:0,eligible:typeof h.eligible=="number"?h.eligible:0,pending:typeof h.pending=="number"?h.pending:0,blocked:typeof h.blocked=="number"?h.blocked:0,in_progress:typeof h.in_progress=="number"?h.in_progress:0,failed:typeof h.failed=="number"?h.failed:0,unresolved:typeof h.unresolved=="number"?h.unresolved:0},cards:R.map(x=>{let A=B(x);return {"card-id":typeof A.name=="string"?A.name:null,status:A.status??null,error:A.error??null,requires:we(A.requires),requires_satisfied:we(A.requires_satisfied),requires_missing:we(A.requires_missing),provides_declared:we(A.provides_declared),provides_runtime:we(A.provides_runtime)}})}}function l(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let R=B($e(t.status({}),"status")),A=we(R.cards).map(B).find(se=>se.name===h);if(!A)throw new Error(`card "${h}" not found in board status`);let T=B(Kr(n,h)),V=we(A.requires_satisfied).filter(se=>typeof se=="string"&&!!se),Q=we(A.provides_runtime).filter(se=>typeof se=="string"&&!!se),te=Object.fromEntries(V.map(se=>[se,$e(t.getOutputsDataObject({params:{key:se}}),`getOutputsDataObject(${se})`)])),ue=Object.fromEntries(Q.map(se=>[se,$e(t.getOutputsDataObject({params:{key:se}}),`getOutputsDataObject(${se})`)])),N=B($e(t.getOutputsComputedValues({params:{key:h}}),"getOutputsComputedValues")),F=$e(t.getOutputsFetchedSources({params:{key:h}}),"getOutputsFetchedSources"),U=we(T.source_defs).map(B),ne={};for(let se of U)typeof se.bindTo=="string"&&typeof se.outputFile=="string"&&(ne[se.outputFile]=se.bindTo);let H={};for(let[se,ve]of Object.entries(F)){let Re=ne[se]??se;if(!i||typeof ve!="string"){H[Re]=null;continue}try{H[Re]=i({cardId:h,ref:ve});}catch{H[Re]=null;}}let be={card_data:B(T.card_data),requires:te,fetched_sources:H,computed_values:N};return {cardId:h,card_status_in_board:A,card_definition_and_static_data:T,refs_for_fetched_source_files:F,runtime_data:{requires:te,provides:ue,computed_values:N,rendered_view:aa(T,be)}}}function g(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("inspectChatMessagesOnCards requires cardId");let R=typeof p.turnId=="string"?p.turnId:"",x=p.allTurns===true,A=typeof p.tailTurnsBeforeId=="string"?p.tailTurnsBeforeId:"",T=x?void 0:p.lastUserTurns??(R?void 0:1),V=p.tail,Q={...T===void 0?{}:{tailTurns:T},...R?{turnId:R}:{},...x?{allTurns:true}:{},...A?{tailTurnsBeforeId:A}:{}},te=Object.keys(Q).length>0?{params:{cardId:h},body:Q}:{params:{cardId:h}},ue=$e(s.readAll(te),"chatStore.readAll"),N=B(Kr(n,h)),F=we(B(N.card_data).files).map((H,be)=>({idx:be,stored_name:B(H).stored_name})).filter(H=>typeof H.stored_name=="string"&&H.stored_name.length>0),ne=(Array.isArray(ue.records)?ue.records:[]).map(H=>{let se=B(H.payload),ve={...H},Re=typeof H?.role=="string"?H.role:typeof se.role=="string"?String(se.role):"",Be=typeof H?.text=="string"?H.text:typeof se.text=="string"?String(se.text):"";if(Re==="system"){let Ke=my(Be);if(Ke!==null&&F.some(Pe=>Pe.idx===Ke)){let Pe=`Retrieve using inspect-file-contents --card-id ${h} --file-idx ${Ke}`;ve.retrieval_hint=Pe,Object.keys(se).length>0&&typeof H.role!="string"&&(ve.payload={...se,retrieval_hint:Pe});}}return ve});return {cardId:h,messages:typeof V=="number"&&V>=0?ne.slice(-V):ne}}function v(p){let h=String(p.cardId||"").trim(),R=Number(p.fileIdx);if(!h)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(R)||R<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let x=B(Kr(n,h)),A=we(B(x.card_data).files).map(B);if(R>=A.length)throw new Error(`attachment index ${R} is out of range for card "${h}"`);let T=A[R],V=typeof T.stored_name=="string"?T.stored_name:null;return {cardId:h,fileIdx:R,downloadUrl:a({cardId:h,fileIdx:R,storedName:V}),...typeof T.name=="string"?{name:T.name}:{},...typeof T.stored_name=="string"?{stored_name:T.stored_name}:{},...typeof T.mime_type=="string"?{mime_type:T.mime_type}:{},...typeof T.size=="number"?{size:T.size}:{},...typeof T.uploaded_at=="string"?{uploaded_at:T.uploaded_at}:{}}}function f(p){return r.validateCardPreflight({body:gy(p.candidateCardContent)})}function m(p){if(!p.mockRequires||typeof p.mockRequires!="object"||Array.isArray(p.mockRequires))throw new Error("preflightMaterializeCandidateCard requires mockRequires");if(!p.mockFetchedSources||typeof p.mockFetchedSources!="object"||Array.isArray(p.mockFetchedSources))throw new Error("preflightMaterializeCandidateCard requires mockFetchedSources");let h=r.evalCardCompute({body:{"card-content":p.candidateCardContent,"mock-requires":p.mockRequires,"mock-fetched-sources":p.mockFetchedSources}});if(h.status!=="success")return h;let R=B(py(h,"evalCardCompute")),x=B(p.candidateCardContent),A={card_data:B(x.card_data),requires:B(p.mockRequires),fetched_sources:B(p.mockFetchedSources),computed_values:B(R.computed_values)};return {status:"success",data:{cardId:typeof R.cardId=="string"?R.cardId:typeof x.id=="string"?x.id:"(unknown)",ok:R.ok===true,computed_values:B(R.computed_values),errors:we(R.errors).map(T=>{let V=B(T);return {bindTo:typeof V.bindTo=="string"?V.bindTo:"",error:typeof V.error=="string"?V.error:""}}),provides_outputs:rd(x,A),rendered_view:aa(x,A)}}}function b(p){return r.probeSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":p.candidateCardContent,"mock-projections":p.mockProjections}})}function C(p){return r.runSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":p.candidateCardContent,"mock-projections":p.mockProjections}})}function q(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("preflightRunSingleSourceInLiveCard requires cardId");if(!p.mockRequires||typeof p.mockRequires!="object"||Array.isArray(p.mockRequires))throw new Error("preflightRunSingleSourceInLiveCard requires mockRequires");let R=B(Kr(n,h)),x=we(R.source_defs).filter(T=>!!T&&typeof T=="object"&&!Array.isArray(T)),A={};if(p.sourceIdx>=0&&p.sourceIdx<x.length){let T=x[p.sourceIdx],V=ut.enrichSourcesSync([T],{card_data:B(R.card_data),requires:p.mockRequires});Array.isArray(V)&&V.length>0&&(A=B(V[0]._projections));}return r.runSourcePreflight({params:{sourceIdx:p.sourceIdx},body:{"card-content":R,"mock-requires":p.mockRequires,"mock-projections":A}})}function _(p){let h=B($e(r.simulateCardCycle({body:{"card-content":p.candidateCardContent,"mock-requires":p.mockRequires}}),"simulateCardCycle")),R=B(p.candidateCardContent),x=B(h.validation),A=we(h.source_probes),T=we(h.projection_errors),V=B(h.fetched_sources),Q=we(h.compute_errors),te=B(h.computed_values),ue={card_data:B(R.card_data),requires:p.mockRequires,fetched_sources:V,computed_values:te},N=[];for(let F of we(x.issues))typeof F=="string"&&F&&N.push(F);for(let F of A){let U=B(F),ne=typeof U.bindTo=="string"?U.bindTo:"source",H=typeof U.error=="string"?U.error:"";H&&N.push(`${ne}: ${H}`);}for(let F of T){let U=B(F),ne=typeof U.bindTo=="string"?U.bindTo:"source",H=typeof U.key=="string"?U.key:"projection",be=typeof U.error=="string"?U.error:"projection failed";N.push(`${ne}.${H}: ${be}`);}for(let F of Q){let U=B(F),ne=typeof U.bindTo=="string"?U.bindTo:"compute",H=typeof U.error=="string"?U.error:"compute failed";N.push(`${ne}: ${H}`);}return {status:"success",data:{cardId:typeof h.cardId=="string"?h.cardId:"(unknown)",ok:h.ok===true,issues:N,provides_outputs:rd(R,ue),rendered_view:aa(R,ue)}}}function I(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("manageReadCard requires cardId");let R=$e(n.get({params:{id:h}}),"cardStore.get");return Array.isArray(R.cards)?R.cards:[]}function S(p){let h=String(p.cardId||"").trim(),R=String(p.role||"").trim(),x=typeof p.text=="string"?p.text:"",A=typeof p.turn=="string"?p.turn:"";if(!h)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!R)throw new Error("manageAddChatEntryAndAnyAttachments requires role");let T=we(p.files).map(Q=>{let te=B(Q),ue=String(te.file_name??te.fileName??te.name??"").trim(),N=String(te.content_type??te.contentType??"application/octet-stream");if(!ue)throw new Error("file entry requires file_name");return o({cardId:h,fileName:ue,contentType:N,bytes:u(te)}).file});T.forEach((Q,te)=>{let ue=R==="assistant"?`AI generated: ${String(Q.name||"")} as ${String(Q.stored_name||"")} #${te}`:`file uploaded: ${String(Q.name||"")} as ${String(Q.stored_name||"")} #${te}`;$e(s.append({params:{cardId:h},body:{role:"system",text:ue,files:[],turn:A}}),"chatStore.append(system attachment message)");});let V=$e(s.append({params:{cardId:h},body:{role:R,text:x,files:T,turn:A}}),"chatStore.append");return {status:"success",data:{cardId:h,id:String(V.id),role:R,turn:A,files:T}}}function k(p){let h=String(p.cardId||"").trim(),R=B(p.candidateCardContent);if(!h)throw new Error("manageUpsertCard requires cardId");if(typeof R.id!="string"||!R.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(R.id!==h)throw new Error(`candidateCardContent.id must match cardId (${h})`);let x=f({candidateCardContent:R}),A=B(x),T=B(A.data);if(A.status!=="success"||T.isValid!==true)return {status:"fail",step:"validate",validation:x};let V=null;try{V=Kr(n,h);}catch{V=null;}let Q=n.set({body:R});$e(Q,"cardStore.set");let te;try{te=t.upsertCard({params:{cardId:h,restart:!0}}),$e(te,"upsertCard");}catch(N){try{V&&n.set({body:V});}catch{}throw N}let ue=null;try{ue=t.cardRefreshedNotify({params:{cardId:h}}),$e(ue,"cardRefreshedNotify");}catch{ue=null;}return {status:"success",data:{validation:x,card_saved:null,board_result:te,refresh_notify:ue}}}function w(p){let h=String(p.cardId||"").trim();if(!h)throw new Error("manageDeprecate requires cardId");let R=t.removeCard({params:{id:h}});return $e(R,"removeCard"),R}return {discoverSourceKinds:c,inspectBoardRuntimeStatus:d,inspectCardDefinitionAndRuntime:l,inspectChatMessagesOnCards:g,inspectFileContents:v,preflightValidateCandidateCardDefinition:f,preflightMaterializeCandidateCard:m,preflightProbeSingleSourceInCandidateCard:b,preflightRunSingleSourceInCandidateCard:C,preflightRunSingleSourceInLiveCard:q,preflightRunOneCycleWithCandidateCard:_,manageReadCard:I,manageAddChatEntryAndAnyAttachments:S,manageUpsertCard:k,manageDeprecate:w}}function yy(e){function t(s){return {status:"success",data:s}}function r(s){return {status:"fail",error:s}}function n(s){return {status:"error",error:s instanceof Error?s.message:String(s)}}return {list(s){try{let o=s.params?.prefix??"";return t({artifacts:e.list(o)})}catch(o){return n(o)}},head(s){try{let o=s.params?.key;return o?t({artifact:e.head(o)}):r("head requires params.key")}catch(o){return n(o)}},put(s){try{let o=s.params?.key,a=s.params?.contentType;if(!o)return r("put requires params.key");let i=s.body;if(typeof i=="string")return t({artifact:e.putText(o,i,a)});if(i&&typeof i=="object"&&typeof i.text=="string")return t({artifact:e.putText(o,i.text,a)});if(i&&typeof i=="object"&&Array.isArray(i.bytes)){let u=i.bytes,c=new Uint8Array(u.map(d=>Math.max(0,Math.min(255,Number(d)||0))));return t({artifact:e.putBytes(o,c,a)})}return r("put requires body as string, {text}, or {bytes:number[]}")}catch(o){return n(o)}},get(s){try{let o=s.params?.key,a=s.params?.as??"base64";if(!o)return r("get requires params.key");let i=e.head(o);if(!i)return r(`artifact "${o}" not found`);if(a==="text"){let c=e.getText(o);return c===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,text:c})}let u=e.getBytes(o);return u===null?r(`artifact "${o}" not found`):t({key:o,contentType:i.contentType,size:i.size,bytes:[...u]})}catch(o){return n(o)}},del(s){try{let o=s.params?.key;return o?(e.remove(o),t({ok:!0})):r("del requires params.key")}catch(o){return n(o)}}}}function nd(){return new Date().toISOString()}function sd(e){return new TextEncoder().encode(e).byteLength}function vy(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function Sy(e){let t=String(e||"").match(/^(\d+)[-_]/);return t?parseInt(t[1],10):0}function wy(e){let t=String(e||"").trim();if(!t)return "upload.bin";let r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return (r>=0?t.slice(r+1):t)||"upload.bin"}function ky(e){return String(e||"").toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"")||"file"}function by(e){if(!e||e===".")return "";let t=String(e).replace(/^\./,"").toLowerCase().replace(/[^a-z0-9]/g,"");return t?`.${t}`:""}function Ry(e){let t=wy(e),r=t.lastIndexOf(".");return r<=0||r===t.length-1?{stem:t,ext:""}:{stem:t.slice(0,r),ext:t.slice(r)}}function _y(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function ca(e){function t(r){let n=e.stat?vy(e.stat(r)):null;if(n)return n;if(!e.exists(r))return null;let s=e.read(r);return s===null?{key:r}:{key:r,size:sd(s)}}return {exists(r){return e.exists(r)},putText(r,n,s="text/plain; charset=utf-8"){e.write(r,n);let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??nd(),o.size=o.size??sd(n),o},putBytes(r,n,s="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,n);else {let a=JSON.stringify({__kind:"bytes-array",data:[...n]});e.write(r,a);}let o=t(r)??{key:r};return o.contentType=s,o.updatedAt=o.updatedAt??nd(),o.size=o.size??n.byteLength,o},getText(r){let n=e.read(r);if(n===null){if(!e.readBytes)return null;let s=e.readBytes(r);return s===null?null:Buffer.from(s).toString("utf-8")}try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new TextDecoder("utf-8").decode(new Uint8Array(s.data))}catch{}return n},getBytes(r){if(e.readBytes){let s=e.readBytes(r);if(s!==null)return s}let n=e.read(r);if(n===null)return null;try{let s=JSON.parse(n);if(s&&s.__kind==="bytes-array"&&Array.isArray(s.data))return new Uint8Array(s.data)}catch{}return new TextEncoder().encode(n)},head:t,list(r=""){return e.listKeys(r).map(n=>t(n)??{key:n}).sort((n,s)=>n.key.localeCompare(s.key))},remove(r){e.remove(r);}}}function Cy(e){function t(s,o){let a=0,i=[];Array.isArray(o)&&i.push(...o);for(let u of e.list(`${s}/`))i.push(_y(u.key));for(let u of i){let c=Sy(u);Number.isFinite(c)&&c>a&&(a=c);}return a+1}function r(s,o,a){let i=Number(a?.maxLen||32),{stem:u,ext:c}=Ry(s),d=by(c),l=ky(u),g=`${String(o).padStart(3,"0")}-`,v=d,f=i-g.length-v.length;f<1&&(v="",f=i-g.length);let m=l.slice(0,Math.max(1,f)),b=`${g}${m}${v}`;return b.length>i&&(b=b.slice(0,i).replace(/\.$/,"")),b}function n(s,o,a){let i=t(s,a?.seedNames),u=r(o,i,{maxLen:a?.maxLen});for(;e.exists(`${s}/${u}`);)i+=1,u=r(o,i,{maxLen:a?.maxLen});return u}return {nextSerial:t,buildStoredName:r,allocateStoredName:n}}function $y(){function e(s,o){if(!Array.isArray(s))return [];let a=[];for(let i of s){if(!i||typeof i!="object")continue;let u=i;typeof u.stored_name=="string"&&a.push({name:typeof u.name=="string"?u.name:u.stored_name,stored_name:u.stored_name,size:typeof u.size=="number"&&Number.isFinite(u.size)?u.size:null,mime_type:typeof u.mime_type=="string"?u.mime_type:null,uploaded_at:typeof u.uploaded_at=="string"?u.uploaded_at:o||null,chat:u.chat===true});}return a}function t(s){return !s||typeof s!="object"?[]:e(s.files,void 0)}function r(s,o){let a=t(s);if(o.length===0)return s.files=a,a;let i=new Set(a.map(u=>u.stored_name));for(let u of o)i.has(u.stored_name)||(a.push(u),i.add(u.stored_name));return s.files=a,a}function n(s,o,a){let i=t(s);if(!Number.isInteger(o)||o<0||o>=i.length)return {ok:false,reason:"index_out_of_range"};let u=i[o];return !u||!u.stored_name?{ok:false,reason:"missing_stored_name"}:a&&a!==u.stored_name?{ok:false,reason:"stale_reference"}:{ok:true,file:u}}return {read:t,normalizeIncoming:e,merge:r,resolve:n}}function bw(){return {async invoke(e,t){if(e.howToRun!=="local-node")return {dispatched:false,error:`createNodeSpawnInvocationAdapter: unsupported howToRun "${e.howToRun}"`};let r="";try{let o=e.whatToRun;r=et(o);}catch{r="";}if(!r)return {dispatched:false,error:"createNodeSpawnInvocationAdapter: could not resolve executable path from whatToRun"};let n={...t},s=Buffer.from(JSON.stringify(n)).toString("base64");try{return spawn(process.execPath,[r,"--boardId",String(t.boardId??""),"--cardId",String(t.cardId??""),"--extraEncJson",s],{stdio:"ignore",windowsHide:!0}).unref(),{dispatched:!0}}catch(o){return {dispatched:false,error:o instanceof Error?o.message:String(o)}}},async describe(e){if(e.howToRun!=="local-node")return null;let t="";try{let r=e.whatToRun;t=et(r);}catch{t="";}if(!t)return null;try{let r=spawnSync(process.execPath,[t,"describe"],{timeout:5e3,encoding:"utf-8",windowsHide:!0});return r.status!==0?null:JSON.parse(String(r.stdout).trim())}catch{return null}}}}var Ay=".board.lock";function od(e,t){if(!e||!t)return false;let r=String(e).replace(/[\\/]+$/,"").split(/[\\/]+/).filter(Boolean);return r.length>0&&r[r.length-1]===t}function Ty(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function Iy(e,t){return typeof e=="string"?{cliDir:e,opts:t}:{cliDir:void 0,opts:e}}function ad(e){if(e)return e;let t=wa(import.meta.url),r=[t,qe(t,"..","cli","node"),qe(t,"..","..","cli","node")];for(let n of r)try{return rs(n),n}catch{}throw new Error(`createFsBoardPlatformAdapter: could not resolve a public CLI directory from module dir ${t}`)}function jy(e,t,r){let{cliDir:n,opts:s}=Ty(t,r),o=ad(n),a=e.value,u={meta:"board-live-cards",howToRun:"local-node",whatToRun:(s?.suppressSpawn?"":rs(o))?pe({kind:"yaml-flow-cli",value:"board-live-cards-cli.js"}):"",...s?.notifyChannel?{extra:{notifyChannel:s.notifyChannel}}:{}};return {kvStorage:c=>nn(qe(a,`.${c}`)),blobStorage:c=>c?Wt(qe(a,c)):Wt(a),scratchStorage:()=>tn(qe(a,".tmp")),scratchStorageForRef:c=>tn(Qe(c).value),archiveFactory:()=>rn(qe(a,"archive")),archiveFactoryForRef:c=>rn(Qe(c).value),journalAdapter:()=>Ma(a),lock:Da(qe(a,Ay)),selfRef:u,async dispatchExecution(c,d){if(s?.suppressSpawn)return {dispatched:false};try{let l=d.source_def?.bindTo??Zn().slice(0,8),g=tn(qe(a,".tmp")),v=g.create(JSON.stringify(d,null,2),`exec-in-${l}`,".json"),f=g.getUniqueKey(`exec-out-${l}`,".json"),m=g.getUniqueKey(`exec-err-${l}`,".txt"),b=pe(g.keyRef(v)),C=pe(g.keyRef(f)),q=pe(g.keyRef(m));return Pa(c,{subcommand:"run-source-fetch",inRef:b,outRef:C,errRef:q},o),{dispatched:!0}}catch(l){let g=l instanceof Error?l.message:String(l);try{let v=rn(qe(a,"archive")),f=new Date().toISOString().replace(/[:.]/g,"-"),m=d.source_def?.bindTo??"unknown";v.blob("exec-failures").write(`${f}-${m}.json`,JSON.stringify({error:g,args:d,ref:c,at:new Date().toISOString()},null,2));}catch{}return {dispatched:false,error:g}}},resolveBlob(c){let d=va(c.value)?us().read(c.value):Wt(a).read(c.value);if(d===null)throw new Error(`resolveBlob: blob not found: ::${c.kind}::${c.value}`);return d},hashFn:Fa,genId:()=>Sa(`${Date.now()}-${Math.random()}`).slice(0,32),kvStorageForRef:c=>nn(Qe(c).value),requestProcessAccumulated(){s?.suppressSpawn||Ra(o,e,s?.notifyChannel);},publishBoardChangeNotifications(c){if(!s?.notifyChannel||c.length===0)return;let d=c.map(l=>({id:Zn(),ts:new Date().toISOString(),boardRef:pe(e),notification:l}));_a(s.notifyChannel,d,s.onWarn);},onWarn:s?.onWarn}}function Rw(e,t,r){let{cliDir:n,opts:s}=Iy(t,r),o=ad(n),a=jy(e,o,s),i=Xr();return {...a,invokeExecutorSync(u,c,d,l){let{command:g,baseArgs:v}=Qr(u,o),f=u.extra?["--extra",Buffer.from(JSON.stringify(u.extra)).toString("base64")]:[];return i.executeSync(g,[...v,c,...d,...f],{timeout:l?.timeout??3e4,encoding:"utf-8",input:l?.input})},validateSchema(u){let c=Xo(u);return {ok:c.errors.length===0,errors:c.errors}},absoluteBlob:us()}}function _w(e,t={}){let r=t.chatsSubdir??"chats",n=t.kvSubdir??".kv",s=n?[n,"chat"]:["chat"],o=r&&!od(e,r)?qe(e,r):e,a=nn(qe(e,...s));return Qo(i=>{let c=`${String(i).replace(/[^a-zA-Z0-9_-]/g,"_")}.jsonl`,d=qe(o,c);return ds(d)},a)}function Cw(e,t={}){let r=t.filesSubdir??"files",n=r&&!od(e,r)?qe(e,r):e;return ca(Wt(n))}function $w(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString());return typeof t.br=="string"?t.br:null}catch{return null}}
19
+ export{xt as BOARD_GRAPH_KEY,zn as EMPTY_CONFIG,Ur as SNAPSHOT_SCHEMA_VERSION_V1,Qr as buildLocalBaseSpec,ca as createArtifactsStore,yy as createArtifactsStorePublic,hy as createBoardLiveCardsMcp,fy as createBoardLiveCardsNonCorePublic,ly as createBoardLiveCardsPublic,$y as createCardFileMetadataStore,Kn as createCardStore,oa as createCardStorePublic,Qo as createChatStorage,Bd as createExecutionRefInvoker,Cy as createFileArtifactsStore,_w as createFsBoardChatStorage,Cw as createFsBoardFileArtifactsStore,Rw as createFsBoardNonCorePlatformAdapter,jy as createFsBoardPlatformAdapter,Ph as createInMemoryChatStorage,bw as createNodeSpawnInvocationAdapter,$w as decodeBoardRefFromToken,ss as evaluateArgsMassaging,sy as executionRefFromScriptPath,Oa as invokeExecutionRef,os as invokeExecutionRefSync,Vd as invokeRefSync,na as parseExecutionRef,Qe as parseRef,et as resolveWhatToRunValue,xa as resolveYamlFlowCliPath,ra as serializeExecutionRef,pe as serializeRef};//# sourceMappingURL=board-live-cards-node.js.map
20
20
  //# sourceMappingURL=board-live-cards-node.js.map